Skip to content

Commit

Permalink
YDA-5562: added copy/move overwrite all option when multiple files/fo…
Browse files Browse the repository at this point in the history
…lders are selected
  • Loading branch information
kaur16 authored Dec 18, 2023
1 parent 675a076 commit 37efb45
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion research/static/research/js/dlgFileBrowseOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ $(document).on('click', '.multi-cancel-button', function () {
const index = $(this).closest('tr').attr('class').split('-').pop()

$('.multi-select-table tr.row-' + index + ' td.item-progress').text('Overwrite cancelled')
if (($('#mutli-select-progress .dlg-multi-action-button span.action').text() === 'Copy and overwrite all') || ($('#mutli-select-progress .dlg-multi-action-button span.action').text() === 'Move and overwrite all')) {
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', true)
}
})

$(document).on('click', '.dlg-multi-action-button', function () {
$('.multi-overwrite-button').click()
})

async function copyFile (filepath, newFilepath, multiple, multipleIndex = null, overwrite = false) {
Expand All @@ -238,6 +245,7 @@ async function copyFile (filepath, newFilepath, multiple, multipleIndex = null,
if (result.status === 'ok') {
if (multiple) {
$('.multi-select-table tr.row-' + multipleIndex + ' td.item-progress').text('Copy completed')
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', true)
browse(currentBrowseFolder, true)
} else {
Yoda.set_message('success', 'The file has been successfully copied.')
Expand Down Expand Up @@ -291,6 +299,7 @@ async function moveFile (filepath, newFilepath, multiple, multipleIndex = null,
if (result.status === 'ok') {
if (multiple) {
$('.multi-select-table tr.row-' + multipleIndex + ' td.item-progress').text('Move completed')
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', true)
browse(currentBrowseFolder, true)
} else {
Yoda.set_message('success', 'The file has been successfully moved.')
Expand Down Expand Up @@ -346,6 +355,7 @@ async function copyFolder (folderPath, newFolderpath, multiple, multipleIndex =
if (result.status === 'ok') {
if (multiple) {
$('.multi-select-table tr.row-' + multipleIndex + ' td.item-progress').text('Copy completed')
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', true)
browse(currentBrowseFolder, true)
} else {
Yoda.set_message('success', 'The folder has been successfully copied.')
Expand Down Expand Up @@ -399,6 +409,7 @@ async function moveFolder (folderPath, newFolderpath, multiple, multipleIndex =
if (result.status === 'ok') {
if (multiple) {
$('.multi-select-table tr.row-' + multipleIndex + ' td.item-progress').text('Move completed')
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', true)
browse(currentBrowseFolder, true)
} else {
Yoda.set_message('success', 'The folder has been successfully moved.')
Expand Down Expand Up @@ -721,13 +732,19 @@ function createOverwriteBtn(multipleIndex, path, type, action) {
cancelOverwriteBtn = '<button type="button" class="btn btn-primary ms-2 multi-cancel-button" data-type="' + type + '" data-name="' +
fileName + '" data-action="' + action + '" data-collection="' + filePath + '">No</button>'
$('.multi-select-table tr.row-' + multipleIndex + ' td.item-progress').append(overwriteBtn + cancelOverwriteBtn)

// Create Overwrite All button
$('#mutli-select-progress .dlg-multi-action-button').html('<span class="action">' + action.charAt(0).toUpperCase() + action.slice(1)
+ ' and overwrite all</span>')
$('#mutli-select-progress .dlg-multi-action-button').removeClass('hidden')
$('#mutli-select-progress .dlg-multi-action-button').prop('disabled', false)
}

function changeActionBtn(action) {
if ($('#dlg-file-browse-operations .dlg-action-button').attr('data-overwrite')) {
$('#dlg-file-browse-operations .dlg-action-button').html('<span class="action">' + action + ' and overwrite</span>')
}
else {
$('#dlg-file-browse-operations .dlg-action-button').html('<span class="action">' + action + 'Move</span>')
$('#dlg-file-browse-operations .dlg-action-button').html('<span class="action">' + action + '</span>')
}
}
1 change: 1 addition & 0 deletions research/templates/research/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ <h5 class="card-title float-start">

<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="finishMultiSelect" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary dlg-multi-action-button hidden"><span class="action"></span></button>
</div>
</div>
</div>
Expand Down

0 comments on commit 37efb45

Please sign in to comment.