From c7cb07588782f037d438c312e1779f37402029f3 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 8 Apr 2013 18:07:30 +0200 Subject: Builder: added pre_ops and post_ops https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/freeipa/_base/Builder.js | 71 ++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 27 deletions(-) (limited to 'install/ui/src/freeipa/_base/Builder.js') diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js index 9fc116ba8..b6ed41c24 100644 --- a/install/ui/src/freeipa/_base/Builder.js +++ b/install/ui/src/freeipa/_base/Builder.js @@ -44,6 +44,10 @@ define(['dojo/_base/declare', */ spec_mod: null, + post_ops: [], + + pre_ops: [], + /** * Build object based on spec. * @@ -63,10 +67,10 @@ define(['dojo/_base/declare', * * All other properties will be passed to object construction method. */ - build: function(spec) { + build: function(spec, context) { var cs = this._get_construction_spec(spec); - var obj = this._build(cs); + var obj = this._build(cs, context); return obj; }, @@ -122,6 +126,7 @@ define(['dojo/_base/declare', cs.post_ops = cs.post_ops || []; if (pre) cs.pre_ops.push.call(cs.pre_ops, pre); if (pre) cs.post_ops.push.call(cs.post_ops, post); + cs.spec = cs.spec || {}; } return cs; @@ -145,27 +150,15 @@ define(['dojo/_base/declare', } }, - _build: function(construction_spec) { + _build: function(construction_spec, context) { var cs = construction_spec, - obj = null, - i; + obj = null; + cs.spec = this._run_preops(this.pre_ops, cs.spec, context); if (cs.pre_ops) { - for (i=0; i