mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Builder: allow string spec as spec property instead of type
https://fedorahosted.org/freeipa/ticket/3235
This commit is contained in:
parent
49b7f4c06e
commit
1221fca662
@ -55,6 +55,28 @@ define(['dojo/_base/declare',
|
|||||||
|
|
||||||
pre_ops: null,
|
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.
|
* Build object based on spec.
|
||||||
*
|
*
|
||||||
@ -141,8 +163,8 @@ define(['dojo/_base/declare',
|
|||||||
cs.factory = spec;
|
cs.factory = spec;
|
||||||
}
|
}
|
||||||
} else if (typeof spec === 'string') {
|
} else if (typeof spec === 'string') {
|
||||||
// spec is type name
|
// spec is type name or spec property
|
||||||
cs = this._query_registry(spec);
|
cs = this._get_cs_string(spec);
|
||||||
} else if (typeof spec === 'object') {
|
} else if (typeof spec === 'object') {
|
||||||
var c = spec.$ctor,
|
var c = spec.$ctor,
|
||||||
f = spec.$factory,
|
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) {
|
_build_core: function(construction_spec, context) {
|
||||||
|
|
||||||
var cs = construction_spec,
|
var cs = construction_spec,
|
||||||
|
Loading…
Reference in New Issue
Block a user