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.
This commit is contained in:
Juan Salvador Pérez García
2018-10-04 11:47:14 +02:00
parent 1163999ec0
commit 491e6e4b6e

View File

@@ -2,7 +2,7 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController
helper_method :dashboard_action, :resource helper_method :dashboard_action, :resource
def index def index
@dashboard_actions = ::Dashboard::Action.order(required_supports: :asc) @dashboard_actions = proposed_actions + resources
end end
def new def new
@@ -64,4 +64,12 @@ class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController
def dashboard_action def dashboard_action
@dashboard_action ||= ::Dashboard::Action.find(params[:id]) @dashboard_action ||= ::Dashboard::Action.find(params[:id])
end 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 end