Hi,

Please review the attached patch. Thanks!

The ipa_add_dialog has been fixed to initialize the fields which
will get the labels from metadata. Hard-coded labels have been
removed from field declarations.

The superior() method has been removed because it doesn't work with
multi-level inheritance. Superclass method for now is called using
<class name>_<method> (e.g. widget_init).

--
Endi S. Dewata
From dd55b9068b445ffcbf8fd553aa04c04521d5d5a5 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Mon, 6 Dec 2010 16:30:10 -0600
Subject: [PATCH] Dialog i18n

The ipa_add_dialog has been fixed to initialize the fields which
will get the labels from metadata. Hard-coded labels have been
removed from field declarations.

The superior() method has been removed because it doesn't work with
multi-level inheritance. Superclass method for now is called using
<class name>_<method> (e.g. widget_init).
---
 install/static/add.js          |    3 ++-
 install/static/details.js      |    7 -------
 install/static/entity.js       |   17 ++---------------
 install/static/group.js        |   15 ++++++---------
 install/static/hbac.js         |    6 ++----
 install/static/hbacsvc.js      |   14 ++++----------
 install/static/hbacsvcgroup.js |    8 +++-----
 install/static/host.js         |    5 ++---
 install/static/hostgroup.js    |   14 ++++++--------
 install/static/netgroup.js     |   14 ++++++--------
 install/static/policy.js       |   34 ++++++++++++++--------------------
 install/static/service.js      |    9 ++++++---
 install/static/sudocmd.js      |   14 ++++----------
 install/static/sudocmdgroup.js |    8 +++-----
 install/static/sudorule.js     |    8 ++------
 install/static/user.js         |   15 +++++++--------
 install/static/widget.js       |   20 +++++---------------
 17 files changed, 74 insertions(+), 137 deletions(-)

diff --git a/install/static/add.js b/install/static/add.js
index d587b80d9525c26c5ad1ea73de3698366222f312..f2eebb8ac2992a5332f6aa929265b5c00898fb69 100644
--- a/install/static/add.js
+++ b/install/static/add.js
@@ -84,6 +84,8 @@ function ipa_add_dialog(spec) {
         that.add_button('Cancel', function() {
             that.close();
         });
+
+        that.dialog_init();
     };
 
     that.add = function(record, on_success, on_error) {
@@ -109,7 +111,6 @@ function ipa_add_dialog(spec) {
         ipa_cmd('add', args, options, on_success, on_error, that.entity_name);
     };
 
-    that.superior_init = that.superior('init');
     that.add_dialog_init = that.init;
 
     return that;
diff --git a/install/static/details.js b/install/static/details.js
index f0e24ac08213c8370291c1fb616f8444066d67d3..cc1a4e19d6872f3ca676905c3ca85e906f3ebcae 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -142,13 +142,6 @@ function ipa_details_section(spec){
     that.fields = [];
     that.fields_by_name = {};
 
-    that.superior = function(name) {
-        var method = that[name];
-        return function () {
-            return method.apply(that, arguments);
-        };
-    };
-
     that.__defineGetter__("entity_name", function(){
         return that._entity_name;
     });
diff --git a/install/static/entity.js b/install/static/entity.js
index dcb7e6f8290fe99dededdeecbe6f2d97da5c284b..9372d917ed98fa150abf4930d1e923ad9556adcf 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -47,13 +47,6 @@ function ipa_facet(spec) {
 
     that.create_action_panel = ipa_facet_create_action_panel;
 
-    that.superior = function(name) {
-        var method = that[name];
-        return function () {
-            return method.apply(that, arguments);
-        };
-    };
-
     function init() {
     }
 
@@ -105,13 +98,6 @@ function ipa_entity(spec) {
     that.associations = [];
     that.associations_by_name = {};
 
-    that.superior = function(name) {
-        var method = that[name];
-        return function () {
-            return method.apply(that, arguments);
-        };
-    };
-
     that.get_dialog = function(name) {
         return that.dialogs_by_name[name];
     };
@@ -273,7 +259,6 @@ function ipa_entity_set_add_definition(entity_name, data) {
         'title': data[1]
     });
     entity.add_dialog(dialog);
-    dialog.init();
 
     for (var i=0; i<data[2].length; i++) {
         var field = data[2][i];
@@ -284,6 +269,8 @@ function ipa_entity_set_add_definition(entity_name, data) {
             undo: false
         }));
     }
+
+    dialog.init();
 }
 
 function ipa_entity_get_add_dialog(entity_name) {
diff --git a/install/static/group.js b/install/static/group.js
index f3dba7b03169273fd68c9d97c0f3ff0470270a73..21a312570de276441ab5987c965b3b9cad6f4294 100644
--- a/install/static/group.js
+++ b/install/static/group.js
@@ -87,16 +87,13 @@ function ipa_group_add_dialog(spec) {
 
     that.init = function() {
 
+        that.add_field(ipa_text_widget({name:'cn', undo: false}));
+        that.add_field(ipa_text_widget({name:'description', undo: false}));
+        // TODO: Replace with i18n label
+        that.add_field(ipa_checkbox_widget({name:'posix', label:'Is this a POSIX group?', undo: false}));
+        that.add_field(ipa_text_widget({name:'gidnumber', undo: false}));
+
         that.add_dialog_init();
-
-        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;
diff --git a/install/static/hbac.js b/install/static/hbac.js
index d5105bace846887f64b1c0afb549b2dacd9bd311..0b642aec5e419d39af969b659b2f5c5fba515ca4 100755
--- a/install/static/hbac.js
+++ b/install/static/hbac.js
@@ -63,23 +63,21 @@ function ipa_hbac_add_dialog(spec) {
 
     that.init = function() {
 
-        that.add_dialog_init();
-
         that.add_field(ipa_text_widget({
             'name': 'cn',
-            'label': 'Rule Name',
             'undo': false
         }));
 
         that.add_field(ipa_radio_widget({
             'name': 'accessruletype',
-            'label': 'Rule type',
             'options': [
                 { 'value': 'allow', 'label': 'Allow' },
                 { 'value': 'deny', 'label': 'Deny' }
             ],
             'undo': false
         }));
+
+        that.add_dialog_init();
     };
 
     return that;
diff --git a/install/static/hbacsvc.js b/install/static/hbacsvc.js
index bf3c2ad71c0719c86c357a591052d44bc483b82b..40454412f633a70156942b0706031aab810eb09b 100755
--- a/install/static/hbacsvc.js
+++ b/install/static/hbacsvc.js
@@ -61,14 +61,12 @@ function ipa_hbacsvc_add_dialog(spec) {
 
     var that = ipa_add_dialog(spec);
 
-    that.superior_init = that.superior('init');
-
     that.init = function() {
 
-        that.superior_init();
+        that.add_field(ipa_text_widget({name:'cn', undo: false}));
+        that.add_field(ipa_text_widget({name:'description', undo: false}));
 
-        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_dialog_init();
     };
 
     return that;
@@ -128,10 +126,6 @@ function ipa_hbacsvc_details_facet(spec) {
 
     var that = ipa_details_facet(spec);
 
-    that.superior_init = that.superior('init');
-    that.superior_create = that.superior('create');
-    that.superior_setup = that.superior('setup');
-
     that.init = function() {
 
         var section = ipa_details_list_section({
@@ -143,7 +137,7 @@ function ipa_hbacsvc_details_facet(spec) {
         section.create_field({'name': 'cn'});
         section.create_field({'name': 'description'});
 
-        that.superior_init();
+        that.details_facet_init();
     };
 
     return that;
diff --git a/install/static/hbacsvcgroup.js b/install/static/hbacsvcgroup.js
index 792bd44e6c230ef7227e5b6ad61de1201a9830b5..6e7460e0b20394a2fe7576ca6e325062124a0c4f 100755
--- a/install/static/hbacsvcgroup.js
+++ b/install/static/hbacsvcgroup.js
@@ -67,14 +67,12 @@ function ipa_hbacsvcgroup_add_dialog(spec) {
 
     var that = ipa_add_dialog(spec);
 
-    that.superior_init = that.superior('init');
-
     that.init = function() {
 
-        that.superior_init();
+        that.add_field(ipa_text_widget({name:'cn', undo: false}));
+        that.add_field(ipa_text_widget({name:'description', undo: false}));
 
-        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_dialog_init();
     };
 
     return that;
diff --git a/install/static/host.js b/install/static/host.js
index 56e3eb30ad95422016afdadbdba0e41a0d32822a..d9ca3c153118816f0ff266953934763a57f164db 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -83,14 +83,13 @@ function ipa_host_add_dialog(spec) {
 
     that.init = function() {
 
-        that.add_dialog_init();
-
         that.add_field(ipa_text_widget({
             'name': 'fqdn',
-            entity_name:'host',
             'size': 40,
             'undo': false
         }));
+
+        that.add_dialog_init();
     };
 
     return that;
diff --git a/install/static/hostgroup.js b/install/static/hostgroup.js
index 99be7259986db3e00f335a79789b3434b79803e6..2fb32dbb815927e494f92d2cbde1303630681d31 100644
--- a/install/static/hostgroup.js
+++ b/install/static/hostgroup.js
@@ -47,19 +47,17 @@ IPA.add_entity( function() {
 
         var dialog = ipa_add_dialog({
             name: 'add',
-            title: 'Add Hostgroup',
-            entity_name:'hostgroup'
+            title: 'Add Hostgroup'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({name: 'cn', undo: false}));
+        dialog.add_field(ipa_text_widget({name: 'description', undo: false}));
         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 b0b2ede33dd504064b4d05857edc042e4f041676..9abf6ae78c9a2634a5286c3bd329d44127e187e4 100644
--- a/install/static/netgroup.js
+++ b/install/static/netgroup.js
@@ -47,19 +47,17 @@ IPA.add_entity( function() {
 
         var dialog = ipa_add_dialog({
             name: 'add',
-            title: 'Add Netgroup',
-            entity_name:'netgroup'
+            title: 'Add Netgroup'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({ name: 'cn', undo: false}));
+        dialog.add_field(ipa_text_widget({ name: 'description', undo: false}));
         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;
 }());
 
diff --git a/install/static/policy.js b/install/static/policy.js
index 9b62a18f442f8098f7cfdfb35f71bdfc376f7b0b..df3970738115b1de13967f9c05132f2df17f02a1 100644
--- a/install/static/policy.js
+++ b/install/static/policy.js
@@ -64,23 +64,18 @@ IPA.add_entity(function (){
 
         var dialog = ipa_add_dialog({
             name: 'add',
-            title: 'Add DNS Zone',
-            entity_name:'dnszone'
+            title: 'Add DNS Zone'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({ name: 'idnsname', undo: false}));
+        dialog.add_field(ipa_text_widget({ name: 'idnssoamname', undo: false}));
+        dialog.add_field(ipa_text_widget({ name: 'idnssoarname', undo: false}));
         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;
@@ -521,14 +516,13 @@ IPA.add_entity(function (){
 
         var dialog = ipa_add_dialog({
             name: 'add',
-            title: 'Add Automount Location',
-            entity_name:'automountlocation'
+            title: 'Add Automount Location'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({ name: 'cn', undo: false}));
         dialog.init();
-        dialog.add_field(ipa_text_widget({ name: 'cn',
-                                           entity_name:'automountlocation'}));
+
         that.create_association_facets();
         that.entity_init();
 
@@ -574,15 +568,15 @@ IPA.add_entity(function (){
             title: 'Add Password Policy',
             entity_name:'pwpolicy'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({ name: 'cn', undo: false}));
         dialog.init();
-        dialog.add_field(ipa_text_widget({ name: 'cn',
-                                           entity_name:'pwpolicy'}));
+
         that.create_association_facets();
         that.entity_init();
 
-    }
+    };
     return that;
 }());
 
diff --git a/install/static/service.js b/install/static/service.js
index c028eb6ada38d9ffc93bfc1ef8ffd2e151f2178c..09fd2eab89032c6f78e4299278e1950d1ea62979 100644
--- a/install/static/service.js
+++ b/install/static/service.js
@@ -76,24 +76,27 @@ function ipa_service_add_dialog(spec) {
 
     that.init = function() {
 
-        that.add_dialog_init();
-
         that.add_field(ipa_widget({
             name: 'krbprincipalname'
         }));
 
+        // TODO: Replace with i18n label
         that.add_field(ipa_text_widget({
-            'name': 'service', 'label': 'Service',
+            'name': 'service',
+            'label': 'Service',
             'size': 20,
             'undo': false
         }));
 
+        // TODO: Replace with i18n label
         that.add_field(ipa_text_widget({
             'name': 'host',
             'label': 'Host Name',
             'size': 40,
             'undo': false
         }));
+
+        that.add_dialog_init();
     };
 
     that.create = function() {
diff --git a/install/static/sudocmd.js b/install/static/sudocmd.js
index 733344a2b457e67e6977d63053e253a690b24049..ebe96b0890dc7856210eb453ba518a895e3551fd 100755
--- a/install/static/sudocmd.js
+++ b/install/static/sudocmd.js
@@ -61,14 +61,12 @@ function ipa_sudocmd_add_dialog(spec) {
 
     var that = ipa_add_dialog(spec);
 
-    that.superior_init = that.superior('init');
-
     that.init = function() {
 
-        that.superior_init();
+        that.add_field(ipa_text_widget({name:'sudocmd', undo: false}));
+        that.add_field(ipa_text_widget({name:'description', undo: false}));
 
-        that.add_field(ipa_text_widget({name:'sudocmd', label:'Command', undo: false}));
-        that.add_field(ipa_text_widget({name:'description', label:'Description', undo: false}));
+        that.add_dialog_init();
     };
 
     return that;
@@ -130,10 +128,6 @@ function ipa_sudocmd_details_facet(spec) {
 
     var that = ipa_details_facet(spec);
 
-    that.superior_init = that.superior('init');
-    that.superior_create = that.superior('create');
-    that.superior_setup = that.superior('setup');
-
     that.init = function() {
 
         var section = ipa_details_list_section({
@@ -145,7 +139,7 @@ function ipa_sudocmd_details_facet(spec) {
         section.create_field({'name': 'sudocmd'});
         section.create_field({'name': 'description'});
 
-        that.superior_init();
+        that.details_facet_init();
     };
 
     return that;
diff --git a/install/static/sudocmdgroup.js b/install/static/sudocmdgroup.js
index 7941a5317aaa04cd8fea8490e789ab9d9d4bba60..4188bc47834b47455e04eddcd7f408c12ac6d3b2 100755
--- a/install/static/sudocmdgroup.js
+++ b/install/static/sudocmdgroup.js
@@ -67,14 +67,12 @@ function ipa_sudocmdgroup_add_dialog(spec) {
 
     var that = ipa_add_dialog(spec);
 
-    that.superior_init = that.superior('init');
-
     that.init = function() {
 
-        that.superior_init();
+        that.add_field(ipa_text_widget({name:'cn', undo: false}));
+        that.add_field(ipa_text_widget({name:'description', undo: false}));
 
-        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_dialog_init();
     };
 
     return that;
diff --git a/install/static/sudorule.js b/install/static/sudorule.js
index 17c0267685338c2ed8bfd1dc123e78d90bc90c05..101f8c41fe171fb4ffcb376696c78fa55fcd3472 100755
--- a/install/static/sudorule.js
+++ b/install/static/sudorule.js
@@ -63,13 +63,9 @@ function ipa_sudorule_add_dialog(spec) {
 
     that.init = function() {
 
+        that.add_field(ipa_text_widget({name: 'cn', undo: false}));
+
         that.add_dialog_init();
-
-        that.add_field(ipa_text_widget({
-            'name': 'cn',
-            'label': 'Rule Name',
-            'undo': false
-        }));
     };
 
     return that;
diff --git a/install/static/user.js b/install/static/user.js
index 8eb412062b50d29b23a07f6df1d6ffbd9b7db682..3e1174ca61003447403a360c0b972ea40dec1de4 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -45,14 +45,13 @@ function ipa_user(){
             'name': 'add',
             'title': 'Add User'
         });
-
         that.add_dialog(dialog);
+
+        dialog.add_field(ipa_text_widget({ name: 'uid', undo: false }));
+        dialog.add_field(ipa_text_widget({ name: 'givenname', undo: false }));
+        dialog.add_field(ipa_text_widget({ name: 'sn', undo: false }));
         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
@@ -60,7 +59,7 @@ function ipa_user(){
 
 
         that.entity_init();
-    }
+    };
 
     function details_facet(spec) {
         spec = spec || {};
@@ -110,7 +109,7 @@ IPA.add_entity(ipa_user());
 
 ipa_entity_set_association_definition('user', {
     'group': { associator: 'serial' },
-    'netgroup': { associator: 'serial' },
+    'netgroup': { associator: 'serial' }
 });
 
 /* ATTRIBUTE CALLBACKS */
diff --git a/install/static/widget.js b/install/static/widget.js
index e864e8b505fc67ce54be9732384c5930e5615775..f4869c99a908b5264855dc569a9a83365cdfd824 100755
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -44,13 +44,6 @@ function ipa_widget(spec) {
     that.save = spec.save || save;
     that.clear = spec.clear || clear;
 
-    that.superior = function(name) {
-        var method = that[name];
-        return function () {
-            return method.apply(that, arguments);
-        };
-    };
-
     that.__defineGetter__("entity_name", function(){
         return that._entity_name;
     });
@@ -793,13 +786,6 @@ function ipa_dialog(spec) {
     that.fields = [];
     that.fields_by_name = {};
 
-    that.superior = function(name) {
-        var method = that[name];
-        return function () {
-            return method.apply(that, arguments);
-        };
-    };
-
     that.__defineGetter__("entity_name", function(){
         return that._entity_name;
     });
@@ -821,12 +807,16 @@ function ipa_dialog(spec) {
     };
 
     that.add_field = function(field) {
-        field.entity_name = that.entity_name;
         that.fields.push(field);
         that.fields_by_name[field.name] = field;
     };
 
     that.init = function() {
+        for (var i=0; i<that.fields.length; i++) {
+            var field = that.fields[i];
+            field.entity_name = that.entity_name;
+            field.init();
+        }
     };
 
     /**
-- 
1.6.6.1

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

Reply via email to