Sha256: 06d13581b3e9bfc7821cad451cc8fed3c7554a67af64f330925397ada0847198

Contents?: true

Size: 1006 Bytes

Versions: 6

Compression:

Stored size: 1006 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module EnhancedTextwork
    module Admin
      class ParagraphsSplitsController < Admin::ApplicationController
        def create
          enforce_permission_to :split, :paragraphs

          @form = form(Admin::ParagraphsSplitForm).from_params(params)

          Admin::SplitParagraphs.call(@form) do
            on(:ok) do |_paragraph|
              flash[:notice] = I18n.t("paragraphs_splits.create.success", scope: "decidim.enhanced_textwork.admin")
              redirect_to EngineRouter.admin_proxy(@form.target_component).root_path
            end

            on(:invalid) do
              flash[:alert_html] = Decidim::ValidationErrorsPresenter.new(
                I18n.t("paragraphs_splits.create.invalid", scope: "decidim.enhanced_textwork.admin"),
                @form
              ).message
              redirect_to EngineRouter.admin_proxy(current_component).root_path
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-enhanced_textwork-1.0.5 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb
decidim-enhanced_textwork-1.0.4 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb
decidim-enhanced_textwork-1.0.3 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb
decidim-enhanced_textwork-1.0.2 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb
decidim-enhanced_textwork-1.0.1 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb
decidim-enhanced_textwork-1.0.0 app/controllers/decidim/enhanced_textwork/admin/paragraphs_splits_controller.rb