From 006c4eabd9f575f9a9537b799acc332258fde148 Mon Sep 17 00:00:00 2001 From: Petr Vobornik 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 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