Class: Decidim::Admin::UpdateComponent
- Inherits:
-
Commands::UpdateResource
- Object
- Commands::UpdateResource
- Decidim::Admin::UpdateComponent
- Defined in:
- app/commands/decidim/admin/update_component.rb
Overview
This command gets called when a component is created from the admin panel.
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#previous_settings ⇒ Object
readonly
Returns the value of attribute previous_settings.
Instance Method Summary collapse
-
#call ⇒ Object
Public: Creates the Component.
-
#initialize(form, component) ⇒ UpdateComponent
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, component) ⇒ UpdateComponent
Public: Initializes the command.
form - The form from which the data in this component comes from. component - The component to update.
13 14 15 16 17 |
# File 'app/commands/decidim/admin/update_component.rb', line 13 def initialize(form, component) @form = form @component = component @manifest = component.manifest end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
7 8 9 |
# File 'app/commands/decidim/admin/update_component.rb', line 7 def component @component end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
7 8 9 |
# File 'app/commands/decidim/admin/update_component.rb', line 7 def form @form end |
#previous_settings ⇒ Object (readonly)
Returns the value of attribute previous_settings.
7 8 9 |
# File 'app/commands/decidim/admin/update_component.rb', line 7 def previous_settings @previous_settings end |
Instance Method Details
#call ⇒ Object
Public: Creates the Component.
Broadcasts :ok if created, :invalid otherwise.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/admin/update_component.rb', line 22 def call return broadcast(:invalid) if form.invalid? Decidim.traceability.perform_action!("update", @component, form.current_user) do transaction do update_component run_hooks end end broadcast(:ok, settings_changed?, previous_settings, current_settings) end |