From ac1850a8f0dd240861e26fe3b5419ade3c2806be Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 17 Apr 2013 19:19:43 +0200 Subject: Use builder for entity dialogs https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/freeipa/entity.js | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js index b002fd877..417d0672b 100644 --- a/install/ui/src/freeipa/entity.js +++ b/install/ui/src/freeipa/entity.js @@ -22,13 +22,14 @@ */ define([ + 'dojo/_base/lang', './builder', './ipa', './jquery', './text', './facets', './facet'], - function(builder, IPA, $, text, facet_reg) { + function(lang, builder, IPA, $, text, facet_reg) { IPA.entity = function(spec) { @@ -89,12 +90,27 @@ IPA.entity = function(spec) { return that.containing_entity; }; + that.dialog_build_overrides = { + $pre_ops: [ + function (spec, context) { + spec.entity = context.entity; + return spec; + } + ], + $post_opts: [ + function (obj, spec, context) { + context.entity.add_dialog(obj); + return obj; + } + ], + $factory: IPA.dialog + }; + that.get_dialog = function(name) { //build all dialogs on the first time if(!that.dialogs_created) { - var builder = IPA.dialog_builder(that); - builder.build_dialogs(); + that.add_dialog(that.dialog_specs); that.dialogs_created = true; } @@ -102,12 +118,22 @@ IPA.entity = function(spec) { }; that.add_dialog = function(dialog) { - return that.dialog(dialog); - }; - that.dialog = function(dialog) { - dialog.entity = that; - that.dialogs.put(dialog.name, dialog); + var add = function (dialog) { + dialog.entity = that; + that.dialogs.put(dialog.name, dialog); + }; + + var context = { entity: that }; + dialog = builder.build('', dialog, context, that.dialog_build_overrides); + if (lang.isArray(dialog)) { + for (var i=0; i