From a6cf44bd6538788a20fd6021b802443d4b0c63d9 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 24 Aug 2011 15:36:48 +0200 Subject: Validation of details facet before update https://fedorahosted.org/freeipa/ticket/1676 The ticket is a duplicate of server error, but it revealed few UI errors. Newly performs validation of details facet before update. If validation fails, notification dialog is shown and command isn't executed. Fixed integer minimum and maximum value checking. Read-only and non-writable fields are no longer considered required. --- install/ui/details.js | 31 +++++++++++++++++++++++++++++-- install/ui/test/data/ipa_init.json | 4 +++- install/ui/widget.js | 12 +++++++----- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'install/ui') diff --git a/install/ui/details.js b/install/ui/details.js index 564d848d4..4550c1abf 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -128,6 +128,18 @@ IPA.details_section = function(spec) { return false; }; + that.is_valid = function() { + var fields = that.fields.values; + var valid = true; + for (var i=0; i meta.maxvalue) { + if (meta.maxvalue !== undefined && value > meta.maxvalue) { that.valid = false; message = IPA.messages.widget.validation.max_value; message = message.replace('${value}', meta.maxvalue); @@ -131,7 +131,9 @@ IPA.widget = function(spec) { if (!values || !values.length || values[0] === '' ) { if (that.param_info && that.param_info.required && - !that.optional) { + !that.optional && + !that.read_only && + that.writable) { that.valid = false; that.show_error(IPA.messages.widget.validation.required); return false; @@ -148,10 +150,10 @@ IPA.widget = function(spec) { that.valid = true; var values = that.save(); - if (!values){ + if (!values) { return; } - if (values.length ===0 ){ + if (values.length === 0) { return; } var value = values[0]; -- cgit