Merge branch 'main' into fix/permisos-mensajeria-sidebar

This commit is contained in:
amazuecos
2025-04-06 09:49:46 +02:00
32 changed files with 689 additions and 153 deletions

View File

@ -23,7 +23,7 @@ const PREVIEW_TEMPLATE = `
class FileUploadDropzone {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null }) {
constructor({ domElement, nameId = "presupuesto_id", getUri = null, postUri = null, resourcePath = "presupuestos" }) {
Dropzone.autoDiscover = false;
this.domElement = domElement
this.jqElement = $(domElement)
@ -35,6 +35,7 @@ class FileUploadDropzone {
this.getUri = getUri
this.postUri = postUri
this.dataPost[nameId] = this.modelId;
this.resourcePath = resourcePath
}
init() {
@ -58,19 +59,21 @@ class FileUploadDropzone {
maxFilesize: 5e+7, // Bytes
init: this._handleGetFiles.bind(this)
});
this.dropzone.on("addedfile", function (file) {
if (file.hash) {
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
file.previewElement.appendChild(viewButton);
// Listen to the view button click event
viewButton.addEventListener("click", function (e) {
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/presupuestos/" + file.hash, '_blank');
});
}
});
this.dropzone.on("addedfile", this._handleAddedFile.bind(this));
}
}
_handleAddedFile(file) {
if (file.hash) {
var viewButton = Dropzone.createElement("<span class='dz-remove'>Ver</span>");
file.previewElement.appendChild(viewButton);
// Listen to the view button click event
viewButton.addEventListener("click", this.onViewButton.bind(this,file));
}
}
onViewButton(file) {
console.log(window.location.protocol + "//" + window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + file.hash)
window.open(window.location.protocol + "//" + window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + file.hash, '_blank');
}
_getDropzoneFilesFormData() {
var files = this.dropzone.files;
@ -81,7 +84,7 @@ class FileUploadDropzone {
if (files[i].upload) {
var file = files[i];
formData.append('file[' + counter + ']', file);
formData.append('file[]', file);
counter += 1;
}
else {
@ -146,7 +149,7 @@ class FileUploadDropzone {
dropZoneAddFile(mockFile) {
this.dropzone.files.push(mockFile); // add to files array
this.dropzone.emit("addedfile", mockFile);
this.dropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/presupuestos/" + mockFile.hash);
this.dropzone.emit("thumbnail", mockFile, window.location.host + "/sistema/intranet/" + this.resourcePath + "/" + mockFile.hash);
this.dropzone.emit("complete", mockFile);
this.dropzone.options.success.call(this.dropzone, mockFile);