diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index 4138bfd..00744de 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -2,7 +2,7 @@ module Management class EventsController < ManagementController def index @conference = find_conference - @events = @conference.events.approved + @events = @conference.events.order(:title) end def show diff --git a/app/controllers/management/propositions_controller.rb b/app/controllers/management/propositions_controller.rb index ebb8eb2..67a7e00 100644 --- a/app/controllers/management/propositions_controller.rb +++ b/app/controllers/management/propositions_controller.rb @@ -5,8 +5,20 @@ module Management @events_by_proposer = @conference.events.undecided.group_by(&:proposer) end + def update + @proposition = Proposition.find(params[:id]) + + @proposition.update(proposition_params) + + redirect_to :back + end + private + def proposition_params + params.require(:proposition).permit(:status) + end + def find_conference Conference.find(params[:conference_id]) end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 190f23c..8991b8b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -5,6 +5,34 @@ module ApplicationHelper end end + def proposition_status_class(status) + { + "undecided" => "default", + "approved" => "info", + "rejected" => "danger", + "backup" => "warning" + }.with_indifferent_access[status] + end + + def proposition_status_glyph(status) + { + "undecided" => "question", + "approved" => "thumbs-up", + "rejected" => "thumbs-down", + "backup" => "refresh" + }.with_indifferent_access[status] + end + + def proposition_status_icon(status) + icon(proposition_status_glyph(status)) + end + + def proposition_status(record) + klass = record.class + output = '' + + end + def action_buttons(conference, record, actions = [:index, :show, :edit, :destroy]) klass = record.class output = '' @@ -34,7 +62,7 @@ module ApplicationHelper output += link_to(icon(:trash), [:management, conference, record], { method: :delete, data: {confirm: t('actions.are_you_sure')}, - title: t('actions.edit.button', model: klass.model_name.human), + title: t('actions.destroy.button', model: klass.model_name.human), class: 'btn btn-danger' }) end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 0000000..45f9d7e --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,9 @@ +module EventsHelper + def participant_names_or_emails(event) + event.participants.map do |participant| + participant.try(:personal_profile, current_conference).try(:name) || + participant.personal_profiles.last.try(:name) || + participant.email + end + end +end diff --git a/app/models/event.rb b/app/models/event.rb index c3ac8fd..c33520c 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -26,6 +26,8 @@ class Event < ActiveRecord::Base scope :confirmed, -> { where.not confirmed_at: nil } + delegate :status, to: :proposition + def proposer_profile proposer.personal_profile(conference) end diff --git a/app/views/management/events/_event.slim b/app/views/management/events/_event.slim new file mode 100644 index 0000000..7c4375d --- /dev/null +++ b/app/views/management/events/_event.slim @@ -0,0 +1,29 @@ +tr + td + = event.title + - if event.subtitle.present? + br + span.small = event.subtitle + td + = participant_names_or_emails(event).join(', ') + td + = t("locales.#{event.language}") + td + = event.track.name + td + = event.event_type.name + td.action + .dropdown + button class="btn btn-sm dropdown-toggle btn-#{proposition_status_class(event.status)}" type="button" data-toggle="dropdown" title="#{t "status.#{event.status}"}" + = icon(proposition_status_glyph(event.status)) + span.caret< + ul.dropdown-menu + - Proposition.statuses.each do |(status, _)| + - next if status == event.status + li + = link_to [:management, @conference, event.proposition, proposition: {status: status}], method: :patch do + = proposition_status_icon(status) + =< t "status.#{status}" + td.actions + .btn-group.btn-group-sm + = action_buttons(@conference, event, [:show, :edit]) diff --git a/app/views/management/events/index.html.slim b/app/views/management/events/index.html.slim index d86cb0b..453e2f3 100644 --- a/app/views/management/events/index.html.slim +++ b/app/views/management/events/index.html.slim @@ -1,36 +1,18 @@ .row - .col-lg-12 - .panel.panel-default - .panel-heading - h2.panel-title= Event.model_name.human(count: 2).mb_chars.capitalize - - .panel-body - table.table.table-striped.table-hover.record-table - thead - tr - th = Event.human_attribute_name :title - th = Event.human_attribute_name :subtitle - th = Event.human_attribute_name :user - th = Event.human_attribute_name :length - th = Event.human_attribute_name :language - th.actions - tbody - - @events.each do |event| - - proposer = event.proposer - - proposer_profile = event.proposer_profile - - tr - td= event.title - td= event.subtitle - td - - if proposer_profile - = link_to proposer_profile.name, [:management, @conference, proposer_profile] - - else - | No profile for user #{proposer.email} - - td #{event.length} minutes - td= event.language - - td.actions - div.btn-group.btn-group-sm - = action_buttons(@conference, event, [:show, :edit, :destroy]) + h1.page-header + = Event.model_name.human(count: 2).mb_chars.titleize +.row + .panel.panel-default + table.table + thead + tr + th = Event.human_attribute_name(:title) + th = Event.human_attribute_name(:user) + th = Event.human_attribute_name(:language) + th = Track.model_name.human + th = Event.human_attribute_name(:type) + th.action + = Event.human_attribute_name(:status) + th.actions + tbody + = render partial: 'event', collection: @events diff --git a/config/locales/management.bg.yml b/config/locales/management.bg.yml index 74757bc..d398863 100644 --- a/config/locales/management.bg.yml +++ b/config/locales/management.bg.yml @@ -2,4 +2,9 @@ bg: are_you_sure: Сигурен ли си? view: Преглед home: Начало - more_about_user: "Повече информация за %{user}" \ No newline at end of file + more_about_user: "Повече информация за %{user}" + status: + undecided: Неопределен + approved: Одобрен + rejected: Отхвърлен + backup: Резерва \ No newline at end of file diff --git a/config/locales/management.en.yml b/config/locales/management.en.yml index 3da14eb..649379b 100644 --- a/config/locales/management.en.yml +++ b/config/locales/management.en.yml @@ -1,4 +1,9 @@ en: are_you_sure: Are you sure? view: View - home: Home \ No newline at end of file + home: Home + status: + undecided: Undecided + approved: Approved + rejected: Rejected + backup: Back-up \ No newline at end of file