summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-06-27 17:31:55 -0500
committerAdam Young <ayoung@redhat.com>2011-06-27 20:55:47 -0400
commitf1e1223bd9c358367baac96ac7d6843edb56c5f6 (patch)
treebf6782c5bdb657a312f9f0b08d13a8d22b09d3c8
parent6e967d8fe709150d44b9af8df7312641a8747acf (diff)
downloadfreeipa-f1e1223bd9c358367baac96ac7d6843edb56c5f6.zip
freeipa-f1e1223bd9c358367baac96ac7d6843edb56c5f6.tar.gz
freeipa-f1e1223bd9c358367baac96ac7d6843edb56c5f6.tar.xz
Fixed undo all problem.
The IPA.multivalued_text_widget has been modified such that the 'undo all' will appear only if at least one of the values is dirty. Ticket #1109
-rw-r--r--install/ui/widget.js59
1 files changed, 36 insertions, 23 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 344d701..5277389 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -149,12 +149,13 @@ IPA.widget = function(spec) {
}
}
};
+
/**
* This function compares the original values and the
* values entered in the UI. If the values have changed
* it will return true.
*/
- that.test_dirty = function(){
+ that.test_dirty = function() {
if (that.read_only) {
return false;
@@ -241,8 +242,8 @@ IPA.widget = function(spec) {
};
that.reset = function() {
- that.set_dirty(false);
that.update();
+ that.set_dirty(false);
};
that.update = function() {
@@ -328,6 +329,7 @@ IPA.widget = function(spec) {
that.widget_reset = that.reset;
that.widget_save = that.save;
that.widget_set_dirty = that.set_dirty;
+ that.widget_test_dirty = that.test_dirty;
return that;
};
@@ -460,35 +462,40 @@ IPA.multivalued_text_widget = function(spec) {
}
};
- that.super_test_dirty = that.test_dirty;
-
- that.test_dirty = function(index){
+ that.test_dirty = function(index) {
if (index === undefined) {
- return that.super_test_dirty();
+ return that.widget_test_dirty();
}
+
var row = that.get_row(index);
- var return_value = false;
+ var input = $('input[name="'+that.name+'"]', row);
- $('input[name="'+that.name+'"]', row).each(function() {
- var input = $(this);
- if (input.is('.strikethrough')) return_value = true;
- var value = input.val();
+ if (input.is('.strikethrough')) {
+ return true;
+ }
- if (value !== that.values[index]){
- return_value = true;
- }
- });
- return return_value;
+ var value = input.val();
+ if (value !== that.values[index]) {
+ return true;
+ }
+
+ return false;
};
that.set_dirty = function(dirty, index) {
- that.widget_set_dirty(dirty);
+ that.dirty = dirty;
+
if (that.undo) {
if (dirty) {
that.show_undo(index);
} else {
that.hide_undo(index);
}
+
+ if (index !== undefined) {
+ // update undo all
+ that.set_dirty(that.test_dirty());
+ }
}
};
@@ -636,7 +643,7 @@ IPA.multivalued_text_widget = function(spec) {
var index = that.row_index(row);
// uncross removed value
input.removeClass('strikethrough');
- that.set_dirty( that.test_dirty(index), index);
+ that.set_dirty(that.test_dirty(index), index);
if (that.undo) {
if (index < that.values.length) {
remove_link.css('display', 'inline');
@@ -655,7 +662,8 @@ IPA.multivalued_text_widget = function(spec) {
remove_link.css('display', 'none');
} else {
// remove new value
- row.remove();
+ that.remove_row(index);
+ that.set_dirty(that.test_dirty());
}
return false;
});
@@ -664,12 +672,13 @@ IPA.multivalued_text_widget = function(spec) {
var index = that.row_index(row);
if (index < that.values.length) {
// restore old value
- that.reset(index);
input.removeClass('strikethrough');
remove_link.css('display', 'inline');
+ that.reset(index);
} else {
// remove new value
- row.remove();
+ that.remove_row(index);
+ that.set_dirty(that.test_dirty());
}
});
}
@@ -679,6 +688,10 @@ IPA.multivalued_text_widget = function(spec) {
that.get_row(index).remove();
};
+ that.remove_rows = function() {
+ that.get_rows().remove();
+ };
+
that.get_row = function(index) {
return $('div[name=value]:eq('+index+')', that.container);
};
@@ -692,8 +705,8 @@ IPA.multivalued_text_widget = function(spec) {
};
that.reset = function(index) {
- that.set_dirty(false, index);
that.update(index);
+ that.set_dirty(false, index);
};
that.update = function(index) {
@@ -701,7 +714,7 @@ IPA.multivalued_text_widget = function(spec) {
var value;
if (index === undefined) {
- $('div[name=value]', that.container).remove();
+ that.remove_rows();
for (var i=0; i<that.values.length; i++) {
value = that.values[i];