Remove datatables if there is no data

This commit is contained in:
rahul 2017-08-28 21:55:31 +05:30
parent b7901e54d6
commit fbd11a1402
3 changed files with 113 additions and 112 deletions

View file

@ -29,48 +29,49 @@
( (
= link_to "#{@conference.booth_limit} booths", edit_admin_conference_path(@conference.short_title) = link_to "#{@conference.booth_limit} booths", edit_admin_conference_path(@conference.short_title)
) )
%table.table.table-striped.table-bordered.table-hover.datatable - if @booths.any?
%thead %table.table.table-striped.table-bordered.table-hover.datatable
%th %thead
%b ID %th
%th %b ID
%b Logo %th
%th %b Logo
%b Title %th
%th %b Title
%b Submitter %th
%th %b Submitter
%b Responsibles %th
%th %b Responsibles
%b State %th
%th %b State
%b Actions %th
- @booths.each do |booth| %b Actions
%tr - @booths.each do |booth|
%td %tr
= booth.id
%td
- if booth.logo_link
= image_tag(booth.picture.thumb.url, width: '20%')
%td
= link_to booth.title, admin_conference_booth_path(@conference.short_title, booth)
%td
= link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter
%td
.responsibles
- booth.responsibles.each_with_index do |responsible, i|
= link_to responsible.name, admin_user_path(responsible)
= ", " unless i == booth.responsibles.length - 1
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
= booth.state.humanize
%span.caret
%ul.dropdown-menu{ role: 'menu' }
= render 'change_state_dropdown', booth: booth
%td %td
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id), = booth.id
class: 'btn btn-primary' %td
- if booth.logo_link
= image_tag(booth.picture.thumb.url, width: '20%')
%td
= link_to booth.title, admin_conference_booth_path(@conference.short_title, booth)
%td
= link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter
%td
.responsibles
- booth.responsibles.each_with_index do |responsible, i|
= link_to responsible.name, admin_user_path(responsible)
= ", " unless i == booth.responsibles.length - 1
%td
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
= booth.state.humanize
%span.caret
%ul.dropdown-menu{ role: 'menu' }
= render 'change_state_dropdown', booth: booth
%td
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id),
class: 'btn btn-primary'
.row .row
.col-md-12.text-right .col-md-12.text-right
- if can? :create, Booth - if can? :create, Booth

View file

@ -7,75 +7,76 @@
Categorize events in your conference Categorize events in your conference
.row .row
.col-md-12 .col-md-12
%table.table.table-hover.table-striped.table-bordered.datatable#tracks - if @tracks.any?
%thead %table.table.table-hover.table-striped.table-bordered.datatable#tracks
%th ID %thead
%th Name %th ID
%th Description %th Name
%th Room %th Description
%th Start Date %th Room
%th End Date %th Start Date
%th Submitter %th End Date
%th Included in Cfp %th Submitter
%th State %th Included in Cfp
%th Actions %th State
%tbody %th Actions
- @tracks.each do |track| %tbody
%tr - @tracks.each do |track|
%td %tr
= track.id %td
%td{ style: 'padding: 15px 0px 0px 10px;' } = track.id
= link_to admin_conference_program_track_path(@conference.short_title, track), class: 'btn' do %td{ style: 'padding: 15px 0px 0px 10px;' }
%span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"} = link_to admin_conference_program_track_path(@conference.short_title, track), class: 'btn' do
= track.name %span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"}
%td = track.name
%p %td
= markdown(truncate(track.description)) %p
%td = markdown(truncate(track.description))
= track.room.try(:name) %td
%td = track.room.try(:name)
= track.start_date.strftime('%A, %B %-d. %Y') if track.start_date %td
%td = track.start_date.strftime('%A, %B %-d. %Y') if track.start_date
= track.end_date.strftime('%A, %B %-d. %Y') if track.end_date %td
%td = track.end_date.strftime('%A, %B %-d. %Y') if track.end_date
= link_to track.submitter.name, admin_user_path(track.submitter) if track.self_organized? %td
%td.text-center{ 'id' => "cfp_switch_#{track.id}", 'data-order' => track.cfp_active.to_s } = link_to track.submitter.name, admin_user_path(track.submitter) if track.self_organized?
= check_box_tag "#{@conference.short_title}_#{track.short_name}", track.id, track.cfp_active, %td.text-center{ 'id' => "cfp_switch_#{track.id}", 'data-order' => track.cfp_active.to_s }
class: 'switch-checkbox', method: :patch, = check_box_tag "#{@conference.short_title}_#{track.short_name}", track.id, track.cfp_active,
url: toggle_cfp_inclusion_admin_conference_program_track_path(@conference.short_title, id: track.short_name)+"?included=", class: 'switch-checkbox', method: :patch,
data: { size: 'small', url: toggle_cfp_inclusion_admin_conference_program_track_path(@conference.short_title, id: track.short_name)+"?included=",
on_color: 'success', data: { size: 'small',
off_color: 'warning', on_color: 'success',
on_text: 'Yes', off_color: 'warning',
off_text: 'No' } on_text: 'Yes',
off_text: 'No' }
%td.text-center %td.text-center
- if track.self_organized?
.btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
= track.state.humanize
%span.caret
%ul.dropdown-menu{ role: 'menu' }
= render 'change_state_dropdown', track: track
- else
= track.state.humanize
%td
.btn-group{ role: 'group' }
- if can? :edit, track
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track), class: 'btn btn-primary'
- special_style = true
- if can? :destroy, track
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track), method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
- if track.self_organized? - if track.self_organized?
- if track.selected_schedule .btn-group
- if can? :show, track.selected_schedule %button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
= link_to 'Show Schedule', admin_conference_schedule_path(@conference.short_title, track.selected_schedule), = track.state.humanize
class: 'btn btn-default' %span.caret
- elsif can? :create, @program.schedules.build(track: track) %ul.dropdown-menu{ role: 'menu' }
= button_to 'Create Schedule', admin_conference_schedules_path(@conference.short_title), = render 'change_state_dropdown', track: track
form: { class: 'btn', style: 'padding: 0px 0px; margin-top: -1px;' }, class: 'btn btn-default', - else
style: ('border-top-left-radius: 0; border-bottom-left-radius: 0;' if special_style), params: { 'schedule[track_id]' => track.id } = track.state.humanize
%td
.btn-group{ role: 'group' }
- if can? :edit, track
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track), class: 'btn btn-primary'
- special_style = true
- if can? :destroy, track
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track), method: :delete, class: 'btn btn-danger',
data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
- if track.self_organized?
- if track.selected_schedule
- if can? :show, track.selected_schedule
= link_to 'Show Schedule', admin_conference_schedule_path(@conference.short_title, track.selected_schedule),
class: 'btn btn-default'
- elsif can? :create, @program.schedules.build(track: track)
= button_to 'Create Schedule', admin_conference_schedules_path(@conference.short_title),
form: { class: 'btn', style: 'padding: 0px 0px; margin-top: -1px;' }, class: 'btn btn-default',
style: ('border-top-left-radius: 0; border-bottom-left-radius: 0;' if special_style), params: { 'schedule[track_id]' => track.id }
.row .row
.col-md-12.text-right .col-md-12.text-right
= link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-primary' = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-primary'

View file

@ -42,10 +42,9 @@ feature Track do
expected.to change { Track.count }.by(-1) expected.to change { Track.count }.by(-1)
expect(flash).to eq('Track successfully deleted.') expect(flash).to eq('Track successfully deleted.')
within('table#tracks') do expect(page.has_css?('table#tracks')).to be false
expect(page.has_content?(track.name)).to be false expect(page.has_content?(track.name)).to be false
expect(page.has_content?(track.description)).to be false expect(page.has_content?(track.description)).to be false
end
end end
scenario 'updates a track', feature: true, js: true do scenario 'updates a track', feature: true, js: true do