Skip to content

Commit c1df06d

Browse files
authored
Merge pull request #9266 from GilbertCherrie/fix_go_embedded_table
Fix generic object embedded table
2 parents f890e1a + f1677a1 commit c1df06d

File tree

7 files changed

+25
-37
lines changed

7 files changed

+25
-37
lines changed

app/controllers/generic_object_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ def textual_group_list
3838
end
3939

4040
helper_method :textual_group_list
41+
has_custom_buttons
4142
end

app/controllers/mixins/custom_buttons.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def custom_toolbar_explorer
2222
def custom_toolbar_simple
2323
if @record && %w[show show_dashboard].include?(@lastaction) && %w[dashboard main].include?(@display)
2424
Mixins::CustomButtons::Result.new(:single)
25-
elsif @lastaction == "show_list"
26-
Mixins::CustomButtons::Result.new(:list)
27-
elsif relationship_table_screen?
25+
elsif @lastaction == "show_list" || relationship_table_screen?
2826
Mixins::CustomButtons::Result.new(:list)
2927
elsif @display == 'generic_objects'
3028
@lastaction == 'generic_object' ? Mixins::CustomButtons::Result.new(:single) : Mixins::CustomButtons::Result.new(:list)

app/controllers/service_controller.rb

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ def show_list
1616
process_show_list(:dbname => :service, :gtl_dbname => :service)
1717
end
1818

19-
def show
20-
super
21-
@options = {}
22-
@view, @pages = get_view(Vm, :parent => @record, :parent_method => :all_vms, :all_pages => true)
23-
end
24-
2519
def button
2620
case params[:pressed]
2721
when 'service_tag'
@@ -38,6 +32,8 @@ def button
3832
javascript_redirect(:action => 'service_reconfigure', :id => params[:id])
3933
when "custom_button"
4034
@display == 'generic_objects' ? generic_object_custom_buttons : custom_buttons
35+
when "generic_object_tag"
36+
tag(GenericObject)
4137
else
4238
add_flash(_("Invalid button action"), :error)
4339
render_flash
@@ -48,7 +44,7 @@ def generic_object_custom_buttons
4844
display_options = {}
4945
ids = @lastaction == 'generic_object' ? @sb[:rec_id] : 'LIST'
5046
display_options[:display] = @display
51-
display_options[:record_id] = parse_nodetype_and_id(x_node).last
47+
display_options[:record_id] = @sb[:rec_id]
5248
display_options[:display_id] = params[:id] if @lastaction == 'generic_object'
5349
custom_buttons(ids, display_options)
5450
end
@@ -57,20 +53,18 @@ def title
5753
_("My Services")
5854
end
5955

56+
def toolbar
57+
return 'generic_object_center' if %w[generic_objects].include?(@display) # for nested generic objects list screen
58+
59+
%w[show_list].include?(@lastaction) ? 'services_center' : 'service_center'
60+
end
61+
6062
def set_display
6163
@display = params[:display]
6264
@display ||= default_display unless pagination_or_gtl_request?
6365
@display ||= 'generic_objects' if role_allows?(:feature => "generic_object_view") && @record.number_of(:generic_objects).positive?
6466
end
6567

66-
def show_generic_object
67-
if params[:generic_object_id]
68-
show_single_generic_object
69-
else
70-
display_nested_list(@display)
71-
end
72-
end
73-
7468
def edit
7569
assert_privileges("service_edit")
7670
checked = find_checked_items
@@ -101,27 +95,17 @@ def service_form_fields
10195
}
10296
end
10397

104-
# display a single generic object
105-
#
106-
def show_single_generic_object
107-
return unless init_show_variables
108-
109-
@lastaction = 'generic_object'
110-
@item = @record.generic_objects.find { |e| e[:id] == params[:generic_object_id].to_i }
111-
drop_breadcrumb(:name => _("%{name} (All Generic Objects)") % {:name => @record.name}, :url => show_link(@record, :display => 'generic_objects'))
112-
drop_breadcrumb(:name => @item.name, :url => show_link(@record, :display => 'generic_objects', :generic_object_id => params[:generic_object_id]))
113-
@view = get_db_view(GenericObject)
114-
@sb[:rec_id] = params[:generic_object_id]
115-
@record = @item
116-
show_item
117-
end
118-
11998
def self.display_methods
12099
%w[generic_objects custom_button_events]
121100
end
122101

123102
def display_generic_objects
124103
nested_list(GenericObject)
104+
105+
if params[:generic_object_id]
106+
generic_object_id = params[:generic_object_id]
107+
redirect_to(:controller => 'generic_object', :action => "show", :id => generic_object_id)
108+
end
125109
end
126110

127111
def reconfigure_form_fields
@@ -287,5 +271,4 @@ def hide_record_info?
287271
menu_section :svc
288272
feature_for_actions "service_view", *ADV_SEARCH_ACTIONS
289273
has_custom_buttons
290-
toolbar :service, :services
291274
end

app/helpers/application_helper/toolbar/generic_object_center.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class ApplicationHelper::Toolbar::GenericObjectCenter < ApplicationHelper::Toolb
1010
:generic_object_tag,
1111
'pficon pficon-edit fa-lg',
1212
N_('Edit Tags for this Generic Object Instance'),
13-
N_('Edit Tags')),
13+
N_('Edit Tags'),
14+
:send_checked => true,
15+
:enabled => false,
16+
:onwhen => "1+"
17+
),
1418
]
1519
),
1620
])

app/helpers/application_helper/toolbar/mixins/custom_button_toolbar_mixin.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def relationship_table_screen?
5555
return false if @display.nil?
5656
display_class = @display.camelize.singularize
5757
return false unless custom_button_appliable_class?(display_class)
58+
# Don't render custom buttons on nested generic object lists since it could contain generic objects with different definitions and custom buttons
59+
return false if @display == 'generic_objects'
5860

5961
show_action = @lastaction == "show"
6062
display_model = custom_button_class_model(display_class)

app/helpers/service_helper/textual_summary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def textual_generic_object_instances
285285
num = @record.number_of(:generic_objects)
286286
h = {:label => _("Instances"), :value => num}
287287
if role_allows?(:feature => "generic_object_view") && num.positive?
288-
h.update(:link => url_for_only_path(:action => 'show', :id => @record, :display => 'generic_objects', :type => 'tile'),
288+
h.update(:link => url_for_only_path(:action => 'show', :id => @record, :display => 'generic_objects'),
289289
:title => _('Show Generic Object Instances for this Service'))
290290
end
291291
h

app/views/service/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- if @display == 'instances'
1+
- if @display == 'generic_objects'
22
= render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"}
33
- elsif @ownershipitems
44
= render :partial => "shared/views/ownership"

0 commit comments

Comments
 (0)