|
|
|
@ -174,6 +174,13 @@ |
|
|
|
|
<Column :exportable="false"> |
|
|
|
|
<template #body="slotProps"> |
|
|
|
|
<div class="flex flex-row justify-end gap-2"> |
|
|
|
|
<BaseButton |
|
|
|
|
v-if="canEdit(slotProps.data)" |
|
|
|
|
icon="folder-move" |
|
|
|
|
size="small" |
|
|
|
|
type="secondary" |
|
|
|
|
@click="openMoveDialog(slotProps.data)" |
|
|
|
|
/> |
|
|
|
|
<BaseButton |
|
|
|
|
icon="information" |
|
|
|
|
size="small" |
|
|
|
@ -255,6 +262,22 @@ |
|
|
|
|
/> |
|
|
|
|
</BaseToolbar> |
|
|
|
|
|
|
|
|
|
<BaseDialogConfirmCancel |
|
|
|
|
v-model:is-visible="isMoveDialogVisible" |
|
|
|
|
:title="t('Move document')" |
|
|
|
|
@confirm-clicked="moveDocument" |
|
|
|
|
@cancel-clicked="isMoveDialogVisible = false" |
|
|
|
|
> |
|
|
|
|
<p>{{ t("Select the destination folder") }}</p> |
|
|
|
|
<Dropdown |
|
|
|
|
v-model="selectedFolder" |
|
|
|
|
:options="folders" |
|
|
|
|
optionLabel="label" |
|
|
|
|
optionValue="value" |
|
|
|
|
placeholder="Select a folder" |
|
|
|
|
/> |
|
|
|
|
</BaseDialogConfirmCancel> |
|
|
|
|
|
|
|
|
|
<BaseDialogConfirmCancel |
|
|
|
|
v-model:is-visible="isNewFolderDialogVisible" |
|
|
|
|
:cancel-label="t('Cancel')" |
|
|
|
@ -420,6 +443,8 @@ const { isImage, isHtml } = useFileUtils() |
|
|
|
|
|
|
|
|
|
const { relativeDatetime } = useFormatDate() |
|
|
|
|
const isAllowedToEdit = ref(false) |
|
|
|
|
const folders = ref([]) |
|
|
|
|
const selectedFolder = ref(null) |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
showNewDocumentButton, |
|
|
|
@ -445,6 +470,7 @@ const isFileUsageDialogVisible = ref(false) |
|
|
|
|
const isRecordAudioDialogVisible = ref(false) |
|
|
|
|
|
|
|
|
|
const submitted = ref(false) |
|
|
|
|
const isMoveDialogVisible = ref(false) |
|
|
|
|
|
|
|
|
|
filters.value.loadNode = 1 |
|
|
|
|
|
|
|
|
@ -501,6 +527,7 @@ onMounted(async () => { |
|
|
|
|
|
|
|
|
|
await loadDefaultCertificate() |
|
|
|
|
onUpdateOptions(options.value) |
|
|
|
|
await loadAllFolders() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
@ -745,6 +772,77 @@ function recordedAudioNotSaved(error) { |
|
|
|
|
console.error(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function openMoveDialog(document) { |
|
|
|
|
item.value = document |
|
|
|
|
isMoveDialogVisible.value = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function fetchFolders(nodeId = null, parentPath = '') { |
|
|
|
|
const foldersList = [{ |
|
|
|
|
label: 'Root', |
|
|
|
|
value: nodeId || route.params.node || route.query.node || 'root-node-id', |
|
|
|
|
}] |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
let nodesToFetch = [{ id: nodeId || route.params.node || route.query.node, path: parentPath }] |
|
|
|
|
let depth = 0 |
|
|
|
|
const maxDepth = 5 |
|
|
|
|
|
|
|
|
|
while (nodesToFetch.length > 0 && depth < maxDepth) { |
|
|
|
|
const currentNode = nodesToFetch.shift() |
|
|
|
|
|
|
|
|
|
const response = await axios.get("/api/documents", { |
|
|
|
|
params: { |
|
|
|
|
filetype: "folder", |
|
|
|
|
"resourceNode.parent": currentNode.id, |
|
|
|
|
cid: route.query.cid, |
|
|
|
|
sid: route.query.sid, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
response.data["hydra:member"].forEach(folder => { |
|
|
|
|
const fullPath = `${currentNode.path}/${folder.title}` |
|
|
|
|
|
|
|
|
|
foldersList.push({ |
|
|
|
|
label: fullPath, |
|
|
|
|
value: folder.resourceNode?.id || folder.resourceNodeId || folder["@id"], |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if (folder.resourceNode && folder.resourceNode.id) { |
|
|
|
|
nodesToFetch.push({ id: folder.resourceNode.id, path: fullPath }) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
depth++ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return foldersList |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("Error fetching folders:", error.message || error) |
|
|
|
|
return [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function loadAllFolders() { |
|
|
|
|
folders.value = await fetchFolders() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function moveDocument() { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
const response = await axios.put(`/api/documents/${item.value.iid}/move`, { |
|
|
|
|
parentResourceNodeId: selectedFolder.value, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
notification.showSuccessNotification(t("Document moved successfully")) |
|
|
|
|
isMoveDialogVisible.value = false |
|
|
|
|
onUpdateOptions(options.value) |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("Error moving document:", error.response || error) |
|
|
|
|
notification.showErrorNotification(t("Error moving the document")) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function selectAsDefaultCertificate(certificate) { |
|
|
|
|
try { |
|
|
|
|
const response = await axios.patch(`/gradebook/set_default_certificate/${cid}/${certificate.iid}`) |
|
|
|
|