Commit 4fb45120 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Sip for file upload and file delete comes from data-sip on <input type="file"> or delete <button>

parent 705f5c59
......@@ -11,11 +11,9 @@ var QfqNS = QfqNS || {};
(function (n) {
'use strict';
n.FileDelete = function (formSelector, targetUrl, sip) {
n.FileDelete = function (formSelector, targetUrl) {
this.formSelector = formSelector;
this.targetUrl = targetUrl;
// TODO: make sip part of url or button element
this.sip = sip;
this.eventEmitter = new EventEmitter();
this.setupOnClickHandler();
......@@ -58,7 +56,7 @@ var QfqNS = QfqNS || {};
var fileDeleteName = htmlButton.getAttribute('name');
var data = {
s: this.sip,
s: $(htmlButton).data('sip'),
name: fileDeleteName
};
......
......@@ -13,10 +13,9 @@ var QfqNS = QfqNS || {};
(function (n) {
'use strict';
n.FileUpload = function (formSelector, targetUrl, sip) {
n.FileUpload = function (formSelector, targetUrl) {
this.formSelector = formSelector;
this.targetUrl = targetUrl;
this.sip = sip;
this.eventEmitter = new EventEmitter();
this.setupOnChangeHandler();
......@@ -65,7 +64,7 @@ var QfqNS = QfqNS || {};
data.append(fileInputName + '_' + key, value);
});
data.append('s', this.sip);
data.append('s', $(htmlFileInput).data('sip'));
data.append('name', fileInputName);
return data;
......
......@@ -52,7 +52,7 @@ var QfqNS = QfqNS || {};
this.setupFormUpdateHandler();
this.fileUploader = new n.FileUpload('#' + this.formId, this.fileUploadTo, this.getSip());
this.fileUploader = new n.FileUpload('#' + this.formId, this.fileUploadTo);
this.fileUploader.on('fileupload.started', this.startUploadHandler);
this.fileUploader.on('fileupload.upload.successful', this.fileUploadSuccessHandler);
......@@ -62,7 +62,7 @@ var QfqNS = QfqNS || {};
});
this.fileUploader.on('fileupload.ended', this.endUploadHandler);
this.fileDeleter = new n.FileDelete("#" + this.formId, this.fileDeleteUrl, this.getSip());
this.fileDeleter = new n.FileDelete("#" + this.formId, this.fileDeleteUrl);
this.fileDeleter.on('filedelete.delete.successful', this.fileDeleteSuccessHandler);
this.fileDeleter.on('filedelete.delete.failed',
......
......@@ -654,11 +654,12 @@
<div class="col-md-6">
<div class="col-md-6">
<div class="uploaded-file "><span class="uploaded-file-name">john.doe.png</span>
<button class="delete-file" data-sip="571f23506ad2a"
<button class="delete-file" data-sip="filedeletesip"
name="trash-picture:1"><span
class="glyphicon glyphicon-trash"></span></button>
</div>
<input id="fileupload" name="picture:1" disabled="disabled" class="hidden" type="file">
<input id="fileupload" name="picture:1" disabled="disabled" class="hidden" type="file"
data-sip="fileuploadsip">
<div class="help-block with-errors"></div>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment