Sha256: f82e78eb11c0f936a583b51514e1d62b2797e15b842e7faf3b0b0861166a1b34
Contents?: true
Size: 1.27 KB
Versions: 39
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Decidim module Admin # This command gets called when a component is created from the admin panel. class CreateComponent < Rectify::Command attr_reader :form, :manifest, :participatory_space # Public: Initializes the command. # # form - The form from which the data in this component comes from. def initialize(form) @form = form @manifest = form.manifest end # Public: Creates the Component. # # Broadcasts :ok if created, :invalid otherwise. def call return broadcast(:invalid) if form.invalid? transaction do create_component run_hooks end broadcast(:ok) end private def create_component @component = Decidim.traceability.create!( Component, form.current_user, manifest_name: manifest.name, name: form.name, participatory_space: form.participatory_space, weight: form.weight, settings: form.settings, default_step_settings: form.default_step_settings, step_settings: form.step_settings ) end def run_hooks manifest.run_hooks(:create, @component) end end end end
Version data entries
39 entries across 39 versions & 1 rubygems