summaryrefslogtreecommitdiffstats
path: root/install/ui/src/freeipa/widget.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-06-28 16:14:45 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-08-13 12:42:09 +0200
commit006c4eabd9f575f9a9537b799acc332258fde148 (patch)
tree0a0b232d95325e44f1d7a2bec0609886a2abb293 /install/ui/src/freeipa/widget.js
parentff6f958d96110a305d2837c89a5415ac0db3c9bc (diff)
downloadfreeipa-006c4eabd9f575f9a9537b799acc332258fde148.tar.gz
freeipa-006c4eabd9f575f9a9537b799acc332258fde148.tar.xz
freeipa-006c4eabd9f575f9a9537b799acc332258fde148.zip
Hide delete button in multivalued widget if attr is not writable
https://fedorahosted.org/freeipa/ticket/3799
Diffstat (limited to 'install/ui/src/freeipa/widget.js')
-rw-r--r--install/ui/src/freeipa/widget.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 850772754..d42b2008d 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -219,6 +219,10 @@ IPA.input_widget = function(spec) {
that.value_changed.notify([value], that);
};
+ that.is_writable = function() {
+ return !that.read_only && !!that.writable;
+ };
+
that.focus_input = function() {};
that.set_deleted = function() {};
@@ -293,11 +297,10 @@ IPA.text_widget = function(spec) {
that.update = function(values) {
var value = values && values.length ? values[0] : '';
- if (that.read_only || !that.writable) {
+ if (!that.is_writable()) {
that.display_control.text(value);
that.display_control.css('display', 'inline');
that.input.css('display', 'none');
-
} else {
that.input.val(value);
that.display_control.css('display', 'none');
@@ -308,9 +311,8 @@ IPA.text_widget = function(spec) {
};
that.save = function() {
- if (that.read_only || !that.writable) {
+ if (!that.is_writable()) {
return null;
-
} else {
var value = that.input.val();
return value === '' ? [] : [value];
@@ -395,7 +397,9 @@ IPA.multivalued_widget = function(spec) {
for(var i=0; i<that.rows.length; i++) {
var row = that.rows[i];
row.widget.hide_undo();
- row.remove_link.show();
+ if (that.is_writable()) {
+ row.remove_link.show();
+ }
}
};
@@ -507,11 +511,14 @@ IPA.multivalued_widget = function(spec) {
}
}).appendTo(row.container);
- if(row.is_new) {
+ if (row.is_new) {
row.remove_link.hide();
row.widget.show_undo();
that.value_changed.notify([], that);
}
+ if (!that.is_writable()) {
+ row.remove_link.hide();
+ }
row.container.insertBefore(that.add_link);
};
@@ -618,7 +625,7 @@ IPA.multivalued_widget = function(spec) {
that.initialized = true;
- if (that.read_only || !that.writable) {
+ if (!that.is_writable()) {
that.add_link.css('display', 'none');
} else {
that.add_link.css('display', 'inline');
@@ -1283,7 +1290,7 @@ IPA.textarea_widget = function (spec) {
};
that.save = function() {
- if (that.read_only || !that.writable) {
+ if (!that.is_writable()) {
return null;
}
var value = that.input.val();
@@ -1291,7 +1298,7 @@ IPA.textarea_widget = function (spec) {
};
that.update = function(values) {
- var read_only = that.read_only || !that.writable;
+ var read_only = !that.is_writable();
that.input.prop('readOnly', read_only);
var value = values && values.length ? values[0] : '';