Skip to content

Commit

Permalink
Use instance methods instead of class ones. Each button has its own c…
Browse files Browse the repository at this point in the history
…lass.
  • Loading branch information
ZitaNemeckova committed Oct 23, 2019
1 parent 35e5cf7 commit 65564e6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/helpers/application_helper/button/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def initialize(view_context, view_binding, instance_data, props)
end
end

def self.data(_record)
nil
def data(data)
data
end

def role_allows_feature?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class ApplicationHelper::Button::GenericObjectDefinitionButtonButtonDelete < ApplicationHelper::Button::Basic
needs :@record

def data(data)
{
'function' => 'sendDataWithRx',
'function-data' => {
:type => 'delete',
:controller => 'toolbarActions',
:payload => {
:entity => "custom_buttons",
:redirect_url => "/generic_object_definition/",
:name => @record.name,
:labels => { :single => _("Button") }
}
}
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ def disabled?
@record.kind_of?(CustomButtonSet) && !@record.custom_buttons.count.zero?
end

def self.data(record)
def data(data)
{
'function' => 'sendDataWithRx',
'function-data' => {
'function' => 'sendDataWithRx',
'function-data' => {
:type => 'delete',
:controller => 'toolbarActions',
:payload => {
:entity => record.class.model_name.plural,
:entity => "custom_button_sets",
:redirect_url => "/generic_object_definition/",
:name => record.name,
:labels => { :single => record.class.name }
:name => @record.name,
:labels => { :single => _("Button Group") }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApplicationHelper::Toolbar::GenericObjectDefinitionButtonCenter < Applicat
'pficon pficon-delete fa-lg',
N_('Remove this Custom Button from Inventory'),
:confirm => N_("Warning: This Button will be permanently removed!"),
:klass => ApplicationHelper::Button::GenericObjectDefinitionButtonButtonGroupDelete
:klass => ApplicationHelper::Button::GenericObjectDefinitionButtonButtonDelete
)
]
)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def build_select_button(bgi, index)
def apply_common_props(button, input)
button.update(
:color => input[:color],
:data => input[:data] || (input[:klass].present? ? input[:klass].data(@record) : nil),
:data => button.data(input[:data]),
:hidden => button[:hidden] || !!input[:hidden],
:icon => input[:icon],
:name => button[:id],
Expand Down

0 comments on commit 65564e6

Please sign in to comment.