defined ,tabular form

defined ,tabular form
This commit is contained in:
Shriyansh 2016-04-03 22:19:08 +05:30
parent 6f667a865b
commit dc0da8c500
2 changed files with 53 additions and 41 deletions

View file

@ -10,10 +10,10 @@ module Admin
#FIXME redirect to tab#commercial #FIXME redirect to tab#commercial
if @commercial.save if @commercial.save
redirect_to admin_conference_venue_path, redirect_to edit_admin_conference_venue_path,
notice: 'Commercial was successfully created.' notice: 'Commercial was successfully created.'
else else
redirect_to admin_conference_venue_path, redirect_to edit_admin_conference_venue_path,
error: 'An error prohibited this Commercial from being saved: '\ error: 'An error prohibited this Commercial from being saved: '\
"#{@commercial.errors.full_messages.join('. ')}." "#{@commercial.errors.full_messages.join('. ')}."
@ -22,10 +22,10 @@ module Admin
def update def update
if @commercial.update(commercial_params) if @commercial.update(commercial_params)
redirect_to admin_conference_venue_path, redirect_to edit_admin_conference_venue_path,
notice: 'Commercial was successfully updated.' notice: 'Commercial was successfully updated.'
else else
redirect_to admin_conference_venue_path, redirect_to edit_admin_conference_venue_path,
error: 'An error prohibited this Commercial from being saved: '\ error: 'An error prohibited this Commercial from being saved: '\
"#{@commercial.errors.full_messages.join('. ')}." "#{@commercial.errors.full_messages.join('. ')}."
end end
@ -33,7 +33,7 @@ module Admin
def destroy def destroy
@commercial.destroy @commercial.destroy
redirect_to admin_conference_venue_path, notice: 'Commercial was successfully destroyed.' redirect_to edit_admin_conference_venue_path, notice: 'Commercial was successfully destroyed.'
end end
def render_commercial def render_commercial

View file

@ -2,40 +2,52 @@
.col-md-12 .col-md-12
.page-header .page-header
%h1 Venue %h1 Venue
.row .tabbable
.col-md-8 %ul.nav.nav-tabs
= semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f| %li.active
= f.inputs :name, :website = link_to 'Details', '#details-content', 'data-toggle' => 'tab'
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint %li
= f.inputs :street, :postalcode, :city, :country, :latitude, :longitude = link_to 'Commercials', '#commercials-content', 'data-toggle' => 'tab'
- unless @venue.photo.blank?
= image_tag @venue.photo(:thumb)
= f.input :photo
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
.row .tab-content
.col-md-6 #details-content.tab-pane.active
#resource-content .col-md-8
#resource-placeholder{ style: 'background-color:#d3d3d3; float: left; width: 400px; height: 250px; margin: 5px; border-width: 1px; border-style: solid; border-color: rgba(0,0,0,.2);' } = semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f|
.row = f.inputs :name, :website
.col-md-6 = f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
= semantic_form_for(@venue.create_commercial,as: :commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title)) do |f| = f.inputs :street, :postalcode, :city, :country, :latitude, :longitude
= f.input :url, label: 'URL', as: :string, input_html: { required: 'required', type: 'url' }, - unless @venue.photo.blank?
hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.' = image_tag @venue.photo(:thumb)
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true } = f.input :photo
%hr = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
- @venue.commercial do |commercial|
- if commercial.persisted? #commercials-content.tab-pane
.col-md-4 - if @venue
.thumbnail .row
.flexvideo{ id: "resource-content-#{commercial.id}"} .col-md-6
= render partial: 'shared/media_item', locals: { commercial: commercial } #resource-content
.caption #resource-placeholder{ style: 'background-color:#d3d3d3; float: left; width: 400px; height: 250px; margin: 5px; border-width: 1px; border-style: solid; border-color: rgba(0,0,0,.2);' }
- if can? :update, commercial .row
= semantic_form_for commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: commercial) do |f| .col-md-6
= f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{commercial.id}", required: 'required' }, hint: 'Just paste the url of your video/photo provider' = semantic_form_for(@venue.create_commercial,as: :commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title)) do |f|
= f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update' = f.input :url, label: 'URL', as: :string, input_html: { required: 'required', type: 'url' },
- if can? :destroy, commercial hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.'
= link_to 'Delete', admin_conference_venue_venue_commercial_path(@conference.short_title, commercial.id), = f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true }
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %hr
%hr - @venue.commercial do |commercial|
- if commercial.persisted?
.col-md-4
.thumbnail
.flexvideo{ id: "resource-content-#{commercial.id}"}
= render partial: 'shared/media_item', locals: { commercial: commercial }
.caption
- if can? :update, commercial
= semantic_form_for commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: commercial.id) do |f|
= f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{commercial.id}", required: 'required' }, hint: 'Just paste the url of your video/photo provider'
= f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update'
- if can? :destroy, commercial
= link_to 'Delete', admin_conference_venue_venue_commercial_path(@conference.short_title, commercial.id),
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
%hr
- else
hint: 'First Create Venue, then update commercial'