mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-73007' of https://github.com/paulholden/moodle
This commit is contained in:
commit
e1c9c7b007
@ -248,6 +248,7 @@ $string['categorysubcategoryof'] = '{$a->category} - subcategory of {$a->parentc
|
||||
$string['idnumbercoursecategory'] = 'Category ID number';
|
||||
$string['idnumbercoursecategory_help'] = 'The ID number of a course category is only used when matching the category against external systems and is not displayed anywhere on the site. If the category has an official code name it may be entered, otherwise the field can be left blank.';
|
||||
$string['categoryupdated'] = 'The category \'{$a}\' was updated';
|
||||
$string['changesmade'] = 'Changes made';
|
||||
$string['changesmadereallygoaway'] = 'You have made changes. Are you sure you want to navigate away and lose your changes?';
|
||||
$string['city'] = 'City/town';
|
||||
$string['cleaningtempdata'] = 'Cleaning temp data';
|
||||
|
2
lib/amd/build/dynamic_tabs.min.js
vendored
2
lib/amd/build/dynamic_tabs.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core/dynamic_tabs",["exports","jquery","core/templates","core/notification","core/pending","core/local/repository/dynamic_tabs"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);c=g(c);d=g(d);e=g(e);function g(a){return a&&a.__esModule?a:{default:a}}function h(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function i(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){h(Object(c),!0).forEach(function(b){j(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{h(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function j(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}var k={dynamicTabs:".dynamictabs",activeTab:".dynamictabs .nav-link.active",allActiveTabs:".dynamictabs .nav-link[data-toggle=\"tab\"]:not(.disabled)",tabContent:".dynamictabs .tab-pane [data-tab-content]",tabToggle:"a[data-toggle=\"tab\"]",tabPane:".dynamictabs .tab-pane",forTabName:function(a){return".dynamictabs [data-tab-content=\"".concat(a,"\"]")},forTabId:function(a){return".dynamictabs [data-toggle=\"tab\"][href=\"#".concat(a,"\"]")}},l=function(){(0,b.default)(k.tabToggle).on("shown.bs.tab",function(){var a=(0,b.default)((0,b.default)(this).attr("href"));if(1!==a.length){return}p(a.attr("id"))});if(!t()){var a=document.querySelector(k.allActiveTabs);if(a){s(a.getAttribute("aria-controls"))}else{var c=document.querySelector(k.tabPane);if(c){c.classList.add("active","show");p(c.getAttribute("id"))}}}};a.init=l;var m=function(a){return c.default.render("core/loading",{}).then(function(b,d){return c.default.replaceNodeContents(a,b,d)}).catch(d.default.exception)},n=function(){var a=document.querySelector(k.activeTab);return(null===a||void 0===a?void 0:a.getAttribute("aria-controls"))||null},o=function(){var a=document.querySelector(k.tabContent);return(null===a||void 0===a?void 0:a.dataset.tabContent)||null},p=function(a){var b,g,h=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};a=null!==(b=null!==(g=a)&&void 0!==g?g:n())&&void 0!==b?b:o();var j=document.querySelector(k.forTabName(a));if(!j){return}var l=new e.default("core/dynamic_tabs:loadTab:"+a),p=j.closest(k.dynamicTabs),q=i({reportid:p.dataset.reportid,id:p.dataset.id},h),r="";j.textContent="";m(j).then(function(){return(0,f.getContent)(j.dataset.tabClass,JSON.stringify(q))}).then(function(a){r=a.javascript;return c.default.render(a.template,JSON.parse(a.content))}).then(function(a,b){return c.default.replaceNodeContents(j,a,b+r)}).then(function(){l.resolve();return null}).catch(d.default.exception)},q=function(a){return document.querySelector(k.forTabId(a))},r=function(a){return document.getElementById(a)},s=function(a){var b=q(a);if(!b){return!1}p(a);b.classList.add("active");r(a).classList.add("active","show");return!0},t=function(){var a=document.location.hash;if(a.match(/^#\w+$/g)){return s(a.replace(/^#/g,""))}return!1}});
|
||||
define ("core/dynamic_tabs",["exports","jquery","core/templates","core/notification","core/pending","core/str","core/local/repository/dynamic_tabs","core_form/changechecker"],function(a,b,c,d,e,f,g,h){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=i(b);c=i(c);d=i(d);e=i(e);function i(a){return a&&a.__esModule?a:{default:a}}function j(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function k(a){for(var b=1,c;b<arguments.length;b++){c=null!=arguments[b]?arguments[b]:{};if(b%2){j(Object(c),!0).forEach(function(b){l(a,b,c[b])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(a,Object.getOwnPropertyDescriptors(c))}else{j(Object(c)).forEach(function(b){Object.defineProperty(a,b,Object.getOwnPropertyDescriptor(c,b))})}}return a}function l(a,b,c){if(b in a){Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}else{a[b]=c}return a}function m(a,b){return r(a)||q(a,b)||o(a,b)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(a,b){if(!a)return;if("string"==typeof a)return p(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return p(a,b)}function p(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c<b;c++){d[c]=a[c]}return d}function q(a,b){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(a)))return;var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function r(a){if(Array.isArray(a))return a}var s={dynamicTabs:".dynamictabs",activeTab:".dynamictabs .nav-link.active",allActiveTabs:".dynamictabs .nav-link[data-toggle=\"tab\"]:not(.disabled)",tabContent:".dynamictabs .tab-pane [data-tab-content]",tabToggle:"a[data-toggle=\"tab\"]",tabPane:".dynamictabs .tab-pane",forTabName:function(a){return".dynamictabs [data-tab-content=\"".concat(a,"\"]")},forTabId:function(a){return".dynamictabs [data-toggle=\"tab\"][href=\"#".concat(a,"\"]")}},t=function(){var a=(0,b.default)(s.tabToggle);a.on("click",function(a){if(!(0,h.isAnyWatchedFormDirty)()){return}a.preventDefault();a.stopPropagation();(0,f.get_strings)([{key:"changesmade",component:"moodle"},{key:"changesmadereallygoaway",component:"moodle"},{key:"confirm",component:"moodle"}]).then(function(c){var e=m(c,3),f=e[0],g=e[1],i=e[2];return d.default.confirm(f,g,i,null,function(){(0,h.resetAllFormDirtyStates)();(0,b.default)(a.target).trigger(a.type)})}).catch(d.default.exception)});a.on("shown.bs.tab",function(){var a=(0,b.default)((0,b.default)(this).attr("href"));if(1!==a.length){return}x(a.attr("id"))});if(!B()){var c=document.querySelector(s.allActiveTabs);if(c){A(c.getAttribute("aria-controls"))}else{var e=document.querySelector(s.tabPane);if(e){e.classList.add("active","show");x(e.getAttribute("id"))}}}};a.init=t;var u=function(a){return c.default.render("core/loading",{}).then(function(b,d){return c.default.replaceNodeContents(a,b,d)}).catch(d.default.exception)},v=function(){var a=document.querySelector(s.activeTab);return(null===a||void 0===a?void 0:a.getAttribute("aria-controls"))||null},w=function(){var a=document.querySelector(s.tabContent);return(null===a||void 0===a?void 0:a.dataset.tabContent)||null},x=function(a){var b,f,h=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};a=null!==(b=null!==(f=a)&&void 0!==f?f:v())&&void 0!==b?b:w();var i=document.querySelector(s.forTabName(a));if(!i){return}var j=new e.default("core/dynamic_tabs:loadTab:"+a),l=i.closest(s.dynamicTabs),m=k({reportid:l.dataset.reportid,id:l.dataset.id},h),n="";i.textContent="";u(i).then(function(){return(0,g.getContent)(i.dataset.tabClass,JSON.stringify(m))}).then(function(a){n=a.javascript;return c.default.render(a.template,JSON.parse(a.content))}).then(function(a,b){return c.default.replaceNodeContents(i,a,b+n)}).then(function(){j.resolve();return null}).catch(d.default.exception)},y=function(a){return document.querySelector(s.forTabId(a))},z=function(a){return document.getElementById(a)},A=function(a){var b=y(a);if(!b){return!1}x(a);b.classList.add("active");z(a).classList.add("active","show");return!0},B=function(){var a=document.location.hash;if(a.match(/^#\w+$/g)){return A(a.replace(/^#/g,""))}return!1}});
|
||||
//# sourceMappingURL=dynamic_tabs.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -25,7 +25,9 @@ import $ from 'jquery';
|
||||
import Templates from 'core/templates';
|
||||
import Notification from 'core/notification';
|
||||
import Pending from 'core/pending';
|
||||
import {get_strings as getStrings} from 'core/str';
|
||||
import {getContent} from 'core/local/repository/dynamic_tabs';
|
||||
import {isAnyWatchedFormDirty, resetAllFormDirtyStates} from 'core_form/changechecker';
|
||||
|
||||
const SELECTORS = {
|
||||
dynamicTabs: '.dynamictabs',
|
||||
@ -43,9 +45,33 @@ SELECTORS.forTabId = tabName => `.dynamictabs [data-toggle="tab"][href="#${tabNa
|
||||
* Initialises the tabs view on the page (only one tabs view per page is supported)
|
||||
*/
|
||||
export const init = () => {
|
||||
const tabToggle = $(SELECTORS.tabToggle);
|
||||
|
||||
// Listen to click, warn user if they are navigating away with unsaved form changes.
|
||||
tabToggle.on('click', (event) => {
|
||||
if (!isAnyWatchedFormDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
getStrings([
|
||||
{key: 'changesmade', component: 'moodle'},
|
||||
{key: 'changesmadereallygoaway', component: 'moodle'},
|
||||
{key: 'confirm', component: 'moodle'},
|
||||
]).then(([strChangesMade, strChangesMadeReally, strConfirm]) =>
|
||||
// Reset form dirty state on confirmation, re-trigger the event.
|
||||
Notification.confirm(strChangesMade, strChangesMadeReally, strConfirm, null, () => {
|
||||
resetAllFormDirtyStates();
|
||||
$(event.target).trigger(event.type);
|
||||
})
|
||||
).catch(Notification.exception);
|
||||
});
|
||||
|
||||
// This code listens to Bootstrap event 'shown.bs.tab' which is triggered using JQuery and
|
||||
// can not be converted yet to native events.
|
||||
$(SELECTORS.tabToggle).on('shown.bs.tab', function() {
|
||||
tabToggle.on('shown.bs.tab', function() {
|
||||
const tab = $($(this).attr('href'));
|
||||
if (tab.length !== 1) {
|
||||
return;
|
||||
|
2
lib/form/amd/build/changechecker.min.js
vendored
2
lib/form/amd/build/changechecker.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core_form/changechecker",["exports","core_editor/events","core/str"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.markFormAsDirtyById=a.resetFormDirtyStateById=a.watchFormById=a.startWatching=a.markAllFormsSubmitted=a.markFormSubmitted=a.markFormChangedFromNode=a.disableAllChecks=a.markFormAsDirty=a.markAllFormsAsDirty=a.resetFormDirtyState=a.resetAllFormDirtyStates=a.unWatchForm=a.watchForm=void 0;var d,e=[],f=!1,g=function(a){return a.closest("form")},h=function(a){a=g(a);if(!a){return}if(q(a)){return}e.push(a)};a.watchForm=h;var i=function(a){e=e.filter(function(b){return!!b.contains(a)})};a.unWatchForm=i;var j=function(){e.forEach(function(a){a.dataset.formSubmitted="false";a.dataset.formDirty="false"})};a.resetAllFormDirtyStates=j;var k=function(a){a=g(a);if(!a){return}a.dataset.formSubmitted="false";a.dataset.formDirty="false"};a.resetFormDirtyState=k;var l=function(){e.forEach(function(a){a.dataset.formDirty="true"})};a.markAllFormsAsDirty=l;var m=function(a){a=g(a);if(!a){return}a.dataset.formDirty="true"};a.markFormAsDirty=m;var n=function(){f=!0};a.disableAllChecks=n;var o=function(){if(f){return!1}var a=e.some(function(a){return"true"===a.dataset.formSubmitted});if(a){return!1}var b=e.some(function(a){if(!a.isConnected){return!1}if("true"===a.dataset.formDirty){return!0}if(document.activeElement&&document.activeElement.dataset.propertyIsEnumerable("initialValue")){var b=q(document.activeElement),c=document.activeElement.dataset.initialValue!==document.activeElement.value;if(b&&c){return!0}}return!1});if(b){return!0}if("undefined"!=typeof window.tinyMCE){if(window.tinyMCE.editors.some(function(a){return a.isDirty()})){return!0}}return!1},p=function(a){return e.find(function(b){return b.contains(a)})},q=function(a){return e.some(function(b){return b.contains(a)})},r=function(a){return!!a.closest(".ignoredirty")},s=function(a){if(a.dataset.formChangeCheckerOverride){n();return}if(!q(a)){return}if(r(a)){return}var b=p(a);b.dataset.formDirty="true"};a.markFormChangedFromNode=s;var t=function(a){a=g(a);if(!a){return}a.dataset.formSubmitted="true"};a.markFormSubmitted=t;var u=function(){e.forEach(function(a){return t(a)})};a.markAllFormsSubmitted=u;var v=function(a){var b=o()&&!M.cfg.behatsiterunning;if(b){a.preventDefault();a.returnValue=d;return a.returnValue}window.removeEventListener("beforeunload",v);return null},w=function(){x();document.addEventListener("change",function(a){if(!q(a.target)){return}s(a.target)});document.addEventListener("click",function(a){var b=a.target.closest("[data-formchangechecker-ignore-submit]");if(!b){return}var c=g(a.target);if(c){c.dataset.ignoreSubmission="true"}});document.addEventListener("focusin",function(a){if(a.target.matches("input, textarea, select")){if(a.target.dataset.propertyIsEnumerable("initialValue")){return}a.target.dataset.initialValue=a.target.value}});document.addEventListener("submit",function(a){var b=g(a.target);if(!b){return}if(b.dataset.ignoreSubmission){b.dataset.ignoreSubmission="false";return}t(b)});document.addEventListener(b.eventTypes.editorContentRestored,function(a){if(a.target!=document){k(a.target)}else{j()}});(0,c.get_string)("changesmadereallygoaway","moodle").then(function(a){d=a}).catch();window.addEventListener("beforeunload",v)};a.startWatching=w;var x=function(){var a=function(a,b,c){return function(){window.console.warn("The moodle-core-formchangechecker has been deprecated and replaced with core_form/changechecker. "+"The ".concat(a," function has been replaced with ").concat(b,"."));c.apply(void 0,arguments)}};window.M.core_formchangechecker={init:a("init","watchFormById",y),reset_form_dirty_state:a("reset_form_dirty_state","resetFormDirtyState",j),set_form_changed:a("set_form_changed","markFormAsDirty",l),set_form_submitted:a("set_form_submitted","markFormSubmitted",u)}},y=function(a){h(document.getElementById(a))};a.watchFormById=y;a.resetFormDirtyStateById=function resetFormDirtyStateById(a){k(document.getElementById(a))};a.markFormAsDirtyById=function markFormAsDirtyById(a){m(document.getElementById(a))};w()});
|
||||
define ("core_form/changechecker",["exports","core_editor/events","core/str"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.markFormAsDirtyById=a.resetFormDirtyStateById=a.watchFormById=a.startWatching=a.markAllFormsSubmitted=a.markFormSubmitted=a.markFormChangedFromNode=a.isAnyWatchedFormDirty=a.disableAllChecks=a.markFormAsDirty=a.markAllFormsAsDirty=a.resetFormDirtyState=a.resetAllFormDirtyStates=a.unWatchForm=a.watchForm=void 0;var d,e=[],f=!1,g=function(a){return a.closest("form")},h=function(a){a=g(a);if(!a){return}if(q(a)){return}e.push(a)};a.watchForm=h;var i=function(a){e=e.filter(function(b){return!!b.contains(a)})};a.unWatchForm=i;var j=function(){e.forEach(function(a){a.dataset.formSubmitted="false";a.dataset.formDirty="false"})};a.resetAllFormDirtyStates=j;var k=function(a){a=g(a);if(!a){return}a.dataset.formSubmitted="false";a.dataset.formDirty="false"};a.resetFormDirtyState=k;var l=function(){e.forEach(function(a){a.dataset.formDirty="true"})};a.markAllFormsAsDirty=l;var m=function(a){a=g(a);if(!a){return}a.dataset.formDirty="true"};a.markFormAsDirty=m;var n=function(){f=!0};a.disableAllChecks=n;var o=function(){if(f){return!1}var a=e.some(function(a){return"true"===a.dataset.formSubmitted});if(a){return!1}var b=e.some(function(a){if(!a.isConnected){return!1}if("true"===a.dataset.formDirty){return!0}if(document.activeElement&&document.activeElement.dataset.propertyIsEnumerable("initialValue")){var b=q(document.activeElement),c=document.activeElement.dataset.initialValue!==document.activeElement.value;if(b&&c){return!0}}return!1});if(b){return!0}if("undefined"!=typeof window.tinyMCE){if(window.tinyMCE.editors.some(function(a){return a.isDirty()})){return!0}}return!1};a.isAnyWatchedFormDirty=o;var p=function(a){return e.find(function(b){return b.contains(a)})},q=function(a){return e.some(function(b){return b.contains(a)})},r=function(a){return!!a.closest(".ignoredirty")},s=function(a){if(a.dataset.formChangeCheckerOverride){n();return}if(!q(a)){return}if(r(a)){return}var b=p(a);b.dataset.formDirty="true"};a.markFormChangedFromNode=s;var t=function(a){a=g(a);if(!a){return}a.dataset.formSubmitted="true"};a.markFormSubmitted=t;var u=function(){e.forEach(function(a){return t(a)})};a.markAllFormsSubmitted=u;var v=function(a){var b=o()&&!M.cfg.behatsiterunning;if(b){a.preventDefault();a.returnValue=d;return a.returnValue}window.removeEventListener("beforeunload",v);return null},w=function(){x();document.addEventListener("change",function(a){if(!q(a.target)){return}s(a.target)});document.addEventListener("click",function(a){var b=a.target.closest("[data-formchangechecker-ignore-submit]");if(!b){return}var c=g(a.target);if(c){c.dataset.ignoreSubmission="true"}});document.addEventListener("focusin",function(a){if(a.target.matches("input, textarea, select")){if(a.target.dataset.propertyIsEnumerable("initialValue")){return}a.target.dataset.initialValue=a.target.value}});document.addEventListener("submit",function(a){var b=g(a.target);if(!b){return}if(b.dataset.ignoreSubmission){b.dataset.ignoreSubmission="false";return}t(b)});document.addEventListener(b.eventTypes.editorContentRestored,function(a){if(a.target!=document){k(a.target)}else{j()}});(0,c.get_string)("changesmadereallygoaway","moodle").then(function(a){d=a}).catch();window.addEventListener("beforeunload",v)};a.startWatching=w;var x=function(){var a=function(a,b,c){return function(){window.console.warn("The moodle-core-formchangechecker has been deprecated and replaced with core_form/changechecker. "+"The ".concat(a," function has been replaced with ").concat(b,"."));c.apply(void 0,arguments)}};window.M.core_formchangechecker={init:a("init","watchFormById",y),reset_form_dirty_state:a("reset_form_dirty_state","resetFormDirtyState",j),set_form_changed:a("set_form_changed","markFormAsDirty",l),set_form_submitted:a("set_form_submitted","markFormSubmitted",u)}},y=function(a){h(document.getElementById(a))};a.watchFormById=y;a.resetFormDirtyStateById=function resetFormDirtyStateById(a){k(document.getElementById(a))};a.markFormAsDirtyById=function markFormAsDirtyById(a){m(document.getElementById(a))};w()});
|
||||
//# sourceMappingURL=changechecker.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -226,9 +226,8 @@ export const disableAllChecks = () => {
|
||||
*
|
||||
* @method
|
||||
* @returns {Bool}
|
||||
* @private
|
||||
*/
|
||||
const isAnyWatchedFormDirty = () => {
|
||||
export const isAnyWatchedFormDirty = () => {
|
||||
if (formChangeCheckerDisabled) {
|
||||
// The form change checker is disabled.
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user