From e100ba7e2b14b74ed548ee0dd6ba1093b17dd795 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Tue, 16 Apr 2013 12:59:38 +0200 Subject: Replace build logic in widget and field builder by new builder https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/freeipa/field.js | 66 ++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) (limited to 'install/ui/src/freeipa/field.js') diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index fb315765f..25576a93a 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -24,6 +24,7 @@ define([ 'dojo/_base/array', + 'dojo/_base/lang', './builder', './ipa', './jquery', @@ -31,7 +32,7 @@ define([ './phases', './reg', './text'], - function(array, builder, IPA, $, navigation, phases, reg, text) { + function(array, lang, builder, IPA, $, navigation, phases, reg, text) { var exp = {}; @@ -878,66 +879,49 @@ IPA.field_builder = function(spec) { var that = IPA.object(); - that.default_factory = spec.default_factory || IPA.field; that.container = spec.container; that.field_options = spec.field_options || {}; - that.get_field_factory = function(spec) { - - var factory; - if (spec.$factory) { - factory = spec.$factory; - } else if(spec.type) { - factory = reg.field.get(spec.type); - factory = factory ? factory.factory : undefined; - } - - if (!factory) { - factory = that.default_factory; - } - - return factory; - }; that.build_field = function(spec, container) { - container = container || that.container; - - if(!(spec instanceof Object)) { - spec = { name: spec }; - } - - if(that.field_options) { - $.extend(spec, that.field_options); - } - - var factory = that.get_field_factory(spec); - - var field = factory(spec); - - if(container) { - container.add_field(field); - } - + var context = lang.mixin({}, that.field_options); + context.container = container || that.container; + var field = builder.build('field', spec, context); return field; }; that.build_fields = function(specs, container) { - container = container || that.container; - - for(var i=0; i