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,7 +2,15 @@
.col-md-12 .col-md-12
.page-header .page-header
%h1 Venue %h1 Venue
.row .tabbable
%ul.nav.nav-tabs
%li.active
= link_to 'Details', '#details-content', 'data-toggle' => 'tab'
%li
= link_to 'Commercials', '#commercials-content', 'data-toggle' => 'tab'
.tab-content
#details-content.tab-pane.active
.col-md-8 .col-md-8
= semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f| = semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f|
= f.inputs :name, :website = f.inputs :name, :website
@ -13,6 +21,8 @@
= f.input :photo = f.input :photo
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
#commercials-content.tab-pane
- if @venue
.row .row
.col-md-6 .col-md-6
#resource-content #resource-content
@ -24,7 +34,7 @@
hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.' hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.'
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true }
%hr %hr
- @venue.commercial do |commercial| - @venue.commercial do |commercial|
- if commercial.persisted? - if commercial.persisted?
.col-md-4 .col-md-4
.thumbnail .thumbnail
@ -32,10 +42,12 @@
= render partial: 'shared/media_item', locals: { commercial: commercial } = render partial: 'shared/media_item', locals: { commercial: commercial }
.caption .caption
- if can? :update, commercial - if can? :update, commercial
= semantic_form_for commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: commercial) do |f| = 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.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' = f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update'
- if can? :destroy, commercial - if can? :destroy, commercial
= link_to 'Delete', admin_conference_venue_venue_commercial_path(@conference.short_title, commercial.id), = 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' method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
%hr %hr
- else
hint: 'First Create Venue, then update commercial'