Class: Decidim::ParticipatoryProcesses::Admin::ReorderParticipatoryProcessSteps

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

Overview

A command that reorders the steps in a participatory process.

Instance Method Summary collapse

Constructor Details

#initialize(collection, order) ⇒ ReorderParticipatoryProcessSteps

Public: Initializes the command.

collection - an ActiveRecord::Relation of steps order - an Array holding the order of IDs of steps


12
13
14
15
# File 'decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb', line 12

def initialize(collection, order)
  @collection = collection
  @order = order
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.


23
24
25
26
27
28
# File 'decidim-participatory_processes/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb', line 23

def call
  return broadcast(:invalid) if order.blank?

  reorder_steps
  broadcast(:ok)
end