Skip to content

Commit

Permalink
Toolbar fixes to account for applies_to_id in button group
Browse files Browse the repository at this point in the history
Toolbar fixes to account for applies_to_id in button group
  • Loading branch information
lgalis committed Nov 13, 2017
1 parent 434a105 commit 165c5e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 15 additions & 7 deletions app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,14 @@ def custom_button_selects(model, record, toolbar_result)
end

def custom_toolbar_class(toolbar_result)
model = if @display == 'generic_objects'
GenericObjectDefinition
else
@record ? @record.class : model_for_custom_toolbar
end
build_custom_toolbar_class(model, @record, toolbar_result)
record = @record
if @display == 'generic_objects'
model = GenericObjectDefinition
record = GenericObject.find_by(:id => @sb[:rec_id])
else
model = @record ? @record.class : model_for_custom_toolbar
end
build_custom_toolbar_class(model, record, toolbar_result)
end

def build_custom_toolbar_class(model, record, toolbar_result)
Expand Down Expand Up @@ -359,7 +361,8 @@ def button_class_name(model)
def service_template_id(record)
case record
when Service then record.service_template_id
when ServiceTemplate then record.id
when ServiceTemplate, GenericObjectDefinition then record.id
when GenericObject then record.generic_object_definition.id
end
end

Expand All @@ -369,6 +372,11 @@ def record_to_service_buttons(record)
record.service_template.custom_buttons.collect { |cb| create_raw_custom_button_hash(cb, record) }
end

def record_to_generic_object_buttons(record)
return [] unless record.kind_of?(GenericObject)
record.generic_object_definition.custom_buttons.collect{ |cb| create_raw_custom_button_hash(cb, record) }
end

def get_custom_buttons(model, record, toolbar_result)
cbses = CustomButtonSet.find_all_by_class_name(button_class_name(model), service_template_id(record))
cbses = CustomButtonSet.filter_with_visibility_expression(cbses, record)
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2968,6 +2968,7 @@

:service => {
:get => %w(
dialog_load
download_data
edit
explorer
Expand Down

0 comments on commit 165c5e9

Please sign in to comment.