mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-12 09:24:17 +00:00
Merge "Prevent the dialog from applying changes on bad input"
This commit is contained in:
commit
d09a78c9f0
|
@ -457,13 +457,12 @@
|
||||||
* Apply the changes made to the parameters to the json
|
* Apply the changes made to the parameters to the json
|
||||||
*
|
*
|
||||||
* @param {Object} originalJsonObject [description]
|
* @param {Object} originalJsonObject [description]
|
||||||
* @param {Object<String,jQuery>} modalDomElements The structure of the
|
* @param {Object<string,jQuery>} modalDomElements The structure of the
|
||||||
* dom elements in the editor, sorted by parameter id and jQuery editable
|
* dom elements in the editor, sorted by parameter id and jQuery editable
|
||||||
* object
|
* object
|
||||||
* @param {String} originalWikitext The original wikitext
|
* @param {boolean} doNotCheckForm if set to true, the system will not validate the form
|
||||||
* @param {Boolean} DoNotCheckForm if set to true, the system will not validate the form
|
|
||||||
* used mostly for tests.
|
* used mostly for tests.
|
||||||
* @returns {Object} Amended json object
|
* @returns {Object|boolean} Amended json object or false if changes are invalid.
|
||||||
*/
|
*/
|
||||||
function applyChangeToJSON( originalJsonObject, modalDomElements, doNotCheckForm ) {
|
function applyChangeToJSON( originalJsonObject, modalDomElements, doNotCheckForm ) {
|
||||||
var paramid,
|
var paramid,
|
||||||
|
@ -483,7 +482,7 @@
|
||||||
if ( !doNotCheckForm ) {
|
if ( !doNotCheckForm ) {
|
||||||
if ( !isFormValid() ) {
|
if ( !isFormValid() ) {
|
||||||
showErrorModal( mw.msg( 'templatedata-modal-errormsg', '|', '=', '}}' ) );
|
showErrorModal( mw.msg( 'templatedata-modal-errormsg', '|', '=', '}}' ) );
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,9 +601,16 @@
|
||||||
var modalButtons = {};
|
var modalButtons = {};
|
||||||
|
|
||||||
modalButtons[btnApply] = function() {
|
modalButtons[btnApply] = function() {
|
||||||
var newJson = applyChangeToJSON(),
|
var finalOutput,
|
||||||
finalOutput = amendWikitext( newJson );
|
newJson = applyChangeToJSON();
|
||||||
|
|
||||||
|
// Check if returned json is valid
|
||||||
|
if ( !newJson ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply changes
|
||||||
|
finalOutput = amendWikitext( newJson );
|
||||||
|
|
||||||
// Close the modal
|
// Close the modal
|
||||||
domObjects.$modalBox.dialog( 'close' );
|
domObjects.$modalBox.dialog( 'close' );
|
||||||
|
|
Loading…
Reference in a new issue