Sha256: 0cd6b18149fb3b6cc29926e729381ab670f5cf4439fb555e82f1616222668d20

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module Decidim
  module EnhancedTextwork
    module Admin
      class ParagraphsImportsController < Admin::ApplicationController
        def new
          enforce_permission_to :import, :paragraphs

          @form = form(Admin::ParagraphsImportForm).instance
        end

        def create
          enforce_permission_to :import, :paragraphs

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

          Admin::ImportParagraphs.call(@form) do
            on(:ok) do |paragraphs|
              flash[:notice] = I18n.t("paragraphs_imports.create.success", scope: "decidim.enhanced_textwork.admin", number: paragraphs.length)
              redirect_to EngineRouter.admin_proxy(current_component).root_path
            end

            on(:invalid) do
              flash.now[:alert] = I18n.t("paragraphs_imports.create.invalid", scope: "decidim.enhanced_textwork.admin")
              render action: "new"
            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_imports_controller.rb
decidim-enhanced_textwork-1.0.4 app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb
decidim-enhanced_textwork-1.0.3 app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb
decidim-enhanced_textwork-1.0.2 app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb
decidim-enhanced_textwork-1.0.1 app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb
decidim-enhanced_textwork-1.0.0 app/controllers/decidim/enhanced_textwork/admin/paragraphs_imports_controller.rb