Skip to content

Commit

Permalink
Fixed issues found dutring testing.
Browse files Browse the repository at this point in the history
- Fixed labels on the copy form.
- Fixed text on toolbar buttons and right cell header in copy form.
- Fixed open_parent_nodes method to retunr parent node of the existing node so children can be added to that node. Also added code to remove any existing children of the node in automate tree before adding child nodes, it was causing duplication of nodes in the tree.
- Changed code to pass in entry_point variable to common ae_tree_select view to display in the title of tree pop-up.

Issue ManageIQ#105
  • Loading branch information
h-kataria committed Jul 9, 2014
1 parent b3f33f0 commit 9cad678
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
5 changes: 5 additions & 0 deletions vmdb/app/assets/javascripts/cfme_dynatree.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ function cfmeAddNodeChildren(treename, key, selected_node, children){
cfmeDynatree_activateNodeSilently(treename, selected_node);
}

function cfmeRemoveNodeChildren(treename, key){
var pnode = $j("#" + treename + "box").dynatree('getTree').getNodeByKey(key);
pnode.removeChildren();
}

// Get children of a tree node via ajax for autoload
function cfmeOnLazyRead_GetNodeChildren(node, tree, controller) {
node.appendAjax({
Expand Down
16 changes: 12 additions & 4 deletions vmdb/app/controllers/miq_ae_class_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def build_and_add_nodes(parents)
existing_node = find_existing_node(parents)
return nil if existing_node.nil?
children = TreeBuilder.tree_add_child_nodes(@sb, x_tree[:klass_name], existing_node)
{:key => existing_node, :children => children}
{:key => existing_node, :children => children}
end

def find_existing_node(parents)
Expand All @@ -291,7 +291,9 @@ def find_existing_node(parents)
x_tree[:open_nodes].include?(x_build_node_id(parents.last))
parents.reverse.each do |p|
p_node = x_build_node_id(p)
unless x_tree[:open_nodes].include?(p_node)
if x_tree[:open_nodes].include?(p_node)
return p_node
else
x_tree[:open_nodes].push(p_node)
existing_node = p_node
end
Expand Down Expand Up @@ -320,9 +322,15 @@ def replace_right_cell(replace_trees = [])

presenter = ExplorerPresenter.new(
:active_tree => x_active_tree,
:add_nodes => add_nodes,
:temp => @temp,
)

if add_nodes
# remove any existing nodes before adding child nodes to avoid duplication
presenter[:remove_nodes] = true
presenter[:add_nodes] = add_nodes
end

r = proc { |opts| render_to_string(opts) }

presenter[:save_open_states_trees] << :ae_tree
Expand Down Expand Up @@ -2130,7 +2138,7 @@ def copy_objects_edit_screen(typ, id, button_pressed)
}
@sb[:domain_id] = domains.first.first
@edit[:current] = copy_hash(@edit[:new])
@right_cell_text = "Copy of '#{ui_lookup(:model => "#{typ}")}'"
@right_cell_text = "Copy of #{ui_lookup(:model => "#{typ}")}"
session[:edit] = @edit
end

Expand Down
6 changes: 6 additions & 0 deletions vmdb/app/presenters/explorer_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def process

@options[:trees_to_replace].each { |tree, opts| @out << replace_tree(tree,opts) }

if @options[:remove_nodes]
@out << "cfmeRemoveNodeChildren('#{@options[:active_tree]}',
'#{@options[:add_nodes][:key]}'
);\n"
end

if @options[:add_nodes]
@out << "
if (typeof #{@options[:active_tree]} == 'undefined') {
Expand Down
3 changes: 2 additions & 1 deletion vmdb/app/views/layouts/_ae_tree_select.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<%# Div to hold the actual tree %>
<% entry_point ||= "Instance" %>
<div id="automate_tree_div">
<%= hidden_field_tag(:ignore_form_changes) %>
<fieldset>
<p class="legend">Select Entry Point Instance</p>
<p class="legend">Select Entry Point <%=entry_point%></p>
<div id="automate_tree_box"></div>
<%= render(:partial => "layouts/dynatree",
:locals => {:tree_id => "automate_tree_box",
Expand Down
4 changes: 2 additions & 2 deletions vmdb/app/views/miq_ae_class/_copy_objects_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= render :partial => "layouts/flash_msg", :locals => {:div_num => "_copy"}
#form_div
= hidden_div_if(!@edit[:new][:namespace], :id => "ae_tree_select_div" ) do
= render(:partial => 'layouts/ae_tree_select')
= render(:partial => 'layouts/ae_tree_select', :locals => {:entry_point => "Namespace"})
%fieldset
%p
%table.style1
Expand Down Expand Up @@ -33,7 +33,7 @@
:onFocus => 'miqShowAE_Tree("namespace");miqButtons(false);')
- if %w(MiqAeInstance MiqAeMethod).include?(@edit[:typ].to_s) && @edit[:new][:namespace]
%tr
%td.key "Overwrite the existing #{ui_lookup(:model => @edit[:typ].to_s)}?"
%td.key Overwrite the #{ui_lookup(:model => @edit[:typ].to_s)} if it already exists?
%td
=check_box_tag("override_existing",
value = "1",
Expand Down
2 changes: 1 addition & 1 deletion vmdb/product/toolbars/miq_ae_instances_center_tb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:onwhen: '1'
- :button: miq_ae_instance_copy
:image: copy
:text: 'Copy Selected Instance'
:text: 'Copy a single Instance'
:title: 'Select a single Instance to copy'
:url_parms: 'main_div'
:enabled: 'false'
Expand Down
2 changes: 1 addition & 1 deletion vmdb/product/toolbars/miq_ae_methods_center_tb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
:onwhen: '1'
- :button: miq_ae_method_copy
:image: copy
:text: 'Copy Selected Method'
:text: 'Copy a single Method'
:title: 'Select a single Method to copy'
:url_parms: 'main_div'
:enabled: 'false'
Expand Down

0 comments on commit 9cad678

Please sign in to comment.