Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/240068
Change subject: Dashboard: Show empty list information when suggestions or
translations are empty
......................................................................
Dashboard: Show empty list information when suggestions or translations are
empty
Change-Id: Ia9e730df296ae2d6857fe4953943ae8037bc8c3e
---
M modules/dashboard/ext.cx.suggestionlist.js
M modules/dashboard/ext.cx.translationlist.js
M modules/dashboard/styles/ext.cx.dashboard.less
3 files changed, 46 insertions(+), 24 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/68/240068/1
diff --git a/modules/dashboard/ext.cx.suggestionlist.js
b/modules/dashboard/ext.cx.suggestionlist.js
index 03d0ae0..23845d9 100644
--- a/modules/dashboard/ext.cx.suggestionlist.js
+++ b/modules/dashboard/ext.cx.suggestionlist.js
@@ -94,6 +94,11 @@
return;
}
lists = suggestions.lists;
+ if ( !lists || !lists.length ) {
+ self.$emptySuggestionList.show();
+ } else {
+ self.$emptySuggestionList.hide();
+ }
self.lists = $.extend( self.lists, lists );
for ( listId in lists ) {
if ( lists.hasOwnProperty( listId ) ) {
@@ -160,27 +165,39 @@
CXSuggestionList.prototype.hide = function () {
this.active = false;
this.$suggestionList.hide();
+ this.$emptySuggestionList.hide();
};
- CXSuggestionList.prototype.applyFilters = function ( filters ) {
- var i, suggestion, visible, j, filterProp, filterValue,
emptyList = true,
- keys = Object.keys( filters );
+ /**
+ * Match the suggestion with the current filter.
+ * @param {Object} suggestion
+ * @return {Boolean}
+ */
+ CXSuggestionList.prototype.matchFilter = function ( suggestion ) {
+ var j, visible = true,
+ filterProp, filterValue,
+ keys = Object.keys( this.filters );
+
+ for ( j = 0; j < keys.length; j++ ) {
+ filterProp = keys[ j ];
+ filterValue = this.filters[ filterProp ];
+
+ if ( filterValue === null || filterValue === '' ) {
+ continue;
+ }
+ visible = visible && suggestion[ filterProp ] ===
filterValue;
+ }
+
+ return visible;
+ };
+
+ CXSuggestionList.prototype.applyFilters = function () {
+ var i, suggestion, visible, emptyList = true;
for ( i = 0; i < this.suggestions.length; i++ ) {
suggestion = this.suggestions[ i ];
- visible = true;
- for ( j = 0; j < keys.length; j++ ) {
- filterProp = keys[ j ];
- filterValue = filters[ filterProp ];
-
- if ( filterValue === null || filterValue === ''
) {
- continue;
- }
-
- visible = visible && suggestion[ filterProp ]
=== filterValue;
- }
-
+ visible = this.matchFilter( suggestion );
if ( visible ) {
emptyList = false;
suggestion.$element.show();
@@ -188,10 +205,8 @@
suggestion.$element.hide();
}
}
- if ( emptyList ) {
- this.hasMore = true;
- this.loadItems();
- }
+ this.hasMore = true;
+ this.loadItems();
};
/**
@@ -274,7 +289,6 @@
for ( i = 0; i < suggestions.length; i++ ) {
suggestion = suggestions[ i ];
- suggestion.id = 'suggestion' + i;
$suggestion = this.buildSuggestionItem( suggestion );
$suggestions.push( $suggestion );
}
@@ -367,7 +381,9 @@
suggestion.$element = $suggestion;
suggestion.$desc = $desc;
suggestion.$image = $image;
-
+ if ( !this.matchFilter( suggestion ) ) {
+ suggestion.$element.hide();
+ }
return $suggestion;
};
diff --git a/modules/dashboard/ext.cx.translationlist.js
b/modules/dashboard/ext.cx.translationlist.js
index cbe4d02..3764974 100644
--- a/modules/dashboard/ext.cx.translationlist.js
+++ b/modules/dashboard/ext.cx.translationlist.js
@@ -83,7 +83,8 @@
this.seed = parseInt( Math.random() * 10000, 10 );
this.$translationsList = $( '<div>' )
.addClass( 'cx-translationlist' );
- this.$container.append( this.$translationsList );
+ this.$emptyTranslationsList = this.buildEmptyTranslationList();
+ this.$container.append( this.$translationsList,
this.$emptyTranslationsList );
};
CXTranslationList.prototype.getLanguages = function () {
@@ -102,7 +103,10 @@
promise = this.getTranslations();
promise.done( function ( translations ) {
if ( !translations.length ) {
+ self.$emptyTranslationsList.show();
return;
+ } else {
+ self.$emptyTranslationsList.hide();
}
self.translations = self.translations.concat(
translations );
self.renderTranslations( translations );
@@ -187,6 +191,7 @@
CXTranslationList.prototype.hide = function () {
this.active = false;
this.$translationsList.hide();
+ this.$emptyTranslationsList.hide();
};
/**
@@ -350,7 +355,8 @@
.addClass( 'cx-translationlist
cx-translationlist-empty' )
.append(
$img, $title, $desc
- );
+ )
+ .hide();
};
CXTranslationList.prototype.listen = function () {
diff --git a/modules/dashboard/styles/ext.cx.dashboard.less
b/modules/dashboard/styles/ext.cx.dashboard.less
index 102c163..1a2377d 100644
--- a/modules/dashboard/styles/ext.cx.dashboard.less
+++ b/modules/dashboard/styles/ext.cx.dashboard.less
@@ -126,7 +126,7 @@
position: fixed;
top: 0;
left: 0;
- z-index: 100;
+ z-index: 101;
width: 66%;
padding-left: 50px;
}
--
To view, visit https://gerrit.wikimedia.org/r/240068
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9e730df296ae2d6857fe4953943ae8037bc8c3e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits