Skip to content

Commit

Permalink
addressed rubocop/codeclimate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
h-kataria committed Jul 31, 2018
1 parent f7144c5 commit e61f273
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions app/controllers/catalog_controller.rb
Expand Up @@ -1213,7 +1213,7 @@ def st_catalog_set_form_vars
@edit[:new][:description] = @record.description
@edit[:new][:fields] = @record.service_templates.collect { |st| [st.name, st.id] }.sort

@edit[:new][:available_fields] = Rbac.filtered(ServiceTemplate, :named_scope => [:displayed, :public_service_templates, :without_service_template_catalog_id])
@edit[:new][:available_fields] = Rbac.filtered(ServiceTemplate, :named_scope => %i(displayed public_service_templates without_service_template_catalog_id))
.collect { |st| [st.name, st.id] }
.sort

Expand Down Expand Up @@ -1732,16 +1732,23 @@ def get_node_info_handle_root_node
typ = root_node_model(x_active_tree)
@no_checkboxes = true if x_active_tree == :svcs_tree
if x_active_tree == :svccat_tree
service_template_list([:displayed, :with_existent_service_template_catalog_id, :public_service_templates], :no_checkboxes => true)
service_template_list(%i(displayed with_existent_service_template_catalog_id public_service_templates), :no_checkboxes => true)
else
options = {:model => typ.constantize}
options[:named_scope] = :public_service_templates if x_active_tree == :sandt_tree
options[:named_scope] = :orderable if x_active_tree == :ot_tree
process_show_list(options)
process_show_list(get_show_list_options(typ))
end
@right_cell_text = _("All %{models}") % {:models => ui_lookup(:models => typ)}
end

def get_show_list_options(typ)
options = {:model => typ.constantize}
if x_active_tree == :sandt_tree
options[:named_scope] = :public_service_templates
elsif x_active_tree == :ot_tree
options[:named_scope] = :orderable
end
options
end

def get_node_info_handle_ot_folder_nodes
typ = node_name_to_template_name(x_node)
@right_cell_text = _("All %{models}") % {:models => ui_lookup(:models => typ)}
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_catalog_items.rb
Expand Up @@ -22,7 +22,7 @@ def root_options

def x_get_tree_stc_kids(object, count_only)
templates = if object.id.nil?
Rbac.filtered(ServiceTemplate, :named_scope => [:public_service_templates, :without_service_template_catalog_id])
Rbac.filtered(ServiceTemplate, :named_scope => %i(public_service_templates without_service_template_catalog_id))
else
Rbac.filtered(object.service_templates, :named_scope => :public_service_templates)
end
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/tree_builder_service_catalog.rb
Expand Up @@ -25,14 +25,14 @@ def x_get_tree_roots(count_only, _options)
filtered_objects = []
# only show catalogs nodes that have any servicetemplate records under them
objects.each do |object|
items = Rbac.filtered(object.service_templates, :named_scope => [:displayed, :public_service_templates])
items = Rbac.filtered(object.service_templates, :named_scope => %i(displayed public_service_templates))
filtered_objects.push(object) unless items.empty?
end
count_only_or_objects(count_only, filtered_objects, 'name')
end

def x_get_tree_stc_kids(object, count_only)
objects = Rbac.filtered(object.service_templates, :named_scope => [:displayed, :public_service_templates])
objects = Rbac.filtered(object.service_templates, :named_scope => %i(displayed public_service_templates))
count_only_or_objects(count_only, objects, 'name')
end
end

0 comments on commit e61f273

Please sign in to comment.