Skip to content
Snippets Groups Projects
Commit ac4b8516 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

list collections in current collection + delete sub collection action

parent 76f24227
Branches
Tags
No related merge requests found
......@@ -38,11 +38,16 @@ function downloadSource(source){
});
}
function deleteCurrentCollection(){
if (confirm(`Supprimer ${currentCollection} ?`)) {
fetch(`/bundles/max-db/${currentCollection}`, { method: 'DELETE' }).then((res) => {
function downloadCollection(collectionPath){
console.debug('todo')
}
function deleteCollection(collectionPath, current = false){
if (confirm(`Supprimer ${collectionPath} ?`)) {
fetch(`/bundles/max-db/${collectionPath}`, { method: 'DELETE' }).then((res) => {
if (res.status == 200){
window.location.href = '/bundles/max-db/';
if(current) window.location.href = '/bundles/max-db/';
else window.location.reload(true)
}
else {
res.text().then((message) => alert(`Une erreur est survenue, suppression impossible. \n\n ${message}).`))
......@@ -51,6 +56,10 @@ function deleteCurrentCollection(){
}
}
function deleteCurrentCollection(){
deleteCollection(currentCollection, true)
}
function openMoveSourceDialog(source) {
document.getElementById('modal-title').innerHTML=`Déplacer <em>${source}</em>`
if(!modal)
......@@ -59,6 +68,10 @@ function openMoveSourceDialog(source) {
modal.show()
}
function openMoveCollectionDialog(collectionPath){
console.debug('todo')
}
function doMoveSource(){
const collection = document.getElementById('move-collection-select').value
const path = currentCollection === '/' ? currentSource : `${currentCollection}/${currentSource}`
......
......@@ -29,7 +29,9 @@
let $parts := tokenize($collection,'/')
return
<sl-breadcrumb>
<sl-breadcrumb-item><a class="text-decoration-none" href="/bundles/max-db?collection=/">/</a></sl-breadcrumb-item>
<sl-breadcrumb-item><a class="text-decoration-none" href="/bundles/max-db?collection=/">
<sl-icon-button name="house"/>
</a></sl-breadcrumb-item>
{
for $part at $i in $parts
let $href := '/bundles/max-db?collection=' || $part
......@@ -66,12 +68,12 @@
</div>
</section>
<section>
<h3>Sources XML (<span id="sources-count">{count($sources[@type='xml'])}</span>)</h3>
<h3><span>Fichiers </span><span class="badge bg-light text-dark" id="sources-count">{count($sources[@type='xml'])}</span><span class="ms-5">Collections </span><span class="badge bg-light text-dark" id="collections-count">{count($sources[local-name()='dir'])}</span></h3>
<table class="table">
<thead>
<tr>
<th scope="col">Nom du fichier</th>
<th>#</th>
<th scope="col">Nom</th>
<th scope="col">Taille</th>
<th scope="col">Dernière modification</th>
<th class="text-center" scope="col">Actions</th>
......@@ -80,12 +82,14 @@
<tbody>
{
for $source in $sources
return if($source/@type="xml")
then <tr id="{$source/data()}">
<td>{$source/data()}</td>
<td>{string($source/@size)}</td>
<td><sl-relative-time title="{string($source/@modified-date)}" date="{string($source/@modified-date)}" lang="fr-FR"></sl-relative-time></td>
<td class="text-center">
where local-name($source)='resource' and $source/@type="xml"
return
<tr id="{$source/data()}">
<td class="align-middle"><div style="font-size: 24px;"><sl-icon-button name="filetype-xml"/></div></td>
<td class="align-middle">{$source/data()}</td>
<td class="align-middle">{string($source/@size)}</td>
<td class="align-middle"><sl-relative-time title="{string($source/@modified-date)}" date="{string($source/@modified-date)}" lang="fr-FR"></sl-relative-time></td>
<td class="text-center align-middle">
<sl-icon-button name="download" title="télécharger" onclick="downloadSource('{$source/data()}')">
</sl-icon-button>
<sl-icon-button name="hand-index" title="déplacer" onclick="openMoveSourceDialog('{$source/data()}')">
......@@ -94,7 +98,26 @@
</sl-icon-button>
</td>
</tr>
else()
}
{
for $dir in $sources
where local-name($dir)='dir'
let $path := if($collection = '/') then $dir/data() else $collection || '/' || $dir/data()
return
<tr id="{$dir/data()}">
<td onclick="window.location.href='{concat('/bundles/max-db?collection=',$path)}'" style="cursor:pointer;" class="align-middle"><div style="font-size: 24px;"><sl-icon-button name="folder2"/></div></td>
<td onclick="window.location.href='{concat('/bundles/max-db?collection=',$path)}'" style="cursor:pointer;" class="align-middle">{$dir/data()}</td>
<td onclick="window.location.href='{concat('/bundles/max-db?collection=',$path)}'" style="cursor:pointer;" class="align-middle"></td>
<td onclick="window.location.href='{concat('/bundles/max-db?collection=',$path)}'" style="cursor:pointer;" class="align-middle"><sl-relative-time title="{string($dir/@modified-date)}" date="{string($dir/@modified-date)}" lang="fr-FR"></sl-relative-time></td>
<td class="text-center align-middle" onclick="">
<sl-icon-button name="download" title="télécharger" onclick="downloadCollection('{$path}')">
</sl-icon-button>
<sl-icon-button name="hand-index" title="déplacer" onclick="openMoveCollectionDialog('{$path}')">
</sl-icon-button>
<sl-icon-button name="trash" title="supprimer" onclick="deleteCollection('{$path}')">
</sl-icon-button>
</td>
</tr>
}
</tbody>
</table>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment