Sha256: c2d3bcd3ab17a8225200b1bbaac0624648e8dc53ba8ec3daa79038a983f920c1

Contents?: true

Size: 964 Bytes

Versions: 25

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This command gets called when a component is unpublished from the admin panel.
    class UnpublishComponent < Decidim::Command
      # Public: Initializes the command.
      #
      # component - The component to unpublish.
      # current_user - the user performing the action
      def initialize(component, current_user)
        @component = component
        @current_user = current_user
      end

      # Public: Unpublishes the Component.
      #
      # Broadcasts :ok if unpublished, :invalid otherwise.
      def call
        unpublish_component

        broadcast(:ok)
      end

      private

      attr_reader :component, :current_user

      def unpublish_component
        Decidim.traceability.perform_action!(
          :unpublish,
          component,
          current_user
        ) do
          component.unpublish!
          component
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.4 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.9 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.29.0 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.3 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.8 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.29.0.rc4 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.29.0.rc3 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.29.0.rc2 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.29.0.rc1 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.2 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.7 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.1 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.6 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.0 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.5 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.4 app/commands/decidim/admin/unpublish_component.rb
decidim-admin-0.27.3 app/commands/decidim/admin/unpublish_component.rb