jenkins-bot has submitted this change and it was merged.

Change subject: Show hide button on collection itself
......................................................................


Show hide button on collection itself

Additional changes:
* Make buttons horizontal as in mock
* Adjust padding

Bug: T94228
Change-Id: I99cbcb27f709c12009ae0edbbd59d00fe08a5311
---
M includes/specials/SpecialGatherLists.php
M includes/views/Collection.php
M resources/Resources.php
A resources/ext.gather.icons/suppress.svg
D resources/ext.gather.lists/init.js
A resources/ext.gather.moderation/init.js
M resources/ext.gather.special/init.js
M resources/ext.gather.styles/collections.less
8 files changed, 72 insertions(+), 45 deletions(-)

Approvals:
  Robmoen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialGatherLists.php 
b/includes/specials/SpecialGatherLists.php
index 54aad96..c74150c 100644
--- a/includes/specials/SpecialGatherLists.php
+++ b/includes/specials/SpecialGatherLists.php
@@ -29,7 +29,7 @@
                ) );
                $out->addModules(
                        array(
-                               'ext.gather.lists',
+                               'ext.gather.moderation',
                        )
                );
        }
diff --git a/includes/views/Collection.php b/includes/views/Collection.php
index 9b2e381..f7a97b9 100644
--- a/includes/views/Collection.php
+++ b/includes/views/Collection.php
@@ -175,6 +175,9 @@
                $html = Html::openElement( 'div', array(
                                'class' => 'collection content',
                                'data-id' => $collection->getId(),
+                               'data-label' => $collection->getTitle(),
+                               'data-owner' => 
$collection->getOwner()->getName(),
+                               'data-is-admin' => $this->user->isAllowed( 
'gather-hidelist' ),
                                'data-is-owner' => $collection->isOwner( 
$this->user ) ? true : false,
                        ) ) .
                        $this->getHeaderHtml( $collection );
diff --git a/resources/Resources.php b/resources/Resources.php
index 2c03aab..92dcb0a 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -64,6 +64,7 @@
                        'collections-read-more' => 'ext.gather.icons/next.svg',
                        'collection-owner' => 'ext.gather.icons/user.svg',
                        'collection-flag' => 'ext.gather.icons/flag.svg',
+                       'collection-hide' => 'ext.gather.icons/suppress.svg',
                ),
        ),
 
@@ -340,6 +341,7 @@
                        'ext.gather.collection.editor',
                        'ext.gather.routes',
                        'ext.gather.collection.flag',
+                       'ext.gather.moderation',
                ),
                'scripts' => array(
                        'ext.gather.special/init.js',
@@ -350,7 +352,7 @@
                ),
        ),
 
-       'ext.gather.lists' => $wgGatherMobileSpecialPageResourceBoilerplate + 
array(
+       'ext.gather.moderation' => 
$wgGatherMobileSpecialPageResourceBoilerplate + array(
                'dependencies' => array(
                        'mobile.toast',
                        'ext.gather.api',
@@ -364,7 +366,7 @@
                        'gather-lists-show-failure-toast',
                ),
                'scripts' => array(
-                       'ext.gather.lists/init.js',
+                       'ext.gather.moderation/init.js',
                ),
        ),
 );
diff --git a/resources/ext.gather.icons/suppress.svg 
b/resources/ext.gather.icons/suppress.svg
new file mode 100644
index 0000000..2b741f8
--- /dev/null
+++ b/resources/ext.gather.icons/suppress.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 
6.00 Build 0)  -->
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; x="0px" y="0px"
+        viewBox="0 0 24 24" enable-background="new 0 0 24 24" 
xml:space="preserve">
+<path d="M12,5c-4.4,0-8,3.6-8,8s3.6,8,8,8s8-3.6,8-8S16.4,5,12,5z 
M17,14H7v-2h10V14z"/>
+</svg>
diff --git a/resources/ext.gather.lists/init.js 
b/resources/ext.gather.lists/init.js
deleted file mode 100644
index 135f000..0000000
--- a/resources/ext.gather.lists/init.js
+++ /dev/null
@@ -1,36 +0,0 @@
-( function ( M, $ ) {
-       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
-               toast = M.require( 'toast' ),
-               api = new CollectionsApi();
-
-       /**
-        * Initialize the moderation buttons
-        */
-       function init() {
-               $( 'ul' ).on( 'click', '.moderate-collection', 
onModerateCollection );
-       }
-
-       /**
-        * Event handler for trying to hide a list
-        * @param {jQuery.Event} ev
-        */
-       function onModerateCollection( ev ) {
-               var $button = $( ev.currentTarget ),
-                       data = $button.data(),
-                       key = 'gather-lists-' + data.action + '-collection';
-
-               if ( window.confirm( mw.msg( key, data.label, data.owner ) ) ) {
-                       api.setVisible( data.id, data.action === 'show' ).done( 
function () {
-                               $button.closest( 'li' ).remove();
-                               key = 'gather-lists-' + data.action + 
'-success-toast';
-                               toast.show( mw.msg( key, data.label ), 'toast' 
);
-                       } ).fail( function () {
-                               key = 'gather-lists-' + data.action + 
'-failure-toast';
-                               toast.show( mw.msg( key, data.label ), 'toast 
fail' );
-                       } );
-               }
-       }
-
-       init();
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/resources/ext.gather.moderation/init.js 
b/resources/ext.gather.moderation/init.js
new file mode 100644
index 0000000..1744c05
--- /dev/null
+++ b/resources/ext.gather.moderation/init.js
@@ -0,0 +1,53 @@
+( function ( M, $ ) {
+       var CollectionsApi = M.require( 'ext.gather.watchstar/CollectionsApi' ),
+               toast = M.require( 'toast' ),
+               Icon = M.require( 'Icon' ),
+               api = new CollectionsApi();
+
+       /**
+        * Initialize the moderation buttons
+        */
+       function init() {
+               var $collection = $( '.collection' );
+               if ( $collection.length && $collection.data( 'is-admin' ) ) {
+                       new Icon( {
+                               name: 'collection-hide',
+                               title: mw.msg( 'gather-lists-hide-collection' ),
+                               additionalClassNames: 'moderate-collection'
+                       } )
+                       .appendTo( '.collection-moderation' );
+                       // FIXME: Should be possible to apply data directly
+                       $( '.moderate-collection' )
+                               .data( 'label', $collection.data( 'label' ) )
+                               .data( 'owner', $collection.data( 'owner' ) )
+                               .data( 'id', $collection.data( 'id' ) )
+                               .data( 'action', 'hide' );
+               }
+               // For Special:GatherEditFeed
+               $( '.moderate-collection' ).on( 'click', onModerateCollection );
+       }
+
+       /**
+        * Event handler for trying to hide a list
+        * @param {jQuery.Event} ev
+        */
+       function onModerateCollection( ev ) {
+               var $button = $( ev.currentTarget ),
+                       data = $button.data(),
+                       key = 'gather-lists-' + data.action + '-collection';
+
+               if ( window.confirm( mw.msg( key, data.label, data.owner ) ) ) {
+                       api.setVisible( data.id, data.action === 'show' ).done( 
function () {
+                               $button.closest( 'li' ).remove();
+                               key = 'gather-lists-' + data.action + 
'-success-toast';
+                               toast.show( mw.msg( key, data.label ), 'toast' 
);
+                       } ).fail( function () {
+                               key = 'gather-lists-' + data.action + 
'-failure-toast';
+                               toast.show( mw.msg( key, data.label ), 'toast 
fail' );
+                       } );
+               }
+       }
+
+       init();
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/resources/ext.gather.special/init.js 
b/resources/ext.gather.special/init.js
index 48c352b..aa4902d 100644
--- a/resources/ext.gather.special/init.js
+++ b/resources/ext.gather.special/init.js
@@ -9,13 +9,12 @@
                var flagIcon, $flag,
                        $collection = $( '.collection' );
 
-               // Only apply to mobile skin since EventLogging doesn't run 
there
                if ( !$collection.data( 'is-owner' ) && mw.config.get( 'skin' ) 
=== 'minerva' ) {
                        flagIcon = new Icon( {
                                name: 'collection-flag',
-                               tagName: 'a',
                                title: mw.msg( 
'gather-flag-collection-flag-label' )
                        } );
+                       // FIXME: See T97077
                        $flag = $( flagIcon.toHtmlString() );
                        $flag.on( 'click', function ( ev ) {
                                var flagOverlay;
@@ -34,7 +33,7 @@
                                        } );
                                }
                        } );
-                       $flag.appendTo( '.collection-moderation' );
+                       $flag.prependTo( '.collection-moderation' );
                }
 
                $( '.collection-actions' ).addClass( 'visible' );
diff --git a/resources/ext.gather.styles/collections.less 
b/resources/ext.gather.styles/collections.less
index c0305af..5af3653 100644
--- a/resources/ext.gather.styles/collections.less
+++ b/resources/ext.gather.styles/collections.less
@@ -44,11 +44,11 @@
        }
 
        .collection-moderation {
+               padding: 1em 0;
                position: absolute;
                right: 0;
-               a {
-                       // Needed so icons actually show up.  Not sure what's 
up with this
-                       display: inline-block;
+               div {
+                       float: left;
                }
        }
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I99cbcb27f709c12009ae0edbbd59d00fe08a5311
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Robmoen <rm...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to