diff --git a/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js b/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js
index edfc9bb4..6f2ec78b 100644
--- a/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js
+++ b/httpdocs/assets/js/safekat/components/forms/fileUploadDropzone.js
@@ -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("Ver");
- 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("Ver");
+ 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);