nukomeet/coworfing

View on GitHub
app/views/places/_form.html.haml

Summary

Maintainability
Test Coverage
#place_form.row
  .span7.details
    = simple_form_for(@place, html: { multipart: true, class: 'form-horizontal'}) do |f|
      %div{class: "control-group string required"}
        %label{class: "string required control-label"}
          %abbr{title: "required"}
            *
          required fields

      .control-group.string.optional
        %label{class: "string optional control-label"}
          Owner
        .controls
          = select_tag :owner, options_from_collection_for_select(owners, "username", "username", @owner.username), class: 'span3 chzn-select first'
      = f.input :name, input_html: { class: 'span5' }
      .control-group.string.optional
        %label{class: "string optional control-label"}
          Geocomplete
        .controls
          = text_field_tag :geocomplete, nil, autocomplete: false, placeholder: "Type the address here, it will fill the next fields automatically", :"data-address" => @place.address,  class: 'span5'

      = f.input :address_line1, input_html: { class: 'span5'}
      = f.input :city, input_html: { class: 'span3', 'data-geo' => 'locality' }
      = f.input :country, input_html: { class: 'span3 chzn-select first', 'data-geo' => 'country' }
      = f.input :desc, as: :text, input_html: { rows: 4, class: 'span5' }
      = f.input :website, input_html: { class: 'span3', 'data-geo' => 'website' }
      = f.input :wifi, input_html: { class: 'span5' }
      = f.input :transport, as: :text, input_html: { rows: 4, class: 'span5' }, placeholder: 'If necessary, explain in a few words how to get there'
      = f.input :kind, required: true, collection: Place.get_kind_values, input_html: { class: 'chzn-select span5 first'}, hint: 'Pro is for coworking spaces, public is for any public place (park, cafe, airport hall...), private is for homes' 

      = f.input :features, label: 'Smoke' do
        = check_box_tag 'place[features][]', 'smoke'

      = f.input :tag_list, as: :text, input_html: { rows:2, class: 'span5 first'}, label: 'Tags', hint: 'Tag this place with relevant characteristics (example: "sunny, park, library, beach, coffee house") separate tags by commas'

      = f.fields_for :photos do |builder|
        = render 'photo_fields', f: builder

      .control-group.string.optional
        %label.file.optional.control-label
        .controls
          = link_to_add_fields "Add photo field", f, :photos

      .controls
        = f.button :submit, class: 'btn btn-primary'

  .span5
    #geo_map


= content_for :preload_javascript do
  %script{:src => "http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places&language=en", :type => "text/javascript"}

= content_for :javascript do
  :javascript
    $("#place_tag_list").select2({
      placeholder: "Enter a tag",
      tags:["Internet + WIFI", "Plugs", "Park", "View", "Conference Room", "24x7 Access", "Air Conditioning", "Alarm", "Free coffee", "Kitchen", "Scan", "Fax", "Copier", "Printer","Reception","Secretariat","Pets Allowed","No Smoking","Children permitted","Free Trial", "Projector", "Smoking Area", "Locker", "Peace and Quiet"],
      tokenSeparators: [",", " "]
    })
    var place_form = new C.NewPlaceView();