summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-07-30 10:08:48 +0200
committerPetr Vobornik <pvoborni@redhat.com>2014-09-11 17:55:17 +0200
commit01a8175119233a4de10dddaf74db5750ff6e0c25 (patch)
treeaec92d8ee9b33beee06574e15dd706ae4312e031
parent2257f12652eb67ab9ece1f1aa79aa9f784adfb05 (diff)
downloadfreeipa-01a8175119233a4de10dddaf74db5750ff6e0c25.zip
freeipa-01a8175119233a4de10dddaf74db5750ff6e0c25.tar.gz
freeipa-01a8175119233a4de10dddaf74db5750ff6e0c25.tar.xz
webui: better value-change reporting
- widget save() save method should try to always return value even if read only - report value-change event with actual value to allow processing of the value https://fedorahosted.org/freeipa/ticket/4402 Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
-rwxr-xr-xinstall/ui/src/freeipa/certificate.js2
-rw-r--r--install/ui/src/freeipa/host.js4
-rw-r--r--install/ui/src/freeipa/service.js2
-rw-r--r--install/ui/src/freeipa/user.js2
-rw-r--r--install/ui/src/freeipa/util.js2
-rw-r--r--install/ui/src/freeipa/widget.js42
6 files changed, 25 insertions, 29 deletions
diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js
index 6a11d95..ccaa258 100755
--- a/install/ui/src/freeipa/certificate.js
+++ b/install/ui/src/freeipa/certificate.js
@@ -880,7 +880,7 @@ IPA.cert.status_widget = function(spec) {
status = IPA.cert.CERTIFICATE_STATUS_REVOKED;
}
that.set_status(status, certificate.revocation_reason);
- that.on_value_changed();
+ that.on_value_changed(certificate);
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js
index 4ccebe4..692441f 100644
--- a/install/ui/src/freeipa/host.js
+++ b/install/ui/src/freeipa/host.js
@@ -599,7 +599,7 @@ IPA.host_keytab_widget = function(spec) {
that.update = function(values) {
set_status(values[0] ? 'present' : 'missing');
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.clear = function() {
@@ -759,7 +759,7 @@ IPA.host_password_widget = function(spec) {
that.update = function(values) {
set_status(values[0] ? 'present' : 'missing');
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js
index 4b04878..ee71e7a 100644
--- a/install/ui/src/freeipa/service.js
+++ b/install/ui/src/freeipa/service.js
@@ -330,7 +330,7 @@ IPA.service_provisioning_status_widget = function (spec) {
that.update = function(values) {
that.status = values && values.length ? values[0] : false;
set_status(that.status ? 'valid' : 'missing');
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index 9872df2..be01170 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -515,7 +515,7 @@ IPA.user_password_widget = function(spec) {
} else {
that.display_control.text(that.unset_value);
}
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/util.js b/install/ui/src/freeipa/util.js
index a33ebee..0032c8a 100644
--- a/install/ui/src/freeipa/util.js
+++ b/install/ui/src/freeipa/util.js
@@ -111,7 +111,7 @@ define([
function is_empty(value) {
var empty = false;
- if (!value) empty = true;
+ if (value === null || value === undefined) empty = true;
if (lang.isArray(value)) {
empty = empty || value.length === 0 ||
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 84afac0..986a3f4 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -578,10 +578,12 @@ IPA.input_widget = function(spec) {
* Raise value change event
* @protected
*/
- that.on_value_changed = function() {
- var value = that.save();
+ that.on_value_changed = function(value) {
+ var old = that.value;
+ if (value === undefined) value = that.save();
+ that.value = value;
that.value_changed.notify([value], that);
- that.emit('value-change', { source: that, value: value });
+ that.emit('value-change', { source: that, value: value, old: old });
};
/**
@@ -797,7 +799,7 @@ IPA.text_widget = function(spec) {
var value = values && values.length ? values[0] : '';
that.display_control.text(value);
that.input.val(value);
- that.on_value_changed();
+ that.on_value_changed(values);
};
/**
@@ -818,12 +820,9 @@ IPA.text_widget = function(spec) {
* @inheritDoc
*/
that.save = function() {
- if (!that.is_writable()) {
- return null;
- } else {
- var value = that.input.val();
- return value === '' ? [] : [value];
- }
+
+ var value = that.input.val();
+ return value === '' ? [] : [value];
};
/**
@@ -832,7 +831,7 @@ IPA.text_widget = function(spec) {
that.clear = function() {
that.input.val('');
that.display_control.text('');
- that.on_value_changed();
+ that.on_value_changed([]);
};
/**
@@ -1741,7 +1740,7 @@ IPA.option_widget_base = function(spec, that) {
}
if (that.on_value_changed) {
- that.on_value_changed();
+ that.on_value_changed(values);
}
};
@@ -2044,7 +2043,7 @@ IPA.select_widget = function(spec) {
// default was selected instead of supplied value, hence notify
util.emit_delayed(that,'value-change', { source: that });
}
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.update_read_only = function() {
@@ -2153,9 +2152,6 @@ IPA.textarea_widget = function (spec) {
};
that.save = function() {
- if (!that.is_writable()) {
- return null;
- }
var value = that.input.val();
return [value];
};
@@ -2164,7 +2160,7 @@ IPA.textarea_widget = function (spec) {
var value = values && values.length ? values[0] : '';
that.input.val(value);
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.update_read_only = function() {
@@ -2949,7 +2945,7 @@ IPA.table_widget = function (spec) {
that.values.push(record[that.value_attr_name]);
that.add_record(record);
}
- that.on_value_changed();
+ that.on_value_changed(records);
};
that.save = function() {
@@ -3841,7 +3837,7 @@ IPA.combobox_widget = function(spec) {
that.select(value);
}
);
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.update_read_only = function() {
@@ -3881,7 +3877,7 @@ IPA.combobox_widget = function(spec) {
that.set_value(option.val());
that.value_changed.notify([], that);
- that.emit('value-change', { source: that });
+ that.emit('value-change', { source: that, value: value });
};
that.select_next = function() {
@@ -4061,7 +4057,7 @@ IPA.link_widget = function(spec) {
that.nonlink.html(that.value);
that.check_entity_link();
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.update_link = function() {
@@ -5306,7 +5302,7 @@ IPA.sshkey_widget = function(spec) {
that.original_key = that.key.key;
}
that.update_link();
- that.on_value_changed();
+ that.on_value_changed(value);
};
that.set_deleted = function(deleted) {
@@ -5617,7 +5613,7 @@ IPA.value_map_widget = function(spec) {
}
that.display_control.text(label);
- that.on_value_changed();
+ that.on_value_changed(values);
};
that.save = function() {