From a3af7d96b9418ec15b66e35afb71278a02de1aab Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Fri, 14 Feb 2020 16:25:48 -0700
Subject: [PATCH] Keep the progress indicator in the row-actions visible while
the export/erase is happening, even when that cell isn't hovered over.
---
src/js/_enqueues/admin/privacy-tools.js | 53 ++++++++++++++++++++-----
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js
index 5d5a2067a4..6a9f93b4c8 100644
|
a
|
b
|
jQuery( document ).ready( function( $ ) {
|
| 55 | 55 | }); |
| 56 | 56 | } |
| 57 | 57 | |
| | 58 | function showRowActions( $rowActions, $hasRowActions ) { |
| | 59 | if ( $rowActions.length > 0 ) { |
| | 60 | $( $rowActions ).addClass( 'visible' ); |
| | 61 | $( $hasRowActions ).removeClass( 'has-row-actions' ); |
| | 62 | } |
| | 63 | } |
| | 64 | |
| | 65 | function hideRowActions( $rowActions, $hasRowActions ) { |
| | 66 | if ( $rowActions.length > 0 ) { |
| | 67 | $( $rowActions ).removeClass( 'visible' ); |
| | 68 | $( $hasRowActions ).addClass( 'has-row-actions' ); |
| | 69 | } |
| | 70 | } |
| | 71 | |
| 58 | 72 | $( '.export-personal-data-handle' ).click( function( event ) { |
| 59 | 73 | var $this = $( this ), |
| 60 | 74 | $action = $this.parents( '.export-personal-data' ), |
| 61 | 75 | $requestRow = $this.parents( 'tr' ), |
| 62 | 76 | $progress = $requestRow.find( '.export-progress' ), |
| | 77 | $rowActions = $this.parents( '.row-actions' ), |
| | 78 | $hasRowActions = $( '.has-row-actions' ), |
| 63 | 79 | requestID = $action.data( 'request-id' ), |
| 64 | 80 | nonce = $action.data( 'nonce' ), |
| 65 | 81 | exportersCount = $action.data( 'exporters-count' ), |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 68 | 84 | event.preventDefault(); |
| 69 | 85 | event.stopPropagation(); |
| 70 | 86 | |
| | 87 | // have to do this before the `$action.blur()`. |
| | 88 | showRowActions( $rowActions, $hasRowActions ); |
| | 89 | |
| 71 | 90 | $action.blur(); |
| 72 | 91 | clearResultsAfterRow( $requestRow ); |
| 73 | 92 | setExportProgress( 0 ); |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 77 | 96 | |
| 78 | 97 | setActionState( $action, 'export-personal-data-success' ); |
| 79 | 98 | |
| | 99 | hideRowActions( $rowActions, $hasRowActions ); |
| | 100 | |
| 80 | 101 | appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] ); |
| 81 | 102 | $this.hide(); |
| 82 | 103 | |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 92 | 113 | if ( errorMessage ) { |
| 93 | 114 | appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] ); |
| 94 | 115 | } |
| | 116 | |
| | 117 | hideRowActions( $rowActions, $hasRowActions ); |
| 95 | 118 | } |
| 96 | 119 | |
| 97 | 120 | function setExportProgress( exporterIndex ) { |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 147 | 170 | }); |
| 148 | 171 | |
| 149 | 172 | $( '.remove-personal-data-handle' ).click( function( event ) { |
| 150 | | var $this = $( this ), |
| 151 | | $action = $this.parents( '.remove-personal-data' ), |
| 152 | | $requestRow = $this.parents( 'tr' ), |
| 153 | | $progress = $requestRow.find( '.erasure-progress' ), |
| 154 | | requestID = $action.data( 'request-id' ), |
| 155 | | nonce = $action.data( 'nonce' ), |
| 156 | | erasersCount = $action.data( 'erasers-count' ), |
| 157 | | hasRemoved = false, |
| 158 | | hasRetained = false, |
| 159 | | messages = []; |
| | 173 | var $this = $( this ), |
| | 174 | $action = $this.parents( '.remove-personal-data' ), |
| | 175 | $requestRow = $this.parents( 'tr' ), |
| | 176 | $progress = $requestRow.find( '.erasure-progress' ), |
| | 177 | requestID = $action.data( 'request-id' ), |
| | 178 | $rowActions = $this.parents( '.row-actions' ), |
| | 179 | $hasRowActions = $( '.has-row-actions' ), |
| | 180 | nonce = $action.data( 'nonce' ), |
| | 181 | erasersCount = $action.data( 'erasers-count' ), |
| | 182 | hasRemoved = false, |
| | 183 | hasRetained = false, |
| | 184 | messages = []; |
| 160 | 185 | |
| 161 | 186 | event.stopPropagation(); |
| 162 | 187 | |
| | 188 | // have to do this before the `$action.blur()`. |
| | 189 | showRowActions( $rowActions, $hasRowActions ); |
| | 190 | |
| 163 | 191 | $action.blur(); |
| 164 | 192 | clearResultsAfterRow( $requestRow ); |
| 165 | 193 | setErasureProgress( 0 ); |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 170 | 198 | |
| 171 | 199 | setActionState( $action, 'remove-personal-data-success' ); |
| 172 | 200 | |
| | 201 | hideRowActions( $rowActions, $hasRowActions ); |
| | 202 | |
| 173 | 203 | if ( false === hasRemoved ) { |
| 174 | 204 | if ( false === hasRetained ) { |
| 175 | 205 | summaryMessage = strings.noDataFound; |
| … |
… |
jQuery( document ).ready( function( $ ) {
|
| 191 | 221 | |
| 192 | 222 | function onErasureFailure() { |
| 193 | 223 | setActionState( $action, 'remove-personal-data-failed' ); |
| | 224 | |
| | 225 | hideRowActions( $rowActions, $hasRowActions ); |
| | 226 | |
| 194 | 227 | appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] ); |
| 195 | 228 | } |
| 196 | 229 | |