Class: Decidim::Notify::Admin::ChaptersController
- Inherits:
-
ApplicationController
- Object
- Admin::Components::BaseController
- ApplicationController
- Decidim::Notify::Admin::ChaptersController
- Includes:
- Broadcasts
- Defined in:
- app/controllers/decidim/notify/admin/chapters_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/decidim/notify/admin/chapters_controller.rb', line 16 def create :create, :chapter @form = form(ChapterForm).from_params(params) CreateChapter.call(@form) do on(:ok) do |chapter| flash[:notice] = I18n.t("chapters.create.success", scope: "decidim.notify.admin") broadcast_create_chapter chapter redirect_to EngineRouter.admin_proxy(current_component).chapters_path end on(:invalid) do flash.now[:alert] = I18n.t("chapters.create.error", scope: "decidim.notify.admin") render :new end end end |
#destroy ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/decidim/notify/admin/chapters_controller.rb', line 60 def destroy :destroy, :chapter, chapter: current_chapter DestroyChapter.call(current_chapter) do on(:ok) do flash[:notice] = I18n.t("chapters.destroy.success", scope: "decidim.notify.admin") broadcast_destroy_chapter params[:id] redirect_to EngineRouter.admin_proxy(current_component).chapters_path end on(:invalid) do flash.now[:alert] = I18n.t("chapters.destroy.error", scope: "decidim.notify.admin") redirect_to EngineRouter.admin_proxy(current_component).chapters_path end end end |
#edit ⇒ Object
36 37 38 39 |
# File 'app/controllers/decidim/notify/admin/chapters_controller.rb', line 36 def edit :update, :chapter, chapter: current_chapter @form = form(ChapterForm).from_model(current_chapter) end |
#new ⇒ Object
11 12 13 14 |
# File 'app/controllers/decidim/notify/admin/chapters_controller.rb', line 11 def new :create, :chapter @form = form(ChapterForm).instance end |
#update ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/decidim/notify/admin/chapters_controller.rb', line 41 def update :update, :chapter, chapter: current_chapter @form = form(ChapterForm).from_params(params) UpdateChapter.call(@form, current_chapter) do on(:ok) do flash[:notice] = I18n.t("chapters.update.success", scope: "decidim.notify.admin") broadcast_update_chapter current_chapter redirect_to EngineRouter.admin_proxy(current_component).chapters_path end on(:invalid) do flash.now[:alert] = I18n.t("chapters.update.error", scope: "decidim.notify.admin") render :edit end end end |