Nextcloud ok save doc
This commit is contained in:
@@ -862,6 +862,7 @@ const individui = @json($individui->map(fn($i) => ['id' => $i->id, 'label' => $i
|
||||
const gruppi = @json($gruppi->map(fn($g) => ['id' => $g->id, 'label' => $g->nome]));
|
||||
const eventi = @json($eventi->map(fn($e) => ['id' => $e->id, 'label' => $e->nome_evento]));
|
||||
const mailingLists = @json($mailingLists ? $mailingLists->map(fn($m) => ['id' => $m->id, 'label' => $m->nome]) : []);
|
||||
const cartelle = @json($cartelleMoveOptions);
|
||||
|
||||
function toggleAll(source) {
|
||||
document.querySelectorAll('.doc-checkbox').forEach(cb => cb.checked = source.checked);
|
||||
@@ -1487,7 +1488,8 @@ function renderRemoteContents(contents, repoId, currentPath, view) {
|
||||
if (isPreviewable) {
|
||||
html += '<button type="button" class="btn btn-xs btn-primary" onclick="previewRepoFile(' + repoId + ',\'' + escJs(item.path) + '\',\'' + escJs(item.mimeType || '') + '\')" title="Anteprima"><i class="fas fa-eye"></i></button> ';
|
||||
}
|
||||
html += '<button type="button" class="btn btn-xs btn-info" onclick="downloadRepoFile(' + repoId + ',\'' + escJs(item.path) + '\')" title="Scarica"><i class="fas fa-download"></i></button>';
|
||||
html += '<button type="button" class="btn btn-xs btn-info" onclick="downloadRepoFile(' + repoId + ',\'' + escJs(item.path) + '\')" title="Scarica"><i class="fas fa-download"></i></button> ';
|
||||
html += '<button type="button" class="btn btn-xs btn-success" onclick="importRepoFile(' + repoId + ',\'' + escJs(item.path) + '\',\'' + escJs(item.basename) + '\')" title="Salva tra i documenti"><i class="fas fa-save"></i></button>';
|
||||
html += '</div></div></div>';
|
||||
}
|
||||
});
|
||||
@@ -1495,7 +1497,7 @@ function renderRemoteContents(contents, repoId, currentPath, view) {
|
||||
} else {
|
||||
document.getElementById('remoteGrid').style.display = 'none';
|
||||
document.getElementById('remoteList').style.display = '';
|
||||
var tblHtml = '<table class="table table-bordered table-hover table-striped mb-0"><thead class="thead-light"><tr><th>Nome</th><th style="width:90px;">Dimensione</th><th style="width:100px;">Data</th><th style="width:100px;">Azioni</th></tr></thead><tbody>';
|
||||
var tblHtml = '<table class="table table-bordered table-hover table-striped mb-0"><thead class="thead-light"><tr><th>Nome</th><th style="width:90px;">Dimensione</th><th style="width:100px;">Data</th><th style="width:150px;">Azioni</th></tr></thead><tbody>';
|
||||
contents.forEach(function(item) {
|
||||
if (item.type === 'dir') {
|
||||
tblHtml += '<tr class="table-warning" style="cursor:pointer;" onclick="browseRepo(' + repoId + ',\'' + escJs(currentRepoBrowse ? currentRepoBrowse.nome : '') + '\',\'' + escJs(item.path) + '\')">';
|
||||
@@ -1516,7 +1518,8 @@ function renderRemoteContents(contents, repoId, currentPath, view) {
|
||||
if (isPreviewable) {
|
||||
tblHtml += '<button type="button" class="btn btn-xs btn-primary" onclick="previewRepoFile(' + repoId + ',\'' + escJs(item.path) + '\',\'' + escJs(item.mimeType || '') + '\')" title="Anteprima"><i class="fas fa-eye"></i></button> ';
|
||||
}
|
||||
tblHtml += '<button type="button" class="btn btn-xs btn-info" onclick="downloadRepoFile(' + repoId + ',\'' + escJs(item.path) + '\')" title="Scarica"><i class="fas fa-download"></i></button>';
|
||||
tblHtml += '<button type="button" class="btn btn-xs btn-info" onclick="downloadRepoFile(' + repoId + ',\'' + escJs(item.path) + '\')" title="Scarica"><i class="fas fa-download"></i></button> ';
|
||||
tblHtml += '<button type="button" class="btn btn-xs btn-success" onclick="importRepoFile(' + repoId + ',\'' + escJs(item.path) + '\',\'' + escJs(item.basename) + '\')" title="Salva tra i documenti"><i class="fas fa-save"></i></button>';
|
||||
tblHtml += '</td></tr>';
|
||||
}
|
||||
});
|
||||
@@ -1535,6 +1538,118 @@ function previewRepoFile(repoId, path, mimeType) {
|
||||
$('#previewModal').modal('show');
|
||||
}
|
||||
|
||||
function toggleImportTarget(value) {
|
||||
var group = document.getElementById('swal-target-group');
|
||||
var select = document.getElementById('swal-target-select');
|
||||
if (!value || value === 'pubblico') {
|
||||
group.style.display = 'none';
|
||||
select.innerHTML = '<option value="">-- Nessuno --</option>';
|
||||
return;
|
||||
}
|
||||
group.style.display = 'block';
|
||||
var data = [];
|
||||
if (value === 'individuo') data = individui;
|
||||
else if (value === 'gruppo') data = gruppi;
|
||||
else if (value === 'evento') data = eventi;
|
||||
else if (value === 'mailing') data = mailingLists;
|
||||
select.innerHTML = '<option value="">-- Seleziona --</option>';
|
||||
data.forEach(function(item) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = item.id;
|
||||
opt.textContent = item.label;
|
||||
select.appendChild(opt);
|
||||
});
|
||||
}
|
||||
|
||||
function importRepoFile(repoId, path, basename) {
|
||||
var folderOptions = '<option value="">-- Nessuna --</option>';
|
||||
cartelle.forEach(function(f) {
|
||||
folderOptions += '<option value="' + f.id + '">' + escHtml(f.nome) + '</option>';
|
||||
if (f.children) {
|
||||
f.children.forEach(function(c) {
|
||||
folderOptions += '<option value="' + c.id + '"> ' + escHtml(c.nome) + '</option>';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Swal.fire({
|
||||
title: 'Importa come documento locale',
|
||||
html:
|
||||
'<div class="text-left">' +
|
||||
'<p class="mb-1"><strong>File:</strong> ' + escHtml(basename) + '</p>' +
|
||||
'<div class="form-group mb-2">' +
|
||||
'<label class="small">Tipologia</label>' +
|
||||
'<select id="swal-tipologia" class="form-control form-control-sm">' +
|
||||
'<option value="documento" selected>Documento</option>' +
|
||||
'<option value="avatar">Avatar</option>' +
|
||||
'<option value="galleria">Galleria</option>' +
|
||||
'<option value="statuto">Statuto</option>' +
|
||||
'<option value="altro">Altro</option>' +
|
||||
'</select></div>' +
|
||||
'<div class="form-group mb-2">' +
|
||||
'<label class="small">Cartella (opzionale)</label>' +
|
||||
'<select id="swal-cartella" class="form-control form-control-sm">' + folderOptions + '</select></div>' +
|
||||
'<div class="form-group mb-2">' +
|
||||
'<label class="small">Visibilità</label>' +
|
||||
'<select id="swal-visibilita" class="form-control form-control-sm" onchange="toggleImportTarget(this.value)">' +
|
||||
'<option value="pubblico" selected>Pubblico</option>' +
|
||||
'<option value="individuo">Individuo</option>' +
|
||||
'<option value="gruppo">Gruppo</option>' +
|
||||
'<option value="evento">Evento</option>' +
|
||||
'<option value="mailing">Mailing List</option>' +
|
||||
'</select></div>' +
|
||||
'<div id="swal-target-group" class="form-group mb-0" style="display:none;">' +
|
||||
'<label class="small">Collega a</label>' +
|
||||
'<select id="swal-target-select" class="form-control form-control-sm">' +
|
||||
'<option value="">-- Seleziona --</option>' +
|
||||
'</select></div>' +
|
||||
'</div>',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Importa',
|
||||
cancelButtonText: 'Annulla',
|
||||
preConfirm: function() {
|
||||
var visibilita = document.getElementById('swal-visibilita').value;
|
||||
var targetEl = document.getElementById('swal-target-select');
|
||||
return {
|
||||
tipologia: document.getElementById('swal-tipologia').value,
|
||||
cartella_id: document.getElementById('swal-cartella').value,
|
||||
visibilita: visibilita,
|
||||
visibilita_target_id: visibilita !== 'pubblico' && targetEl && targetEl.value ? targetEl.value : null
|
||||
};
|
||||
}
|
||||
}).then(function(result) {
|
||||
if (!result.isConfirmed) return;
|
||||
var data = result.value;
|
||||
fetch('/storage-repositories/' + repoId + '/import', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name=\"csrf-token\"]').getAttribute('content'),
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
path: path,
|
||||
basename: basename,
|
||||
tipologia: data.tipologia,
|
||||
cartella_id: data.cartella_id || null,
|
||||
visibilita: data.visibilita,
|
||||
visibilita_target_id: data.visibilita_target_id
|
||||
})
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(r) {
|
||||
if (r.success) {
|
||||
Swal.fire('Importato!', r.message, 'success');
|
||||
} else {
|
||||
Swal.fire('Errore', r.message || 'Errore durante l\'importazione.', 'error');
|
||||
}
|
||||
})
|
||||
.catch(function(e) {
|
||||
Swal.fire('Errore', 'Errore di rete: ' + e.message, 'error');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getFileIcon(mimeType, basename) {
|
||||
if (!mimeType) {
|
||||
var ext = (basename || '').split('.').pop().toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user