Note that this patch needs a review by UXD in addition to code review
From 021a1dd03df86496d79a4b398f1e655d0306b8f1 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Mon, 20 Jun 2011 21:20:13 -0400
Subject: [PATCH] optional uid

Make the uid field optional
---
 install/ui/dialog.js               |   27 +++++++++++++++++++++++++++
 install/ui/test/data/ipa_init.json |    1 +
 install/ui/user.js                 |    8 +++++++-
 ipalib/plugins/internal.py         |    1 +
 4 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index ebd6c9968bccff40d56d5a686bdc18abb83ae445..6b418b49a0b7ff536f13fad0ffbaedd920227aa4 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -188,6 +188,24 @@ IPA.dialog = function(spec) {
 
             var span = $('<span/>', { 'name': field.name }).appendTo(td);
             field.create(span);
+            field.field_span = span;
+
+            if (field.optional){
+                var inputs = span.find('input');
+                    inputs.css('display','none');
+                span.append(
+                    $('<a/>',{
+                        text: IPA.messages.widget.optional,
+                        href:'',
+                        click: function(){
+                            $(this).parent().find('input').
+                                css('display','inline');
+                            $(this).css('display','none');
+                            return false;
+                        }
+                    }));
+            }
+
         }
 
         var sections = that.sections.values;
@@ -305,6 +323,13 @@ IPA.dialog = function(spec) {
         for (var i=0; i<fields.length; i++) {
             var field = fields[i];
             field.reset();
+            if (field.optional){
+                field.field_span.find('input').
+                    css('display','none');
+                field.field_span.find('a').
+                    css('display','inline');
+            }
+
         }
 
         var sections = that.sections.values;
@@ -327,6 +352,8 @@ IPA.dialog = function(spec) {
             var factory = field_spec.factory || IPA.text_widget;
             field = factory(field_spec);
 
+            field.optional = field_spec.optional || false;
+
             /* This is a bit of a hack, and is here to support ACI
                permissions. The target section is a group of several
                widgets together. It makes more sense to do them as a
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index b74e1b41a4d35dd68b83b6239f772649e2c79e0a..fa00a5a0603d9672c8c6891a84666c19be2899b9 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -15605,6 +15605,7 @@
                         "sudo": "Sudo"
                     },
                     "widget": {
+                        "optional": "Optional field: click to show",
                         "validation_error": "Text does not match field pattern"
                     }
                 }
diff --git a/install/ui/user.js b/install/ui/user.js
index 0a13a546d4dd32cb5353d7960a6d91329632bc23..ccddbaf611bd47798d8cd4d6697809b1739c0afe 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -119,7 +119,13 @@ IPA.entity_factories.user = function() {
             link: link
         }).
         adder_dialog({
-            fields: ['uid', 'givenname', 'sn']
+            fields: [
+                {
+                    factory : IPA.text_widget,
+                    optional: true,
+                    name:'uid'
+                },
+                'givenname', 'sn']
         });
 
     return builder.build();
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 78c5a8480c44b10c83d50b71b209dc031ab08603..7cc7d63eac1534ef395ff9736214bcb34b0511fd 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -389,6 +389,7 @@ class i18n_messages(Command):
             "remove":_("Remove ${other_entity} from ${entity} ${primary_key}"),
             },
         "widget":{
+            "optional":_("Optional field: click to show"),
             "validation_error":_("Text does not match field pattern"),
             },
         "ajax":{
-- 
1.7.5.2

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

Reply via email to