From 41107173e44c6f2d4512f0734036aaa79f2585fa Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 31 Oct 2014 14:48:27 +0800 Subject: [PATCH] MDL-46262 availability: validation of fields without value Thanks to Tomasz Pawlik | CKO USl for the patch --- .../moodle-availability_profile-form-debug.js | 3 +++ .../moodle-availability_profile-form-min.js | 2 +- .../moodle-availability_profile-form.js | 3 +++ availability/condition/profile/yui/src/form/js/form.js | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js index 0973f47626a..c4b906d1f60 100644 --- a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js +++ b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-debug.js @@ -74,6 +74,9 @@ M.availability_profile.form.getNode = function(json) { if (json.op !== undefined && node.one('select[name=op] > option[value=' + json.op + ']')) { node.one('select[name=op]').set('value', json.op); + if (json.op === 'isempty' || json.op === 'isnotempty') { + node.one('input[name=value]').set('disabled', true); + } } if (json.v !== undefined) { node.one('input').set('value', json.v); diff --git a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js index f0ab24128c1..6251004ef35 100644 --- a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js +++ b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form-min.js @@ -1 +1 @@ -YUI.add("moodle-availability_profile-form",function(e,t){M.availability_profile=M.availability_profile||{},M.availability_profile.form=e.Object(M.core_availability.plugin),M.availability_profile.form.profiles=null,M.availability_profile.form.initInner=function(e,t){this.standardFields=e,this.customFields=t},M.availability_profile.form.getNode=function(t){var n=M.str.availability_profile,r=' ';var u=e.Node.create(""+r+"");t.sf!==undefined&&u.one("select[name=field] > option[value=sf_"+t.sf+"]")?u.one("select[name=field]").set("value","sf_"+t.sf):t.cf!==undefined&&u.one("select[name=field] > option[value=cf_"+t.cf+"]")&&u.one("select[name=field]").set("value","cf_"+t.cf),t.op!==undefined&&u.one("select[name=op] > option[value="+t.op+"]")&&u.one("select[name=op]").set("value",t.op),t.v!==undefined&&u.one("input").set("value",t.v);if(!M.availability_profile.form.addedEvents){M.availability_profile.form.addedEvents=!0;var a=function(e){var t=e.ancestor("span.availability_profile"),n=t.one("select[name=op]"),r=n.get("value")==="isempty"||n.get("value")==="isnotempty";t.one("input[name=value]").set("disabled",r),M.core_availability.form.update()},f=e.one("#fitem_id_availabilityconditionsjson");f.delegate("change",function(){a(this)},".availability_profile select"),f.delegate("change",function(){a(this)},".availability_profile input[name=value]")}return u},M.availability_profile.form.fillValue=function(e,t){var n=t.one("select[name=field]").get("value");n.substr(0,3)==="sf_"?e.sf=n.substr(3):n.substr(0,3)==="cf_"&&(e.cf=n.substr(3)),e.op=t.one("select[name=op]").get("value");var r=t.one("input[name=value]");r.get("disabled")||(e.v=r.get("value"))},M.availability_profile.form.fillErrors=function(e,t){var n={};this.fillValue(n,t),n.sf===undefined&&n.cf===undefined&&e.push("availability_profile:error_selectfield"),n.v!==undefined&&/^\s*$/.test(n.v)&&e.push("availability_profile:error_setvalue")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); +YUI.add("moodle-availability_profile-form",function(e,t){M.availability_profile=M.availability_profile||{},M.availability_profile.form=e.Object(M.core_availability.plugin),M.availability_profile.form.profiles=null,M.availability_profile.form.initInner=function(e,t){this.standardFields=e,this.customFields=t},M.availability_profile.form.getNode=function(t){var n=M.str.availability_profile,r=' ';var u=e.Node.create(""+r+"");t.sf!==undefined&&u.one("select[name=field] > option[value=sf_"+t.sf+"]")?u.one("select[name=field]").set("value","sf_"+t.sf):t.cf!==undefined&&u.one("select[name=field] > option[value=cf_"+t.cf+"]")&&u.one("select[name=field]").set("value","cf_"+t.cf),t.op!==undefined&&u.one("select[name=op] > option[value="+t.op+"]")&&(u.one("select[name=op]").set("value",t.op),(t.op==="isempty"||t.op==="isnotempty")&&u.one("input[name=value]").set("disabled",!0)),t.v!==undefined&&u.one("input").set("value",t.v);if(!M.availability_profile.form.addedEvents){M.availability_profile.form.addedEvents=!0;var a=function(e){var t=e.ancestor("span.availability_profile"),n=t.one("select[name=op]"),r=n.get("value")==="isempty"||n.get("value")==="isnotempty";t.one("input[name=value]").set("disabled",r),M.core_availability.form.update()},f=e.one("#fitem_id_availabilityconditionsjson");f.delegate("change",function(){a(this)},".availability_profile select"),f.delegate("change",function(){a(this)},".availability_profile input[name=value]")}return u},M.availability_profile.form.fillValue=function(e,t){var n=t.one("select[name=field]").get("value");n.substr(0,3)==="sf_"?e.sf=n.substr(3):n.substr(0,3)==="cf_"&&(e.cf=n.substr(3)),e.op=t.one("select[name=op]").get("value");var r=t.one("input[name=value]");r.get("disabled")||(e.v=r.get("value"))},M.availability_profile.form.fillErrors=function(e,t){var n={};this.fillValue(n,t),n.sf===undefined&&n.cf===undefined&&e.push("availability_profile:error_selectfield"),n.v!==undefined&&/^\s*$/.test(n.v)&&e.push("availability_profile:error_setvalue")}},"@VERSION@",{requires:["base","node","event","moodle-core_availability-form"]}); diff --git a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js index 0973f47626a..c4b906d1f60 100644 --- a/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js +++ b/availability/condition/profile/yui/build/moodle-availability_profile-form/moodle-availability_profile-form.js @@ -74,6 +74,9 @@ M.availability_profile.form.getNode = function(json) { if (json.op !== undefined && node.one('select[name=op] > option[value=' + json.op + ']')) { node.one('select[name=op]').set('value', json.op); + if (json.op === 'isempty' || json.op === 'isnotempty') { + node.one('input[name=value]').set('disabled', true); + } } if (json.v !== undefined) { node.one('input').set('value', json.v); diff --git a/availability/condition/profile/yui/src/form/js/form.js b/availability/condition/profile/yui/src/form/js/form.js index afc486ecdd8..aa01d6a64a2 100644 --- a/availability/condition/profile/yui/src/form/js/form.js +++ b/availability/condition/profile/yui/src/form/js/form.js @@ -72,6 +72,9 @@ M.availability_profile.form.getNode = function(json) { if (json.op !== undefined && node.one('select[name=op] > option[value=' + json.op + ']')) { node.one('select[name=op]').set('value', json.op); + if (json.op === 'isempty' || json.op === 'isnotempty') { + node.one('input[name=value]').set('disabled', true); + } } if (json.v !== undefined) { node.one('input').set('value', json.v); -- 2.11.4.GIT