From b7901e54d664998def94cfcbfa4a0834c68ec025 Mon Sep 17 00:00:00 2001 From: rahul Date: Mon, 28 Aug 2017 21:44:39 +0530 Subject: [PATCH 1/2] Fix layout for booths and tracks --- app/views/admin/booths/index.html.haml | 7 ++++--- app/views/admin/tracks/index.html.haml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/admin/booths/index.html.haml b/app/views/admin/booths/index.html.haml index fc3f3ba3..9eef8f96 100644 --- a/app/views/admin/booths/index.html.haml +++ b/app/views/admin/booths/index.html.haml @@ -4,9 +4,6 @@ %h1 Booths = "(#{@booths.length})" if @booths.any? - .pull-right - - if can? :create, Booth - = link_to 'Add Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary' %p.text-muted All the booth requests @@ -74,3 +71,7 @@ %td = link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id), class: 'btn btn-primary' +.row + .col-md-12.text-right + - if can? :create, Booth + = link_to 'New Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary' diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index 6ac42003..95eafcb3 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -78,4 +78,4 @@ style: ('border-top-left-radius: 0; border-bottom-left-radius: 0;' if special_style), params: { 'schedule[track_id]' => track.id } .row .col-md-12.text-right - = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-success' + = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-primary' From fbd11a1402a83e3b05b3d3d13c128ccc61d3468c Mon Sep 17 00:00:00 2001 From: rahul Date: Mon, 28 Aug 2017 21:55:31 +0530 Subject: [PATCH 2/2] Remove datatables if there is no data --- app/views/admin/booths/index.html.haml | 83 +++++++-------- app/views/admin/tracks/index.html.haml | 135 +++++++++++++------------ spec/features/tracks_spec.rb | 7 +- 3 files changed, 113 insertions(+), 112 deletions(-) diff --git a/app/views/admin/booths/index.html.haml b/app/views/admin/booths/index.html.haml index 9eef8f96..428895e5 100644 --- a/app/views/admin/booths/index.html.haml +++ b/app/views/admin/booths/index.html.haml @@ -29,48 +29,49 @@ ( = link_to "#{@conference.booth_limit} booths", edit_admin_conference_path(@conference.short_title) ) - %table.table.table-striped.table-bordered.table-hover.datatable - %thead - %th - %b ID - %th - %b Logo - %th - %b Title - %th - %b Submitter - %th - %b Responsibles - %th - %b State - %th - %b Actions - - @booths.each do |booth| - %tr - %td - = 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 + - if @booths.any? + %table.table.table-striped.table-bordered.table-hover.datatable + %thead + %th + %b ID + %th + %b Logo + %th + %b Title + %th + %b Submitter + %th + %b Responsibles + %th + %b State + %th + %b Actions + - @booths.each do |booth| + %tr %td - = link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id), - class: 'btn btn-primary' + = 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 + = link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id), + class: 'btn btn-primary' .row .col-md-12.text-right - if can? :create, Booth diff --git a/app/views/admin/tracks/index.html.haml b/app/views/admin/tracks/index.html.haml index 95eafcb3..b814ac8e 100644 --- a/app/views/admin/tracks/index.html.haml +++ b/app/views/admin/tracks/index.html.haml @@ -7,75 +7,76 @@ Categorize events in your conference .row .col-md-12 - %table.table.table-hover.table-striped.table-bordered.datatable#tracks - %thead - %th ID - %th Name - %th Description - %th Room - %th Start Date - %th End Date - %th Submitter - %th Included in Cfp - %th State - %th Actions - %tbody - - @tracks.each do |track| - %tr - %td - = track.id - %td{ style: 'padding: 15px 0px 0px 10px;' } - = link_to admin_conference_program_track_path(@conference.short_title, track), class: 'btn' do - %span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"} - = track.name - %td - %p - = markdown(truncate(track.description)) - %td - = track.room.try(:name) - %td - = track.start_date.strftime('%A, %B %-d. %Y') if track.start_date - %td - = track.end_date.strftime('%A, %B %-d. %Y') if track.end_date - %td - = link_to track.submitter.name, admin_user_path(track.submitter) if track.self_organized? - %td.text-center{ 'id' => "cfp_switch_#{track.id}", 'data-order' => track.cfp_active.to_s } - = check_box_tag "#{@conference.short_title}_#{track.short_name}", track.id, track.cfp_active, - class: 'switch-checkbox', method: :patch, - url: toggle_cfp_inclusion_admin_conference_program_track_path(@conference.short_title, id: track.short_name)+"?included=", - data: { size: 'small', - on_color: 'success', - off_color: 'warning', - on_text: 'Yes', - off_text: 'No' } + - if @tracks.any? + %table.table.table-hover.table-striped.table-bordered.datatable#tracks + %thead + %th ID + %th Name + %th Description + %th Room + %th Start Date + %th End Date + %th Submitter + %th Included in Cfp + %th State + %th Actions + %tbody + - @tracks.each do |track| + %tr + %td + = track.id + %td{ style: 'padding: 15px 0px 0px 10px;' } + = link_to admin_conference_program_track_path(@conference.short_title, track), class: 'btn' do + %span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"} + = track.name + %td + %p + = markdown(truncate(track.description)) + %td + = track.room.try(:name) + %td + = track.start_date.strftime('%A, %B %-d. %Y') if track.start_date + %td + = track.end_date.strftime('%A, %B %-d. %Y') if track.end_date + %td + = link_to track.submitter.name, admin_user_path(track.submitter) if track.self_organized? + %td.text-center{ 'id' => "cfp_switch_#{track.id}", 'data-order' => track.cfp_active.to_s } + = check_box_tag "#{@conference.short_title}_#{track.short_name}", track.id, track.cfp_active, + class: 'switch-checkbox', method: :patch, + url: toggle_cfp_inclusion_admin_conference_program_track_path(@conference.short_title, id: track.short_name)+"?included=", + data: { size: 'small', + on_color: 'success', + off_color: 'warning', + on_text: 'Yes', + off_text: 'No' } - %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" } + %td.text-center - 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 } + .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.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 .col-md-12.text-right = link_to 'New Track', new_admin_conference_program_track_path(@conference.short_title), class: 'btn btn-primary' diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index 0819c650..934f28ba 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -42,10 +42,9 @@ feature Track do expected.to change { Track.count }.by(-1) expect(flash).to eq('Track successfully deleted.') - within('table#tracks') do - expect(page.has_content?(track.name)).to be false - expect(page.has_content?(track.description)).to be false - end + expect(page.has_css?('table#tracks')).to be false + expect(page.has_content?(track.name)).to be false + expect(page.has_content?(track.description)).to be false end scenario 'updates a track', feature: true, js: true do