Note that this does not cover HBAC or SUDO, as Edewate is currently working on those.
From 07c07de994de1a22d38e270841f75a83b74f9c5c Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Sat, 4 Dec 2010 00:29:05 -0500
Subject: [PATCH] entity i18n

Updated the user,group,host, hostgroup, netgroup, service, and all policy
entities to use the newer framework functions, in order to
replaced the old array style definitions which did not support i18n.
update a few of the newer framerwork functions to get the lables from the
meta data.

Fixed the unit tests which were expecting a details facet for users,
no longer automatically created
---
 install/static/details.js           |    4 +-
 install/static/group.js             |   37 ++----
 install/static/host.js              |   29 ++---
 install/static/hostgroup.js         |   65 +++++++---
 install/static/netgroup.js          |   60 ++++++---
 install/static/policy.js            |  242 ++++++++++++++++++++++------------
 install/static/search.js            |    7 +
 install/static/service.js           |    6 +-
 install/static/test/entity_tests.js |    9 +-
 install/static/user.js              |  146 +++++++++++++---------
 install/static/widget.js            |   10 ++-
 11 files changed, 382 insertions(+), 233 deletions(-)

diff --git a/install/static/details.js b/install/static/details.js
index b6503a1c743eb39b26031c94283e05880f0fd12c..59b9aad9fb2d4d15239b2c8b8855043298e10c61 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -339,7 +339,7 @@ function ipa_details_list_section(spec){
         }
     };
 
-    // Deprecated: Used for backward compatibility only.
+    // This is to allow declarative style programming for details
     function input(spec){
         that.create_field(spec);
         return that;
@@ -350,7 +350,7 @@ function ipa_details_list_section(spec){
     return that;
 }
 
-// Deprecated: Used for backward compatibility only.
+// shorthand notation used for declarative definitions of details pages
 function ipa_stanza(spec) {
     return ipa_details_list_section(spec);
 }
diff --git a/install/static/group.js b/install/static/group.js
index b44463439d73d6059b32751c07530c41b6d1a4dc..8c2087f66f3ca4a9feac2001aba18ec0d446eb7b 100644
--- a/install/static/group.js
+++ b/install/static/group.js
@@ -89,10 +89,14 @@ function ipa_group_add_dialog(spec) {
 
         that.add_dialog_init();
 
-        that.add_field(ipa_text_widget({name:'cn', label:'Name', undo: false}));
-        that.add_field(ipa_text_widget({name:'description', label:'Description', undo: false}));
-        that.add_field(ipa_checkbox_widget({name:'posix', label:'Is this a POSIX group?', undo: false}));
-        that.add_field(ipa_text_widget({name:'gidnumber', label:'GID', undo: false}));
+        that.add_field(ipa_text_widget({name:'cn', entity_name:'group',
+                                        undo: false}));
+        that.add_field(ipa_text_widget({name:'description',
+                                        entity_name:'group', undo: false}));
+        that.add_field(ipa_checkbox_widget({name:'posix', entity_name:'group',
+                                            undo: false}));
+        that.add_field(ipa_text_widget({name:'gidnumber', entity_name:'group',
+                                        undo: false}));
     };
 
     return that;
@@ -105,11 +109,9 @@ function ipa_group_search_facet(spec) {
     var that = ipa_search_facet(spec);
 
     that.init = function() {
-
-        that.create_column({name:'cn', label:'Name'});
-        that.create_column({name:'gidnumber', label:'GID'});
-        that.create_column({name:'description', label:'Description'});
-
+        that.create_column({name:'cn'});
+        that.create_column({name:'gidnumber'});
+        that.create_column({name:'description'});
         that.search_facet_init();
     };
 
@@ -130,20 +132,9 @@ function ipa_group_details_facet(spec) {
         });
         that.add_section(section);
 
-        section.create_field({
-            name: 'cn',
-            label: 'Group Name'
-        });
-
-        section.create_field({
-            name: 'description',
-            label: 'Description'
-        });
-
-        section.create_field({
-            name: 'gidnumber',
-            label: 'Group ID'
-        });
+        section.create_field({name: 'cn' });
+        section.create_field({name: 'description'});
+        section.create_field({name: 'gidnumber' });
 
         that.details_facet_init();
     };
diff --git a/install/static/host.js b/install/static/host.js
index 484b64771ecf6f1be948974f424606476375a276..4a60bbccd3ca965f2ff8263e3859d6ac4710e2cc 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -87,7 +87,7 @@ function ipa_host_add_dialog(spec) {
 
         that.add_field(ipa_text_widget({
             'name': 'fqdn',
-            'label': 'Name',
+            entity_name:'host',
             'size': 40,
             'undo': false
         }));
@@ -104,10 +104,11 @@ function ipa_host_search_facet(spec) {
 
     that.init = function() {
 
-        that.create_column({name:'fqdn', label:'Name'});
-        that.create_column({name:'description', label:'Description'});
-        that.create_column({name:'enrolled', label:'Enrolled?'});
-        that.create_column({name:'manages', label:'Manages?'});
+        that.create_column({name:'fqdn'});
+        that.create_column({name:'description'});
+        //TODO use the value of this field to set enrollment status
+        that.create_column({name:'krblastpwdchange', label:'Enrolled?'});
+        that.create_column({name:'nshostlocation'});
 
         that.search_facet_init();
     };
@@ -129,25 +130,16 @@ function ipa_host_details_facet(spec) {
         });
         that.add_section(section);
 
-        section.create_field({
-            'name': 'fqdn',
-            'label': 'Fully Qualified Domain Name'
-        });
-
-        section.create_field({
-            'name': 'krbprincipalname',
-            'label': 'Kerberos Principal'
-        });
+        section.create_field({'name': 'fqdn'});
+        section.create_field({'name': 'krbprincipalname'});
 
+        //TODO add this to the host plugin
         section.create_field({
             'name': 'serverhostname',
             'label': 'Server Host Name'
         });
 
-        section.create_field({
-            'name': 'description',
-            'label': 'Description'
-        });
+        section.create_field({'name': 'description'});
 
         section = ipa_details_list_section({
             'name': 'enrollment',
@@ -155,6 +147,7 @@ function ipa_host_details_facet(spec) {
         });
         that.add_section(section);
 
+        //TODO add label to messages
         section.add_field(host_provisioning_status_widget({
             'name': 'provisioning_status',
             'label': 'Status',
diff --git a/install/static/hostgroup.js b/install/static/hostgroup.js
index eb7f8b5c0f08c6c2dc9a1183e0c7f02bfade9e16..99be7259986db3e00f335a79789b3434b79803e6 100644
--- a/install/static/hostgroup.js
+++ b/install/static/hostgroup.js
@@ -20,23 +20,48 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
-ipa_entity_set_search_definition('hostgroup', [
-    ['cn', 'Name', null],
-    ['description', 'Description', null]
-]);
-
-ipa_entity_set_add_definition('hostgroup', [
-    'dialog-add-hostgroup', 'Add New Hostgroup', [
-        ['cn', 'Name', null],
-        ['description', 'Description', null]
-    ]
-]);
-
-ipa_entity_set_details_definition('hostgroup', [
-    ipa_stanza({name:'identity', label:'Hostgroup Details'}).
-        input({name:'cn', label:'Name'}).
-        input({name: 'description', label:'Description'})
-]);
-
-ipa_entity_set_association_definition('hostgroup', {
-});
+
+IPA.add_entity( function() {
+    var that = ipa_entity({
+        'name': 'hostgroup'
+    });
+    that.init = function() {
+        var search_facet = ipa_search_facet({
+            name: 'search',
+            label: 'Search',
+            entity_name: that.name
+        });
+        search_facet.create_column({name:'cn'});
+        search_facet.create_column({name:'description'});
+        that.add_facet(search_facet);
+
+        that.add_facet(function() {
+            var that = ipa_details_facet({name:'details',label:'Details'});
+            that.add_section(
+                ipa_stanza({name:'identity', label:'Hostgroup Details'}).
+                    input({name:'cn'}).
+                    input({name: 'description'}));
+            return that;
+        }());
+
+
+        var dialog = ipa_add_dialog({
+            name: 'add',
+            title: 'Add Hostgroup',
+            entity_name:'hostgroup'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+        dialog.add_field(ipa_text_widget({ name: 'cn',
+                                           entity_name:'hostgroup'}));
+        dialog.add_field(ipa_text_widget({ name: 'description',
+                                           entity_name:'hostgroup' }));
+        that.create_association_facets();
+        that.entity_init();
+    }
+    return that;
+}());
+
+
+
diff --git a/install/static/netgroup.js b/install/static/netgroup.js
index 0341ed78a6d3200119f6d7bb25ad35bc92ec3dcd..b0b2ede33dd504064b4d05857edc042e4f041676 100644
--- a/install/static/netgroup.js
+++ b/install/static/netgroup.js
@@ -20,24 +20,48 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
-ipa_entity_set_search_definition('netgroup', [
-    ['cn', 'Name', null],
-    ['description', 'Description', null]
-]);
+IPA.add_entity( function() {
+    var that = ipa_entity({
+        'name': 'netgroup'
+    });
+    that.init = function() {
+        var search_facet = ipa_search_facet({
+            name: 'search',
+            label: 'Search',
+            entity_name: that.name
+        });
+        search_facet.create_column({name:'cn'});
+        search_facet.create_column({name:'description'});
+        that.add_facet(search_facet);
+
+        that.add_facet(function() {
+            var that = ipa_details_facet({name:'details',label:'Details'});
+            that.add_section(
+                ipa_stanza({name:'identity', label:'Netgroup Details'}).
+                    input({name:'cn'}).
+                    input({name: 'description'}).
+                    input({name:'nisdomainname'}));
+            return that;
+        }());
+
+
+        var dialog = ipa_add_dialog({
+            name: 'add',
+            title: 'Add Netgroup',
+            entity_name:'netgroup'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+        dialog.add_field(ipa_text_widget({ name: 'cn',
+                                           entity_name:'netgroup'}));
+        dialog.add_field(ipa_text_widget({ name: 'description',
+                                           entity_name:'netgroup' }));
+        that.create_association_facets();
+        that.entity_init();
+    }
+    return that;
+}());
 
-ipa_entity_set_add_definition('netgroup', [
-    'dialog-add-netgroup', 'Add New Netgroup', [
-        ['cn', 'Name', null],
-        ['description', 'Description', null]
-    ]
-]);
 
-ipa_entity_set_details_definition('netgroup', [
-    ipa_stanza({name:'identity', label:'Netgroup Details'}).
-        input({name:'cn', label:'Name'}).
-        input({name:'description', label:'Description'}).
-        input({name:'nisdomainname', label:'NIS Domain'})
-]);
 
-ipa_entity_set_association_definition('netgroup', {
-});
diff --git a/install/static/policy.js b/install/static/policy.js
index 18c4ef5503c36e1bc8a0d04facdc64a97c969483..9b62a18f442f8098f7cfdfb35f71bdfc376f7b0b 100644
--- a/install/static/policy.js
+++ b/install/static/policy.js
@@ -21,46 +21,72 @@
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
 /* DNS */
-ipa_entity_set_search_definition('dnszone', [
-    ['idnsname', 'Zone Name', null]
-]);
-
-
-ipa_entity_set_add_definition('dnszone', [
-    'dialog-add-dns', 'Add New Zone', [
-        ['idnsname', 'Name', null],
-        ['idnssoamname', 'Authoritative name server'],
-        ['idnssoarname','administrator e-mail address']
-    ]
-]);
-
-ipa_entity_set_details_definition('dnszone', [
-    ipa_stanza({name:'identity', label:'DNS Zone Details'}).
-        input({name:'idnsname', label:'DNS Name'}).
-        input({name:'idnszoneactive', label:'Zone Active'}).
-        input({name:'idnssoamname', label:'Authoritative name server'}).
-        input({name:'idnssoarname', label:'administrator e-mail address'}).
-        input({name:'idnssoaserial', label:'SOA serial'}).
-        input({name:'idnssoarefresh', label:'SOA refresh'}).
-        input({name:'idnssoaretry', label:'SOA retry'}).
-        input({name:'idnssoaexpire', label:'SOA expire'}).
-        input({name:'idnssoaminimum', label:'SOA minimum'}).
-        input({name:'dnsttl', label:'SOA time to live'}).
-        input({name:'dnsclass', label:'SOA class'}).
-        input({name:'idnsallowdynupdate', label:'allow dynamic update?'}).
-        input({name:'idnsupdatepolicy', label:'BIND update policy'})
-]);
-
-ipa_entity_set_association_definition('dnszone', {
-});
-
-
-ipa_entity_set_facet_definition('dnszone', [
-    ipa_records_facet({
-        'name': 'records',
-        'label': 'Records'
-    })]
-);
+
+IPA.add_entity(function (){
+    var that = ipa_entity({
+        name: 'dnszone'
+    });
+
+    that.init = function() {
+        var search_facet = ipa_search_facet({
+            name: 'search',
+            label: 'Search',
+            entity_name: that.name
+        });
+        search_facet.create_column({name:'idnsname'});
+        that.add_facet(search_facet);
+
+        that.add_facet(function() {
+            var that = ipa_details_facet({name:'details',label:'Details'});
+            that.add_section(
+                ipa_stanza({name:'identity', label:'DNS Zone Details'}).
+                    input({name:'idnsname'}).
+                    input({name:'idnszoneactive'}).
+                    input({name:'idnssoamname'}).
+                    input({name:'idnssoarname'}).
+                    input({name:'idnssoaserial'}).
+                    input({name:'idnssoarefresh'}).
+                    input({name:'idnssoaretry'}).
+                    input({name:'idnssoaexpire'}).
+                    input({name:'idnssoaminimum'}).
+                    input({name:'dnsttl'}).
+                    input({name:'dnsclass'}).
+                    input({name:'idnsallowdynupdate'}).
+                    input({name:'idnsupdatepolicy'}));
+
+            return that;
+        }());
+
+        that.add_facet(  ipa_records_facet({
+            'name': 'records',
+            'label': IPA.metadata.dnsrecord.label
+        }));
+
+        var dialog = ipa_add_dialog({
+            name: 'add',
+            title: 'Add DNS Zone',
+            entity_name:'dnszone'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+
+        dialog.add_field(ipa_text_widget({ name: 'idnsname',
+                                           entity_name:'dnszone'}));
+        dialog.add_field(ipa_text_widget({ name: 'idnssoamname',
+                                           entity_name:'dnszone'}));
+        dialog.add_field(ipa_text_widget({ name: 'idnssoarname',
+                                           entity_name:'dnszone'}));
+
+        that.create_association_facets();
+        that.entity_init();
+    }
+
+
+    return that;
+}());
+
+
 
 function ipa_records_facet(spec){
 
@@ -256,7 +282,6 @@ function ipa_records_facet(spec){
     };
 
     function create(container) {
-//        that.setup_views(container);
     }
 
     function setup(container){
@@ -322,9 +347,6 @@ function ipa_records_facet(spec){
             'click': function(){delete_records(records_table);}
         }).appendTo(action_controls);
 
-
-
-
         div.append('<span class="records-buttons"></span>');
 
         var records_results = $('<div/>', {
@@ -349,8 +371,9 @@ function ipa_records_facet(spec){
                 }
             })
         ));
-        tr.append($('<th>Resource</th>'));
-        tr.append($('<th>Record Type</th>'));
+        tr.append($('<th/>',{
+            text: ipa_get_param_info("dnsrecord", "idnsname").label  }));
+         tr.append($('<th>Record Type</th>'));
         tr.append($('<th>Data</th>'));
 
         refresh();
@@ -472,50 +495,97 @@ function ipa_records_facet(spec){
 
 /**Automount*/
 
-ipa_entity_set_search_definition('automountlocation', [
-    ['cn', 'Name', null]
-]);
+IPA.add_entity(function (){
+    var that = ipa_entity({
+        name: 'automountlocation'
+    });
 
-ipa_entity_set_add_definition('automountlocation', [
-    'dialog-add-location', 'Add New Location', [
-        ['cn', 'Name', null]
-    ]
-]);
 
-ipa_entity_set_details_definition('automountlocation', [
-    ipa_stanza({name:'identity', label:'Automount Location Details'}).
-        input({name:'cn', label:'Automount Location'})
-]);
+   var search_facet = ipa_search_facet({
+            name: 'search',
+            label: 'Search',
+            entity_name: that.name
+        });
+    that.init = function() {
+        search_facet.create_column({name:'cn'});
+        that.add_facet(search_facet);
 
-ipa_entity_set_association_definition('automountlocation', {
-});
+
+        that.add_facet(function() {
+            var that = ipa_details_facet({name:'details',label:'Details'});
+            that.add_section(
+                ipa_stanza({name:'identity', label:'Automount Location Details'}).
+                    input({name:'cn'}));
+            return that;
+        }());
+
+        var dialog = ipa_add_dialog({
+            name: 'add',
+            title: 'Add Automount Location',
+            entity_name:'automountlocation'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+        dialog.add_field(ipa_text_widget({ name: 'cn',
+                                           entity_name:'automountlocation'}));
+        that.create_association_facets();
+        that.entity_init();
+
+    }
+    return that;
+}());
 
 
 /**pwpolicy*/
 
-ipa_entity_set_search_definition('pwpolicy', [
-    ['cn', 'Name', null]
-
-]);
-
-ipa_entity_set_add_definition('pwpolicy', [
-    'dialog-add-dns', 'Add New Location', [
-        ['cn', 'Name', null]
-    ]
-]);
-
-ipa_entity_set_details_definition('pwpolicy', [
-    ipa_stanza({name:'identity', label:'Password Policy'}).
-        input({name:'krbmaxpwdlife',label:'Max Password Life'}).
-        input({name:'krbminpwdlife',label:'Min Password Life'}).
-        input({name:'krbpwdhistorylength',label:'Password History Length'}).
-        input({name:'krbpwdmindiffchars',
-                   label:'Min Different Characters'}).
-        input({name:'krbpwdminlength', label:'Password Minimum Length'})
-]);
-
-ipa_entity_set_association_definition('pwpolicy', {
-});
+
+IPA.add_entity(function (){
+    var that = ipa_entity({
+        name: 'pwpolicy'
+    });
+
+
+   var search_facet = ipa_search_facet({
+            name: 'search',
+            label: 'Search',
+            entity_name: that.name
+        });
+    that.init = function() {
+        search_facet.create_column({name:'cn'});
+        that.add_facet(search_facet);
+
+
+        that.add_facet(function() {
+            var that = ipa_details_facet({name:'details',label:'Details'});
+            that.add_section(
+
+                ipa_stanza({name:'identity', label:'Password Policy'}).
+                    input({name:'krbmaxpwdlife'}).
+                    input({name:'krbminpwdlife'}).
+                    input({name:'krbpwdhistorylength'}).
+                    input({name:'krbpwdmindiffchars'}).
+                    input({name:'krbpwdminlength'}));
+            return that;
+        }());
+
+        var dialog = ipa_add_dialog({
+            name: 'add',
+            title: 'Add Password Policy',
+            entity_name:'pwpolicy'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+        dialog.add_field(ipa_text_widget({ name: 'cn',
+                                           entity_name:'pwpolicy'}));
+        that.create_association_facets();
+        that.entity_init();
+
+    }
+    return that;
+}());
+
 
 
 /**
@@ -525,9 +595,9 @@ ipa_entity_set_association_definition('pwpolicy', {
 
 ipa_entity_set_details_definition('krbtpolicy', [
     ipa_stanza({name:'identity', label:'Krbtpolicy Location Details'}).
-        input({name:'cn', label:'Krbtpolicy Location'}).
-        input({name:'krbmaxrenewableage', label:'Max Renewable Age'}).
-        input({name:'krbmaxticketlife', label:'Max Ticket Life'})
+        input({name:'cn'}).
+        input({name:'krbmaxrenewableage'}).
+        input({name:'krbmaxticketlife'})
 ]);
 
 IPA.get_entity('krbtpolicy').default_facet = 'details';
diff --git a/install/static/search.js b/install/static/search.js
index f267c701a06f9b637e2f8436d7dcf72a75439683..a9f71b9ac19738ec0fd1d9b15792ac356040cc46 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -285,6 +285,13 @@ function ipa_search_facet(spec) {
     };
 
     that.create_column = function(spec) {
+        if (!spec.label){
+            var param_info = ipa_get_param_info(this.entity_name, spec.name);
+            if (param_info){
+                spec.label = param_info.label;
+            }
+        }
+
         var column = ipa_column(spec);
         that.add_column(column);
         return column;
diff --git a/install/static/service.js b/install/static/service.js
index 5d9e21ad118d9ece595dc413aa65149e5113cbde..218e6af7f00973f554df19bec38b987f4634b5ba 100644
--- a/install/static/service.js
+++ b/install/static/service.js
@@ -80,7 +80,6 @@ function ipa_service_add_dialog(spec) {
 
         that.add_field(ipa_widget({
             name: 'krbprincipalname',
-            label: 'Principal'
         }));
 
         that.add_field(ipa_text_widget({
@@ -159,7 +158,7 @@ function ipa_service_search_facet(spec) {
 
     that.init = function() {
 
-        that.create_column({name:'krbprincipalname', label:'Principal'});
+        that.create_column({name:'krbprincipalname'});
         that.search_facet_init();
     };
 
@@ -181,8 +180,7 @@ function ipa_service_details_facet(spec) {
         that.add_section(section);
 
         section.create_field({
-            name: 'krbprincipalname',
-            label: 'Principal'
+            name: 'krbprincipalname'
         });
 
         section.create_field({
diff --git a/install/static/test/entity_tests.js b/install/static/test/entity_tests.js
index 504775eb1ea2f07db05c98ec5e4a0aa660cd5ab7..45834ac3cd8fb49ab9b6fec9bdcbe394500dd7a5 100644
--- a/install/static/test/entity_tests.js
+++ b/install/static/test/entity_tests.js
@@ -109,8 +109,12 @@ test('Testing ipa_facet_setup_views().', function() {
 
     var views = ul.children();
 
+    /*5 Views:
+      one for each of 3 associations
+      one for search
+      a blank one for the action controls*/
     equals(
-        views.length, 6,
+        views.length, 5,
         'Checking number of views'
     );
 
@@ -142,7 +146,8 @@ test('Testing ipa_facet_setup_views().', function() {
     var search_facets = $('li.search-facet', action_panel);
     equals(search_facets.length,1,'one search facet in action panel');
     var entity_facets = $('li.entity-facet', action_panel);
-    equals(entity_facets.length,4,'4 entity facets in action panel');
+    /*No longer automatically adding details, so ony the assoc. facets */
+    equals(entity_facets.length,3,'3 entity facets in action panel');
 
 
     for ( var entity_facet = entity_facets.first();
diff --git a/install/static/user.js b/install/static/user.js
index 21619ec5320e960d86fce55e4eb523038983d2a8..8eb412062b50d29b23a07f6df1d6ffbd9b7db682 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -20,71 +20,99 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
-ipa_entity_set_search_definition('user', [
-    ['cn', 'Name', null],
-    ['uid', 'Login', null],
-    ['uidnumber', 'UID', null],
-    ['mail', 'EMAIL', null],
-    ['telephonenumber', 'Phone', null],
-    ['title', 'Job Title', null]
-]);
-
-ipa_entity_set_add_definition('user', [
-    'dialog-add-user', 'Add New User', [
-        ['uid', 'Login', null],
-        ['givenname', 'First Name', null],
-        ['sn', 'Last Name', null]
-    ]
-]);
-
-
-ipa_entity_set_details_definition('user', [
-    ipa_stanza({name:'identity', label:'Identity Details'}).
-        input({name:'title', label: 'Title'}).
-        input({name:'givenname'}).
-        input({name:'sn'}).
-        input({name:'cn', label:'Full Name'}).
-        input({name:'displayname', label:'Display Name'}).
-        input({name:'initials', label:'Initials'}),
-    ipa_stanza({name:'account', label:'Account Details'}).
-        input({name:'nsaccountlock', label:'Account Status',
-               load:user_status_load}).
-        input({name:'uid'}).
-        input({name:'userpassword',
-               load: user_password_load}).
-        input({name:'uidnumber'}).
-        input({name:'gidnumber', label:'GID'}).
-        input({name:'loginshell'}).
-        input({name:'homedirectory'}),
-    ipa_stanza({name:'contact', label:'Contact Details'}).
-        input({name:'mail'}).
-        input({name:'telephonenumber'}).
-        input({name:'pager'}).
-        input({name:'mobile'}).
-        input({name:'facsimiletelephonenumber'}),
-    ipa_stanza({name:'address', label:'Mailing Address'}).
-        input({name:'street'}).
-        input({name:'location', label:'City'}).
-        input({name:'state', label:'State', load:user_state_load}).
-        input({name:'postalcode', label:'ZIP'}),
-    ipa_stanza({name:'employee', label:'Employee Information'}).
-        input({name:'ou', label:'Org. Unit'}).
-        input({name:'manager', label:'Manager'}),
-    ipa_stanza({name:'misc', label:'Misc. Information'}).
-        input({name:'carlicense', label:'Car License'})
-]);
+function ipa_user(){
+    var that = ipa_entity({
+        name: 'user'
+    });
+    that.init = function() {
+        var search_facet = ipa_search_facet({
+            'name': 'search',
+            'label': 'Search',
+            entity_name: that.name
+        });
+        search_facet.create_column({name:'cn'});
+        search_facet.create_column({name:'uid'});
+        search_facet.create_column({name:'uidnumber'});
+        search_facet.create_column({name:'mail'});
+        search_facet.create_column({name:'telephonenumber'});
+        search_facet.create_column({name:'title'});
+        that.add_facet(search_facet);
+
+
+        that.add_facet(details_facet({name:'details',label:'Details'}));
+
+        var dialog = ipa_add_dialog({
+            'name': 'add',
+            'title': 'Add User'
+        });
+
+        that.add_dialog(dialog);
+        dialog.init();
+        dialog.add_field(ipa_text_widget({ name: 'uid',entity_name:'user' }));
+        dialog.add_field(ipa_text_widget({ name: 'givenname',
+                                           entity_name:'user' }));
+        dialog.add_field(ipa_text_widget({ name: 'sn',entity_name:'user' }));
+        
+        /*eventually,  we need to call
+          entity.create_association_facets();
+          but we are currently defining the associator using the global
+          function after the registration of the entity */
+
+
+        that.entity_init();
+    }
+
+    function details_facet(spec) {
+        spec = spec || {};
+        var that = ipa_details_facet(spec);
+
+        var sections =[
+            ipa_stanza({name:'identity', label:'Identity Details'}).
+                input({name:'title'}).
+                input({name:'givenname'}).
+                input({name:'sn'}).
+                input({name:'cn'}).
+                input({name:'displayname'}).
+                input({name:'initials'}),
+            ipa_stanza({name:'account', label:'Account Details'}).
+                input({name:'nsaccountlock', load:user_status_load}).
+                input({name:'uid'}).
+                input({name:'userpassword', load: user_password_load}).
+                input({name:'uidnumber'}).
+                input({name:'gidnumber'}).
+                input({name:'loginshell'}).
+                input({name:'homedirectory'}),
+            ipa_stanza({name:'contact', label:'Contact Details'}).
+                input({name:'mail'}).
+                input({name:'telephonenumber'}).
+                input({name:'pager'}).
+                input({name:'mobile'}).
+                input({name:'facsimiletelephonenumber'}),
+            ipa_stanza({name:'address', label:'Mailing Address'}).
+                input({name:'street'}).
+                input({name:'location'}).
+                input({name:'state', load:user_state_load}).
+                input({name:'postalcode'}),
+            ipa_stanza({name:'employee', label:'Employee Information'}).
+                input({name:'ou', label:'Org. Unit'}).
+                input({name:'manager'}),
+            ipa_stanza({name:'misc', label:'Misc. Information'}).
+                input({name:'carlicense'})
+        ];
+        for (var i = 0; i < sections.length; i += 1){
+            that.add_section(sections[i]);
+        }
+        return that;
+    }
+    return that;
+}
+IPA.add_entity(ipa_user());
 
 ipa_entity_set_association_definition('user', {
     'group': { associator: 'serial' },
     'netgroup': { associator: 'serial' },
-    'rolegroup': { associator: 'serial' },
-    'taskgroup': { associator: 'serial' }
 });
 
-
-
-
-
 /* ATTRIBUTE CALLBACKS */
 
 
diff --git a/install/static/widget.js b/install/static/widget.js
index 429773ef0f9624bddefcabc919cbae98183cd15c..02759992e8a813a43f18ba7aaac535354fe468f4 100755
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -28,10 +28,18 @@ function ipa_widget(spec) {
 
     that.id = spec.id;
     that.name = spec.name;
-    that.label = spec.label;
+    that.label = spec.label ;
     that.read_only = spec.read_only;
     that._entity_name = spec.entity_name;
 
+    if (spec.entity_name && ! spec.label){
+        var param_info = ipa_get_param_info(spec.entity_name, spec.name);
+        if (param_info){
+            that.label = param_info.label;
+        }
+    }
+
+
     that.width = spec.width;
     that.height = spec.height;
 
-- 
1.7.2.3

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

Reply via email to