From c83a6fb719c53db5372e5308e5162c38cc205559 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Fri, 10 Oct 2014 20:25:41 +0300 Subject: [PATCH] Add a backup event status --- app/controllers/management/events_controller.rb | 5 +++++ app/models/event.rb | 6 +++--- app/views/layouts/management.html.slim | 6 +++++- app/views/management/events/_state.html.slim | 4 ++-- config/routes.rb | 1 + 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/management/events_controller.rb b/app/controllers/management/events_controller.rb index 9bb0ac9..c809481 100644 --- a/app/controllers/management/events_controller.rb +++ b/app/controllers/management/events_controller.rb @@ -21,6 +21,11 @@ module Management render :index end + def backup + @suggestion_groups = SuggestionGroup.for_conference Conference.current, state: Event.states[:backup] + render :index + end + def show end diff --git a/app/models/event.rb b/app/models/event.rb index fd25349..9431b39 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -13,11 +13,11 @@ class Event < ActiveRecord::Base after_create :send_new_event_notification - enum state: [:undecided, :approved, :rejected] + enum state: [:undecided, :approved, :rejected, :backup] # XXX: this belongs in a decorator - STATE_TO_GLYPH = {undecided: 'question-sign', rejected: 'thumbs-down', approved: 'thumbs-up'} - STATE_TO_CLASS = {undecided: 'warning', rejected: 'danger', approved: 'success'} + STATE_TO_GLYPH = {undecided: 'question-sign', rejected: 'thumbs-down', approved: 'thumbs-up', backup: 'retweet'} + STATE_TO_CLASS = {undecided: 'warning', rejected: 'danger', approved: 'success', backup: 'info'} private diff --git a/app/views/layouts/management.html.slim b/app/views/layouts/management.html.slim index 0b969ee..03f7c7c 100644 --- a/app/views/layouts/management.html.slim +++ b/app/views/layouts/management.html.slim @@ -7,6 +7,7 @@ html meta name="viewport" content="width=device-width, initial-scale=1" title Clarion = stylesheet_link_tag "management/application" + = stylesheet_link_tag '//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.2.4/bootstrap-table.min.css' = csrf_meta_tags body nav.navbar.navbar-default.navbar-fixed-top @@ -30,12 +31,15 @@ html li class="#{'active' if action_name == 'index'}" = link_to "Всички", management_events_path li class="#{'active' if action_name == 'undecided'}" - = link_to "Висящи", undecided_management_events_path + = link_to "Нерешени", undecided_management_events_path li class="#{'active' if action_name == 'approved'}" = link_to "Одобрени", approved_management_events_path + li class="#{'active' if action_name == 'backup'}" + = link_to "Резерви", backup_management_events_path li class="#{'active' if action_name == 'rejected'}" = link_to "Отхвърлени", rejected_management_events_path div.container == yield = javascript_include_tag "management/application" + = javascript_include_tag '//cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.2.4/bootstrap-table.min.js' diff --git a/app/views/management/events/_state.html.slim b/app/views/management/events/_state.html.slim index 3412220..bacf668 100644 --- a/app/views/management/events/_state.html.slim +++ b/app/views/management/events/_state.html.slim @@ -1,9 +1,9 @@ .btn-group id="suggestion-#{suggestion.id}-state" - button class="btn dropdown-toggle btn-#{Event::STATE_TO_CLASS[suggestion.state.to_sym]}" type="button" data-toggle="dropdown" + button class="btn dropdown-toggle btn-#{Event::STATE_TO_CLASS[suggestion.state.to_sym]}" type="button" title="#{suggestion.state}" data-toggle="dropdown" => glyph Event::STATE_TO_GLYPH[suggestion.state.to_sym] span.caret ul.dropdown-menu role="menu" - Event.states.each do |state, number| - next if state == suggestion.state li - = link_to glyph(Event::STATE_TO_GLYPH[state.to_sym]), state_management_event_path(suggestion, state: state), class: "btn text-#{Event::STATE_TO_CLASS[state.to_sym]}", remote: true, method: :patch + = link_to glyph(Event::STATE_TO_GLYPH[state.to_sym]), state_management_event_path(suggestion, state: state), title: state, class: "btn text-#{Event::STATE_TO_CLASS[state.to_sym]}", remote: true, method: :patch diff --git a/config/routes.rb b/config/routes.rb index 5f10322..3ce2018 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,7 @@ Rails.application.routes.draw do get 'approved' get 'rejected' get 'undecided' + get 'backup' end end end