Hide delete button in multivalued widget if attr is not writable
https://fedorahosted.org/freeipa/ticket/3799 -- Petr Vobornik
From 0f133f0aa47f0bd1b6567c3adeb37e58e73df859 Mon Sep 17 00:00:00 2001 From: Petr Vobornik <[email protected]> Date: Fri, 28 Jun 2013 16:14:45 +0200 Subject: [PATCH] Hide delete button in multivalued widget if attr is not writable https://fedorahosted.org/freeipa/ticket/3799 --- install/ui/src/freeipa/widget.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 06fcef563ca416e6e3e1cc454f2e1dd665c68f26..c25c79b0bfa8057b411bfb5918263916e1a856a2 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -205,6 +205,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() {}; @@ -279,11 +283,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'); @@ -294,9 +297,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]; @@ -390,7 +392,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(); + } } }; @@ -501,11 +505,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); }; @@ -612,7 +619,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'); @@ -1253,7 +1260,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(); @@ -1261,7 +1268,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] : ''; -- 1.8.3.1
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
