jenkins-bot has submitted this change and it was merged.
Change subject: paginate the content overlay list of collections
......................................................................
paginate the content overlay list of collections
Bug: T94523
Change-Id: I036ea2bbf1f11e8c5bfc850b55d0458e6561d0ee
---
M i18n/en.json
M i18n/qqq.json
M resources/Resources.php
M resources/ext.gather.watchstar/CollectionsApi.js
M resources/ext.gather.watchstar/CollectionsContentOverlay.js
M resources/ext.gather.watchstar/content.hogan
M resources/ext.gather.watchstar/contentOverlay.less
7 files changed, 75 insertions(+), 12 deletions(-)
Approvals:
Jhernandez: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/en.json b/i18n/en.json
index 2784fae..0c82caf 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -79,5 +79,6 @@
"apihelp-gather-example-1": "List the collections for user
<kbd>john</kbd>.",
"gather-lists-collection-more-link-label": "View more public
collections.",
"gather-lists-more": "View more collections from this user.",
- "gather-collection-more": "View more pages in this collection"
+ "gather-collection-more": "View more pages in this collection",
+ "gather-add-to-another": "Show my other collections"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 9ad9b7a..c700eb4 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -82,5 +82,6 @@
"apihelp-gather-example-1": "{{doc-apihelp-example|gather}}",
"gather-lists-collection-more-link-label": "Link label for a more type
link on the Special:GatherLists page.",
"gather-lists-more": "Link label for more link at the bottom of a list
of users existing collections.",
- "gather-collection-more": "Label for link at bottom of Gather
collection when there are more than 50 items."
+ "gather-collection-more": "Label for link at bottom of Gather
collection when there are more than 50 items.",
+ "gather-add-to-another": "Label for button at bottom of collection
overlay for when you have more collections that you could potentially add to."
}
diff --git a/resources/Resources.php b/resources/Resources.php
index bd74619..8d268bd 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -140,6 +140,7 @@
'gather-add-to-collection-summary',
'gather-add-to-collection-confirm',
'gather-add-to-collection-cancel',
+ 'gather-add-to-another',
),
'templates' => array(
'content.hogan' => 'ext.gather.watchstar/content.hogan',
diff --git a/resources/ext.gather.watchstar/CollectionsApi.js
b/resources/ext.gather.watchstar/CollectionsApi.js
index 41461d2..f9c2f31 100644
--- a/resources/ext.gather.watchstar/CollectionsApi.js
+++ b/resources/ext.gather.watchstar/CollectionsApi.js
@@ -92,17 +92,23 @@
* @method
* @param {String} owner of the collections
* @param {Page} page the current page.
+ * @param {Object} [queryArgs] parameters to send to api
*/
- getCurrentUsersCollections: function ( owner, page ) {
- return this.get( {
+ getCurrentUsersCollections: function ( owner, page, queryArgs )
{
+ var args = $.extend( {}, queryArgs || {}, {
action: 'query',
list: 'lists',
lsttitle: page.getTitle(),
lstprop: 'label|description|public|image|count',
lstowner: owner
- } ).then( function ( resp ) {
+ } );
+ return this.get( args ).then( function ( resp ) {
+ var result = {};
+ if ( resp['query-continue'] ) {
+ result.continueArgs =
resp['query-continue'].lists;
+ }
if ( resp.query && resp.query.lists ) {
- return $.map( resp.query.lists,
function ( list ) {
+ result.collections = $.map(
resp.query.lists, function ( list ) {
// FIXME: API should handle all
these inconsistencies.
list.isWatchlist = list.id ===
0;
list.titleInCollection =
list.title;
@@ -112,8 +118,9 @@
return list;
} );
} else {
- return [];
+ result.collections = [];
}
+ return result;
} );
},
/**
diff --git a/resources/ext.gather.watchstar/CollectionsContentOverlay.js
b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
index f4a0c09..71d55be 100644
--- a/resources/ext.gather.watchstar/CollectionsContentOverlay.js
+++ b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
@@ -27,6 +27,7 @@
appendTo: 'body',
/** @inheritdoc */
events: {
+ 'click .more-collections': 'onClickLoadMoreCollections',
click: 'onClickInsideOverlay',
'focus input': 'onFocusInput',
'blur input': 'onBlurInput',
@@ -55,21 +56,18 @@
placeholder: mw.msg( 'gather-add-new-placeholder' ),
subheadingNewCollection: mw.msg( 'gather-add-to-new' ),
subheading: mw.msg( 'gather-add-to-existing' ),
+ moreLinkLabel: mw.msg( 'gather-add-to-another' ),
collections: undefined
},
/** @inheritdoc */
initialize: function ( options ) {
- var self = this;
this.api = new CollectionsApi();
if ( options.collections === undefined ) {
options.collections = [];
CollectionsContentOverlayBase.prototype.initialize.call( this, options );
// load the collections.
this.showSpinner();
- this.api.getCurrentUsersCollections(
user.getName(), options.page ).done( function ( collections ) {
- self.options.collections = collections;
- self.render.call( self );
- } );
+ this._loadCollections( user.getName(),
options.page );
} else {
CollectionsContentOverlayBase.prototype.initialize.call( this, options );
}
@@ -101,6 +99,53 @@
return title.length <= 90;
},
/**
+ * Loads collections from the api and renders them in the view.
+ * @param {String} username
+ * @param {Page} page
+ * @param {Object} qs query string parameters to query the api
with
+ * @private
+ * @returns {jQuery.promise}
+ */
+ _loadCollections: function ( username, page, qs ) {
+ var self = this;
+
+ return this.api.getCurrentUsersCollections( username,
page, qs ).done(
+ function ( resp ) {
+ var reset,
+ s = self._scrollTop || 0,
+ threshold = 100,
+ curScrollTop = self.$(
'.overlay-content' ).scrollTop();
+
+ self.options.collections =
self.options.collections.concat( resp.collections );
+ if ( resp.continueArgs ) {
+ self.options.moreLink = true;
+ self._continue =
resp.continueArgs;
+ } else {
+ self.options.moreLink = false;
+ self._continue = false;
+ }
+ if ( s > curScrollTop - threshold && s
< curScrollTop + threshold ) {
+ reset = true;
+ }
+ self.render.call( self );
+ if ( reset ) {
+ // reset the scroll top to
avoid losing the current place of the user.
+ self.$( '.overlay-content'
).scrollTop( s );
+ self._scrollTop = 0;
+ }
+ } );
+ },
+ /**
+ * Event handler for clicking on the load more collections link
+ * @param {jQuery.Event} ev
+ */
+ onClickLoadMoreCollections: function ( ev ) {
+ this._scrollTop = this.$( '.overlay-content'
).scrollTop();
+
+ $( ev.currentTarget ).remove();
+ this._loadCollections( user.getName(),
this.options.page, this._continue );
+ },
+ /**
* Event handler for focusing input
* @param {jQuery.Event} ev
*/
diff --git a/resources/ext.gather.watchstar/content.hogan
b/resources/ext.gather.watchstar/content.hogan
index 6b3b5f9..94b1163 100644
--- a/resources/ext.gather.watchstar/content.hogan
+++ b/resources/ext.gather.watchstar/content.hogan
@@ -28,3 +28,6 @@
</li>
{{/collections}}
</ul>
+{{#moreLink}}
+<button class="mw-ui-quiet mw-ui-anchor mw-ui-progressive
more-collections">{{moreLinkLabel}}</button>
+{{/moreLink}}
diff --git a/resources/ext.gather.watchstar/contentOverlay.less
b/resources/ext.gather.watchstar/contentOverlay.less
index d766605..f626979 100644
--- a/resources/ext.gather.watchstar/contentOverlay.less
+++ b/resources/ext.gather.watchstar/contentOverlay.less
@@ -143,4 +143,9 @@
bottom: 1px;
}
}
+
+ .more-collections {
+ margin: auto;
+ display: block;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/201354
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I036ea2bbf1f11e8c5bfc850b55d0458e6561d0ee
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits