Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/110907
Change subject: Prevent the dialog from applying changes on bad input ...................................................................... Prevent the dialog from applying changes on bad input Make sure the dialog does not change the json string if the editor form contains any errors. Change-Id: Ib4d36f70e1f9d5b34605b4e54fd12b6e2405c37a --- M modules/ext.templateDataGenerator.core.js 1 file changed, 15 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TemplateData refs/changes/07/110907/1 diff --git a/modules/ext.templateDataGenerator.core.js b/modules/ext.templateDataGenerator.core.js index d2e8fe6..895d68d 100644 --- a/modules/ext.templateDataGenerator.core.js +++ b/modules/ext.templateDataGenerator.core.js @@ -483,7 +483,7 @@ if ( !doNotCheckForm ) { if ( !isFormValid() ) { showErrorModal( mw.msg( 'templatedata-modal-errormsg' ) ); - return; + return false; } } @@ -602,18 +602,24 @@ var modalButtons = {}; modalButtons[btnApply] = function() { - var newJson = applyChangeToJSON(), + var finalOutput, + newJson = applyChangeToJSON(); + + // Check if returned json is valid + if ( newJson ) { + // Apply changes finalOutput = amendWikitext( newJson ); + // Close the modal + domObjects.$modalBox.dialog( 'close' ); - // Close the modal - domObjects.$modalBox.dialog( 'close' ); + // Trigger the closing event so the new output can be put + // back to the textbox + domObjects.$modalBox.trigger( 'TemplateDataGeneratorDone', [ finalOutput ] ); - // Trigger the closing event so the new output can be put - // back to the textbox - domObjects.$modalBox.trigger( 'TemplateDataGeneratorDone', [ finalOutput ] ); - - return finalOutput; + return finalOutput; + } + return false; }; modalButtons[btnCancel] = function () { -- To view, visit https://gerrit.wikimedia.org/r/110907 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib4d36f70e1f9d5b34605b4e54fd12b6e2405c37a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TemplateData Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits