Jsahleen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183892
Change subject: Source Selector: Allow unsupported languages from url for
testing
......................................................................
Source Selector: Allow unsupported languages from url for testing
* Removes validations that were excluding unsupported languages from url
* Adds check to make sure source and target languages are not the same.
Bug: T85333
Change-Id: I3423b2c5c654c079c2f3aa55814a60ce78c3387c
---
M modules/source/ext.cx.source.selector.js
1 file changed, 13 insertions(+), 19 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/92/183892/1
diff --git a/modules/source/ext.cx.source.selector.js
b/modules/source/ext.cx.source.selector.js
index 7ef184f..e7d3b44 100644
--- a/modules/source/ext.cx.source.selector.js
+++ b/modules/source/ext.cx.source.selector.js
@@ -176,7 +176,7 @@
* @return {array} An array of valid target languages
*/
CXSourceSelector.prototype.getValidTargetLanguages = function (
sourceLanguage ) {
- return this.languagePairs[ sourceLanguage ];
+ return this.languagePairs[ sourceLanguage ] || [];
};
/**
@@ -344,7 +344,9 @@
CXSourceSelector.prototype.sourceLanguageChangeHandler = function (
language ) {
this.setSourceLanguage( language );
this.fillTargetLanguages();
- this.setTargetLanguage( this.getValidTargetLanguages( language
)[ 0 ] );
+ if ( this.getValidTargetLanguages( language ).length > 0 ) {
+ this.setTargetLanguage( this.getValidTargetLanguages(
language )[ 0 ] );
+ }
this.check();
};
@@ -353,18 +355,11 @@
* @param {string} language Language code.
*/
CXSourceSelector.prototype.targetLanguageChangeHandler = function (
language ) {
- // Only allow valid target languages to be selected
- if ( !this.isValidTarget( language, this.getSourceLanguage() )
) {
+ // Don't allow setting the target language to the source
language.
+ if ( language === this.getSourceLanguage() ) {
return;
}
-
this.setTargetLanguage( language );
-
- // Disable the target input if the target language is not valid
- // for the current source language
- this.$targetTitleInput
- .prop( 'disabled', !this.isValidTarget( language,
this.getSourceLanguage() ) );
-
this.check();
};
@@ -440,11 +435,11 @@
existingTargetTitle
);
- // If there is just a matching target
page
+ // If there is just a matching
target page
} else if ( equivalentTargetPage ) {
selector.showPageExistsError(
equivalentTargetPage );
- // If the specified target title is in
use
+ // If the specified target
title is in use
} else if ( existingTargetTitle ) {
selector.showTitleInUseError(
existingTargetTitle );
}
@@ -843,12 +838,12 @@
sourceLanguage = contentLanguage;
} else {
// Give up: just set the first available source
language
- sourceLanguage = this.sourceLanguages[0];
+ sourceLanguage = this.sourceLanguages[ 0 ];
}
}
if ( sourceLanguage === targetLanguage ) {
- targetLanguage = this.getValidTargetLanguages(
sourceLanguage )[0];
+ targetLanguage = this.getValidTargetLanguages(
sourceLanguage )[ 0 ];
}
// Set the source language
@@ -952,7 +947,7 @@
$sourceLanguageLabelContainer,
$sourceLanguageContainer,
$sourceTitleInputContainer
- );
+ );
$targetInputs = $( '<div>' )
.addClass( 'cx-sourceselector-dialog__target-inputs' )
@@ -960,7 +955,7 @@
$targetLanguageLabelContainer,
$targetLanguageContainer,
$targetTitleInputContainer
- );
+ );
this.$messageBar = $( '<div>' )
.addClass( 'cx-sourceselector-dialog__messagebar' );
@@ -1014,8 +1009,7 @@
if ( !data ) {
$this.data(
- 'cxsourceselector',
- ( data = new CXSourceSelector( this,
mw.cx.siteMapper, options ) )
+ 'cxsourceselector', ( data = new
CXSourceSelector( this, mw.cx.siteMapper, options ) )
);
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/183892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3423b2c5c654c079c2f3aa55814a60ce78c3387c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Jsahleen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits