Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/239102
Change subject: Prevent creation of unadapted link in target
......................................................................
Prevent creation of unadapted link in target
Commented some member variables and removed this.options as
it is currently unused.
We could possible inform the user why we did not create the link, but
the link card which says the page is missing in target is quite visible
already.
Bug: T85932
Change-Id: I6bd1a4f61a56895e6976daea795b183d9938632a
---
M modules/tools/ext.cx.tools.link.js
1 file changed, 16 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/02/239102/1
diff --git a/modules/tools/ext.cx.tools.link.js
b/modules/tools/ext.cx.tools.link.js
index adcd3f6..fe2c98b 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -212,11 +212,17 @@
* @param {Object} [options] Optional options object
*/
function CXLink( link, options ) {
+ options = $.extend( true, {}, CXLink.defaults, options );
+
this.$link = $( link );
- this.options = $.extend( true, {}, CXLink.defaults, options );
- this.siteMapper = this.options.siteMapper;
+ this.siteMapper = options.siteMapper;
+ // The link text and title attribute (they are the same)
this.title = null;
+ // Details about the actual target page.
+ // page.title is title of the actual page.
this.page = null;
+ // Unique id which connects source and target titles together.
+ // There might be multiple target links corresponding to the
same source link.
this.id = null;
}
@@ -290,6 +296,7 @@
// Restore the selection
mw.cx.selection.restore( 'translation' );
selection = mw.cx.selection.get();
+
$link = $( '<a>' )
.addClass( 'cx-target-link' )
.text( selection.toString() || this.getTargetTitle() )
@@ -573,6 +580,13 @@
return false;
}
+ // User click a blue link in source, which has no
equivalent in target
+ // language. Prevent creation of a such link.
+ if ( !self.getTargetLink().page ) {
+ mw.log( '[CX] link does not exist in target' );
+ return false;
+ }
+
selection = mw.cx.selection.get();
// Is this selection valid and editable?
if ( isValidSelection( selection ) ) {
--
To view, visit https://gerrit.wikimedia.org/r/239102
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bd1a4f61a56895e6976daea795b183d9938632a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits