Updates: Improve bulk update failure notice

When doing a bulk update, if there are failures the user needs to know about that. This makes it clearer that you can click on the notification to see more details, especially for screen reader users.

Fixes #37510.
Props  juhise, Ankit K Gupta, afercia, jorbin, ocean90. 



git-svn-id: https://develop.svn.wordpress.org/trunk@38185 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin 2016-08-03 22:23:50 +00:00
parent cc524820be
commit 10906c673f
3 changed files with 35 additions and 21 deletions

View File

@ -3024,7 +3024,8 @@ img {
/* Metabox collapse arrow indicators */
.js .sidebar-name .sidebar-name-arrow:before,
.js .meta-box-sortables .postbox .toggle-indicator:before {
.js .meta-box-sortables .postbox .toggle-indicator:before,
.bulk-action-notice .toggle-indicator:before {
content: "\f142";
display: inline-block;
font: normal 20px/1 dashicons;
@ -3035,7 +3036,8 @@ img {
}
.js .widgets-holder-wrap.closed .sidebar-name-arrow:before,
.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before {
.js .meta-box-sortables .postbox.closed .handlediv .toggle-indicator:before,
.bulk-action-notice .bulk-action-errors-collapsed .toggle-indicator:before {
content: "\f140";
}
@ -3065,6 +3067,12 @@ img {
text-indent: 1px; /* account for the dashicon alignment */
}
.bulk-action-notice .toggle-indicator:before {
line-height: 16px;
vertical-align: top;
color: #72777c;
}
.js .postbox .handlediv:focus {
-webkit-box-shadow: none;
box-shadow: none;

View File

@ -634,7 +634,7 @@ function wp_print_admin_notice_templates() {
<div <# if ( data.id ) { #>id="{{ data.id }}"<# } #> class="notice {{ data.className }}"><p>{{{ data.message }}}</p></div>
</script>
<script id="tmpl-wp-bulk-updates-admin-notice" type="text/html">
<div id="{{ data.id }}" class="notice <# if ( data.errors ) { #>notice-error<# } else { #>notice-success<# } #>">
<div id="{{ data.id }}" class="{{ data.className }} notice <# if ( data.errors ) { #>notice-error<# } else { #>notice-success<# } #>">
<p>
<# if ( data.successes ) { #>
<# if ( 1 === data.successes ) { #>
@ -664,25 +664,25 @@ function wp_print_admin_notice_templates() {
<# } #>
<# } #>
<# if ( data.errors ) { #>
<button class="button-link bulk-action-errors-collapsed" aria-expanded="false">
<# if ( 1 === data.errors ) { #>
<button class="button-link">
<?php
/* translators: %s: Number of failures */
printf( __( '%s failure.' ), '{{ data.errors }}' );
/* translators: %s: Number of failed updates */
printf( __( '%s update failed.' ), '{{ data.errors }}' );
?>
</button>
<# } else { #>
<button class="button-link">
<?php
/* translators: %s: Number of failures */
printf( __( '%s failures.' ), '{{ data.errors }}' );
/* translators: %s: Number of failed updates */
printf( __( '%s updates failed.' ), '{{ data.errors }}' );
?>
</button>
<# } #>
<span class="screen-reader-text"><?php _e( 'Show more details' ); ?></span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
<# } #>
</p>
<# if ( data.errors ) { #>
<ul class="hidden">
<ul class="bulk-action-errors hidden">
<# _.each( data.errorMessages, function( errorMessage ) { #>
<li>{{ errorMessage }}</li>
<# } ); #>

View File

@ -2023,6 +2023,7 @@
wp.updates.addAdminNotice( {
id: 'bulk-action-notice',
className: 'bulk-action-notice',
successes: success,
errors: error,
errorMessages: errorMessages,
@ -2030,7 +2031,12 @@
} );
$bulkActionNotice = $( '#bulk-action-notice' ).on( 'click', 'button', function() {
$bulkActionNotice.find( 'ul' ).toggleClass( 'hidden' );
// $( this ) is the clicked button, no need to get it again.
$( this )
.toggleClass( 'bulk-action-errors-collapsed' )
.attr( 'aria-expanded', ! $( this ).hasClass( 'bulk-action-errors-collapsed' ) );
// Show the errors list.
$bulkActionNotice.find( '.bulk-action-errors' ).toggleClass( 'hidden' );
} );
if ( error > 0 && ! wp.updates.queue.length ) {