Class: Decidim::Admin::DestroyParticipatoryProcessStep

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb

Overview

A command that sets all steps in a participatory process as inactive

Instance Method Summary collapse

Constructor Details

#initialize(step) ⇒ DestroyParticipatoryProcessStep

Public: Initializes the command.

step - A ParticipatoryProcessStep that will be deactivated



10
11
12
13
# File 'decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb', line 10

def initialize(step)
  @step = step
  @participatory_process = step.participatory_process
end

Instance Method Details

#callObject

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.



21
22
23
24
25
26
27
28
# File 'decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb', line 21

def call
  return broadcast(:invalid, :last_step) if @participatory_process.steps.count == 1
  return broadcast(:invalid, :active_step) if @step.active?

  @step.destroy!
  reorder_steps
  broadcast(:ok)
end