summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2011-11-23 16:57:57 +0100
committerEndi S. Dewata <edewata@redhat.com>2011-12-05 16:00:58 +0000
commit5b26a383ceb7c9293ae3850316a29de477c43303 (patch)
tree609bab3a79e908e2abdcd3e8032313f20c68c0c4
parente0215421208d853e853f9c7b66add1e145982fbc (diff)
downloadfreeipa.git-5b26a383ceb7c9293ae3850316a29de477c43303.tar.gz
freeipa.git-5b26a383ceb7c9293ae3850316a29de477c43303.tar.xz
freeipa.git-5b26a383ceb7c9293ae3850316a29de477c43303.zip
Added possibility to define facet/dialog specific policies
After deleting section as a special type of object a new way of defining inter-field logic is needed. For this purpose a facet_policy was created. It is a simple object with init() method. Init method should contain logic for attaching to fields' or widgets' events. When a policy is added to facet or dialog its container property should be set to that facet or dialog. It gives the policy an access to fields and widgets. Init method should be called after widgets creation. https://fedorahosted.org/freeipa/ticket/2040
-rw-r--r--install/ui/details.js71
-rw-r--r--install/ui/dialog.js9
2 files changed, 79 insertions, 1 deletions
diff --git a/install/ui/details.js b/install/ui/details.js
index b84f7f46..320ed9a4 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -163,6 +163,70 @@ IPA.section_builder = function(spec) {
return that;
};
+IPA.facet_policy = function() {
+
+ var that = {};
+
+ that.init = function() {
+ };
+
+ that.post_create = function() {
+ };
+
+ that.post_load = function() {
+ };
+
+ return that;
+};
+
+IPA.facet_policies = function(spec) {
+
+ var that = {};
+
+ that.container = spec.container;
+ that.policies = [];
+
+ that.add_policy = function(policy) {
+
+ policy.container = that.container;
+ that.policies.push(policy);
+ };
+
+ that.add_policies = function(policies) {
+
+ if (!policies) return;
+
+ for (var i=0; i<policies.length; i++) {
+ that.add_policy(policies[i]);
+ }
+ };
+
+ that.init = function() {
+
+ for (var i=0; i<that.policies.length; i++) {
+ that.policies[i].init();
+ }
+ };
+
+ that.post_create = function() {
+
+ for (var i=0; i<that.policies.length; i++) {
+ that.policies[i].post_create();
+ }
+ };
+
+ that.post_load = function(data) {
+
+ for (var i=0; i<that.policies.length; i++) {
+ that.policies[i].post_load(data);
+ }
+ };
+
+ that.add_policies(spec.policies);
+
+ return that;
+};
+
IPA.details_facet = function(spec) {
spec = spec || {};
@@ -181,6 +245,10 @@ IPA.details_facet = function(spec) {
that.widgets = IPA.widget_container();
that.fields = IPA.field_container({ container: that });
+ that.policies = IPA.facet_policies({
+ container: that,
+ policies: spec.policies
+ });
that.fields.add_field = function(field) {
@@ -228,6 +296,7 @@ IPA.details_facet = function(spec) {
}
that.facet_create(container);
+ that.policies.post_create();
};
that.create_controls = function() {
@@ -390,6 +459,7 @@ IPA.details_facet = function(spec) {
var field = fields[i];
field.load(data);
}
+ that.policies.post_load(data);
that.enable_update(false);
};
@@ -658,6 +728,7 @@ IPA.details_facet = function(spec) {
that.create_builder();
that.builder.build(spec);
that.fields.widgets_created();
+ that.policies.init();
};
that.init();
diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index c03bf801..44bd11cc 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -1,6 +1,7 @@
/*jsl:import ipa.js */
/* Authors:
* Endi Sukma Dewata <edewata@redhat.com>
+ * Petr Vobornik <pvoborni@redhat.com>
*
* Copyright (C) 2010 Red Hat
* see file 'COPYING' for use and warranty information
@@ -19,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* REQUIRES: widget.js */
+/* REQUIRES: widget.js, details.js */
IPA.dialog_button = function(spec) {
@@ -68,6 +69,10 @@ IPA.dialog = function(spec) {
that.widgets = IPA.widget_container();
that.fields = IPA.field_container({ container: that });
that.buttons = $.ordered_map();
+ that.policies = IPA.facet_policies({
+ container: that,
+ policies: spec.policies
+ });
that.create_button = function(spec) {
var factory = spec.factory || IPA.dialog_button;
@@ -122,6 +127,7 @@ IPA.dialog = function(spec) {
widget.create(div);
}
+ that.policies.post_create();
};
that.show_message = function(message) {
@@ -233,6 +239,7 @@ IPA.dialog = function(spec) {
that.create_builder();
that.builder.build(spec);
that.fields.widgets_created();
+ that.policies.init();
};
that.init();