summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-04-17 19:18:24 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-05-06 16:22:28 +0200
commit2cf0542b0d443fd268a9f09807a2edb98f6172fc (patch)
treec9cb9dedf60a59d4f8c2b9ffde8e2132bacf8b8a
parentf188fcdfa78d206b3cef84f3b8d128c144c483b6 (diff)
downloadfreeipa-2cf0542b0d443fd268a9f09807a2edb98f6172fc.tar.gz
freeipa-2cf0542b0d443fd268a9f09807a2edb98f6172fc.tar.xz
freeipa-2cf0542b0d443fd268a9f09807a2edb98f6172fc.zip
Builders: allow pre_ops and post_ops in build overrides
https://fedorahosted.org/freeipa/ticket/3235
-rw-r--r--install/ui/src/freeipa/_base/Builder.js29
1 files changed, 26 insertions, 3 deletions
diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js
index cfbda097c..4c542fc53 100644
--- a/install/ui/src/freeipa/_base/Builder.js
+++ b/install/ui/src/freeipa/_base/Builder.js
@@ -51,11 +51,25 @@ define(['dojo/_base/declare',
ctor: null,
- post_ops: null,
-
+ /**
+ * Array of spec modifiers.
+ *
+ * Spec modifier is a function which is called before build.
+ * takes params: spec, context
+ * returns spec
+ */
pre_ops: null,
/**
+ * Array of object modifiers.
+ *
+ * Object modifier is a function which is after build.
+ * takes params: built object, spec, context
+ * returns object
+ */
+ post_ops: null,
+
+ /**
* Controls what builder do when spec is a string. Possible values:
* * 'type'
* * 'property'
@@ -104,16 +118,19 @@ define(['dojo/_base/declare',
*/
build: function(spec, context, overrides) {
- var f,c;
+ var f,c, pre, post;
if (spec === undefined || spec === null) return null;
if (!construct.is_spec(spec)) return spec;
context = context || {};
+ // save
if (overrides) {
f = this.factory;
c = this.ctor;
+ pre = this.pre_ops;
+ post = this.post_ops;
if (typeof overrides === 'function') {
if (construct.is_ctor(overrides)) {
overrides = { $ctor: overrides };
@@ -123,8 +140,11 @@ define(['dojo/_base/declare',
}
this.factory = overrides.$factory;
this.ctor = overrides.$ctor;
+ if (overrides.$pre_ops) this.pre_ops = overrides.$pre_ops;
+ if (overrides.$post_ops) this.post_ops = overrides.$post_ops;
}
+ // build
var objects;
if (lang.isArray(spec)) {
objects = [];
@@ -136,9 +156,12 @@ define(['dojo/_base/declare',
objects = this._build(spec, context);
}
+ // restore
if (overrides) {
this.factory = f;
this.ctor = c;
+ this.pre_ops = pre;
+ this.post_ops = post;
}
return objects;