https://fedorahosted.org/freeipa/ticket/204


Comments for what was fixed are in the patch.  Here's what I didn't change:

4. Clicking 'Back to List' when viewing a map brings you back to list
   of locations. Is this still intentional? Perhaps the label should be
   changed to 'Back to Locations' or simply hidden.

Left it as is.  if UXD objects, we can change in a follow on patch.


5. The conditional fields in IPA.dialog are a little bit limited
   because there is only one set of conditional fields which has to be
   enabled/disabled together. It might be better to replace the
   'conditional' boolean paramter into 'field_group' then replace the
   enable/disable methods to accept a field group. This could be done
   later.
Agreed.  I'd like to merge this with the sections code used for aci

8. In dialog.js line 626 and search.js line 253, the hasOwnProperty()
   invocations are probably redundant because the key is obtained from
   the object itself, so that method will always return true.
This falls under the rules from "Javascript the good parts" and is probably a good idea to leave in, even though in our code it is strictly unnecessary.


10. The 3rd level tab for automount key was removed. At this point does
    it makes sense to remove the 3rd level tabs completely?
The 3rd tab will come back if/when we do autmountkey details. Leaving for now.


11. The option values for automount map adder dialog could be
    simplified to "direct" and "indirect".


The values used are what is appended to the command's method. Had to leave them as is to keep that working.

From f3a313b393a51b2a7e83e35882565ff5601f5ae0 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 27 May 2011 11:32:17 -0400
Subject: [PATCH] automount delete key indirect automount maps

code review changes for automount:

Removed: fields for mount and parentmap in maps details since they are not present in show or mod

Hid undo link for adder dialog

set up click handler for checkboxes when row does not have primary key

removed add override in automountmap_adder_dialog

moved 'var input...' in automount.js  line 158 to start of method.

changed logic in if statmenet ,dialog.js line 628 it if (!first) as suggested
---
 install/ui/add.js       |    4 +-
 install/ui/automount.js |   81 +++++++++++++++++++++++++++++++++++++++++++++-
 install/ui/dialog.js    |   51 ++++++++++++++++++++++++++++-
 install/ui/search.js    |   23 +++++++++++--
 install/ui/webui.js     |    3 +-
 install/ui/widget.js    |   15 +++++----
 6 files changed, 159 insertions(+), 18 deletions(-)

diff --git a/install/ui/add.js b/install/ui/add.js
index 73a423f00744394241638acceeb0dfa315af40cf..33df62abcaef6e5ec30e397b10d73ea5d8b478ff 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -32,7 +32,7 @@ IPA.add_dialog = function (spec) {
     that.name = spec.name;
     that.title = spec.title;
     that._entity_name = spec.entity_name;
-
+    that.method = spec.method || 'add';
     that.init = function() {
 
         that.add_button(IPA.messages.buttons.add, function() {
@@ -102,7 +102,7 @@ IPA.add_dialog = function (spec) {
 
         var command = IPA.command({
             entity: that.entity_name,
-            method: 'add',
+            method: that.method,
             on_success: on_success,
             on_error: on_error
         });
diff --git a/install/ui/automount.js b/install/ui/automount.js
index f865fe73f315c224b53bbe2d74ff2f0109e4d6f2..f98b0b06cf498ac84ded0e3d48673438f1539bf2 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -63,7 +63,8 @@ IPA.entity_factories.automountmap = function() {
             nested_entity : 'automountkey',
             label : IPA.metadata.objects.automountkey.label,
             name: 'keys',
-            columns:['description']
+            get_values: IPA.get_option_values,
+            columns:['automountkey','automountinformation']
         }).
         details_facet({
             sections:[
@@ -75,7 +76,27 @@ IPA.entity_factories.automountmap = function() {
             ]
         }).
         adder_dialog({
-            fields:['automountmapname','description']
+            factory: IPA.automountmap_adder_dialog,
+            fields:[{factory:IPA.method_radio_widget,
+                     name: 'method',
+                     undo: false,
+                     label:'Map Type',
+                     options:[{value:'add',label:'Direct'},
+                              {value:'add_indirect',label:'Indirect'}]
+                    },
+                    'automountmapname','description',
+                    {
+                        name:'key',
+                        label:'Mount Point',
+                        conditional:true,
+                        undo: false
+                    },
+                    {
+                        name:'parentmap',
+                        label:'Parent Map',
+                        conditional:true,
+                        undo: false
+                    }]
         }).
         build();
 };
@@ -99,3 +120,59 @@ IPA.entity_factories.automountkey = function() {
         }).
         build();
 };
+
+
+IPA.automountmap_adder_dialog = function(spec){
+    var that = IPA.add_dialog(spec);
+
+    that.super_setup = that.setup;
+    that.setup = function(container) {
+        that.super_setup(container);
+        that.disable_conditional_fields();
+    };
+
+    return that;
+};
+
+
+IPA.get_option_values = function(){
+
+    var values = [];
+    $('input[name="select"]:checked', this.table.tbody).each(function() {
+        var value = {};
+        $('span',$(this).parent().parent()).each(function(){
+            var name = this.attributes['name'].value;
+
+            value[name] = $(this).text();
+        });
+        values.push (value);
+    });
+    return values;
+};
+
+IPA.method_radio_widget = function(spec){
+    var direct = true;
+
+    var that = IPA.radio_widget(spec);
+
+    that.setup = function(container) {
+
+        var input = $('input[name="'+that.name+'"]', that.container);
+        input.
+            filter("[value="+ that.dialog.method+"]").
+            attr('checked', true);
+
+
+        input.change(function() {
+            that.dialog.method = this.value;
+
+            if (this.value === 'add_indirect'){
+                that.dialog.enable_conditional_fields();
+            }else{
+                that.dialog.disable_conditional_fields();
+            }
+        });
+    };
+
+    return that;
+};
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 4f93760bf1d5365fdf783081b13573c16568d8bb..3bcb4556dfd2cfe4008951e0339c6846da4cc3c2 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -43,6 +43,31 @@ IPA.dialog = function(spec) {
     that.fields = $.ordered_map();
     that.sections = $.ordered_map();
 
+    that.conditional_fields = [];
+
+    that.enable_conditional_fields = function(){
+        for (var i =0; i < that.conditional_fields.length; i+=1) {
+            $('label[id='+
+               that.conditional_fields[i] +'-label]',
+              that.container).css('visibility','visible');
+            $('input[name='+
+               that.conditional_fields[i] +
+              ']',that.container).css('visibility','visible');
+        }
+    };
+
+    that.disable_conditional_fields = function(){
+        for (var i =0; i < that.conditional_fields.length; i+=1) {
+            $('label[id='+
+               that.conditional_fields[i] +'-label]',
+              that.container).css('visibility','hidden');
+
+            $('input[name='+
+              that.conditional_fields[i] +
+              ']',that.container).css('visibility','hidden');
+        }
+    };
+
     that.__defineGetter__("entity_name", function(){
         return that._entity_name;
     });
@@ -70,7 +95,12 @@ IPA.dialog = function(spec) {
     };
 
     that.add_field = function(field) {
+        field.dialog = that;
         that.fields.put(field.name, field);
+        if (field.conditional){
+            that.conditional_fields.push(field.name);
+        }
+
     };
 
     that.field = function(field) {
@@ -149,7 +179,8 @@ IPA.dialog = function(spec) {
                 style: 'vertical-align: top;',
                 title: field.label
             }).appendTo(tr);
-            td.append(field.label+': ');
+            td.append($('<label />',{id: field.name+'-label',
+                                     text:field.label+': '}));
 
             td = $('<td/>', {
                 style: 'vertical-align: top;'
@@ -595,8 +626,24 @@ IPA.deleter_dialog =  function (spec) {
         ul.appendTo(div);
 
         for (var i=0; i<that.values.length; i++) {
+            var value = that.values[i];
+            if (value instanceof Object){
+                var first = true;
+                var str_value = "";
+                for (var key in value){
+                    if (value.hasOwnProperty(key)){
+                        if (!first){
+                            str_value += ',';
+                        }
+                        str_value += (key + ':' +value[key]);
+                        first = false;
+                    }
+                }
+                value = str_value;
+            }
+
             $('<li/>',{
-                'text': that.values[i]
+                'text': value
             }).appendTo(ul);
         }
     };
diff --git a/install/ui/search.js b/install/ui/search.js
index 5786886ac8459e5b0e34bb881cc20707dcab19eb..ba27cc9ddf818c11003fe8f9a1c89c4c84d7a448 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -37,6 +37,12 @@ IPA.search_facet = function(spec) {
     that.search_all = spec.search_all || false;
 
 
+    function get_values (){
+        return that.table.get_selected_values();
+    }
+
+    that.get_values = spec.get_values || get_values;
+
     that.init = function() {
         that.facet_init();
         that.managed_entity = IPA.get_entity(that.managed_entity_name);
@@ -193,9 +199,10 @@ IPA.search_facet = function(spec) {
         that.remove_instances(that.managed_entity);
     };
 
+
     that.remove_instances = function(entity) {
 
-        var values = that.table.get_selected_values();
+        var values = that.get_values();
 
         var title;
         if (!values.length) {
@@ -240,8 +247,16 @@ IPA.search_facet = function(spec) {
                 for (var k=0; k<pkeys.length; k++) {
                     command.add_arg(pkeys[k]);
                 }
-
-                command.add_arg(values[i]);
+                var value = values[i];
+                if (value instanceof Object){
+                    for (var key in value){
+                        if (value.hasOwnProperty(key)){
+                            command.set_option(key, value[key]);
+                        }
+                    }
+                }else{
+                    command.add_arg(value);
+                }
                 batch.add_command(command);
             }
 
@@ -266,6 +281,8 @@ IPA.search_facet = function(spec) {
 
     that.search_refresh = function(entity){
 
+        $('input[type=checkbox]',that.table.thead).removeAttr("checked");
+
         function on_success(data, text_status, xhr) {
 
             that.table.empty();
diff --git a/install/ui/webui.js b/install/ui/webui.js
index ce2cf2dfe49bc760c53a62fffe2a232215d1e10c..4f27272f8eb969c312bc22ec195971776b509d21 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -53,8 +53,7 @@ IPA.admin_navigation = function(spec) {
             ]},
             {name: 'automount', label: IPA.messages.tabs.automount, children: [
                 {entity: 'automountlocation'},
-                {entity: 'automountmap'},
-                {entity: 'automountkey'}
+                {entity: 'automountmap'}
             ]},
             {entity: 'pwpolicy'},
             {entity: 'krbtpolicy'}
diff --git a/install/ui/widget.js b/install/ui/widget.js
index ac78de2594f760265cb66cfc61f6f431d59a3883..1c12ac480365328cc86c5da7d039fe2bd06ac5ba 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -36,7 +36,7 @@ IPA.widget = function(spec) {
 
     that.disabled = spec.disabled;
     that.hidden = spec.hidden;
-
+    that.conditional = spec.conditional;
     // read_only is set during initialization
     that.read_only = spec.read_only;
 
@@ -1143,7 +1143,8 @@ IPA.table_widget = function (spec) {
 
             if (that.scrollable && (i == columns.length-1)) {
                 if (column.width) {
-                    var width = parseInt(column.width.substring(0, column.width.length-2),10);
+                    var width = parseInt(
+                        column.width.substring(0, column.width.length-2),10);
                     width += 16;
                     th.css('width', width+'px');
                 }
@@ -1348,6 +1349,11 @@ IPA.table_widget = function (spec) {
         var tr = that.row.clone();
         tr.appendTo(that.tbody);
 
+        $('input[name="select"]', tr).click(function(){
+            that.select_changed();
+        });
+
+
         var columns = that.columns.values;
         for (var i=0; i<columns.length; i++){
             var column = columns[i];
@@ -1356,12 +1362,7 @@ IPA.table_widget = function (spec) {
             value = value ? value.toString() : '';
 
             if (column.primary_key) {
-                // set checkbox value
                 $('input[name="select"]', tr).val(value);
-
-                $('input[name="select"]', tr).click(function(){
-                    that.select_changed();
-                });
             }
 
             var span = $('span[name="'+column.name+'"]', tr);
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to