Class: Decidim::Admin::HideMenuComponent

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

Overview

This command gets called when a component is marked as not visible (hidden) in the menu from the admin panel.

Instance Method Summary collapse

Constructor Details

#initialize(component, current_user) ⇒ HideMenuComponent

Public: Initializes the command.

component - The component to publish. current_user - the user performing the action



11
12
13
14
# File 'app/commands/decidim/admin/hide_menu_component.rb', line 11

def initialize(component, current_user)
  @component = component
  @current_user = current_user
end

Instance Method Details

#callObject

Public: Publishes the Component.

Broadcasts :ok if disabled visibility, :invalid otherwise.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/commands/decidim/admin/hide_menu_component.rb', line 19

def call
  Decidim.traceability.perform_action!(
    :menu_hidden,
    component,
    current_user,
    visibility: "all"
  ) do
    component.update!(visible: false)
  end

  broadcast(:ok)
end