summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-04-17 19:19:43 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-05-06 16:22:28 +0200
commitac1850a8f0dd240861e26fe3b5419ade3c2806be (patch)
tree53b6c7a8c8ae644149cdd197ec22a5207504ea2e /install
parent2cf0542b0d443fd268a9f09807a2edb98f6172fc (diff)
downloadfreeipa-ac1850a8f0dd240861e26fe3b5419ade3c2806be.tar.gz
freeipa-ac1850a8f0dd240861e26fe3b5419ade3c2806be.tar.xz
freeipa-ac1850a8f0dd240861e26fe3b5419ade3c2806be.zip
Use builder for entity dialogs
https://fedorahosted.org/freeipa/ticket/3235
Diffstat (limited to 'install')
-rw-r--r--install/ui/src/freeipa/entity.js68
1 files 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<dialog.length; i++) {
+ add(dialog[i]);
+ }
+ } else {
+ add(dialog);
+ }
+
return that;
};
@@ -424,32 +450,6 @@ IPA.entity_builder = function(entity) {
return that;
};
-IPA.dialog_builder = function(entity) {
-
- var that = IPA.object();
-
- that.build_dialogs = function() {
-
- if(entity.dialog_specs && entity.dialog_specs.length) {
- var dialogs = entity.dialog_specs;
- for(var i=0; i<dialogs.length; i++) {
- that.build_dialog(dialogs[i]);
- }
- }
- };
-
- that.build_dialog = function(spec) {
- //do common logic
- spec.entity = entity;
-
- //add dialog
- var dialog = spec.$factory(spec);
- entity.dialog(dialog);
- };
-
- return that;
-};
-
IPA.entity_policy = function(spec) {
spec = spec || {};