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
  • Loading branch information
lgalis committed Nov 13, 2017
1 parent 4113418 commit 1cb14f8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 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
2 changes: 2 additions & 0 deletions app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ def center_toolbar_filename_classic
elsif to_display_center.include?(@display)
return "#{@display}_center"
end
elsif @display == 'generic_objects'
return "#{@display}_center"
elsif @lastaction == "compare_miq" || @lastaction == "compare_compress"
return "compare_center_tb"
elsif @lastaction == "drift_history"
Expand Down
4 changes: 2 additions & 2 deletions app/views/service/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#main_div
- if %w(generic_objects).include?(@display)
- if @lastaction == 'generic_object'
= render :partial => "layouts/item", :locals => {:action_url => "show/#{@item.id}"}
- if @lastaction == 'generic_object' && @item
= render :partial => "layouts/item", :locals => {:action_url => "show/#{@item}"}
- else
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
- else
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 1cb14f8

Please sign in to comment.