mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
resourcePath config value
This commit is contained in:
@ -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 + this.resourcePath + "/" + file.hash)
|
||||
window.open(window.location.protocol + "//" + window.location.host + this.resourcePath + "/" + file.hash, '_blank');
|
||||
}
|
||||
_getDropzoneFilesFormData() {
|
||||
var files = this.dropzone.files;
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user