summaryrefslogtreecommitdiffstats
path: root/install/ui
diff options
context:
space:
mode:
Diffstat (limited to 'install/ui')
-rw-r--r--install/ui/src/freeipa/entities.js12
-rw-r--r--install/ui/src/freeipa/entity.js38
-rw-r--r--install/ui/src/freeipa/ipa.js65
3 files changed, 32 insertions, 83 deletions
diff --git a/install/ui/src/freeipa/entities.js b/install/ui/src/freeipa/entities.js
index 1a4d337c8..abc464975 100644
--- a/install/ui/src/freeipa/entities.js
+++ b/install/ui/src/freeipa/entities.js
@@ -39,6 +39,18 @@ define(['./_base/Singleton_registry'], function(Singleton_registry) {
* entities.get('entity_name');
*
*/
+
var entities = new Singleton_registry();
+
+ var init = function(entity, spec, context) {
+
+ if (entity.init) {
+ entity.init(spec, context);
+ }
+ return entity;
+ };
+ entities.builder.post_ops.push(init);
+
+
return entities;
}); \ No newline at end of file
diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js
index e20efc0f4..3e054467c 100644
--- a/install/ui/src/freeipa/entity.js
+++ b/install/ui/src/freeipa/entity.js
@@ -41,7 +41,6 @@ IPA.entity = function(spec) {
that.defines_key = spec.defines_key !== undefined ? spec.defines_key : true;
that.metadata = spec.metadata;
- that.builder = spec.builder;
that.dialogs = $.ordered_map();
that.dialog_specs = spec.dialogs || [];
@@ -180,41 +179,21 @@ IPA.entity = function(spec) {
return that;
};
+ that.builder = spec.builder || IPA.entity_builder(that);
+
that.entity_init = that.init;
return that;
};
-IPA.entity_builder = function() {
+IPA.entity_builder = function(entity) {
var that = IPA.object();
- var entity = null;
var facet_group = null;
var facet = null;
var section = null;
- that.entity = function(spec) {
- var factory = IPA.entity;
- if (spec instanceof Object) {
- factory = spec.$factory || IPA.entity;
- } else {
- spec = { name: spec };
- }
- spec.builder = that;
-
- entity = factory(spec);
-
- that.facet_groups([
- 'member',
- 'settings',
- 'memberof',
- 'managedby'
- ]);
-
- return that;
- };
-
that.facet_group = function(spec) {
spec.entity = entity;
if (spec instanceof Object) {
@@ -427,9 +406,14 @@ IPA.entity_builder = function() {
return that.dialog(spec);
};
- that.build = function(){
- return entity;
- };
+ that.facet_groups([
+ 'member',
+ 'settings',
+ 'memberof',
+ 'managedby'
+ ]);
+
+
return that;
};
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index a92b23ac8..1bcee8391 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -27,8 +27,9 @@ define(['./jquery',
'./_base/Builder',
'./_base/i18n',
'./_base/metadata_provider',
+ './entities',
'./text'],
- function($, JSON, Builder, i18n, metadata_provider, text) {
+ function($, JSON, Builder, i18n, metadata_provider, entities, text) {
var IPA = function() {
@@ -220,64 +221,16 @@ var IPA = function() {
};
that.register = function(name, factory) {
- that.remove_entity(name);
- that.entity_factories[name] = factory;
- };
-
- that.create_entity = function(name) {
- var factory = that.entity_factories[name];
- if (!factory) return null;
-
- try {
- var builder = IPA.entity_builder();
-
- builder.entity({
- $factory: factory,
- name: name
- });
-
- var entity = builder.build();
- entity.init();
-
- return entity;
-
- } catch (e) {
- if (e.expected) {
- /*expected exceptions thrown by builder just mean that
- entities are not to be registered. */
- return null;
- }
-
- if (e.message) {
- alert(e.message);
- } else {
- alert(e);
- }
-
- return null;
- }
- };
-
- that.get_entities = function() {
- return that.entities.values;
+ entities.remove(name);
+ entities.register({
+ type: name,
+ factory: factory,
+ spec: { name: name }
+ });
};
that.get_entity = function(name) {
- if (typeof name === 'object') return name;
- var entity = that.entities.get(name);
- if (!entity) {
- entity = that.create_entity(name);
- if (entity) that.add_entity(entity);
- }
- return entity;
- };
-
- that.add_entity = function(entity) {
- that.entities.put(entity.name, entity);
- };
-
- that.remove_entity = function(name) {
- that.entities.remove(name);
+ return entities.get(name);
};
that.display_activity_icon = function() {