-_                              = require 'underscore'
-Backbone                       = require 'backbone'
-{ compactObject } = require './mixins/compact_object.coffee'
+_                   = require 'underscore'
+Backbone            = require 'backbone'
+{ compactObject }   = require './mixins/compact_object.coffee'
 
 module.exports = class Location extends Backbone.Model
-
   defaults: ->
     raw: ''
     address: ''

    telephone = "Tel: #{@get('phone')}" if @get('phone')
    _.compact(_.flatten([@lines(), telephone])).join '<br/>'

  displayAddress: -> if @lines() then @lines().join(", ") else ""

  displayName: -> if @has("display") then @get("display") else @get("name")

  getMapsLocation: ->
    if @get('coordinates')


  lines: ->
    _.compact([
      @get 'address' or ''
      @get 'address_2' or ''
      @cityStatePostalCode() or ''
      @get 'country' or ''
    ])

  cityState: ->
    _.compact([
      @get 'city' or ''
      @get 'state' or ''
    ]).join(', ')

  cityStateCountry: ->
    _.compact([
      @get 'city' or ''
      @get 'state' or ''
      @get 'country' or ''
    ]).join(', ')

  cityStatePostalCode: ->
    _.compact([
      @cityState() or ''
      @get('postal_code') or ''
    ]).join(' ')

  singleLine: ->
    _.compact([
      @get 'city' or ''
      _.compact([
        @get 'address' or ''
        @get 'address_2' or ''
      ]).join(' ')
    ]).join(', ')

