Skip to content

Commit

Permalink
Allow to select multiple conversations using SHIFT button - closes #1312
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Nov 20, 2023
1 parent c2a8894 commit 4fbe3a3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var fs_actions = {};
var fs_filters = {};
var fs_body_default = '<div><br></div>';
var fs_prev_focus = true;
var fs_checkbox_shift_last_checked = null;

var FS_STATUS_CLOSED = 3;

Expand Down Expand Up @@ -4816,6 +4817,32 @@ function converstationBulkActionsInit()
$('.toggle-all:checkbox').on('click', function () {
$('.conv-checkbox:checkbox').prop('checked', this.checked).trigger('change');
});

$('.conv-cb label').on( 'click', function(e){

var all_checkboxes = $('input.conv-checkbox');
var this_input = $( this ).parent('td').find('input.conv-checkbox' )[0];

// Remove the selection of text that happens.
document.getSelection().removeAllRanges();

if (!fs_checkbox_shift_last_checked) {
fs_checkbox_shift_last_checked = this_input;
return;
}

if (e.shiftKey) {
var start = all_checkboxes.index( this_input );
var end = all_checkboxes.index(fs_checkbox_shift_last_checked);

all_checkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', fs_checkbox_shift_last_checked.checked);

// When removing the selected text using getSelection(), the last click gets nullified. Let's re-do it.
$( this_input ).trigger('click');
}

fs_checkbox_shift_last_checked = this_input;
});
});
}

Expand Down

0 comments on commit 4fbe3a3

Please sign in to comment.