Refactoring lodgings

This commit is contained in:
chrisbr 2014-11-12 12:00:03 +01:00
parent c0cdf3e6e5
commit 580c6c6ed9
11 changed files with 177 additions and 68 deletions

View file

@ -0,0 +1,8 @@
= f.input :name
= f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint("Write about the hotel/place, of what they are offering, about types of rooms, prices and address.")
= image_tag f.object.photo(:thumb) if !f.object.photo.blank?
= f.input :photo
= f.input :website_link
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
= link_to 'Back', admin_conference_lodgings_path(@conference.short_title)

View file

@ -1,10 +0,0 @@
<div class="nested-fields">
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :description, :input_html => {:rows => 2, data: { provide: "markdown-editable" } }, hint: markdown_hint("Write about the hotel/place, of what they are offering, about types of rooms, prices and address.") %>
<%= image_tag f.object.photo(:thumb) if !f.object.photo.blank? %>
<%= f.input :photo %>
<%= f.input :website_link %>
<%= remove_association_link :lodging, f %>
<% end %>
</div>

View file

@ -0,0 +1,6 @@
%h1
Edit Lodging
.row
.col-md-8
= semantic_form_for(@lodging, :url => admin_conference_lodging_path(@conference.short_title, @lodging)) do |f|
= render partial: 'form', locals: { f: f }

View file

@ -1,5 +1,26 @@
.row
.col-md-8
= semantic_form_for(@venue, :url => admin_conference_lodging_path(@conference.short_title, @conference.venue.lodgings), :html => {:multipart => true}) do |f|
= dynamic_association :lodgings, "Lodgings", f
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
%h1 Lodgings
- if @venue.lodgings.any?
.row
.col-md-12
%table.table
%thead
%th #
%th Name
%th Edit
%th Delete
%tbody
- @venue.lodgings.each_with_index do |lodging, index|
%tr
%td
= index + 1
%td
= link_to lodging.name, admin_conference_lodging_path(@conference.short_title, lodging.id)
%td
= link_to 'Edit', edit_admin_conference_lodging_path(@conference.short_title, lodging.id),
method: :get, class: 'btn btn-primary'
%td
= link_to 'Delete', admin_conference_lodging_path(@conference.short_title, lodging.id),
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the lodging #{lodging.name}?" }
= link_to 'Add Lodging', new_admin_conference_lodging_path(@conference.short_title), class: 'btn btn-success'

View file

@ -0,0 +1,6 @@
%h1
New Lodging
.row
.col-md-8
= semantic_form_for(@lodging, :url => admin_conference_lodgings_path(@conference.short_title, @lodging)) do |f|
= render partial: 'form', locals: { f: f }

View file

@ -0,0 +1,16 @@
%h1
= @lodging.name
- unless @lodging.photo.blank? || @lodging.description.blank? || @lodging.website_link.blank?
.div.thumbnail
- unless @lodging.photo.blank?
= image_tag @lodging.photo(:large), class: 'img-responsive'
- unless @lodging.description.blank?
.lead.text-center #{ markdown(@lodging.description) }
- unless @lodging.website_link.blank?
.text-center
= link_to 'Go to Website', @lodging.website_link
= link_to 'Edit', edit_admin_conference_lodging_path(@conference.short_title, @lodging.id),
method: :get, class: 'btn btn-primary'
= link_to 'Back', admin_conference_lodgings_path(@conference.short_title)