Sha256: 39e281df93dc32e923dce93827660b4ffccde74b2456f37f92a53d7436fad96d
Contents?: true
Size: 1.08 KB
Versions: 14
Compression:
Stored size: 1.08 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command that sets all steps in a participatory process as inactive class DestroyParticipatoryProcessStep < Rectify::Command # Public: Initializes the command. # # step - A ParticipatoryProcessStep that will be deactivated def initialize(step) @step = step @participatory_process = step.participatory_process end # Executes the command. Broadcasts these events: # # - :ok when everything is valid. # - :invalid if the data wasn't valid and we couldn't proceed. # # Returns nothing. def call return broadcast(:invalid, :active_step) if active_step? @step.destroy! reorder_steps broadcast(:ok) end private def active_step? @participatory_process.steps.count > 1 && @step.active? end def reorder_steps steps = @participatory_process.steps.reload ReorderParticipatoryProcessSteps .new(steps, steps.map(&:id)) .call end end end end
Version data entries
14 entries across 14 versions & 2 rubygems