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

Change subject: Use button with spinner for create collection button
......................................................................


Use button with spinner for create collection button

* Use oo-ui class ButtonWithSpinner for create button
* Removes duplicate call to addCollection
* Still uses loading spinner for loading and toggling
** collections

NOTE:
Cannot be pushed to stable until T95490 is complete

bug: T93424
Change-Id: I308fea0abbff555fe3f5cebc78c72543de784500
---
M resources/Resources.php
M resources/ext.gather.watchstar/CollectionsContentOverlay.js
M resources/ext.gather.watchstar/content.hogan
3 files changed, 23 insertions(+), 12 deletions(-)

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



diff --git a/resources/Resources.php b/resources/Resources.php
index 407b006..b103deb 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -130,6 +130,8 @@
                        'ext.gather.collection.base',
                        'mobile.settings',
                        'ext.gather.watchstar.icons',
+                       // FIXME: Cannot push to stable until buttonWithSpinner 
is a view (T95490)
+                       'mobile.buttonWithSpinner',
                ),
                'styles' => array(
                        'ext.gather.watchstar/contentOverlay.less',
diff --git a/resources/ext.gather.watchstar/CollectionsContentOverlay.js 
b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
index 44e719e..b7c22fd 100644
--- a/resources/ext.gather.watchstar/CollectionsContentOverlay.js
+++ b/resources/ext.gather.watchstar/CollectionsContentOverlay.js
@@ -7,7 +7,8 @@
                user = M.require( 'user' ),
                Icon = M.require( 'Icon' ),
                CollectionsApi = M.require( 
'ext.gather.watchstar/CollectionsApi' ),
-               CollectionsContentOverlayBase = M.require( 
'ext.gather.collection.base/CollectionsContentOverlayBase' );
+               CollectionsContentOverlayBase = M.require( 
'ext.gather.collection.base/CollectionsContentOverlayBase' ),
+               ButtonWithSpinner = M.require( 'ButtonWithSpinner' );
 
        /**
         * A clickable watchstar for managing collections
@@ -52,7 +53,6 @@
                        } ).toHtmlString(),
                        title: mw.config.get( 'wgTitle' ),
                        spinner: icons.spinner().toHtmlString(),
-                       createButtonLabel: mw.msg( 
'gather-create-new-button-label' ),
                        placeholder: mw.msg( 'gather-add-new-placeholder' ),
                        subheadingNewCollection: mw.msg( 'gather-add-to-new' ),
                        subheading: mw.msg( 'gather-add-to-existing' ),
@@ -87,6 +87,20 @@
                },
                /** @inheritdoc */
                postRender: function () {
+                       var $form = this.$( 'form' );
+
+                       this.createButton  = new ButtonWithSpinner( {
+                               label: mw.msg( 'gather-create-new-button-label' 
),
+                               flags: ['primary', 'constructive']
+                       } );
+                       this.createButton.setDisabled( true );
+                       // Binding here as widgets are not views and are 
created after events map runs
+                       this.createButton.on( 'click', function () {
+                               $form.submit();
+                       } );
+
+                       $form.append( this.createButton.$element );
+                       // Hide base overlay's spinner
                        this.hideSpinner();
                },
                /**
@@ -168,9 +182,8 @@
                 */
                onInput: function ( ev ) {
                        var $input = $( ev.target ),
-                               val = $input.val(),
-                               $button = $input.next( 'button' );
-                       $button.prop( 'disabled', val === '' );
+                               val = $input.val();
+                       this.createButton.setDisabled( val === '' );
                },
                /**
                 * Event handler for setting up a new collection
@@ -182,13 +195,10 @@
 
                        ev.preventDefault();
                        if ( this.isTitleValid( title ) ) {
-                               this.showSpinner();
                                this.addCollection( title, page );
                                schema.log( {
                                        eventName: 'new-collection'
                                } );
-
-                               this.addCollection( title, page );
                        } else {
                                toast.show( mw.msg( 
'gather-add-title-invalid-toast' ), 'toast error' );
                        }
@@ -305,7 +315,7 @@
                        var self = this,
                                api = this.api;
 
-                       this.showSpinner();
+                       this.createButton.showSpinner();
                        return api.addCollection( title ).done( function ( 
collection ) {
                                api.addPageToCollection( collection.id, page 
).done(
                                        $.proxy( self, 
'_collectionStateChange', collection, true )
@@ -320,7 +330,7 @@
                                        errorText: errMsg
                                } );
                                toast.show( mw.msg( 
'gather-new-collection-failed-toast', title ), 'toast error' );
-                               self.hideSpinner();
+                               self.createButton.hideSpinner();
                        } );
                }
        } );
diff --git a/resources/ext.gather.watchstar/content.hogan 
b/resources/ext.gather.watchstar/content.hogan
index 94b1163..ae3c7f6 100644
--- a/resources/ext.gather.watchstar/content.hogan
+++ b/resources/ext.gather.watchstar/content.hogan
@@ -13,8 +13,7 @@
 </div>
 <h3>{{subheadingNewCollection}}</h3>
 <form>
-       <input class="mw-ui-input mw-ui-input-inline"
-               placeholder="{{placeholder}}"><button class='mw-ui-button 
mw-ui-constructive' disabled>{{createButtonLabel}}</button>
+       <input class="mw-ui-input mw-ui-input-inline" 
placeholder="{{placeholder}}">
 </form>
 <hr/>
 <h3>{{subheading}}</h3>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I308fea0abbff555fe3f5cebc78c72543de784500
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Robmoen <rm...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@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