The entity definitions have been converted into classes. The entity
init() method will use the builder to construct the facets and dialogs.
The UI can be customized by creating a subclass of the original entity
in extension.js and then overriding the init() method.

Ticket #2043

--
Endi S. Dewata
From 509cf7f568d763058f6133a6f71feb5ccb5c4b97 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Wed, 2 Nov 2011 14:07:07 -0500
Subject: [PATCH] Added extensible UI framework.

The entity definitions have been converted into classes. The entity
init() method will use the builder to construct the facets and dialogs.
The UI can be customized by creating a subclass of the original entity
in extension.js and then overriding the init() method.

Ticket #2043
---
 install/ui/aci.js          |   87 +++++++++++++++++++++++++++++---------------
 install/ui/automount.js    |   56 +++++++++++++++++++----------
 install/ui/dns.js          |   38 +++++++++++++-------
 install/ui/entitle.js      |   31 ++++++----------
 install/ui/entity.js       |   10 +++---
 install/ui/group.js        |   22 ++++++++----
 install/ui/hbac.js         |   56 +++++++++++++++++++---------
 install/ui/host.js         |   20 +++++++---
 install/ui/hostgroup.js    |   20 ++++++----
 install/ui/index.html      |    2 +-
 install/ui/ipa.js          |   29 +++++++++++----
 install/ui/netgroup.js     |   20 +++++++---
 install/ui/policy.js       |   46 +++++++++++++++---------
 install/ui/serverconfig.js |   21 +++++++----
 install/ui/service.js      |   21 +++++++----
 install/ui/sudo.js         |   55 ++++++++++++++++++----------
 install/ui/user.js         |   19 ++++++----
 17 files changed, 355 insertions(+), 198 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index 5ffb2108b51b2e30113221d9ab1af107635eb8b4..92c5dcf02db36dfe48be4b80f0d6d0656c72de61 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -23,11 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.permission = function() {
+IPA.aci = {};
 
-    return IPA.entity_builder().
-        entity('permission').
-        facet_groups([ 'privilege' , 'settings' ]).
+IPA.aci.permission_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'privilege' , 'settings' ]).
         search_facet({
             columns:['cn']
         }).
@@ -78,15 +82,19 @@ IPA.entity_factories.permission = function() {
                     label: IPA.messages.objects.permission.target
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
+IPA.aci.privilege_entity = function(spec) {
 
-IPA.entity_factories.privilege = function() {
-    return IPA.entity_builder().
-        entity('privilege').
-        facet_groups([ 'role', 'settings', 'permission' ]).
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'role', 'settings', 'permission' ]).
         search_facet({
             columns: [
                 'cn',
@@ -130,16 +138,19 @@ IPA.entity_factories.privilege = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
 
+    return that;
 };
 
+IPA.aci.role_entity = function(spec) {
 
-IPA.entity_factories.role = function() {
-    return  IPA.entity_builder().
-        entity('role').
-        facet_groups([ 'member', 'settings', 'privilege' ]).
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'member', 'settings', 'privilege' ]).
         search_facet({
             columns: [
                 'cn',
@@ -176,15 +187,19 @@ IPA.entity_factories.role = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
+IPA.aci.selfservice_entity = function(spec) {
 
-IPA.entity_factories.selfservice = function() {
-    return IPA.entity_builder().
-        entity('selfservice').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns:['aciname']}).
         details_facet({
             sections:[{
@@ -204,15 +219,19 @@ IPA.entity_factories.selfservice = function() {
                  object_type:'user',
                  name:'attrs'
                 }]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
+IPA.aci.delegation_entity = function(spec) {
 
-IPA.entity_factories.delegation = function() {
-    return IPA.entity_builder().
-        entity('delegation').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns:['aciname']}).
         details_facet({sections:[
             {
@@ -261,8 +280,10 @@ IPA.entity_factories.delegation = function() {
                     object_type: 'user',
                     join: true
                 }]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 
@@ -738,3 +759,9 @@ IPA.target_section = function(spec) {
 
     return that;
 };
+
+IPA.register('permission', IPA.aci.permission_entity);
+IPA.register('privilege', IPA.aci.privilege_entity);
+IPA.register('role', IPA.aci.role_entity);
+IPA.register('selfservice', IPA.aci.selfservice_entity);
+IPA.register('delegation', IPA.aci.delegation_entity);
diff --git a/install/ui/automount.js b/install/ui/automount.js
index b692e5831467542ab75ace700e2c461e2c69d561..054d2aee414254d600d5319371e1e301b65c98cb 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -23,13 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
+IPA.automount = {};
 
-/**Automount*/
+IPA.automount.location_entity = function(spec) {
 
-IPA.entity_factories.automountlocation = function() {
-    return IPA.entity_builder().
-        entity({ name: 'automountlocation' }).
-        facet_groups([ 'automountmap', 'settings' ]).
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'automountmap', 'settings' ]).
         search_facet({
             title: IPA.metadata.objects.automountlocation.label,
             columns:['cn']
@@ -52,14 +54,19 @@ IPA.entity_factories.automountlocation = function() {
         }).
         adder_dialog({
             fields: [ 'cn' ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-IPA.entity_factories.automountmap = function() {
-    return IPA.entity_builder().
-        entity({ name: 'automountmap' }).
-        containing_entity('automountlocation').
+IPA.automount.map_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.containing_entity('automountlocation').
         facet_groups([ 'automountkey', 'settings' ]).
         nested_search_facet({
             facet_group: 'automountkey',
@@ -135,14 +142,19 @@ IPA.entity_factories.automountmap = function() {
                     ]
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-IPA.entity_factories.automountkey = function() {
-    return IPA.entity_builder().
-        entity({ name: 'automountkey' }).
-        containing_entity('automountmap').
+IPA.automount.key_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.containing_entity('automountmap').
         details_facet({
             sections: [
                 {
@@ -188,8 +200,10 @@ IPA.entity_factories.automountkey = function() {
                 return false;
             },
             fields:['automountkey','automountinformation']
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.automount_key_column = function(spec) {
@@ -275,3 +289,7 @@ IPA.get_option_values = function(){
     });
     return values;
 };
+
+IPA.register('automountlocation', IPA.automount.location_entity);
+IPA.register('automountmap', IPA.automount.map_entity);
+IPA.register('automountkey', IPA.automount.key_entity);
diff --git a/install/ui/dns.js b/install/ui/dns.js
index b7de11bd66ba332a78cce960ec41ddb06d7193d4..2cf5cd4a9f02442731aefd7298127c0d1fa7ae69 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -23,8 +23,11 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js, widget.js */
 
-/* DNS */
-IPA.entity_factories.dnszone = function() {
+IPA.dns = {};
+
+IPA.dns.zone_entity = function(spec) {
+
+    var that = IPA.entity(spec);
 
     if (!IPA.dns_enabled) {
         var except = {
@@ -33,9 +36,9 @@ IPA.entity_factories.dnszone = function() {
         throw except;
     }
 
-    return IPA.entity_builder().
-        entity('dnszone').
-        facet_groups([ 'dnsrecord', 'settings' ]).
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'dnsrecord', 'settings' ]).
         search_facet({
             title: IPA.metadata.objects.dnszone.label,
             columns: [ 'idnsname' ]
@@ -140,8 +143,10 @@ IPA.entity_factories.dnszone = function() {
                     ]
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.dnszone_details_facet = function(spec) {
@@ -429,7 +434,9 @@ IPA.dns_record_search_load = function (result) {
     }
 };
 
-IPA.entity_factories.dnsrecord = function() {
+IPA.dns.record_entity = function(spec) {
+
+    var that = IPA.entity(spec);
 
     if (!IPA.dns_enabled) {
         var except = {
@@ -438,9 +445,9 @@ IPA.entity_factories.dnsrecord = function() {
         throw except;
     }
 
-    return IPA.entity_builder().
-        entity('dnsrecord').
-        containing_entity('dnszone').
+    that.init = function(params) {
+
+        params.builder.containing_entity('dnszone').
         details_facet({
             post_update_hook:function(data){
                 var result = data.result.result;
@@ -604,8 +611,10 @@ IPA.entity_factories.dnsrecord = function() {
                     required: true
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.dnsrecord_redirection_dialog = function(spec) {
@@ -710,3 +719,6 @@ IPA.dnsrecord_get_delete_values = function() {
 
     return value_array;
 };
+
+IPA.register('dnszone', IPA.dns.zone_entity);
+IPA.register('dnsrecord', IPA.dns.record_entity);
diff --git a/install/ui/entitle.js b/install/ui/entitle.js
index 8bd6c456cc95fa6ab217c0954ab83d765c3cd605..d2039c4b5d04274aea43f3a7ae95e16c96dd862b 100644
--- a/install/ui/entitle.js
+++ b/install/ui/entitle.js
@@ -29,16 +29,17 @@ IPA.entitle.unregistered = 'unregistered';
 IPA.entitle.online = 'online';
 IPA.entitle.offline = 'offline';
 
-IPA.entity_factories.entitle = function() {
+IPA.entitle.entity = function(spec) {
 
-    var builder = IPA.entity_builder();
+    spec = spec || {};
 
-    builder.
-        entity({
-            factory: IPA.entitle.entity,
-            name: 'entitle'
-        }).
-        facet_groups([ 'account', 'certificates' ]).
+    var that = IPA.entity(spec);
+
+    that.status = IPA.entitle.unregistered;
+
+    that.init = function(params) {
+
+        params.builder.facet_groups([ 'account', 'certificates' ]).
         details_facet({
             factory: IPA.entitle.details_facet,
             label: IPA.messages.objects.entitle.account,
@@ -171,17 +172,7 @@ IPA.entity_factories.entitle = function() {
                 }
             ]
         });
-
-    return builder.build();
-};
-
-IPA.entitle.entity = function(spec) {
-
-    spec = spec || {};
-
-    var that = IPA.entity(spec);
-
-    that.status = IPA.entitle.unregistered;
+    };
 
     that.get_accounts = function(on_success, on_error) {
 
@@ -751,3 +742,5 @@ IPA.entitle.download_widget = function(spec) {
 
     return that;
 };
+
+IPA.register('entitle', IPA.entitle.entity);
diff --git a/install/ui/entity.js b/install/ui/entity.js
index ce086bd1c2388f7d51fe3a36dab94ea25417bbec..75f781e627f39489e464b950dc64f54d3063b64b 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -52,6 +52,9 @@ IPA.entity = function(spec) {
     that.redirect_facet = spec.redirect_facet;
     that.containing_entity = null;
 
+    that.init = function(params) {
+    };
+
     that.get_containing_entity = function() {
         return that.containing_entity ?
                 IPA.get_entity(that.containing_entity) : null;
@@ -282,7 +285,7 @@ IPA.nested_tabs = function(entity_name) {
     return siblings;
 };
 
-IPA.entity_builder = function(){
+IPA.entity_builder = function() {
 
     var that = {};
 
@@ -523,10 +526,7 @@ IPA.entity_builder = function(){
     };
 
     that.build = function(){
-        var item = entity;
-        entity = null;
-
-        return item;
+        return entity;
     };
 
     return that;
diff --git a/install/ui/group.js b/install/ui/group.js
index 418724e871243df7829f3ab6adeaca9bfa3ce64f..305fb400726dc4096945eec241a860a548627a10 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -24,11 +24,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.group =  function () {
+IPA.group = {};
 
-    return IPA.entity_builder().
-        entity('group').
-        search_facet({
+IPA.group.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'gidnumber',
@@ -117,8 +121,10 @@ IPA.entity_factories.group =  function () {
                 },
                 'gidnumber'
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.group_nonposix_checkbox_widget = function (spec) {
@@ -136,7 +142,7 @@ IPA.group_nonposix_checkbox_widget = function (spec) {
     return that;
 };
 
-IPA.group_adder_dialog = function (spec) {
+IPA.group_adder_dialog = function(spec) {
 
     spec = spec || {};
 
@@ -161,3 +167,5 @@ IPA.group_adder_dialog = function (spec) {
 
     return that;
 };
+
+IPA.register('group', IPA.group.entity);
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 4199c269fd1f2e7058cbe257d8db836596e9724a..31f789a84071bdcfd6e29c318d13d6444812bafe 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -23,10 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.hbacrule = function() {
-    return IPA.entity_builder().
-        entity('hbacrule').
-        search_facet({
+IPA.hbac = {};
+
+IPA.hbac.rule_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             search_all: true,
             columns: [
                 'cn',
@@ -39,14 +44,19 @@ IPA.entity_factories.hbacrule = function() {
         }).
         adder_dialog({
             fields: [ 'cn' ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-IPA.entity_factories.hbacsvc = function() {
-    return IPA.entity_builder().
-        entity('hbacsvc').
-        search_facet({
+IPA.hbac.service_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'description'
@@ -99,15 +109,19 @@ IPA.entity_factories.hbacsvc = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
+IPA.hbac.service_group_entity = function(spec) {
 
-IPA.entity_factories.hbacsvcgroup = function() {
-    return IPA.entity_builder().
-        entity('hbacsvcgroup').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'description'
@@ -159,8 +173,10 @@ IPA.entity_factories.hbacsvcgroup = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.hbacrule_details_facet = function(spec) {
@@ -557,3 +573,7 @@ IPA.hbacrule_details_facet = function(spec) {
 
     return that;
 };
+
+IPA.register('hbacrule', IPA.hbac.rule_entity);
+IPA.register('hbacsvc', IPA.hbac.service_entity);
+IPA.register('hbacsvcgroup', IPA.hbac.service_group_entity);
diff --git a/install/ui/host.js b/install/ui/host.js
index fe08294143a3cbceab7477f194db230e8c0f142a..857f854347d45d3e467b576ad3cb736e01e424e7 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -24,11 +24,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.host = function () {
+IPA.host = {};
 
-    return IPA.entity_builder().
-        entity('host').
-        search_facet({
+IPA.host.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'fqdn',
                 'description',
@@ -166,8 +170,10 @@ IPA.entity_factories.host = function () {
         }).
         deleter_dialog({
             factory: IPA.host_deleter_dialog
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
 IPA.host_fqdn_section = function(spec) {
@@ -779,3 +785,5 @@ IPA.host_certificate_status_widget = function (spec) {
 
     return that;
 };
+
+IPA.register('host', IPA.host.entity);
diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js
index f01e5b5e8f22b98fea481b5ca3934d48a856dc36..58e25e3f1867b37153727f8b1f7b0cae5cab77f4 100644
--- a/install/ui/hostgroup.js
+++ b/install/ui/hostgroup.js
@@ -22,12 +22,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
+IPA.hostgroup = {};
 
-IPA.entity_factories.hostgroup = function() {
+IPA.hostgroup.entity = function(spec) {
 
-    return IPA.entity_builder().
-        entity('hostgroup').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'description'
@@ -77,9 +80,10 @@ IPA.entity_factories.hostgroup = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-
-
+IPA.register('hostgroup', IPA.hostgroup.entity);
diff --git a/install/ui/index.html b/install/ui/index.html
index d1aab0c475bc78f2f31596b57d11931290b9aa43..cb014815b423389a9c77df3a4431b93a7c40f356 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -38,7 +38,7 @@
     <script type="text/javascript" src="aci.js"></script>
     <script type="text/javascript" src="entitle.js"></script>
 
-
+    <script type="text/javascript" src="extension.js"></script>
     <script type="text/javascript" src="develop.js"></script>
     <script type="text/javascript" src="webui.js"></script>
 
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 0ce783dbcf6a6607f7b00056ca47b72509854731..c0aa98b9854a87ffb8e7175ea5699b9a0727afe1 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -25,7 +25,7 @@
 /* REQUIRES: jquery.ordered-map.js */
 /*global $:true, location:true */
 
-var IPA = ( function () {
+var IPA = function() {
 
     var that = {
         jsonrpc_id: 0
@@ -172,22 +172,37 @@ var IPA = ( function () {
         batch.execute();
     };
 
+    that.register = function(name, factory) {
+        that.entity_factories[name] = factory;
+    };
+
     that.get_entities = function() {
         return that.entities.values;
     };
 
-
-
     that.get_entity = function(name) {
         var entity = that.entities.get(name);
-        if (!entity){
+        if (!entity) {
             var factory = that.entity_factories[name];
-            if (!factory){
+            if (!factory) {
                 return null;
             }
+
             try {
-                entity = factory();
+                var builder = that.entity_builder();
+
+                builder.entity({
+                    factory: factory,
+                    name: name
+                });
+
+                entity = builder.build();
+                entity.init({
+                    builder: builder
+                });
+
                 that.add_entity(entity);
+
             } catch (e) {
                 if (e.expected){
                     /*expected exceptions thrown by builder just mean that
@@ -256,7 +271,7 @@ var IPA = ( function () {
     };
 
     return that;
-}());
+}();
 
 /**
  * Call an IPA command over JSON-RPC.
diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js
index a99c6c7ef9246ab9e439ccd434847b94c0385664..dcec180feeb2ae67ad19e7ce12addc707ef165dd 100644
--- a/install/ui/netgroup.js
+++ b/install/ui/netgroup.js
@@ -22,11 +22,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.netgroup = function() {
+IPA.netgroup = {};
 
-    return IPA.entity_builder().
-        entity('netgroup').
-        search_facet({
+IPA.netgroup.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'description'
@@ -76,6 +80,10 @@ IPA.entity_factories.netgroup = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
+
+IPA.register('netgroup', IPA.netgroup.entity);
diff --git a/install/ui/policy.js b/install/ui/policy.js
index 8a0571394e4265f6e96c737de89faf830daa2693..4726608c24376f5d0faedeb27d311accc24f9ba6 100644
--- a/install/ui/policy.js
+++ b/install/ui/policy.js
@@ -23,11 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-/**pwpolicy*/
-IPA.entity_factories.pwpolicy = function() {
-    return IPA.entity_builder().
-        entity('pwpolicy').
-        search_facet({
+IPA.pwpolicy = {};
+
+IPA.pwpolicy.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns:['cn','cospriority']}).
         details_facet({
             sections:[
@@ -63,18 +67,21 @@ IPA.entity_factories.pwpolicy = function() {
                 'cospriority'
             ],
             height: 300
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-/**
-   krbtpolicy
-   Does not have search
-*/
-IPA.entity_factories.krbtpolicy =  function() {
-    return IPA.entity_builder().
-        entity('krbtpolicy').
-        details_facet({
+IPA.krbtpolicy = {};
+
+IPA.krbtpolicy.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.details_facet({
             title: IPA.metadata.objects.krbtpolicy.label,
             sections: [
                 {
@@ -86,6 +93,11 @@ IPA.entity_factories.krbtpolicy =  function() {
                 }
             ],
             needs_update: true
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
+
+IPA.register('pwpolicy', IPA.pwpolicy.entity);
+IPA.register('krbtpolicy', IPA.krbtpolicy.entity);
diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js
index be2a3df94d73bdfff1dda9bf85b07ea21d43c4a8..9ecf190c492409080d3d2fd697ada972fadaa720 100644
--- a/install/ui/serverconfig.js
+++ b/install/ui/serverconfig.js
@@ -23,14 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
+IPA.config = {};
 
+IPA.config.entity = function(spec) {
 
-/* Configuration */
+    var that = IPA.entity(spec);
 
-IPA.entity_factories.config = function(){
-    return IPA.entity_builder().
-        entity('config').
-        details_facet({
+    that.init = function(params) {
+
+        params.builder.details_facet({
             title: IPA.metadata.objects.config.label,
             sections: [
                 {
@@ -80,6 +81,10 @@ IPA.entity_factories.config = function(){
                 }
             ],
             needs_update: true
-        }).
-        build();
-};
\ No newline at end of file
+        });
+    };
+
+    return that;
+};
+
+IPA.register('config', IPA.config.entity);
diff --git a/install/ui/service.js b/install/ui/service.js
index 5f88f8f10960dcf8301968d2b13944f3b5b2970a..7dc73488e0dd1b0127d6334c1a3e11b6e1f57dae 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -23,11 +23,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
-IPA.entity_factories.service = function() {
+IPA.service = {};
 
-    return  IPA.entity_builder().
-        entity('service').
-        search_facet({
+IPA.service.entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [ 'krbprincipalname' ]
         }).
         details_facet({
@@ -81,10 +85,11 @@ IPA.entity_factories.service = function() {
         adder_dialog({
             factory: IPA.service_adder_dialog,
             height: 350
-        }).
-        build();
-};
+        });
+    };
 
+    return that;
+};
 
 IPA.service_adder_dialog = function(spec) {
 
@@ -341,3 +346,5 @@ IPA.service_certificate_status_widget = function (spec) {
 
     return that;
 };
+
+IPA.register('service', IPA.service.entity);
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 1c79e03363a5c7ab101a0d5fb0e74cbd4ea9564d..862478c600488cc42cbe1fa563639bb206a922e1 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -22,12 +22,15 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
+IPA.sudo = {};
 
-IPA.entity_factories.sudorule = function() {
+IPA.sudo.rule_entity = function(spec) {
 
-    return IPA.entity_builder().
-        entity('sudorule').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'ipaenabledflag',
@@ -39,15 +42,19 @@ IPA.entity_factories.sudorule = function() {
         }).
         adder_dialog({
             fields: [ 'cn' ]
-        }).
-        build();
+        });
+    };
+
+    return that;
 };
 
-IPA.entity_factories.sudocmd = function() {
+IPA.sudo.command_entity = function(spec) {
 
-    return IPA.entity_builder().
-        entity('sudocmd').
-        search_facet({
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'sudocmd',
                 'description'
@@ -100,15 +107,19 @@ IPA.entity_factories.sudocmd = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
+        });
+    };
 
+    return that;
 };
 
-IPA.entity_factories.sudocmdgroup = function() {
-    return IPA.entity_builder().
-        entity('sudocmdgroup').
-        search_facet({
+IPA.sudo.command_group_entity = function(spec) {
+
+    var that = IPA.entity(spec);
+
+    that.init = function(params) {
+
+        params.builder.search_facet({
             columns: [
                 'cn',
                 'description'
@@ -160,11 +171,11 @@ IPA.entity_factories.sudocmdgroup = function() {
                     name: 'description'
                 }
             ]
-        }).
-        build();
-};
+        });
+    };
 
-IPA.sudo = {};
+    return that;
+};
 
 IPA.sudorule_details_facet = function(spec) {
 
@@ -1186,3 +1197,7 @@ IPA.sudo.rule_association_adder_dialog = function(spec) {
 
     return that;
 };
+
+IPA.register('sudorule', IPA.sudo.rule_entity);
+IPA.register('sudocmd', IPA.sudo.command_entity);
+IPA.register('sudocmdgroup', IPA.sudo.command_group_entity);
diff --git a/install/ui/user.js b/install/ui/user.js
index 8e2205686ba558a9177fd37d815365f6c8e53ddf..8207bf091843507a21ec0294994a556ea32b3c6b 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -23,19 +23,20 @@
 
 /* REQUIRES: ipa.js, details.js, search.js, add.js, facet.js, entity.js */
 
+IPA.user = {};
 
-IPA.entity_factories.user = function() {
+IPA.user.entity = function(spec) {
+
+    var that = IPA.entity(spec);
 
     var link = true;
     if (IPA.nav && IPA.nav.name == 'self-service') {
         link = false;
     }
 
-    var builder = IPA.entity_builder();
+    that.init = function(params) {
 
-    builder.
-        entity('user').
-        search_facet({
+        params.builder.search_facet({
             columns: [
                 'uid',
                 'givenname',
@@ -105,7 +106,8 @@ IPA.entity_factories.user = function() {
             {
                 name: 'misc',
                 fields: ['carlicense']
-            }]}).
+            }]
+        }).
         association_facet({
             name: 'memberof_group',
             associator: IPA.serial_associator,
@@ -167,8 +169,9 @@ IPA.entity_factories.user = function() {
                 }
             ]
         });
+    };
 
-    return builder.build();
+    return that;
 };
 
 IPA.user_adder_dialog = function(spec) {
@@ -461,3 +464,5 @@ IPA.user_password_widget = function(spec) {
 
     return that;
 };
+
+IPA.register('user', IPA.user.entity);
-- 
1.7.5.1

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

Reply via email to