UI/UX changes related to tracks

Add confirmed and cfp_active scopes to Track
Render markdown in track's description
Make the views more similar to the proposal/events views
Change the sequence of columns in admin/Tracks#index
Remove the short_name column from the index views
Add button "My Tracks" in the user menu
Fix track count in proposals
Add details of track in admin/Tracks#show
Use tabs to show track details and events
This commit is contained in:
AEtherC0r3 2017-07-19 18:28:57 +03:00 committed by Stella Rouzi
parent f9903eba16
commit 3d250ecf75
14 changed files with 269 additions and 132 deletions

View file

@ -182,6 +182,7 @@ linters:
- "app/views/tracks/show.html.haml" - "app/views/tracks/show.html.haml"
- "app/views/conferences/_call_for_tracks.html.haml" - "app/views/conferences/_call_for_tracks.html.haml"
- "app/views/admin/tracks/_change_state_dropdown.html.haml" - "app/views/admin/tracks/_change_state_dropdown.html.haml"
- "app/views/proposals/_encouragement_text.html.haml"
# Offense count: 223 # Offense count: 223
InstanceVariables: InstanceVariables:

View file

@ -17,7 +17,7 @@ module Admin
def index def index
@events = @program.events @events = @program.events
@tracks = @program.tracks @tracks = @program.tracks.confirmed.cfp_active
@difficulty_levels = @program.difficulty_levels @difficulty_levels = @program.difficulty_levels
@event_types = @program.event_types @event_types = @program.event_types
@tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed) @tracks_distribution_confirmed = @conference.tracks_distribution(:confirmed)
@ -43,7 +43,7 @@ module Admin
end end
def show def show
@tracks = @program.tracks @tracks = @program.tracks.confirmed.cfp_active
@event_types = @program.event_types @event_types = @program.event_types
@comments = @event.root_comments @comments = @event.root_comments
@comment_count = @event.comment_threads.count @comment_count = @event.comment_threads.count
@ -58,7 +58,7 @@ module Admin
def edit def edit
@event_types = @program.event_types @event_types = @program.event_types
@tracks = Track.all @tracks = @program.tracks.confirmed.cfp_active
@comments = @event.root_comments @comments = @event.root_comments
@comment_count = @event.comment_threads.count @comment_count = @event.comment_threads.count
@user = @event.submitter @user = @event.submitter

View file

@ -56,7 +56,7 @@ module ApplicationHelper
end end
def tracks(conference) def tracks(conference)
all = conference.program.tracks.where(state: 'confirmed', cfp_active: true).pluck(:name) all = conference.program.tracks.confirmed.cfp_active.pluck(:name)
first = all[0...-1] first = all[0...-1]
last = all[-1] last = all[-1]
ts = '' ts = ''

View file

@ -32,6 +32,9 @@ class Track < ActiveRecord::Base
before_validation :capitalize_color before_validation :capitalize_color
scope :confirmed, -> { where(state: 'confirmed') }
scope :cfp_active, -> { where(cfp_active: true) }
state_machine initial: :pending do state_machine initial: :pending do
state :new state :new
state :to_accept state :to_accept

View file

@ -6,39 +6,46 @@
Categorize events in your conference Categorize events in your conference
.row .row
.col-md-12 .col-md-12
%table.table.table-hover#tracks %table.table.table-hover.table-striped.table-bordered.datatable#tracks
%thead %thead
%th Name %th Name
%th Short name
%th Description %th Description
%th Submitter
%th Color
%th State
%th Included in the Cfp
%th Room %th Room
%th Start Date %th Start Date
%th End Date %th End Date
%th Submitter
%th Included in Cfp
%th State
%th Actions %th Actions
%tbody %tbody
- @tracks.each do |track| - @tracks.each do |track|
%tr %tr
%td %td{style: "padding: 15px 0px 0px 10px;"}
= link_to(admin_conference_program_track_path(@conference.short_title, track)) do = 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
= track.short_name
%td %td
%p %p
= truncate(track.description) = markdown(truncate(track.description))
%td %td
- if track.self_organized? = track.room.try(:name)
= link_to track.submitter.name, admin_user_path(track.submitter)
- else
N/A
%td %td
%span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"} = track.start_date.strftime('%A, %B %-d. %Y') if track.start_date
= track.color
%td %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
= 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? - if track.self_organized?
.btn-group .btn-group
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' } %button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
@ -48,39 +55,12 @@
= render 'change_state_dropdown', track: track = render 'change_state_dropdown', track: track
- else - else
= track.state.humanize = track.state.humanize
%td
= 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
- if track.room
= link_to track.room.name, admin_conference_venue_room_path(@conference.short_title, track.room.id)
- else
N/A
%td
- if track.start_date
= track.start_date.strftime('%A, %B %-d. %Y')
- else
N/A
%td
- if track.end_date
= track.end_date.strftime('%A, %B %-d. %Y')
- else
N/A
%td %td
.btn-group{role: "group"} .btn-group{role: "group"}
- if can? :edit, track - if can? :edit, track
= link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track), = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, track), class: 'btn btn-primary'
method: :get, class: 'btn btn-primary'
- if can? :destroy, track - if can? :destroy, track
= link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track), = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, track), method: :delete, class: 'btn btn-danger',
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" } data: { confirm: "Do you really want to delete #{track.name}? Attention: This track will be removed from all Events that have it set" }
.row .row
.col-md-12.text-right .col-md-12.text-right

View file

@ -4,27 +4,114 @@
%h1 %h1
= @track.name = @track.name
Track Track
%p.text-muted
Events in this track .tabbable
.row %ul.nav.nav-tabs
.col-md-12 %li.active
%table.table.table-hover.datatable = link_to 'Details', '#details', 'data-toggle' => 'tab'
%thead %li
%th Title = link_to 'Events', '#events', 'data-toggle' => 'tab'
%th Type
%th Submitter .tab-content
%th State .tab-pane.active#details
%th Time .row
%tbody .col-md-12
- @track.events.each_with_index do |event| .btn-group.pull-right
%tr - if can? :edit, @track
%td = link_to 'Edit', edit_admin_conference_program_track_path(@conference.short_title, @track),
=link_to event.title, admin_conference_program_event_path(@conference.short_title, event) method: :get, class: 'btn btn-primary'
%td - if can? :destroy, @track
= event.event_type.title = link_to 'Delete', admin_conference_program_track_path(@conference.short_title, @track),
%td method: :delete, class: 'btn btn-danger',
=link_to event.submitter.name, admin_user_path(event.submitter) data: { confirm: "Do you really want to delete #{@track.name}? Attention: This track will be removed from all Events that have it set" }
%td .row
= event.state .col-md-12
%td %table.table
= event.time %tr
%td.col-md-2
%b Color
%td
%span.label{ style: "background-color: #{@track.color}; color: #{ contrast_color(@track.color) }" }
= @track.color
%tr
%td
%b Room
%td
= @track.room.try(:name)
%tr
%td
%b Start date
%td
= @track.start_date.strftime('%A, %B %-d. %Y') if @track.start_date
%tr
%td
%b End date
%td
= @track.end_date.strftime('%A, %B %-d. %Y') if @track.end_date
- if @track.self_organized?
%tr
%td
%b Submitter
%td
= link_to @track.submitter.name, admin_user_path(@track.submitter)
- if @track.confirmed?
%tr
%td
%b Organizers
%td
- Role.find_by(name: 'track_organizer', resource: @track).users.each do |organizer|
%div
= link_to organizer.name, admin_user_path(organizer)
%tr
%td
%b Included in the Cfp?
%td
= 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' }
%tr
%td
%b State
%td
- 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
%tr
%td
%b Description
%td
= markdown(@track.description)
.tab-pane#events
.col-md-12
%table.table.table-hover.datatable
%thead
%th Title
%th Type
%th Submitter
%th State
%th Time
%tbody
- @track.events.each_with_index do |event|
%tr
%td
=link_to event.title, admin_conference_program_event_path(@conference.short_title, event)
%td
= event.event_type.title
%td
=link_to event.submitter.name, admin_user_path(event.submitter)
%td
= event.state
%td
= event.time

View file

@ -10,13 +10,22 @@
- if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks - if @conference.splashpage and @conference.program.tracks.any? and @conference.splashpage.include_tracks
See rock-star speakers cover the topics of See rock-star speakers cover the topics of
- if @conference.splashpage and @conference.splashpage.include_tracks - if @conference.splashpage and @conference.splashpage.include_tracks
- @conference.program.tracks.each_slice(3) do |slice| - @conference.program.tracks.confirmed.cfp_active.each_slice(3) do |slice|
.row.row-centered .row.row-centered
- slice.each do |track| - slice.each do |track|
.col-md-4.col-sm-4.col-centered.col-top.track .col-md-4.col-sm-4.col-centered.col-top.track
%h4.text-center %h4.text-center
= track.name = track.name
= markdown(track.description) = markdown(track.description)
- if track.start_date
%br
From: #{track.start_date.strftime('%A, %B %-d. %Y')}
- if track.end_date
%br
To: #{track.end_date.strftime('%A, %B %-d. %Y')}
- if track.room
%br
In: #{track.room.name}
- if @conference.program and @conference.program.schedule_public - if @conference.program and @conference.program.schedule_public
.row .row

View file

@ -12,6 +12,10 @@
= link_to(conference_program_proposals_path(@conference.short_title)) do = link_to(conference_program_proposals_path(@conference.short_title)) do
%span.fa.fa-comment %span.fa.fa-comment
My Submissions My Submissions
%li
= link_to(conference_program_tracks_path(@conference.short_title)) do
%span.fa.fa-road
My Tracks
%li %li
- if ENV['OSEM_ICHAIN_ENABLED'] == 'true' - if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
= link_to(destroy_user_ichain_session_path, method: 'delete') do = link_to(destroy_user_ichain_session_path, method: 'delete') do

View file

@ -4,7 +4,7 @@
= "#{event_types(@conference)}." = "#{event_types(@conference)}."
- if @program.tracks.any? - if @program.tracks.any?
Proposals should fit in one of the Proposals should fit in one of the
= "#{pluralize(@program.tracks.count, 'track')}:" = "#{pluralize(@program.tracks.confirmed.cfp_active.count, 'track')}:"
= "#{tracks(@conference)}." = "#{tracks(@conference)}."
- if @program.cfp_open? - if @program.cfp_open?
The submission period has begun The submission period has begun

View file

@ -15,5 +15,5 @@
= f.input :color, input_html: {size: 6, type: 'color'}, required: true = f.input :color, input_html: {size: 6, type: 'color'}, required: true
= f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', start_date: @conference.start_date, end_date: @conference.end_date, readonly: 'readonly' } = f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', start_date: @conference.start_date, end_date: @conference.end_date, readonly: 'readonly' }
= f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' } = f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' }
= f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, required: true, hint: markdown_hint = f.input :description, input_html: {rows: 2, data: { provide: 'markdown-editable' } }, required: true, hint: "This will be public #{markdown_hint}".html_safe
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }

View file

@ -6,46 +6,60 @@
%span.notranslate %span.notranslate
= @conference.title = @conference.title
.row
.col-md-12
%p.text-right
= link_to '#status-help', class: 'btn btn-default', "data-toggle"=>"collapse" do
Help?
.collapse#status-help
%p
%strong
What happens next with my track request?
%p
If you submit a track request, the conference organizers will review it and either accept or reject it.
%br
If your track request is accepted, the conference organizers expect you to confirm that you will be able to hold it.
Then you will gain the Track organizer role.
%br
If your track request is rejected, you can either live with that or adapt it and resubmit it for review again.
%br
If something changes and you can't organize the track any more, you should withdraw it.
- if @tracks.any? - if @tracks.any?
.row .row
.col-md-12 .col-md-12
%table.table.table-hover#tracks %table.table.table-striped#tracks
%thead - @tracks.each do |track|
%th Name %tr
%th Short name %td{style: "padding:15px 0px 0px 8px;"}
%th Description - if %w(new to_accept to_reject).include? track.state
%th Color %span{ title: 'In review', class: 'fa fa-eye' }
%th State - elsif track.state == 'accepted'
%th Start Date %span{ title: 'Accepted', class: 'fa fa-check text-muted' }
%th End Date - elsif track.state == 'confirmed'
%th Actions %spam{ title: 'Confirmed', class: 'fa fa-check text-success' }
%tbody - elsif %w(rejected withdrawn canceled).include? track.state
- @tracks.each do |track| %span{ title: track.state.humanize, class: 'fa fa-ban'}
%tr %td{style: "padding: 15px 0px 0px 0px;"}
%td = link_to conference_program_track_path(@conference.short_title, track), class: 'btn' do
= link_to(conference_program_track_path(@conference.short_title, track)) do
= track.name
%td
= track.short_name
%td
%p
= truncate(track.description)
%td
%span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"} %span.label{style: "background-color: #{track.color}; color: #{ contrast_color(track.color) }"}
= track.color = track.name
%td %td
= track.state.humanize = markdown(truncate(track.description))
%td %td
- if track.start_date - if track.start_date
= track.start_date.strftime('%A, %B %-d. %Y') From:
- else = track.start_date.strftime('%A, %B %-d. %Y')
N/A %td
%td - if track.end_date
- if track.end_date To:
= track.end_date.strftime('%A, %B %-d. %Y') = track.end_date.strftime('%A, %B %-d. %Y')
- else %td
N/A - if track.room
%td In:
= track.room.name
%td
.pull-right
- if track.transition_possible? :confirm - if track.transition_possible? :confirm
= link_to 'Confirm', confirm_conference_program_track_path(@conference.short_title, track), = link_to 'Confirm', confirm_conference_program_track_path(@conference.short_title, track),
method: :patch, class: 'btn btn-mini btn-success', id: "confirm_track_#{track.id}" method: :patch, class: 'btn btn-mini btn-success', id: "confirm_track_#{track.id}"
@ -57,8 +71,7 @@
= link_to 'Re-Submit', restart_conference_program_track_path(@conference.short_title, track), = link_to 'Re-Submit', restart_conference_program_track_path(@conference.short_title, track),
method: :patch, class: 'btn btn-mini btn-success', id: "resubmit_track_request_#{track.id}" method: :patch, class: 'btn btn-mini btn-success', id: "resubmit_track_request_#{track.id}"
- if can? :edit, track - if can? :edit, track
= link_to 'Edit', edit_conference_program_track_path(@conference.short_title, track), = link_to 'Edit', edit_conference_program_track_path(@conference.short_title, track), class: 'btn btn-default'
method: :get, class: 'btn btn-primary'
.row .row
.col-md-12 .col-md-12

View file

@ -2,9 +2,12 @@
.row .row
.col-md-12 .col-md-12
.page-header .page-header
%h1 %h2
= @track.name = @track.name
Track Track
.btn-group.pull-right
- if can? :edit, @track
= link_to 'Edit Track request', edit_conference_program_track_path(@conference.short_title, @track), class: 'btn btn-primary'
.row .row
.col-md-8 .col-md-8
%dl.dl-horizontal %dl.dl-horizontal
@ -16,26 +19,23 @@
%dt %dt
State: State:
%dd %dd
= @track.state.humanize - if %w(new to_accept to_reject).include? @track.state
New
- else
= @track.state.humanize
%dt %dt
Start date: Start date:
%dd %dd
- if @track.start_date = @track.start_date.strftime('%A, %B %-d. %Y') if @track.start_date
= @track.start_date.strftime('%A, %B %-d. %Y')
- else
N/A
%dt %dt
End date: End date:
%dd %dd
- if @track.end_date = @track.end_date.strftime('%A, %B %-d. %Y') if @track.end_date
= @track.end_date.strftime('%A, %B %-d. %Y') %dt
- else Room:
N/A %dd
= @track.room.try(:name)
%dt %dt
Description Description
%dd %dd
= @track.description = markdown(@track.description)
.row
.col-md-12.text-right
- if can? :edit, @track
= link_to 'Edit Track request', edit_conference_program_track_path(@conference.short_title, @track), class: 'btn btn-primary'

View file

@ -39,7 +39,7 @@ feature Track do
within('table#tracks') do within('table#tracks') do
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
expect(page.assert_selector('tr', count: 1)).to be true expect(page.has_content?('No data available in table')).to eq true
end end
end end

View file

@ -120,6 +120,46 @@ describe Track do
end end
end end
describe 'scope' do
describe '#confirmed' do
before :each do
@program = create(:program)
end
context 'includes' do
it 'when track is confirmed' do
confirmed_track = create(:track, state: 'confirmed', program: @program)
expect(@program.tracks.confirmed.include?(confirmed_track)).to eq true
end
end
context 'excludes' do
%w[new to_accept accepted to_reject rejected canceled withdrawn].each do |state|
it "when track is #{state.humanize}" do
unconfirmed_track = create(:track, state: state, program: @program)
expect(@program.tracks.confirmed.include?(unconfirmed_track)).to eq false
end
end
end
end
describe '#cfp_active' do
before :each do
@program = create(:program)
@cfp_active_track = create(:track, cfp_active: true, program: @program)
@non_cfp_active_track = create(:track, cfp_active: false, program: @program)
end
it 'include tracks with the cfp_active flag enabled' do
expect(@program.tracks.cfp_active.include?(@cfp_active_track)).to eq true
end
it 'excludes tracks with the cfp_active flag disabled' do
expect(@program.tracks.cfp_active.include?(@non_cfp_active_track)).to eq false
end
end
end
describe '#self_organized?' do describe '#self_organized?' do
it 'returns true when it has a submitter' do it 'returns true when it has a submitter' do
expect(self_organized_track.submitter).to be_a User expect(self_organized_track.submitter).to be_a User