Robmoen has uploaded a new change for review. https://gerrit.wikimedia.org/r/204611
Change subject: Add flag collection button and confirm overlay ...................................................................... Add flag collection button and confirm overlay Added flag icon to collection when not watchlist or ** collection owner Added CollectionFlagOverlay for flag confirmation Added SchemaGatherFlags NEEDS: * Review * Schema logging tested * userGroups is currently an empty string bug: T94871 Change-Id: I2b373e5415f76f85dba78d246b3c22af2284c261 --- M i18n/en.json M i18n/qqq.json M includes/Gather.hooks.php M includes/views/Collection.php A resources/ext.gather.collection.flag/CollectionFlagOverlay.js A resources/ext.gather.collection.flag/content.hogan A resources/ext.gather.collection.flag/flagOverlay.less A resources/ext.gather.icons/flag.svg A resources/ext.gather.logging/SchemaGatherFlags.js M resources/ext.gather.special/init.js M resources/ext.gather.styles/collections.less 11 files changed, 179 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather refs/changes/11/204611/1 diff --git a/i18n/en.json b/i18n/en.json index 567ead9..b974dce 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -40,9 +40,13 @@ "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-flag-collection-heading": "Flag collection", + "gather-flag-collection-confirm": "Are you sure you want to flag this collection for review?", + "gather-flag-collection-flag-label": "Flag", + "gather-flag-collection-success": "Collection was successfully flagged.", + "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 d7a66ff..1d1c9b4 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -43,11 +43,15 @@ "gather-edit-collection-save-label": "Label for save button in collection editor.\n{{Identical|Done}}", "gather-edit-collection-failed-error": "There was a problem saving the changes.", "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-heading": "Heading for collection delete confirmation overlay", + "gather-delete-collection-delete-label": "Label for delete button in delete confirmation overlay.\n{{Identical|Delete}}", "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-flag-collection-heading": "Heading text for collection flag conirmation overlay", + "gather-flag-collection-confirm": "Text under the heading asking the user if they would like to flag a collection for review.", + "gather-flag-collection-flag-label": "Label for flag button in flag collection confirmation overlay.", + "gather-flag-collection-success": "Toast message indicating that flagging the collection was successful.", + "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/includes/Gather.hooks.php b/includes/Gather.hooks.php index 119e5cb..5351ff1 100644 --- a/includes/Gather.hooks.php +++ b/includes/Gather.hooks.php @@ -62,8 +62,9 @@ public static function onEventLoggingRegisterSchemas( &$schemas ) { $schemas += array( 'GatherClicks' => 11770314, + 'GatherFlags' => 11793295, ); - self::registerSchemas( array( 'schema.GatherClicks' ) ); + self::registerSchemas( array( 'schema.GatherClicks', 'schema.GatherFlags' ) ); return true; } diff --git a/includes/views/Collection.php b/includes/views/Collection.php index 3abde95..4492740 100644 --- a/includes/views/Collection.php +++ b/includes/views/Collection.php @@ -50,7 +50,10 @@ $privacy = $collection->isPublic() ? 'Public' : 'Private'; } - $html = Html::openElement( 'div', array( 'class' => 'collection-header' ) ) . + $html = Html::openElement( 'div', array( 'class' => 'collection-moderation' ) ) . + $this->getModerationButtons() . + Html::closeElement( 'div' ) . + Html::openElement( 'div', array( 'class' => 'collection-header' ) ) . Html::openElement( 'div', array( 'class' => 'collection-meta' ) ) . Html::element( 'div', array( 'class' => 'collection-privacy' ), $privacy ) . Html::closeElement( 'div' ) . @@ -80,6 +83,26 @@ $owner->getName() . Html::closeElement( 'a' ); } + /** + * Returns the html for moderation buttons + * + * @return string Html + */ + private function getModerationButtons() { + $id = $this->collection->getId(); + // Don't show for watchlist as its private, don't show for owner + if ( $id !== 0 && !$this->collection->isOwner( $this->user ) ) { + return Html::openElement( 'a', array( + 'href' => '#/collection/flag/' . $id, + 'class' => 'collection-flag', + ) ) . + Html::element( 'span', array( + 'class' => CSS::iconClass( 'collection-flag', 'before', 'collection-flag-icon' ) ) ) . + Html::closeElement( 'a' ); + } else { + return ''; + } + } /** * Get action buttons of the header diff --git a/resources/ext.gather.collection.flag/CollectionFlagOverlay.js b/resources/ext.gather.collection.flag/CollectionFlagOverlay.js new file mode 100644 index 0000000..b2e55d7 --- /dev/null +++ b/resources/ext.gather.collection.flag/CollectionFlagOverlay.js @@ -0,0 +1,46 @@ +( function ( M, $ ) { + + var CollectionFlagOverlay, + ConfirmationOverlay = M.require( 'ext.gather.confirm/ConfirmationOverlay' ), + SchemaGatherFlags = M.require( 'ext.gather.logging/SchemaGatherFlags' ), + schema = new SchemaGatherFlags(), + toast = M.require( 'toast' ); + + /** + * Overlay for deleting a collection + * @extends ConfirmationOverlay + * @class CollectionFlagOverlay + */ + CollectionFlagOverlay = ConfirmationOverlay.extend( { + /** @inheritdoc */ + defaults: $.extend( {}, ConfirmationOverlay.prototype.defaults, { + flagSuccessMsg: mw.msg( 'gather-flag-collection-success' ), + subheading: mw.msg( 'gather-flag-collection-heading' ), + confirmMessage: mw.msg( 'gather-flag-collection-confirm' ), + confirmButtonClass: 'mw-ui-destructive', + confirmButtonLabel: mw.msg( 'gather-flag-collection-flag-label' ) + } ), + /** @inheritdoc */ + events: $.extend( {}, ConfirmationOverlay.prototype.events, { + 'click .confirm': 'onFlagClick' + } ), + /** + * Event handler when the delete button is clicked. + */ + onFlagClick: function () { + var self = this; + this.showSpinner(); + // disable buttons + this.$( '.confirm, .cancel' ).prop( 'disabled', true ); + schema.log( { + collectionId: self.id + } ).always( function () { + toast.show( self.options.flagSuccessMsg, 'toast' ); + self.hide(); + } ); + } + } ); + + M.define( 'ext.gather.flag/CollectionFlagOverlay', CollectionFlagOverlay ); + +}( mw.mobileFrontend, jQuery ) ); diff --git a/resources/ext.gather.collection.flag/content.hogan b/resources/ext.gather.collection.flag/content.hogan new file mode 100644 index 0000000..2870119 --- /dev/null +++ b/resources/ext.gather.collection.flag/content.hogan @@ -0,0 +1,9 @@ +{{{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> diff --git a/resources/ext.gather.collection.flag/flagOverlay.less b/resources/ext.gather.collection.flag/flagOverlay.less new file mode 100644 index 0000000..e99838d --- /dev/null +++ b/resources/ext.gather.collection.flag/flagOverlay.less @@ -0,0 +1,27 @@ +@import "minerva.variables"; +@import "minerva.mixins"; + +.content-overlay.collection-flag-overlay { + font-size: .9em; + text-align: center; + + h3 { + padding: 0.25em; + } + + span { + display: block; + padding: 0.5em; + } + + .collection-flag-actions { + padding: 0.5em; + } + + &.content-overlay { + background-color: white; + top: @headerHeight * 1.2; + color: @grayDark; + width: auto; + } +} \ No newline at end of file diff --git a/resources/ext.gather.icons/flag.svg b/resources/ext.gather.icons/flag.svg new file mode 100644 index 0000000..4cbf19a --- /dev/null +++ b/resources/ext.gather.icons/flag.svg @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<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="M13,7.5c0-0.6,0-1.1,0-1.5c-1.4-1.5-5.2-1.2-6,0c0-1,0-1,0-1H6v15h1c0,0,0-3.1,0-7c0.8-0.8,3.4-0.9,5-0.5c0,0.6,0,1.1,0,1.5 + c1.2,1.5,4.3,1.2,5,0V7C16.3,7.7,14.3,7.9,13,7.5z"/> +</svg> diff --git a/resources/ext.gather.logging/SchemaGatherFlags.js b/resources/ext.gather.logging/SchemaGatherFlags.js new file mode 100644 index 0000000..25b5ddf --- /dev/null +++ b/resources/ext.gather.logging/SchemaGatherFlags.js @@ -0,0 +1,30 @@ +( function ( M, $ ) { + var SchemaGatherFlags, + Schema = M.require( 'Schema' ), + user = M.require( 'user' ); + + /** + * @class SchemaGatherFlags + * @extends Schema + */ + SchemaGatherFlags = Schema.extend( { + /** + * @inheritdoc + */ + defaults: $.extend( {}, Schema.prototype.defaults, { + userId: mw.user.getId(), + // FIXME: use mw.user when method available + // Null when user is anon, set to 0 + userEditCount: user.getEditCount() || 0, + // FIXME: Needs + userGroups: '' + } ), + /** + * @inheritdoc + */ + name: 'GatherFlags' + } ); + + M.define( 'ext.gather.logging/SchemaGatherFlags', SchemaGatherFlags ); + +}( mw.mobileFrontend, jQuery ) ); diff --git a/resources/ext.gather.special/init.js b/resources/ext.gather.special/init.js index 919fe98..bcd6753 100644 --- a/resources/ext.gather.special/init.js +++ b/resources/ext.gather.special/init.js @@ -2,6 +2,7 @@ var CollectionEditOverlay = M.require( 'ext.gather.edit/CollectionEditOverlay' ), CollectionDeleteOverlay = M.require( 'ext.gather.delete/CollectionDeleteOverlay' ), + CollectionFlagOverlay = M.require( 'ext.gather.flag/CollectionFlagOverlay' ), toast = M.require( 'toast' ), overlayManager = M.require( 'overlayManager' ); @@ -11,17 +12,22 @@ var collection = mw.config.get( 'wgGatherCollections' ); if ( collection ) { - if ( action === 'edit' ) { - return new CollectionEditOverlay( { - collection: collection - } ); - } else if ( action === 'delete' ) { - return new CollectionDeleteOverlay( { - collection: collection - } ); - } else { - toast.show( mw.msg( 'gather-no-such-action' ), 'error' ); - return $.Deferred(); + switch ( action ) { + case 'edit': + return new CollectionEditOverlay( { + collection: collection + } ); + case 'delete': + return new CollectionDeleteOverlay( { + collection: collection + } ); + case 'flag': + return new CollectionFlagOverlay( { + collection: collection + } ); + default: + toast.show( mw.msg( 'gather-no-such-action' ), 'error' ); + return $.Deferred(); } } else { toast.show( mw.msg( 'gather-unknown-error' ), 'error' ); diff --git a/resources/ext.gather.styles/collections.less b/resources/ext.gather.styles/collections.less index 84d3c90..af86550 100644 --- a/resources/ext.gather.styles/collections.less +++ b/resources/ext.gather.styles/collections.less @@ -42,6 +42,10 @@ margin-top: 0; padding-top: 0; } + .collection-moderation { + position: absolute; + right: 0; + } .collection-header { text-align: center; -- To view, visit https://gerrit.wikimedia.org/r/204611 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2b373e5415f76f85dba78d246b3c22af2284c261 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Robmoen <rm...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits