From 8ca348b99e350862418ac2fe0addfb0e354ea57e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 2 Nov 2011 14:07:07 -0500 Subject: 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/ipa.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'install/ui/ipa.js') diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 0ce783db..c0aa98b9 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. -- cgit