diff options
Diffstat (limited to 'install/ui/src/freeipa/_base/Singleton_registry.js')
-rw-r--r-- | install/ui/src/freeipa/_base/Singleton_registry.js | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/install/ui/src/freeipa/_base/Singleton_registry.js b/install/ui/src/freeipa/_base/Singleton_registry.js index 6aa105456..0c89e65bf 100644 --- a/install/ui/src/freeipa/_base/Singleton_registry.js +++ b/install/ui/src/freeipa/_base/Singleton_registry.js @@ -106,13 +106,7 @@ define(['dojo/_base/declare', * @return {Object} */ register: function(type, func, default_spec) { - if (!lang.exists('builder.registry', this)) { - throw { - error: 'Object Initialized Exception: builder not initalized', - context: this - }; - } - + this._check_builder(); this.builder.registry.register(type, func, default_spec); }, @@ -125,13 +119,35 @@ define(['dojo/_base/declare', * @param {Object} construct_spec Construction specification */ copy: function(org_type, new_type, construct_spec) { + this._check_builder(); + this.builder.registry.copy(org_type, new_type, construct_spec); + }, + + /** + * Create new construction specification based on an existing one and + * a specification object. Save it as a new type. + * @param {string|Function} type New type or a callback to get + * the type: `callback(spec)` + * @param {Object} spec Construction specification + */ + register_from_spec: function(type, spec) { + this._check_builder(); + var cs = this.builder.merge_spec(spec, true); + if (typeof type === 'function') { + cs.type = type(cs.spec); + } else { + cs.type = type; + } + this.builder.registry.register(cs); + }, + + _check_builder: function() { if (!lang.exists('builder.registry', this)) { throw { error: 'Object Initialized Exception: builder not initalized', context: this }; } - this.builder.registry.copy(org_type, new_type, construct_spec); }, constructor: function(spec) { |