jenkins-bot has submitted this change and it was merged.
Change subject: Sandbox: remove requests once accepted or rejected
......................................................................
Sandbox: remove requests once accepted or rejected
Change-Id: Id15a004129f0ab372b578f9e17380d243a367b46
---
M Resources.php
M TranslateSandbox.i18n.php
M resources/js/ext.translate.special.translatesandbox.js
3 files changed, 56 insertions(+), 8 deletions(-)
Approvals:
Amire80: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Resources.php b/Resources.php
index cba15fd..d3158da 100644
--- a/Resources.php
+++ b/Resources.php
@@ -363,14 +363,18 @@
'mediawiki.api',
'jquery.uls.grid',
'jquery.ui.dialog',
+ 'mediawiki.jqueryMsg',
),
'messages' => array(
'tsb-accept-button-label',
'tsb-reject-button-label',
+ 'tsb-accept-all-button-label',
+ 'tsb-reject-all-button-label',
'tsb-reminder-link-text',
'tsb-translations-source',
'tsb-translations-user',
'tsb-translations-current',
+ 'tsb-request-count',
),
) + $resourcePaths;
diff --git a/TranslateSandbox.i18n.php b/TranslateSandbox.i18n.php
index 73c44d2..1a136af 100644
--- a/TranslateSandbox.i18n.php
+++ b/TranslateSandbox.i18n.php
@@ -30,6 +30,8 @@
'tsb-search-requests' => 'Search requests',
'tsb-accept-button-label' => 'Accept',
'tsb-reject-button-label' => 'Reject',
+ 'tsb-accept-all-button-label' => 'Accept all',
+ 'tsb-reject-all-button-label' => 'Reject all',
'tsb-reminder-link-text' => 'Send email reminder',
'tsb-translations-source' => 'Source',
'tsb-translations-user' => 'User translations',
@@ -70,6 +72,10 @@
{{Identical|Accept}}',
'tsb-reject-button-label' => 'Button label for reject button in
[[Special:TranslateSandbox]].
{{Identical|Reject}}',
+ 'tsb-accept-all-button-label' => 'Button label for accept-all button in
[[Special:TranslateSandbox]].
+{{Identical|Accept all}}',
+ 'tsb-reject-all-button-label' => 'Button label for reject-all button in
[[Special:TranslateSandbox]]
+{{Identical|Reject all}}',
'tsb-reminder-link-text' => 'Link text for sending reminder emails
about translator signup requests.',
'tsb-translations-source' => 'Table header label for source messages of
user translations in [[Special:TranslateSandbox]].
{{Identical|Source}}',
diff --git a/resources/js/ext.translate.special.translatesandbox.js
b/resources/js/ext.translate.special.translatesandbox.js
index 4057d55..d75972c 100644
--- a/resources/js/ext.translate.special.translatesandbox.js
+++ b/resources/js/ext.translate.special.translatesandbox.js
@@ -12,9 +12,8 @@
options = $.extend( {}, { action: 'translatesandbox' }, options
);
- api.postWithToken( 'translatesandbox', options )
- .done( function () { window.alert( 'Success' ); } )
- .fail( function () { window.alert( 'Failure' ); } );
+ return api.postWithToken( 'translatesandbox', options )
+ .promise();
}
/**
@@ -105,6 +104,13 @@
} );
}
+ function removeSelectedRequests() {
+ $( '.request-selector:checked' )
+ .closest( '.request' ).remove();
+ $( '.request-count div' )
+ .text( mw.msg( 'tsb-request-count', $(
'.request').length ) );
+ }
+
/**
* Display the request details when user clicks on a request item
*
@@ -137,7 +143,7 @@
doApiAction( {
userid:
request.userid,
'do': 'promote'
- } );
+ } ).done(
removeSelectedRequests );
} ),
$( '<button>' )
.addClass( 'delete destructive
button' )
@@ -146,7 +152,7 @@
doApiAction( {
userid:
request.userid,
'do': 'delete'
- } );
+ } ).done(
removeSelectedRequests );
} )
),
$( '<div>' )
@@ -217,12 +223,41 @@
} );
}
+ /**
+ * Display when multiple requests are checked
+ */
+ function displayOnMultipleSelection() {
+ var $detailsPane = $( '.details.pane' );
+
+ $detailsPane.empty().append(
+ $( '<div>' )
+ .addClass( 'actions row' )
+ .append(
+ $( '<button>' )
+ .addClass( 'accept primary
green button' )
+ .text( mw.msg(
'tsb-accept-all-button-label' ) ),
+ // FIXME add api action
+ $( '<button>' )
+ .addClass( 'delete destructive
button' )
+ .text( mw.msg(
'tsb-reject-all-button-label' ) )
+ // FIXME add api action
+ )
+ );
+ }
+
$( document ).ready( function () {
- var $selectAll = $( '.request-selector-all' );
+ var $selectAll = $( '.request-selector-all' ),
+ $detailsPane = $( '.details.pane' );
// Handle clicks for the select all checkbox
- $selectAll.click( function () {
+ $selectAll.on( 'click', function () {
$( '.request-selector' ).prop( 'checked', this.checked
);
+
+ if ( this.checked ) {
+ displayOnMultipleSelection();
+ } else {
+ $detailsPane.empty();
+ }
} );
// And update the state of select-all checkbox
@@ -234,17 +269,20 @@
if ( checked === total ) {
$selectAll.prop( 'checked', true ).prop(
'indeterminate', false );
+ displayOnMultipleSelection();
} else if ( checked === 0 ) {
+ $detailsPane.empty();
$selectAll.prop( 'checked', false ).prop(
'indeterminate', false );
} else {
$selectAll.prop( 'indeterminate', true );
+ displayOnMultipleSelection();
}
e.stopPropagation();
} );
// Handle clicks on requests
- $( '.requests .request' ).on( 'click', function () {
+ $( '.requests .request' ).on( 'click', function () {
displayRequestDetails( $( this ).data( 'data' ) );
} );
--
To view, visit https://gerrit.wikimedia.org/r/89152
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id15a004129f0ab372b578f9e17380d243a367b46
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: SuchetaG <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits