From 491e6e4b6e548e9638939de3230c359be098af08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Thu, 4 Oct 2018 11:47:14 +0200 Subject: [PATCH] Fixes action sorting Administration of dashboard actions currently shows proposed actions as well as resources mixed. This patch tries to improve how they're shown making things easier for administrators: Resources will be shown after proposed actions, never mixed. Proposed actions will be sorted according to the order attribute. Resources will be sort according the two attributes that define its availability: The number of supports required. The number of days after the proposal publication. --- app/controllers/admin/dashboard/actions_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/dashboard/actions_controller.rb b/app/controllers/admin/dashboard/actions_controller.rb index 358174c0e..07eae766c 100644 --- a/app/controllers/admin/dashboard/actions_controller.rb +++ b/app/controllers/admin/dashboard/actions_controller.rb @@ -2,7 +2,7 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController helper_method :dashboard_action, :resource def index - @dashboard_actions = ::Dashboard::Action.order(required_supports: :asc) + @dashboard_actions = proposed_actions + resources end def new @@ -64,4 +64,12 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController def dashboard_action @dashboard_action ||= ::Dashboard::Action.find(params[:id]) end + + def proposed_actions + ::Dashboard::Action.proposed_actions.order(order: :asc) + end + + def resources + ::Dashboard::Action.resources.order(required_supports: :asc, day_offset: :asc) + end end