Commit 75598195 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge remote-tracking branch 'origin/raos_work' into crose_work

parents bd9014f9 a232579c
......@@ -38,51 +38,7 @@ var QfqNS = QfqNS || {};
n.FileDelete.prototype.performFileDelete = function (event) {
this.eventEmitter.emitEvent('filedelete.started', n.EventEmitter.makePayload(event.target, null));
var data = this.prepareData(event.target);
$.ajax({
url: this.targetUrl,
type: 'POST',
data: data,
cache: false
})
.done(this.ajaxSuccessHandler.bind(this, event.target))
.fail(this.ajaxErrorHandler.bind(this, event.target));
};
n.FileDelete.prototype.prepareData = function (htmlButton) {
if (!htmlButton.hasAttribute("name")) {
throw new Error("File delete button element requires 'name' attribute");
}
var fileDeleteName = htmlButton.getAttribute('name');
var data = {
s: this.sip,
name: fileDeleteName
};
return data;
this.eventEmitter.emitEvent('filedelete.delete.successful', n.EventEmitter.makePayload(event.target, null));
this.eventEmitter.emitEvent('filedelete.ended', n.EventEmitter.makePayload(event.target, null));
};
n.FileDelete.prototype.ajaxSuccessHandler = function (uploadTriggeredBy, data, textStatus, jqXHR) {
var eventData = n.EventEmitter.makePayload(uploadTriggeredBy, data, {
textStatus: textStatus,
jqXHR: jqXHR
});
this.eventEmitter.emitEvent('filedelete.delete.successful', eventData);
this.eventEmitter.emitEvent('filedelete.ended', eventData);
};
n.FileDelete.prototype.ajaxErrorHandler = function (uploadTriggeredBy, jqXHR, textStatus, errorThrown) {
var eventData = n.EventEmitter.makePayload(uploadTriggeredBy, null, {
textStatus: textStatus,
errorThrown: errorThrown,
jqXHR: jqXHR
});
this.eventEmitter.emitEvent('filedelete.delete.failed', eventData);
this.eventEmitter.emitEvent('filedelete.ended', eventData);
};
})(QfqNS);
\ No newline at end of file
......@@ -22,13 +22,12 @@ var QfqNS = QfqNS || {};
* @param fileUploadTo {string} url used for file uploads
* @constructor
*/
n.QfqForm = function (formId, submitTo, deleteUrl, dataRefreshUrl, fileUploadTo, fileDeleteUrl) {
n.QfqForm = function (formId, submitTo, deleteUrl, dataRefreshUrl, fileUploadTo) {
this.formId = formId;
this.submitTo = submitTo;
this.deleteUrl = deleteUrl;
this.dataRefreshUrl = dataRefreshUrl;
this.fileUploadTo = fileUploadTo;
this.fileDeleteUrl = fileDeleteUrl;
this.form = new n.Form(this.formId);
// This is required when displaying validation messages, in to activate the tab, which has validation issues
......@@ -85,15 +84,6 @@ var QfqNS = QfqNS || {};
* @private
*/
n.QfqForm.prototype.fileDeleteSuccessHandler = function (obj) {
if (!obj.data.status) {
throw Error("Response on file upload missing status");
}
if (obj.data.status === "error") {
var alert = new n.Alert(obj.data.message, "error");
alert.show();
return;
}
var $button = $(obj.target);
$button.prop("disabled", true);
......
......@@ -20,7 +20,6 @@ var QfqNS = QfqNS || {};
deleteUrl: "typo3conf/ext/qfq/qfq/api/delete.php",
refreshUrl: "typo3conf/ext/qfq/qfq/api/load.php",
fileUploadTo: "typo3conf/ext/qfq/qfq/api/upload.php",
fileDeleteUrl: "typo3conf/ext/qfq/qfq/api/filedelete.php",
pageState: new n.PageState()
}, settings
);
......@@ -49,8 +48,7 @@ var QfqNS = QfqNS || {};
this.settings.submitTo,
this.settings.deleteUrl,
this.settings.refreshUrl,
this.settings.fileUploadTo,
this.settings.fileDeleteUrl);
this.settings.fileUploadTo);
this.qfqForm.setBsTabs(this.bsTabs);
this.qfqForm.on('qfqform.destroyed', this.destroyFormHandler.bind(this));
} catch (e) {
......
......@@ -45,14 +45,6 @@
</select>
</label>
<label>File Delete Url
<select name="fileDeleteUrl" id="fileDeleteUrl">
<option>404 error</option>
<option>delete_file_ok.json</option>
<option>delete_file_error.json</option>
</select>
</label>
<div class="container-fluid">
<div class="row hidden-xs">
......@@ -1020,8 +1012,7 @@
formId: 'myForm',
submitTo: 'api/' + $("#submitTo").val(),
deleteUrl: 'api/' + $("#deleteUrl").val(),
fileUploadTo: 'api/' + $("#uploadTo").val(),
fileDeleteUrl: 'api/' + $("#fileDeleteUrl").val(),
fileUploadTo: 'api/' + $("#uploadTo").val()
});
$("#submitTo").on("change", function (evt) {
......@@ -1039,11 +1030,6 @@
qfqPage.qfqForm.fileUploader.targetUrl = 'api/' + $(evt.target).val();
});
$("#fileDeleteUrl").on("change", function (evt) {
qfqPage.settings.fileDeleteUrl = 'api/' + $(evt.target).val();
qfqPage.qfqForm.fileDeleter.targetUrl = 'api/' + $(evt.target).val();
});
$('#myForm').on('invalid', function () {
console.log("Invalid event catched");
});
......
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