On 05/31/2011 10:00 AM, Adam Young wrote:
On 05/31/2011 09:57 AM, Adam Young wrote:
On 05/28/2011 08:54 PM, Adam Young wrote:


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


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel
rebased on top of recent changes


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

From 8d142f02c0e42a58b49e335943e8f2375811062c 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

---
 install/ui/add.js       |    4 +-
 install/ui/automount.js |   77 +++++++++++++++++++++++++++++++++++++++++++++--
 install/ui/dialog.js    |   41 ++++++++++++++++++++++++-
 install/ui/search.js    |   23 ++++++++++++--
 install/ui/webui.js     |    3 +-
 install/ui/widget.js    |    2 +-
 6 files changed, 138 insertions(+), 12 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..5b62bd912e85eb75a3570f1e2a06975d67180965 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -63,19 +63,30 @@ 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:[
                 {
                     name:'identity',
                     label: IPA.messages.details.identity,
-                    fields:['automountmapname','description']
+                    fields:['automountmapname','description','mount','parentmap']
                 }
             ]
         }).
         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},
+                    {name:'parentmap', label:'Parent Map',conditional:true}]
         }).
         build();
 };
@@ -99,3 +110,63 @@ 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();
+    };
+
+    that.super_add = that.add;
+    that.add = function(record, on_success, on_error) {
+        that.super_add(record, on_success, on_error);
+    };
+    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) {
+
+        $('input[name="'+that.name+'"]', that.container).
+            filter("[value="+ that.dialog.method+"]").
+            attr('checked', true);
+
+        var input = $('input[name="'+that.name+'"]', that.container);
+
+        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..a6a2692714bc358715abe809aa13ae703b7f90c3 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -43,6 +43,24 @@ 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) {
+            $('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) {
+            $('input[name='+
+              that.conditional_fields[i] +
+              ']',that.container).css('visibility','hidden');
+        }
+    };
+
     that.__defineGetter__("entity_name", function(){
         return that._entity_name;
     });
@@ -70,7 +88,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) {
@@ -595,8 +618,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)){
+                        str_value += (key + ':' +value[key]);
+                        if (first){
+                            str_value += ',';
+                        }
+                        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 66dedbdfe12ea223aa42f5db8e9b35a24b7752dc..2e9aef5bbd7fa75ba9374e58f6bf6601f846ac32 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;
 
-- 
1.7.5.1

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

Reply via email to