Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/vault/vault-ui.js
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | .then(cookingTasks => { | ||||
} | } | ||||
} | } | ||||
localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultCookingTasks)); | localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultCookingTasks)); | ||||
checkVaultId = setTimeout(checkVaultCookingTasks, pollingInterval); | checkVaultId = setTimeout(checkVaultCookingTasks, pollingInterval); | ||||
}) | }) | ||||
.catch(() => {}); | .catch(() => {}); | ||||
} | } | ||||
export function removeVaultCookingTaskStatuses(tasksToRemove) { | |||||
vlorentz: `s/Statuses//`? | |||||
anlambertAuthorUnsubmitted Done Inline ActionsI will go for s/Statuses/Info/ anlambert: I will go for `s/Statuses/Info/` | |||||
let vaultCookingTasks = JSON.parse(localStorage.getItem('swh-vault-cooking-tasks')); | |||||
if (!vaultCookingTasks) { | |||||
return; | |||||
} | |||||
vaultCookingTasks = $.grep(vaultCookingTasks, task => { | |||||
return $.inArray(task.object_id, tasksToRemove) === -1; | |||||
}); | |||||
localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultCookingTasks)); | |||||
} | |||||
export function initUi() { | export function initUi() { | ||||
$('#vault-tasks-toggle-selection').change(event => { | $('#vault-tasks-toggle-selection').change(event => { | ||||
$('.vault-task-toggle-selection').prop('checked', event.currentTarget.checked); | $('.vault-task-toggle-selection').prop('checked', event.currentTarget.checked); | ||||
}); | }); | ||||
$('#vault-remove-tasks').click(() => { | $('#vault-remove-tasks').click(() => { | ||||
clearTimeout(checkVaultId); | clearTimeout(checkVaultId); | ||||
let tasksToRemove = []; | let tasksToRemove = []; | ||||
$('.swh-vault-table tbody tr').each((i, row) => { | $('.swh-vault-table tbody tr').each((i, row) => { | ||||
let taskSelected = $(row).find('.vault-task-toggle-selection').prop('checked'); | let taskSelected = $(row).find('.vault-task-toggle-selection').prop('checked'); | ||||
if (taskSelected) { | if (taskSelected) { | ||||
let objectId = $(row).find('.vault-object-id').data('object-id'); | let objectId = $(row).find('.vault-object-id').data('object-id'); | ||||
tasksToRemove.push(objectId); | tasksToRemove.push(objectId); | ||||
$(row).remove(); | $(row).remove(); | ||||
} | } | ||||
}); | }); | ||||
let vaultCookingTasks = JSON.parse(localStorage.getItem('swh-vault-cooking-tasks')); | removeVaultCookingTaskStatuses(tasksToRemove); | ||||
vaultCookingTasks = $.grep(vaultCookingTasks, task => { | |||||
return $.inArray(task.object_id, tasksToRemove) === -1; | |||||
}); | |||||
localStorage.setItem('swh-vault-cooking-tasks', JSON.stringify(vaultCookingTasks)); | |||||
$('#vault-tasks-toggle-selection').prop('checked', false); | $('#vault-tasks-toggle-selection').prop('checked', false); | ||||
checkVaultId = setTimeout(checkVaultCookingTasks, pollingInterval); | checkVaultId = setTimeout(checkVaultCookingTasks, pollingInterval); | ||||
}); | }); | ||||
checkVaultCookingTasks(); | checkVaultCookingTasks(); | ||||
window.onfocus = () => { | window.onfocus = () => { | ||||
clearTimeout(checkVaultId); | clearTimeout(checkVaultId); | ||||
checkVaultCookingTasks(); | checkVaultCookingTasks(); | ||||
}; | }; | ||||
} | } |
s/Statuses//?