Implement event filtering in the admin interface

This commit is contained in:
Petko Bordjukov 2016-10-08 19:29:08 +03:00
parent 90faed37b8
commit 9e27186b3a
7 changed files with 123 additions and 27 deletions

View File

@ -31,3 +31,9 @@ th.action, td.action {
float: right;
text-align: right;
}
@media (min-width: $screen-md-min) {
#filters {
display: block !important;
}
}

View File

@ -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

View File

@ -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

View File

@ -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}"}"

View File

@ -0,0 +1,3 @@
tr
td colspan="20"
= t '.no_records_found'

View File

@ -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')

View File

@ -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