Class: Decidim::Accountability::Admin::TimelineEntriesController
- Inherits:
-
ApplicationController
- Object
- Decidim::Admin::Components::BaseController
- ApplicationController
- Decidim::Accountability::Admin::TimelineEntriesController
- Defined in:
- app/controllers/decidim/accountability/admin/timeline_entries_controller.rb
Overview
This controller allows an admin to manage timeline entries for a Result
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/decidim/accountability/admin/timeline_entries_controller.rb', line 16 def create :create, :timeline_entry @form = form(TimelineEntryForm).from_params(params) @form.decidim_accountability_result_id = params[:result_id] CreateTimelineEntry.call(@form) do on(:ok) do flash[:notice] = I18n.t("timeline_entries.create.success", scope: "decidim.accountability.admin") redirect_to result_timeline_entries_path(params[:result_id]) end on(:invalid) do flash.now[:alert] = I18n.t("timeline_entries.create.invalid", scope: "decidim.accountability.admin") render action: "new" end end end |
#destroy ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/decidim/accountability/admin/timeline_entries_controller.rb', line 59 def destroy (:destroy, :timeline_entry, timeline_entry:) Decidim::Commands::DestroyResource.call(timeline_entry, current_user) do on(:ok) do flash[:notice] = I18n.t("timeline_entries.destroy.success", scope: "decidim.accountability.admin") redirect_to result_timeline_entries_path(params[:result_id]) end end end |
#edit ⇒ Object
35 36 37 38 39 |
# File 'app/controllers/decidim/accountability/admin/timeline_entries_controller.rb', line 35 def edit (:update, :timeline_entry, timeline_entry:) @form = form(TimelineEntryForm).from_model(timeline_entry) end |
#new ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/decidim/accountability/admin/timeline_entries_controller.rb', line 10 def new :create, :timeline_entry @form = form(TimelineEntryForm).instance end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/decidim/accountability/admin/timeline_entries_controller.rb', line 41 def update (:update, :timeline_entry, timeline_entry:) @form = form(TimelineEntryForm).from_params(params) UpdateTimelineEntry.call(@form, timeline_entry) do on(:ok) do flash[:notice] = I18n.t("timeline_entries.update.success", scope: "decidim.accountability.admin") redirect_to result_timeline_entries_path(params[:result_id]) end on(:invalid) do flash.now[:alert] = I18n.t("timeline_entries.update.invalid", scope: "decidim.accountability.admin") render action: "edit" end end end |