-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposals dashboard refactored to dashboard. Added missing specs for the dashboard.
- Loading branch information
Showing
82 changed files
with
1,131 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
class Admin::Dashboard::ActionsController < Admin::Dashboard::BaseController | ||
helper_method :dashboard_action, :resource | ||
|
||
def index | ||
@dashboard_actions = ::Dashboard::Action.order(required_supports: :asc) | ||
end | ||
|
||
def new | ||
@dashboard_action = ::Dashboard::Action.new( | ||
active: true, | ||
day_offset: 0, | ||
required_supports: 0, | ||
request_to_administrators: true, | ||
action_type: 'proposed_action' | ||
) | ||
end | ||
|
||
def create | ||
@dashboard_action = ::Dashboard::Action.new(dashboard_action_params) | ||
if @dashboard_action.save | ||
redirect_to admin_dashboard_actions_path, notice: t('admin.dashboard.actions.create.notice') | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def edit; end | ||
|
||
def update | ||
if dashboard_action.update(dashboard_action_params) | ||
redirect_to admin_dashboard_actions_path | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
if dashboard_action.destroy | ||
flash[:notice] = t('admin.dashboard.actions.delete.success') | ||
else | ||
flash[:error] = dashboard_action.errors.full_messages.join(',') | ||
end | ||
|
||
redirect_to admin_dashboard_actions_path | ||
end | ||
|
||
private | ||
|
||
def resource | ||
@dashboard_action | ||
end | ||
|
||
def dashboard_action_params | ||
params | ||
.require(:dashboard_action) | ||
.permit( | ||
:title, :description, :short_description, :request_to_administrators, :day_offset, | ||
:required_supports, :order, :active, :action_type, | ||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy], | ||
links_attributes: [:id, :label, :url, :open_in_new_tab, :_destroy] | ||
) | ||
end | ||
|
||
def dashboard_action | ||
@dashboard_action ||= ::Dashboard::Action.find(params[:id]) | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
app/controllers/admin/dashboard/administrator_tasks_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Admin::Dashboard::AdministratorTasksController < Admin::Dashboard::BaseController | ||
helper_method :administrator_task | ||
|
||
def index | ||
authorize! :index, ::Dashboard::AdministratorTask | ||
@administrator_tasks = ::Dashboard::AdministratorTask.pending | ||
end | ||
|
||
def edit | ||
authorize! :edit, administrator_task | ||
end | ||
|
||
def update | ||
authorize! :update, administrator_task | ||
|
||
administrator_task.update(user: current_user, executed_at: Time.now) | ||
redirect_to admin_dashboard_administrator_tasks_path, | ||
{ flash: { notice: t("admin.dashboard.administrator_tasks.update.success") } } | ||
end | ||
|
||
private | ||
|
||
def administrator_task | ||
@administrator_task ||= ::Dashboard::AdministratorTask.find(params[:id]) | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...min/proposal_dashboard/base_controller.rb → ...ollers/admin/dashboard/base_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
app/controllers/admin/proposal_dashboard/actions_controller.rb
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
app/controllers/admin/proposal_dashboard/administrator_tasks_controller.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Admin::ProposalDashboardActionsHelper | ||
def active_human_readable(active) | ||
return t('admin.proposal_dashboard_actions.index.active') if active | ||
t('admin.proposal_dashboard_actions.index.inactive') | ||
return t('admin.dashboard.actions.index.active') if active | ||
t('admin.dashboard.actions.index.inactive') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.