diff --git a/app/assets/stylesheets/management/_record_tables.scss b/app/assets/stylesheets/management/_record_tables.scss index 80438a8..41f9ca1 100644 --- a/app/assets/stylesheets/management/_record_tables.scss +++ b/app/assets/stylesheets/management/_record_tables.scss @@ -31,3 +31,9 @@ th.action, td.action { float: right; text-align: right; } + +@media (min-width: $screen-md-min) { + #filters { + display: block !important; + } +} diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index 9662155..44677eb 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -2,7 +2,9 @@ module Management class EventsController < ManagementController def index @conference = find_conference - @events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type) + @filters = params[:filters] || {} + @events = EventSearch.new(scope: Event.where(conference: @conference).eager_load(:proposition, :proposer, :track, :event_type), filters: params[:filters]).results + # @events = @conference.events.order(:title).includes(:proposition, :proposer, :track, :event_type) end def show diff --git a/app/models/event_search.rb b/app/models/event_search.rb new file mode 100644 index 0000000..5c068ac --- /dev/null +++ b/app/models/event_search.rb @@ -0,0 +1,9 @@ +class EventSearch + include SearchObject.module + + option(:title) { |scope, value| scope.where title: value } + option(:language) { |scope, value| scope.where language: value } + option(:track_id) { |scope, value| scope.where track_id: value } + option(:event_type_id) { |scope, value| scope.where event_type_id: value } + option(:status) { |scope, value| scope.joins(:proposition).where(propositions: {status: value}) } +end diff --git a/app/views/management/events/_event.slim b/app/views/management/events/_event.slim index 7c4375d..144b08c 100644 --- a/app/views/management/events/_event.slim +++ b/app/views/management/events/_event.slim @@ -1,17 +1,20 @@ tr td - = event.title - - if event.subtitle.present? - br - span.small = event.subtitle + dl.dl-horizontal + dt = Event.human_attribute_name :title + dd = event.title + - if event.subtitle.present? + dt = Event.human_attribute_name :subtitle + dd = event.subtitle + dt = EventType.model_name.human.mb_chars.titleize + dd = event.event_type.name + dt = Event.human_attribute_name :track + dd = event.track.name + dt = Event.human_attribute_name :language + dd = t("locales.#{event.language}") + 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}"}" diff --git a/app/views/management/events/_no_records.html.slim b/app/views/management/events/_no_records.html.slim new file mode 100644 index 0000000..9a51861 --- /dev/null +++ b/app/views/management/events/_no_records.html.slim @@ -0,0 +1,3 @@ +tr + td colspan="20" + = t '.no_records_found' diff --git a/app/views/management/events/index.html.slim b/app/views/management/events/index.html.slim index 998493a..5b9e48f 100644 --- a/app/views/management/events/index.html.slim +++ b/app/views/management/events/index.html.slim @@ -1,21 +1,82 @@ - content_for :title = Event.model_name.human(count: 2).mb_chars.capitalize +/.row +/ ul.nav.nav-tabs +/ = content_tag :li, role: "presentation", class: params[:event_type_id].blank? ? 'active' : nil +/ = link_to management_conference_events_path(current_conference) +/ = t '.all' +/ - current_conference.event_types.each do |event_type| +/ = content_tag :li, role: "presentation", class: params[:event_type_id].to_i == event_type.id ? 'active' : nil +/ = link_to management_conference_events_path(current_conference, event_type_id: event_type.id) +/ = event_type.name +/ .row - h1.page-header - = Event.model_name.human(count: 2).mb_chars.titleize + .col-lg-12 + h1.page-header + = Event.model_name.human(count: 2).mb_chars.titleize +.row.visible-sm + .col-xs-12 + = link_to t('.filters'), '#filters', aria_expanded: true, aria_controls: 'filters', data: {toggle: 'collapse'}, role: 'button', class: 'btn btn-info' .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 + .col-md-2.collapse#filters + .panel.panel-default + .panel-heading + = EventType.model_name.human.mb_chars.titleize + .panel-body + ul.nav.nav-pills.nav-stacked + = content_tag :li, role: "presentation", class: @filters[:event_type_id].blank? ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.except(:event_type_id)) + = t '.all' + - current_conference.event_types.each do |event_type| + = content_tag :li, role: "presentation", class: @filters[:event_type_id].to_i == event_type.id ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.merge({event_type_id: event_type.id})) + = event_type.name + .panel.panel-default + .panel-heading + = Event.human_attribute_name(:track) + .panel-body + ul.nav.nav-pills.nav-stacked + = content_tag :li, role: "presentation", class: @filters[:track].blank? ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.except(:track)) + = t '.all' + - current_conference.tracks.each do |track| + = content_tag :li, role: "presentation", class: @filters[:track] == track.id.to_s ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.merge({track: track.id})) + = track.name + .panel.panel-default + .panel-heading + = Event.human_attribute_name(:language) + .panel-body + ul.nav.nav-pills.nav-stacked + = content_tag :li, role: "presentation", class: @filters[:language].blank? ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.except(:language)) + = t '.all' + - I18n.available_locales.map(&:to_s).each do |language| + = content_tag :li, role: "presentation", class: @filters[:language] == language ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.merge({language: language})) + = t("locales.#{language}") + .panel.panel-default + .panel-heading + = Proposition.human_attribute_name(:status) + .panel-body + ul.nav.nav-pills.nav-stacked + = content_tag :li, role: "presentation", class: @filters[:status].blank? ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.except(:status)) + = t '.all' + - Proposition.statuses.each do |status_name, status_id| + = content_tag :li, role: "presentation", class: @filters[:status] == status_id.to_s ? 'active' : nil + = link_to management_conference_events_path(current_conference, filters: @filters.merge({status: status_id})) + = t "activerecord.attributes.proposition.statuses.#{status_name}" + .col-md-10 + .panel.panel-default + table.table.table-striped.table-hover + thead + tr + th = Event.model_name.human.mb_chars.titleize + th = Event.human_attribute_name(:user) + th.action + = Event.human_attribute_name(:status) + th.actions + tbody + = render(partial: 'event', collection: @events) || render(partial: 'no_records') diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 838a8ae..a57ff5f 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -3,6 +3,11 @@ bg: conferences: show: cfp_status: 'Състояние на CFP:' + events: + index: + all: "Всички" + no_records: + no_records_found: 'Не бяха открити записи, които да отговарят на изискванията' abstract: "Резюме" helpers: submit: @@ -33,6 +38,13 @@ bg: title: "Преглед на %{model}" activerecord: attributes: + proposition: + status: Състояние + statuses: + undecided: Неопределено + approved: Одобрено + rejected: Отхвърлено + backup: Резерва conference: description: "Описание" email: E-mail