Santhosh has uploaded a new change for review.

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

Change subject: Suggestions: When suggestions are empty from all sources, show 
empty info
......................................................................

Suggestions: When suggestions are empty from all sources, show empty info

Change-Id: I278a0506e11e507c1f502f1ceed3286e1fb79571
---
M modules/dashboard/ext.cx.suggestionlist.js
1 file changed, 27 insertions(+), 16 deletions(-)


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

diff --git a/modules/dashboard/ext.cx.suggestionlist.js 
b/modules/dashboard/ext.cx.suggestionlist.js
index 6d77304..6723a3a 100644
--- a/modules/dashboard/ext.cx.suggestionlist.js
+++ b/modules/dashboard/ext.cx.suggestionlist.js
@@ -94,6 +94,7 @@
 
        /**
         * @param {Object} [list]
+        * @return {jQuery.Promise}
         */
        CXSuggestionList.prototype.loadItems = function ( list ) {
                var lists, promise,
@@ -112,7 +113,7 @@
                        promise = this.loadSuggestionsForList( list );
                }
 
-               promise.done( function ( suggestions ) {
+               return promise.then( function ( suggestions ) {
                        var i, list, listId, listIds;
 
                        lists = suggestions.lists;
@@ -142,15 +143,31 @@
                                self.insertSuggestionList( listId, 
list.suggestions );
                        }
 
-                       if ( isEmpty ) {
-                               self.showEmptySuggestionList();
-                       }
-               } ).fail( function () {
-                       // Show empty list
-                       self.showEmptySuggestionList();
+                       return isEmpty;
                } );
 
-               return promise;
+       };
+
+       /**
+        * @return {jQuery.Promise}
+        */
+       CXSuggestionList.prototype.loadAllSuggestions = function () {
+               var self = this;
+
+               return $.when(
+                       this.loadItems(),
+                       this.loadItems( {
+                               id: 'trex'
+                       } )
+               ).then( function ( empty1, empty2 ) {
+                       if ( empty1 && empty2 ) {
+                               // If both are empty Show empty list 
information.
+                               self.showEmptySuggestionList();
+                       }
+               }, function () {
+                       // On Fail, show empty list
+                       self.showEmptySuggestionList();
+               } );
        };
 
        /**
@@ -222,10 +239,7 @@
                this.active = true;
                this.$suggestionsContainer.show();
                if ( !Object.keys( this.lists ).length ) {
-                       this.loadItems();
-                       this.loadItems( {
-                               id: 'trex'
-                       } );
+                       this.loadAllSuggestions();
                }
        };
 
@@ -254,10 +268,7 @@
                this.$personalCollection.empty().show();
                this.$publicCollection.empty().show();
 
-               this.loadItems();
-               this.loadItems( {
-                       id: 'trex'
-               } );
+               this.loadAllSuggestions();
        };
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/254830
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I278a0506e11e507c1f502f1ceed3286e1fb79571
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