Skip to content

Commit

Permalink
Fix bulk copy from original (#397)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniele Scasciafratte <[email protected]>
  • Loading branch information
vlad-timotei and Mte90 authored Oct 20, 2022
1 parent 9725bd6 commit 2ba2085
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#2.0.10

* Fix: Fix bulk copy from original to comply with the latest GP Translation Helpers on W.org [Fixes #396]
# 2.0.9

* Fix: Fixes to comply with the w.org Beta Testing program [Fixes #391]
Expand Down
24 changes: 22 additions & 2 deletions js/glotdict-bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,33 @@ jQuery( '.bulk-action' ).append( jQuery( '<option>', {
text: 'Copy From Original',
} ) );

const gd_checked_rows = [];

jQuery( 'tbody th.checkbox input' ).on( 'change', function() {
if ( jQuery( this ).is( ':checked' ) ) {
gd_checked_rows.push( jQuery( this ) );
} else {
gd_checked_rows.splice( gd_checked_rows.indexOf( jQuery( this ) ), 1 );
}
} );

jQuery( 'tbody th.checkbox input, .gp-column-checkbox input' ).on( 'change', function() {
if ( jQuery( this ).is( ':checked' ) ) {
jQuery('.preview .checkbox input').each( function() {
gd_checked_rows.push( jQuery( this ) );
});
} else {
gd_checked_rows.slice(0);
}
} );

jQuery( '.bulk-actions' ).on( 'click', '.button', ( e ) => {
if ( 'copy-from-original' === jQuery( '.bulk-action option:selected' ).val() ) {
let copied_count = 0;
let timeout = 0;
$gp.editor.hide(); // Avoid validation on open editors that are empty.
jQuery( 'tbody th.checkbox input:checked' ).each( function() {
const checkbox = jQuery( this );
gd_checked_rows.forEach( el => {
const checkbox = jQuery( el );
const parent = checkbox.closest( 'tr' );
const row = parent.attr( 'row' );
if ( gd_get_setting( 'autosubmit_bulk_copy_from_original' ) ) {
Expand Down

0 comments on commit 2ba2085

Please sign in to comment.