From 568752434fe364b112e3a66684c926ab7344ad0b Mon Sep 17 00:00:00 2001 From: goltz Date: Thu, 26 Sep 2019 12:19:32 +0200 Subject: [PATCH] BUGFIX also check for name = undefined --- amd/build/mod_form.min.js | 2 +- amd/src/mod_form.js | 2 +- version.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/amd/build/mod_form.min.js b/amd/build/mod_form.min.js index e1e90c7..d637cdc 100644 --- a/amd/build/mod_form.min.js +++ b/amd/build/mod_form.min.js @@ -1 +1 @@ -define(["jquery","core/templates","core/modal_factory","auth_mumie/mumie_server_config","core/ajax"],function(){function a(a){if(0!=Object.keys(r).length){var b=k.options[k.selectedIndex].text,c=r[b].courses;d(l);for(var e in c){var f=c[e],g=document.createElement("option");g.setAttribute("value",f.name),g.text=f.name,l.append(g),f.name===a&&(l.selectedIndex=e)}}}function b(a){if(0!=Object.keys(r).length){d(m);var b=l.options[l.selectedIndex].text,c=k.options[k.selectedIndex].text;for(var e in i(c,b)){var f=document.createElement("option");f.setAttribute("value",e),f.text=e,m.append(f),e===a&&(m.selectedIndex=m.options.length-1)}}}function c(a){if(0!=Object.keys(r).length){var b=l.options[l.selectedIndex].text,c=k.options[k.selectedIndex].text,f=m.options[m.selectedIndex].text,g=r[c].courses.find(function(a){return a.name===b}).tasks;d(n);for(var h in g){var i=g[h].link+"?lang="+f,j=null,o=g[h].headline;for(var p in o){var q=o[p];if(q.language===f){j=q.name;break}}var s=document.createElement("option");s.setAttribute("value",i),s.text=j,null!==j&&n.append(s),i===a&&(n.selectedIndex=h)}e()}}function d(a){for(;a.firstChild;)a.removeChild(a.firstChild)}function e(){var a=n.options[n.selectedIndex].text;o.value=a}function f(){if(0!=Object.keys(r).length){var a=k.options[k.selectedIndex].text;p.value=r[a].courses[l.selectedIndex].pathToCourseFile}}function g(){k.onchange=function(){a(),b(m.options[m.selectedIndex].text),c(),f()},l.onchange=function(){b(m.options[m.selectedIndex].text),c(),f()},m.onchange=function(){c()},n.onchange=function(){e()}}function h(){return""===q.getAttribute("value")}function i(a,b){var c=[],d=r[a].courses.find(function(a){return a.name===b}).tasks;for(var e in d){var f=d[e];for(var g in f.headline){var h=f.headline[g];c[h.language]=h.language}}return c}var j=document.getElementById("id_add_server_button"),k=document.getElementById("id_server"),l=document.getElementById("id_mumie_course"),m=document.getElementById("id_language"),n=document.getElementById("id_taskurl"),o=document.getElementById("id_name"),p=document.getElementsByName("mumie_coursefile")[0],q=document.getElementsByName("mumie_missing_config")[0],r={};return{init:function(e){var i=null!==o.getAttribute("value")&&o.getAttribute("value").length>0;i&&!h()?(require(["core/str","core/notification"],function(a,b){a.get_strings([{key:"mumie_form_missing_server",component:"mod_mumie"}]).done(function(a){b.addNotification({message:a[0]+""+q.getAttribute("value")+"",type:"problem"})}).fail(b.exception)}),k.disabled=!0,l.disabled=!0,m.disabled=!0,n.disabled=!0,d(l),d(k),d(m),d(n)):require(["core/ajax"],function(d){d.call([{methodname:"auth_mumie_get_available_courses",args:{contextid:e},done:function(d){if(r=JSON.parse(d),i){var e=o.getAttribute("value"),h=l.options[l.selectedIndex].text,j=n.options[n.selectedIndex].getAttribute("value"),k=m.options[m.selectedIndex].text;a(h),b(k),c(j),g(),f(),o.value=e}else a(),b(),c(),g(),f()},fail:function(a){alert(JSON.stringify(a))}}])}),require(["auth_mumie/mumie_server_config"],function(a){a.init(j,e)})}}}); \ No newline at end of file +define(["jquery","core/templates","core/modal_factory","auth_mumie/mumie_server_config","core/ajax"],function(){function a(a){if(0!=Object.keys(r).length){var b=k.options[k.selectedIndex].text,c=r[b].courses;d(l);for(var e in c){var f=c[e],g=document.createElement("option");g.setAttribute("value",f.name),g.text=f.name,l.append(g),f.name===a&&(l.selectedIndex=e)}}}function b(a){if(0!=Object.keys(r).length){d(m);var b=l.options[l.selectedIndex].text,c=k.options[k.selectedIndex].text;for(var e in i(c,b)){var f=document.createElement("option");f.setAttribute("value",e),f.text=e,m.append(f),e===a&&(m.selectedIndex=m.options.length-1)}}}function c(a){if(0!=Object.keys(r).length){var b=l.options[l.selectedIndex].text,c=k.options[k.selectedIndex].text,f=m.options[m.selectedIndex].text,g=r[c].courses.find(function(a){return a.name===b}).tasks;d(n);for(var h in g){var i=g[h].link+"?lang="+f,j=null,o=g[h].headline;for(var p in o){var q=o[p];if(q.language===f){j=q.name;break}}var s=document.createElement("option");s.setAttribute("value",i),s.text=j,null!==j&&n.append(s),i===a&&(n.selectedIndex=h)}e()}}function d(a){for(;a.firstChild;)a.removeChild(a.firstChild)}function e(){var a=n.options[n.selectedIndex].text;o.value=a}function f(){if(0!=Object.keys(r).length){var a=k.options[k.selectedIndex].text;p.value=r[a].courses[l.selectedIndex].pathToCourseFile}}function g(){k.onchange=function(){a(),b(m.options[m.selectedIndex].text),c(),f()},l.onchange=function(){b(m.options[m.selectedIndex].text),c(),f()},m.onchange=function(){c()},n.onchange=function(){e()}}function h(){return""===q.getAttribute("value")}function i(a,b){var c=[],d=r[a].courses.find(function(a){return a.name===b}).tasks;for(var e in d){var f=d[e];for(var g in f.headline){var h=f.headline[g];c[h.language]=h.language}}return c}var j=document.getElementById("id_add_server_button"),k=document.getElementById("id_server"),l=document.getElementById("id_mumie_course"),m=document.getElementById("id_language"),n=document.getElementById("id_taskurl"),o=document.getElementById("id_name"),p=document.getElementsByName("mumie_coursefile")[0],q=document.getElementsByName("mumie_missing_config")[0],r={};return{init:function(e){var i=o.getAttribute("value");i&&!h()?(require(["core/str","core/notification"],function(a,b){a.get_strings([{key:"mumie_form_missing_server",component:"mod_mumie"}]).done(function(a){b.addNotification({message:a[0]+""+q.getAttribute("value")+"",type:"problem"})}).fail(b.exception)}),k.disabled=!0,l.disabled=!0,m.disabled=!0,n.disabled=!0,d(l),d(k),d(m),d(n)):require(["core/ajax"],function(d){d.call([{methodname:"auth_mumie_get_available_courses",args:{contextid:e},done:function(d){if(r=JSON.parse(d),i){var e=o.getAttribute("value"),h=l.options[l.selectedIndex].text,j=n.options[n.selectedIndex].getAttribute("value"),k=m.options[m.selectedIndex].text;a(h),b(k),c(j),g(),f(),o.value=e}else a(),b(),c(),g(),f()},fail:function(a){alert(JSON.stringify(a))}}])}),require(["auth_mumie/mumie_server_config"],function(a){a.init(j,e)})}}}); \ No newline at end of file diff --git a/amd/src/mod_form.js b/amd/src/mod_form.js index 6d5941c..b7cf1a5 100644 --- a/amd/src/mod_form.js +++ b/amd/src/mod_form.js @@ -12,7 +12,7 @@ define(['jquery', 'core/templates', 'core/modal_factory', 'auth_mumie/mumie_serv return { init: function (contextid) { - var isEdit = nameElem.getAttribute('value') !== null && nameElem.getAttribute("value").length > 0; + var isEdit = nameElem.getAttribute('value'); if (isEdit && !serverConfigExists()) { require(['core/str', "core/notification"], function (str, notification) { diff --git a/version.php b/version.php index 55311ce..e1c9afa 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2019092600; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2019092601; // The current module version (Date: YYYYMMDDXX). $plugin->component = 'mod_mumie'; // Full name of the plugin (used for diagnostics). $plugin->requires = 2015041700; $plugin->release = "v1.1";