MDL-72308 forms: final removal of legacy formchangechecker YUI.

This commit is contained in:
Paul Holden 2023-09-20 18:43:52 +01:00
parent 2ac0df331c
commit e2cb2fa5dc
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
13 changed files with 7 additions and 269 deletions

View File

@ -781,7 +781,7 @@ EditorTextArea.prototype = {
// Insert the cleaned content.
this.textarea.set('value', newValue);
// Trigger the onchange callback on the textarea, essentially to notify moodle-core-formchangechecker.
// Trigger the onchange callback on the textarea, essentially to notify the formchangechecker module.
this.textarea.simulate('change');
// Trigger handlers for this action.

View File

@ -776,7 +776,7 @@ EditorTextArea.prototype = {
// Insert the cleaned content.
this.textarea.set('value', newValue);
// Trigger the onchange callback on the textarea, essentially to notify moodle-core-formchangechecker.
// Trigger the onchange callback on the textarea, essentially to notify the formchangechecker module.
this.textarea.simulate('change');
// Trigger handlers for this action.

View File

@ -106,7 +106,7 @@ EditorTextArea.prototype = {
// Insert the cleaned content.
this.textarea.set('value', newValue);
// Trigger the onchange callback on the textarea, essentially to notify moodle-core-formchangechecker.
// Trigger the onchange callback on the textarea, essentially to notify the formchangechecker module.
this.textarea.simulate('change');
// Trigger handlers for this action.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -418,9 +418,6 @@ export const startWatching = () => {
return;
}
// Add legacy support to provide b/c for the old YUI version.
addLegacyFunctions();
document.addEventListener('change', e => {
if (!isWatchingForm(e.target)) {
return;
@ -485,33 +482,6 @@ export const startWatching = () => {
window.addEventListener('beforeunload', beforeUnloadHandler);
};
/**
* Add legacy functions for backwards compatability.
*
* @method
* @private
*/
const addLegacyFunctions = () => {
// Create a curried function to log use of the old function and provide detail on its replacement.
const getLoggedLegacyFallback = (oldFunctionName, newFunctionName, newFunction) => (...args) => {
window.console.warn(
`The moodle-core-formchangechecker has been deprecated ` +
`and replaced with core_form/changechecker. ` +
`The ${oldFunctionName} function has been replaced with ${newFunctionName}.`
);
newFunction(...args);
};
/* eslint-disable */
window.M.core_formchangechecker = {
init: getLoggedLegacyFallback('init', 'watchFormById', watchFormById),
reset_form_dirty_state: getLoggedLegacyFallback('reset_form_dirty_state', 'resetFormDirtyState', resetAllFormDirtyStates),
set_form_changed: getLoggedLegacyFallback('set_form_changed', 'markFormAsDirty', markAllFormsAsDirty),
set_form_submitted: getLoggedLegacyFallback('set_form_submitted', 'markFormSubmitted', markAllFormsSubmitted),
};
/* eslint-enable */
};
/**
* Watch the form matching the specified ID for changes.
*

View File

@ -9,6 +9,8 @@ information provided here is intended especially for developers.
which the previous `enhance` is now a wrapper of, while preserving jQuery promise return)
* The group element has a new method `getAttributesForFormElement` which should be used in conjunction
with `createFormElement` to ensure that all elements within the group have unique IDs
* The deprecated `moodle-core-formchangechecker` YUI module and legacy `M.core_formchangechecker` have been
removed and can no longer be used
=== 4.3 ===

View File

@ -1,73 +0,0 @@
YUI.add('moodle-core-formchangechecker', function (Y, NAME) {
/**
* A utility to check for form changes before navigating away from a page.
*
* @module moodle-core-formchangechecker
*/
/**
* A utility to check for form changes before navigating away from a page.
*
* Please note that this YUI module has been deprecated in favour of the core_form/changechecker AMD module.
*
* @class M.core.formchangechecker
* @deprecated
*/
window.console.warn(
'The moodle-core-formchangechecker has been deprecated ' +
'and replaced with core_form/changechecker. ' +
'Please update your code to make use of the new module.'
);
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.startWatching();
});
// The following are provided to prevent race conditions.
// Because the AMD module is loaded asynchronously after the YUI module is loaded, there is a possibility that the
// calling code may call the YUI function calls before the AMD module has finished loading.
// These will be removed in future and are automatically overwritten by the legacy helper provided as part of the new
// changechecker AMD module.
// eslint-disable-next-line camelcase
M.core_formchangechecker = M.core_formchangechecker || {
init: function(config) {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.watchFormById(config.formid);
});
},
/**
* Set the form changed state to true
*/
// eslint-disable-next-line camelcase
set_form_changed: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsAsDirty();
});
},
/**
* Set the form submitted state to true
*/
// eslint-disable-next-line camelcase
set_form_submitted: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsSubmitted();
});
},
/**
* Reset the form state
*/
// eslint-disable-next-line camelcase
reset_form_dirty_state: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.resetAllFormDirtyStates();
});
},
};
}, '@VERSION@', {"requires": ["base", "event-focus", "moodle-core-event"]});

View File

@ -1 +0,0 @@
YUI.add("moodle-core-formchangechecker",function(e,r){window.console.warn("The moodle-core-formchangechecker has been deprecated and replaced with core_form/changechecker. Please update your code to make use of the new module."),require(["core_form/changechecker"],function(e){e.startWatching()}),M.core_formchangechecker=M.core_formchangechecker||{init:function(r){require(["core_form/changechecker"],function(e){e.watchFormById(r.formid)})},set_form_changed:function(){require(["core_form/changechecker"],function(e){e.markAllFormsAsDirty()})},set_form_submitted:function(){require(["core_form/changechecker"],function(e){e.markAllFormsSubmitted()})},reset_form_dirty_state:function(){require(["core_form/changechecker"],function(e){e.resetAllFormDirtyStates()})}}},"@VERSION@",{requires:["base","event-focus","moodle-core-event"]});

View File

@ -1,73 +0,0 @@
YUI.add('moodle-core-formchangechecker', function (Y, NAME) {
/**
* A utility to check for form changes before navigating away from a page.
*
* @module moodle-core-formchangechecker
*/
/**
* A utility to check for form changes before navigating away from a page.
*
* Please note that this YUI module has been deprecated in favour of the core_form/changechecker AMD module.
*
* @class M.core.formchangechecker
* @deprecated
*/
window.console.warn(
'The moodle-core-formchangechecker has been deprecated ' +
'and replaced with core_form/changechecker. ' +
'Please update your code to make use of the new module.'
);
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.startWatching();
});
// The following are provided to prevent race conditions.
// Because the AMD module is loaded asynchronously after the YUI module is loaded, there is a possibility that the
// calling code may call the YUI function calls before the AMD module has finished loading.
// These will be removed in future and are automatically overwritten by the legacy helper provided as part of the new
// changechecker AMD module.
// eslint-disable-next-line camelcase
M.core_formchangechecker = M.core_formchangechecker || {
init: function(config) {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.watchFormById(config.formid);
});
},
/**
* Set the form changed state to true
*/
// eslint-disable-next-line camelcase
set_form_changed: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsAsDirty();
});
},
/**
* Set the form submitted state to true
*/
// eslint-disable-next-line camelcase
set_form_submitted: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsSubmitted();
});
},
/**
* Reset the form state
*/
// eslint-disable-next-line camelcase
reset_form_dirty_state: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.resetAllFormDirtyStates();
});
},
};
}, '@VERSION@', {"requires": ["base", "event-focus", "moodle-core-event"]});

View File

@ -1,10 +0,0 @@
{
"name": "moodle-core-formchangechecker",
"builds": {
"moodle-core-formchangechecker": {
"jsfiles": [
"formchangechecker.js"
]
}
}
}

View File

@ -1,68 +0,0 @@
/**
* A utility to check for form changes before navigating away from a page.
*
* @module moodle-core-formchangechecker
*/
/**
* A utility to check for form changes before navigating away from a page.
*
* Please note that this YUI module has been deprecated in favour of the core_form/changechecker AMD module.
*
* @class M.core.formchangechecker
* @deprecated
*/
window.console.warn(
'The moodle-core-formchangechecker has been deprecated ' +
'and replaced with core_form/changechecker. ' +
'Please update your code to make use of the new module.'
);
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.startWatching();
});
// The following are provided to prevent race conditions.
// Because the AMD module is loaded asynchronously after the YUI module is loaded, there is a possibility that the
// calling code may call the YUI function calls before the AMD module has finished loading.
// These will be removed in future and are automatically overwritten by the legacy helper provided as part of the new
// changechecker AMD module.
// eslint-disable-next-line camelcase
M.core_formchangechecker = M.core_formchangechecker || {
init: function(config) {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.watchFormById(config.formid);
});
},
/**
* Set the form changed state to true
*/
// eslint-disable-next-line camelcase
set_form_changed: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsAsDirty();
});
},
/**
* Set the form submitted state to true
*/
// eslint-disable-next-line camelcase
set_form_submitted: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.markAllFormsSubmitted();
});
},
/**
* Reset the form state
*/
// eslint-disable-next-line camelcase
reset_form_dirty_state: function() {
require(['core_form/changechecker'], function(ChangeChecker) {
ChangeChecker.resetAllFormDirtyStates();
});
},
};

View File

@ -1,9 +0,0 @@
{
"moodle-core-formchangechecker": {
"requires": [
"base",
"event-focus",
"moodle-core-event"
]
}
}