jenkins-bot has submitted this change and it was merged.
Change subject: Fully render collections list with templates
......................................................................
Fully render collections list with templates
And add a JS view to take care of that content. View is enhanced so no much
happening right now.
Future patch will take care of the loading button, and transform it into
infinite scrolling.
Bug: T97459
Change-Id: I9ecea478e553b3fbf1688bc780ea37b8fc945fac
---
M includes/views/CollectionsList.php
M resources/Resources.php
A resources/ext.gather.collections.list/CollectionsList.js
A resources/ext.gather.special.usercollections/init.js
A templates/CollectionsList.mustache
5 files changed, 69 insertions(+), 12 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/views/CollectionsList.php
b/includes/views/CollectionsList.php
index 12db333..931f032 100644
--- a/includes/views/CollectionsList.php
+++ b/includes/views/CollectionsList.php
@@ -6,7 +6,7 @@
namespace Gather\views;
use Gather\models;
-use Html;
+use Gather\views\helpers\Template;
/**
* Renders a mobile collection card list
@@ -25,16 +25,15 @@
* @return string Html
*/
public static function getListItemsHtml( $collectionsList ) {
- $html = Html::openElement( 'div', array( 'class' =>
'collection-cards' ) );
+ $html = '';
foreach ( $collectionsList as $item ) {
- $view = new CollectionsListItemCard( $item );
- $html .= $view->getHtml();
+ $collectionsListItemCard = new CollectionsListItemCard(
$item );
+ $html .= $collectionsListItemCard->getHtml();
}
$url = $collectionsList->getContinueUrl();
if ( $url ) {
$html .= Pagination::more( $url, wfMessage(
'gather-lists-more' )->text() );
}
- $html .= Html::closeElement( 'div' );
return $html;
}
@@ -54,13 +53,9 @@
* @inheritdoc
*/
public function getHtml( $data = array() ) {
- $html = Html::openElement(
- 'div',
- array( 'class' => 'collections-list content
view-border-box' )
+ $defaults = array(
+ 'items' => $this->getListItemsHtml(
$this->collectionsList )
);
- // Get items
- $html .= $this->getListItemsHtml( $this->collectionsList );
- $html .= Html::closeElement( 'div' );
- return $html;
+ return Template::render( 'CollectionsList', array_merge(
$defaults, $data ) );
}
}
diff --git a/resources/Resources.php b/resources/Resources.php
index b1e3e0f..07858d6 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -116,6 +116,22 @@
),
),
+ 'ext.gather.collections.list' => $wgGatherResourceFileModuleBoilerplate
+ array(
+ 'dependencies' => array(
+ ),
+ 'styles' => array(
+ ),
+ 'messages' => array(
+ ),
+ 'templates' => array(
+ 'CollectionsList.hogan' =>
'../templates/CollectionsList.mustache',
+ 'CollectionsListItemCard.hogan' =>
'../templates/CollectionsListItemCard.mustache',
+ ),
+ 'scripts' => array(
+ 'ext.gather.collections.list/CollectionsList.js',
+ ),
+ ),
+
'ext.gather.collection.base' => $wgGatherResourceFileModuleBoilerplate
+ array(
'dependencies' => array(
'ext.gather.logging',
@@ -377,6 +393,10 @@
'ext.gather.special.usercollections' =>
$wgGatherMobileSpecialPageResourceBoilerplate + array(
'dependencies' => array(
'ext.gather.special.base',
+ 'ext.gather.collections.list',
+ ),
+ 'scripts' => array(
+ 'ext.gather.special.usercollections/init.js',
),
),
diff --git a/resources/ext.gather.collections.list/CollectionsList.js
b/resources/ext.gather.collections.list/CollectionsList.js
new file mode 100644
index 0000000..5fe050e
--- /dev/null
+++ b/resources/ext.gather.collections.list/CollectionsList.js
@@ -0,0 +1,26 @@
+( function ( M ) {
+
+ var CollectionsList,
+ View = M.require( 'View' );
+
+ CollectionsList = View.extend( {
+ defaults: {
+ enhance: false,
+ collections: []
+ },
+ template: mw.template.get( 'ext.gather.collections.list',
'CollectionsList.hogan' ),
+ templatePartials: {
+ item: mw.template.get( 'ext.gather.collections.list',
'CollectionsListItemCard.hogan' )
+ },
+ /** @inheritdoc */
+ initialize: function ( options ) {
+ if ( options.enhance ) {
+ this.template = false;
+ }
+ View.prototype.initialize.apply( this, arguments );
+ }
+ } );
+
+ M.define( 'ext.gather.collections.list/CollectionsList',
CollectionsList );
+
+} )( mw.mobileFrontend, jQuery );
diff --git a/resources/ext.gather.special.usercollections/init.js
b/resources/ext.gather.special.usercollections/init.js
new file mode 100644
index 0000000..a658633
--- /dev/null
+++ b/resources/ext.gather.special.usercollections/init.js
@@ -0,0 +1,11 @@
+( function ( M, $ ) {
+ var CollectionsList = M.require(
'ext.gather.collections.list/CollectionsList' );
+
+ $( function () {
+ new CollectionsList( {
+ el: $( '.collections-list' ),
+ enhance: true
+ } );
+ } );
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/templates/CollectionsList.mustache
b/templates/CollectionsList.mustache
new file mode 100644
index 0000000..fa7b2b8
--- /dev/null
+++ b/templates/CollectionsList.mustache
@@ -0,0 +1,5 @@
+<div class='collections-list content view-border-box'>
+ <div class='collection-cards'>
+ {{{items}}}
+ </div>
+</div>
--
To view, visit https://gerrit.wikimedia.org/r/207177
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ecea478e553b3fbf1688bc780ea37b8fc945fac
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits