jenkins-bot has submitted this change and it was merged. Change subject: Introduce validation error and success events for sections ......................................................................
Introduce validation error and success events for sections The current linter card is invoked on translation focus and it does not update the errors while save is happening. This new events provide instant update to the linter cards while editing is happening. Bug: T123912 Change-Id: I07d100a5c26de104976ca21d7e00366143415bed --- M hooks.md M modules/tools/ext.cx.tools.linter.js M modules/translation/ext.cx.translation.storage.js 3 files changed, 12 insertions(+), 1 deletion(-) Approvals: Nikerabbit: Checked; Looks good to me, approved jenkins-bot: Verified diff --git a/hooks.md b/hooks.md index bd8adc4..eb5182a 100644 --- a/hooks.md +++ b/hooks.md @@ -178,3 +178,11 @@ # mw.cx.cta.shown Fired when the Content Translation entry point or campaign is shown. The unique campaign identifier is passed. + +## mw.cx.translation.validation.error + +Fired when there are AbuseFilter based validation errors for the section. + +## mw.cx.translation.validation.success + +Fired when there are no AbuseFilter based validation errors for the section. diff --git a/modules/tools/ext.cx.tools.linter.js b/modules/tools/ext.cx.tools.linter.js index 5b43ae1..850bea9 100644 --- a/modules/tools/ext.cx.tools.linter.js +++ b/modules/tools/ext.cx.tools.linter.js @@ -98,7 +98,8 @@ LinterCard.prototype.getTriggerEvents = function () { return [ 'mw.cx.translation.focus', - 'mw.cx.translation.change' + 'mw.cx.translation.validation.success', + 'mw.cx.translation.validation.error' ]; }; diff --git a/modules/translation/ext.cx.translation.storage.js b/modules/translation/ext.cx.translation.storage.js index ebfb610..f4e6c35 100644 --- a/modules/translation/ext.cx.translation.storage.js +++ b/modules/translation/ext.cx.translation.storage.js @@ -158,8 +158,10 @@ // Annotate the section with errors. if ( validations[ sectionId ] && Object.keys( validations[ sectionId ] ).length ) { $targetSection.data( 'errors', validations[ sectionId ] ); + mw.hook( 'mw.cx.translation.validation.error' ).fire( $targetSection ); } else { $targetSection.removeData( 'errors' ); + mw.hook( 'mw.cx.translation.validation.success' ).fire( $targetSection ); } } -- To view, visit https://gerrit.wikimedia.org/r/273854 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I07d100a5c26de104976ca21d7e00366143415bed Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits