Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/273854

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(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/54/273854/1

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: newchange
Gerrit-Change-Id: I07d100a5c26de104976ca21d7e00366143415bed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to