jenkins-bot has submitted this change and it was merged.
Change subject: Hide unrelated cards by checking intersection of trigger events
......................................................................
Hide unrelated cards by checking intersection of trigger events
Change-Id: Iabe9b5f10e41ed4425edcbc950c9c8d7e5796fdc
---
M modules/tools/ext.cx.tools.manager.js
1 file changed, 34 insertions(+), 0 deletions(-)
Approvals:
Amire80: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/tools/ext.cx.tools.manager.js
b/modules/tools/ext.cx.tools.manager.js
index 680bc0f..b4ee65d 100644
--- a/modules/tools/ext.cx.tools.manager.js
+++ b/modules/tools/ext.cx.tools.manager.js
@@ -118,6 +118,40 @@
}
tool.start.apply( tool, data );
this.tools[ toolName ] = tool;
+ this.hideUnrelatedCards( toolName );
+ };
+
+ /**
+ * Find intersection of two arrays
+ * @param {Array} array1
+ * @param {Array} array2
+ * @return {Array} intersection array
+ */
+ function intersection( array1, array2 ) {
+ return array1.filter( function ( n ) {
+ return array2.indexOf( n ) !== -1;
+ } );
+ }
+
+ /**
+ * Hide unrelated cards
+ * Find out cards not having trigger events intersecton and hide them.
+ * @param {string} currentToolName current tool name
+ */
+ CXToolManager.prototype.hideUnrelatedCards = function ( currentToolName
) {
+ var currentToolEvents, toolEvents, toolName;
+ if ( this.tools[ currentToolName ] ) {
+ currentToolEvents = this.tools[ currentToolName
].getTriggerEvents();
+ }
+ for ( toolName in this.tools ) {
+ if ( toolName === currentToolName ) {
+ continue;
+ }
+ toolEvents = this.tools[ toolName ].getTriggerEvents();
+ if ( intersection( currentToolEvents, toolEvents
).length === 0 ) {
+ this.hideCard( toolName );
+ }
+ }
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/142218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iabe9b5f10e41ed4425edcbc950c9c8d7e5796fdc
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits