diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-04-16 12:55:36 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-05-06 16:22:26 +0200 |
commit | 1221fca6628450c6cd3031b377c7426fa4b1b0ad (patch) | |
tree | 3c0b57ce1afb2aee160af72c5b8a8e19faf7b934 /install/ui/src | |
parent | 49b7f4c06e17b91372decf33b812a7fbbfa01ff4 (diff) | |
download | freeipa-1221fca6628450c6cd3031b377c7426fa4b1b0ad.tar.gz freeipa-1221fca6628450c6cd3031b377c7426fa4b1b0ad.tar.xz freeipa-1221fca6628450c6cd3031b377c7426fa4b1b0ad.zip |
Builder: allow string spec as spec property instead of type
https://fedorahosted.org/freeipa/ticket/3235
Diffstat (limited to 'install/ui/src')
-rw-r--r-- | install/ui/src/freeipa/_base/Builder.js | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js index 124d5ddb4..cfbda097c 100644 --- a/install/ui/src/freeipa/_base/Builder.js +++ b/install/ui/src/freeipa/_base/Builder.js @@ -56,6 +56,28 @@ define(['dojo/_base/declare', pre_ops: null, /** + * Controls what builder do when spec is a string. Possible values: + * * 'type' + * * 'property' + * Type: + * Spec is type. Queries registry for obtaining construction spec. + * + * Property: + * Spec is a property of spec, name of property is set in + * `string_property`. This mode should be combined with default + * factory or ctor otherwise the build will fail. + * + * @type {String} + */ + string_mode: 'type', + + /** + * Property name for `string_mode` == `property` + * @type {String} + */ + string_property: '', + + /** * Build object based on spec. * * @param {String|Function|Object|Array} Build spec @@ -141,8 +163,8 @@ define(['dojo/_base/declare', cs.factory = spec; } } else if (typeof spec === 'string') { - // spec is type name - cs = this._query_registry(spec); + // spec is type name or spec property + cs = this._get_cs_string(spec); } else if (typeof spec === 'object') { var c = spec.$ctor, f = spec.$factory, @@ -206,6 +228,22 @@ define(['dojo/_base/declare', } }, + /** + * Get cs from string according to string mode + */ + _get_cs_string: function(spec) { + + var cs; + if (this.string_mode === 'type') { + cs = this._query_registry(spec); + } else { + var sp = {}; + sp[this.string_property] = spec; + cs = { spec: sp }; + } + return cs; + }, + _build_core: function(construction_spec, context) { var cs = construction_spec, |