Skip to content

Commit f09914b

Browse files
authored
Hofix for bulk copy from original (#398)
1 parent e35125c commit f09914b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

js/glotdict-bulk.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,30 @@ jQuery( '.bulk-action' ).append( jQuery( '<option>', {
66
const gd_checked_rows = [];
77

88
jQuery( 'tbody th.checkbox input' ).on( 'change', function() {
9+
const row = jQuery( this ).parent().parent().attr( 'row' );
910
if ( jQuery( this ).is( ':checked' ) ) {
10-
gd_checked_rows.push( jQuery( this ) );
11+
gd_checked_rows.push( row );
1112
} else {
12-
gd_checked_rows.splice( gd_checked_rows.indexOf( jQuery( this ) ), 1 );
13+
gd_checked_rows.splice( gd_checked_rows.indexOf( row ), 1 );
1314
}
1415
} );
1516

16-
jQuery( 'tbody th.checkbox input, .gp-column-checkbox input' ).on( 'change', function() {
17-
if ( jQuery( this ).is( ':checked' ) ) {
18-
jQuery('.preview .checkbox input').each( function() {
19-
gd_checked_rows.push( jQuery( this ) );
20-
});
21-
} else {
22-
gd_checked_rows.slice(0);
23-
}
17+
jQuery( 'thead th.checkbox input' ).on( 'change', function() {
18+
gd_checked_rows.splice( 0, gd_checked_rows.length );
19+
if ( jQuery( this ).is( ':checked' ) ) {
20+
jQuery( 'tbody th.checkbox input' ).each( function() {
21+
gd_checked_rows.push( jQuery( this ).parent().parent().attr( 'row' ) );
22+
} );
23+
}
2424
} );
2525

2626
jQuery( '.bulk-actions' ).on( 'click', '.button', ( e ) => {
2727
if ( 'copy-from-original' === jQuery( '.bulk-action option:selected' ).val() ) {
2828
let copied_count = 0;
2929
let timeout = 0;
3030
$gp.editor.hide(); // Avoid validation on open editors that are empty.
31-
gd_checked_rows.forEach( el => {
32-
const checkbox = jQuery( el );
33-
const parent = checkbox.closest( 'tr' );
34-
const row = parent.attr( 'row' );
31+
gd_checked_rows.forEach( row => {
32+
const checkbox = jQuery( `#preview-${row} th.checkbox input` );
3533
if ( gd_get_setting( 'autosubmit_bulk_copy_from_original' ) ) {
3634
setTimeout( () => {
3735
$gp.editor.show( checkbox );
@@ -55,6 +53,7 @@ jQuery( '.bulk-actions' ).on( 'click', '.button', ( e ) => {
5553
gd_copied_count_notice( copied_count );
5654
}
5755
} );
56+
gd_checked_rows.splice( 0, gd_checked_rows.length );
5857
e.preventDefault();
5958
return false;
6059
}

0 commit comments

Comments
 (0)