jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Split out dialog from collection delete overlay
......................................................................
Hygiene: Split out dialog from collection delete overlay
Introduces new ConfirmationOverlay class
Change-Id: Iafc725abdac69597af55f25116e49160853554a5
---
M i18n/en.json
M i18n/qqq.json
M resources/Resources.php
A resources/ext.gather.collection.confirm/ConfirmationOverlay.js
A resources/ext.gather.collection.confirm/confirmationOverlay.hogan
R resources/ext.gather.collection.confirm/confirmationOverlay.less
M resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
D resources/ext.gather.collection.delete/content.hogan
8 files changed, 102 insertions(+), 62 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/en.json b/i18n/en.json
index 45158f0..0a61fca 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -44,9 +44,9 @@
"gather-delete-collection-confirm": "Are you sure you want to delete
this collection?",
"gather-delete-collection-heading": "Delete collection",
"gather-delete-collection-delete-label": "Delete",
- "gather-delete-collection-cancel-label": "Cancel",
"gather-delete-collection-success": "Collection was successfully
deleted.",
"gather-delete-collection-failed-error": "There was a problem deleting
this collection.",
+ "gather-confirmation-cancel-button-label": "Cancel",
"gather-error-unknown-collection": "Cannot find the requested
collection to edit.",
"gather-collection-member": "Is member of collection.",
"gather-collection-non-member": "Is not member of collection.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 050792b..2e56a26 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -49,9 +49,9 @@
"gather-delete-collection-confirm": "Text under the heading asking the
user if they would like to delete a collection.",
"gather-delete-collection-heading": "Heading for collection delete
overlay",
"gather-delete-collection-delete-label": "Label for delete button in
delete overlay.\n{{Identical|Delete}}",
- "gather-delete-collection-cancel-label": "Label for cancel button in
delete overlay.\n{{Identical|Cancel}}",
"gather-delete-collection-success": "Toast message indicating that
deletion was successful.",
"gather-delete-collection-failed-error": "Toast error indicating there
was a problem deleting the collection.",
+ "gather-confirmation-cancel-button-label": "Label for cancel button in
confirmation overlay.\n{{Identical|Cancel}}",
"gather-error-unknown-collection": "Error message test when you try to
edit a collection you do not own or that does not exist.",
"gather-collection-member": "Alternative text displayed next to
collection name when page is a member.",
"gather-collection-non-member": "Alternative text displayed next to
collection name when page is not a member.",
diff --git a/resources/Resources.php b/resources/Resources.php
index d6fd4c6..2437006 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -123,6 +123,25 @@
),
),
+ 'ext.gather.collection.confirm' =>
$wgGatherResourceFileModuleBoilerplate + array(
+ 'dependencies' => array(
+ 'ext.gather.collection.base',
+ ),
+ 'styles' => array(
+
'ext.gather.collection.confirm/confirmationOverlay.less',
+ ),
+ 'messages' => array(
+ 'gather-error-unknown-collection',
+ 'gather-confirmation-cancel-button-label',
+ ),
+ 'templates' => array(
+ 'confirmationOverlay.hogan' =>
'ext.gather.collection.confirm/confirmationOverlay.hogan',
+ ),
+ 'scripts' => array(
+ 'ext.gather.collection.confirm/ConfirmationOverlay.js',
+ ),
+ ),
+
'ext.gather.watchstar' => $wgGatherResourceFileModuleBoilerplate +
array(
'dependencies' => array(
'mediawiki.util',
@@ -243,7 +262,7 @@
'ext.gather.collection.delete' =>
$wgGatherResourceFileModuleBoilerplate + array(
'dependencies' => array(
- 'ext.gather.collection.base',
+ 'ext.gather.collection.confirm',
'mobile.toast',
'ext.gather.api',
'mediawiki.util'
@@ -252,19 +271,11 @@
'gather-delete-collection-confirm',
'gather-delete-collection-heading',
'gather-delete-collection-delete-label',
- 'gather-delete-collection-cancel-label',
'gather-delete-collection-success',
'gather-delete-collection-failed-error',
- 'gather-error-unknown-collection',
- ),
- 'templates' => array(
- 'content.hogan' =>
'ext.gather.collection.delete/content.hogan',
),
'scripts' => array(
'ext.gather.collection.delete/CollectionDeleteOverlay.js',
- ),
- 'styles' => array(
- 'ext.gather.collection.delete/deleteOverlay.less',
),
),
diff --git a/resources/ext.gather.collection.confirm/ConfirmationOverlay.js
b/resources/ext.gather.collection.confirm/ConfirmationOverlay.js
new file mode 100644
index 0000000..aa3ee26
--- /dev/null
+++ b/resources/ext.gather.collection.confirm/ConfirmationOverlay.js
@@ -0,0 +1,54 @@
+( function ( M, $ ) {
+
+ var ConfirmationOverlay,
+ toast = M.require( 'toast' ),
+ icons = M.require( 'icons' ),
+ CollectionsContentOverlayBase = M.require(
'ext.gather.collection.base/CollectionsContentOverlayBase' );
+
+ /**
+ * Action confirmation overlay base class
+ * @extends CollectionsContentOverlayBase
+ * @class ConfirmationOverlay
+ */
+ ConfirmationOverlay = CollectionsContentOverlayBase.extend( {
+ /** @inheritdoc */
+ className: 'collection-confirmation-overlay content-overlay
position-fixed',
+ /** @inheritdoc */
+ defaults: $.extend( {},
CollectionsContentOverlayBase.prototype.defaults, {
+ fixedHeader: false,
+ collection: null,
+ spinner: icons.spinner().toHtmlString(),
+ unknownCollectionError: mw.msg(
'gather-error-unknown-collection' ),
+ cancelButtonClass: 'mw-ui-progressive',
+ cancelButtonLabel: mw.msg(
'gather-confirmation-cancel-button-label' )
+ } ),
+ /** @inheritdoc */
+ events: $.extend( {},
CollectionsContentOverlayBase.prototype.events, {
+ 'click .cancel': 'onCancelClick'
+ } ),
+ /** @inheritdoc */
+ templatePartials: $.extend( {},
CollectionsContentOverlayBase.prototype.templatePartials, {
+ content: mw.template.get(
'ext.gather.collection.confirm', 'confirmationOverlay.hogan' )
+ } ),
+ /** @inheritdoc */
+ initialize: function ( options ) {
+ var collection = options.collection;
+ if ( !collection ) {
+ // use toast
+ toast.show( options.unknownCollectionError,
'toast error' );
+ } else {
+ this.id = collection.id;
+
CollectionsContentOverlayBase.prototype.initialize.apply( this, arguments );
+ }
+ },
+ /**
+ * Event handler when the cancel button is clicked.
+ */
+ onCancelClick: function () {
+ this.hide();
+ }
+ } );
+
+ M.define( 'ext.gather.confirm/ConfirmationOverlay', ConfirmationOverlay
);
+
+}( mw.mobileFrontend, jQuery ) );
diff --git a/resources/ext.gather.collection.confirm/confirmationOverlay.hogan
b/resources/ext.gather.collection.confirm/confirmationOverlay.hogan
new file mode 100644
index 0000000..a16bb72
--- /dev/null
+++ b/resources/ext.gather.collection.confirm/confirmationOverlay.hogan
@@ -0,0 +1,9 @@
+{{{spinner}}}
+<div class="confirm-collection-content">
+ <h3>{{subheading}}</h3>
+ <span>{{confirmMessage}}</span>
+ <div class="collection-confirm-actions">
+ <button class='mw-ui-button {{confirmButtonClass}}
confirm'>{{confirmButtonLabel}}</button>
+ <button class='mw-ui-button {{cancelButtonClass}}
cancel'>{{cancelButtonLabel}}</button>
+ </div>
+</div>
diff --git a/resources/ext.gather.collection.delete/deleteOverlay.less
b/resources/ext.gather.collection.confirm/confirmationOverlay.less
similarity index 78%
rename from resources/ext.gather.collection.delete/deleteOverlay.less
rename to resources/ext.gather.collection.confirm/confirmationOverlay.less
index b1912b8..00e7c5e 100644
--- a/resources/ext.gather.collection.delete/deleteOverlay.less
+++ b/resources/ext.gather.collection.confirm/confirmationOverlay.less
@@ -1,7 +1,7 @@
@import "minerva.variables";
@import "minerva.mixins";
-.content-overlay.collection-delete-overlay {
+.content-overlay.collection-confirmation-overlay {
font-size: .9em;
text-align: center;
@@ -14,7 +14,7 @@
padding: 0.5em;
}
- .collection-delete-actions {
+ .collection-confirm-actions {
padding: 0.5em;
}
diff --git a/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
b/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
index 1ce42d4..f54668a 100644
--- a/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
+++ b/resources/ext.gather.collection.delete/CollectionDeleteOverlay.js
@@ -4,60 +4,41 @@
SchemaGather = M.require( 'ext.gather.logging/SchemaGather' ),
schema = new SchemaGather(),
toast = M.require( 'toast' ),
- icons = M.require( 'icons' ),
CollectionsApi = M.require(
'ext.gather.watchstar/CollectionsApi' ),
- CollectionsContentOverlayBase = M.require(
'ext.gather.collection.base/CollectionsContentOverlayBase' );
+ ConfirmationOverlay = M.require(
'ext.gather.confirm/ConfirmationOverlay' );
/**
* Overlay for deleting a collection
- * @extends CollectionsContentOverlayBase
+ * @extends ConfirmationOverlay
* @class CollectionDeleteOverlay
*/
- CollectionDeleteOverlay = CollectionsContentOverlayBase.extend( {
+ CollectionDeleteOverlay = ConfirmationOverlay.extend( {
/** @inheritdoc */
- className: 'collection-delete-overlay content-overlay
position-fixed',
- /** @inheritdoc */
- defaults: $.extend( {},
CollectionsContentOverlayBase.prototype.defaults, {
- fixedHeader: false,
- collection: null,
- spinner: icons.spinner().toHtmlString(),
+ defaults: $.extend( {}, ConfirmationOverlay.prototype.defaults,
{
deleteSuccessMsg: mw.msg(
'gather-delete-collection-success' ),
deleteFailedError: mw.msg(
'gather-delete-collection-failed-error' ),
- unknownCollectionError: mw.msg(
'gather-error-unknown-collection' ),
- subheadingDeleteCollection: mw.msg(
'gather-delete-collection-heading' ),
+ subheading: mw.msg( 'gather-delete-collection-heading'
),
confirmMessage: mw.msg(
'gather-delete-collection-confirm' ),
- deleteButtonLabel: mw.msg(
'gather-delete-collection-delete-label' ),
- cancelButtonLabel: mw.msg(
'gather-delete-collection-cancel-label' )
+ confirmButtonClass: 'mw-ui-destructive',
+ confirmButtonLabel: mw.msg(
'gather-delete-collection-delete-label' )
} ),
/** @inheritdoc */
- events: $.extend( {},
CollectionsContentOverlayBase.prototype.events, {
- 'click .delete-collection': 'onDeleteClick',
- 'click .cancel-delete': 'onCancelClick'
+ events: $.extend( {}, ConfirmationOverlay.prototype.events, {
+ 'click .confirm': 'onDeleteClick'
} ),
/** @inheritdoc */
- templatePartials: $.extend( {},
CollectionsContentOverlayBase.prototype.templatePartials, {
- content: mw.template.get(
'ext.gather.collection.delete', 'content.hogan' )
- } ),
- /** @inheritdoc */
- initialize: function ( options ) {
- var collection = options.collection;
- if ( !collection ) {
- // use toast
- toast.show( options.unknownCollectionError,
'toast error' );
- } else {
- this.id = collection.id;
- this.api = new CollectionsApi();
-
CollectionsContentOverlayBase.prototype.initialize.apply( this, arguments );
- }
+ initialize: function () {
+ this.api = new CollectionsApi();
+ ConfirmationOverlay.prototype.initialize.apply( this,
arguments );
},
/**
- * Event handler when the save button is clicked.
+ * Event handler when the delete button is clicked.
*/
onDeleteClick: function () {
var self = this;
this.showSpinner();
// disable button and inputs
- this.$( '.delete-collection, .cancel-delete' ).prop(
'disabled', true );
+ this.$( '.confirm, .cancel' ).prop( 'disabled', true );
this.api.removeCollection( this.id ).done( function () {
// Show toast
self.$( '.spinner' ).hide();
@@ -74,18 +55,12 @@
toast.show( self.options.deleteFailedError,
'toast error' );
self.hide();
// Make it possible to try again.
- self.$( '.delete-collection, .cancel-delete'
).prop( 'disabled', false );
+ self.$( '.confirm, .cancel' ).prop( 'disabled',
false );
schema.log( {
eventName: 'delete-collection-error',
errorText: errMsg
} );
} );
- },
- /**
- * Event handler when the cancel button is clicked.
- */
- onCancelClick: function () {
- this.hide();
}
} );
diff --git a/resources/ext.gather.collection.delete/content.hogan
b/resources/ext.gather.collection.delete/content.hogan
deleted file mode 100644
index 2870119..0000000
--- a/resources/ext.gather.collection.delete/content.hogan
+++ /dev/null
@@ -1,9 +0,0 @@
-{{{spinner}}}
-<div class="delete-collection-content">
- <h3>{{subheadingDeleteCollection}}</h3>
- <span>{{confirmMessage}}</span>
- <div class="collection-delete-actions">
- <button class='mw-ui-button mw-ui-destructive
delete-collection'>{{deleteButtonLabel}}</button>
- <button class='mw-ui-button mw-ui-progressive
cancel-delete'>{{cancelButtonLabel}}</button>
- </div>
-</div>
--
To view, visit https://gerrit.wikimedia.org/r/204609
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iafc725abdac69597af55f25116e49160853554a5
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits