summaryrefslogtreecommitdiffstats
path: root/install/ui/widget.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2011-08-30 13:39:53 +0200
committerEndi S. Dewata <edewata@redhat.com>2011-08-31 05:09:11 +0000
commit776af82572b56d9c66a2eadabdb5bced9316648a (patch)
treef66ac15ee4dd1fdb7b68c901b908f56bb718d356 /install/ui/widget.js
parent44dafb18cec8f1f225b6aaa7ec300446993853de (diff)
downloadfreeipa-776af82572b56d9c66a2eadabdb5bced9316648a.tar.gz
freeipa-776af82572b56d9c66a2eadabdb5bced9316648a.tar.xz
freeipa-776af82572b56d9c66a2eadabdb5bced9316648a.zip
Enable update and reset button only if dirty
https://fedorahosted.org/freeipa/ticket/1697 Original problem: WEBUI: Update automount location refer to unknown command Update name of the automount location (Policy -> Automount -> custom_location -> Settings -> Update) in the WEBUI refer to an unknown command. Solution: Tracking dirty state in field -> section -> details facet. 'Reset' and 'Updates' in details facet are enabled only if facet is dirty. Removes the problem above and 'no modification to be performed' annoyance.
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r--install/ui/widget.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index f3559a35b..1a0683546 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -62,6 +62,8 @@ IPA.widget = function(spec) {
that.dirty = false;
that.valid = true;
+ that.dirty_changed = IPA.observer();
+
function set_param_info(){
if (!that.param_info && that.entity){
@@ -296,6 +298,7 @@ IPA.widget = function(spec) {
};
that.set_dirty = function(dirty) {
+ var old = that.dirty;
that.dirty = dirty;
if (that.undo) {
if (dirty) {
@@ -304,6 +307,10 @@ IPA.widget = function(spec) {
that.hide_undo();
}
}
+
+ if(old !== dirty) {
+ that.dirty_changed.notify([], that);
+ }
};
that.get_undo = function() {
@@ -496,6 +503,7 @@ IPA.multivalued_text_widget = function(spec) {
};
that.set_dirty = function(dirty, index) {
+ var old = that.dirty;
that.dirty = dirty;
if (that.undo) {
@@ -510,6 +518,10 @@ IPA.multivalued_text_widget = function(spec) {
that.set_dirty(that.test_dirty());
}
}
+
+ if(old !== dirty) {
+ that.dirty_changed.notify([], that);
+ }
};
that.show_undo = function(index) {
@@ -1939,3 +1951,33 @@ IPA.button = function(spec) {
return button;
};
+IPA.observer = function(spec) {
+
+ var that = {};
+
+ that.listeners = [];
+
+ that.attach = function(callback) {
+ that.listeners.push(callback);
+ };
+
+ that.detach = function(callback) {
+ for(var i=0; i < that.listeners.length; i++) {
+ if(callback === that.listeners[i]) {
+ that.listeners.splice(i,1);
+ break;
+ }
+ }
+ };
+
+ that.notify = function(args, context) {
+ args = args || [];
+ context = context || this;
+
+ for(var i=0; i < that.listeners.length; i++) {
+ that.listeners[i].apply(context, args);
+ }
+ };
+
+ return that;
+};