Commit 77f63245 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Documentation/UsersManual/index.rst: merge conflict resolved

parents 4c7b2ef3 6e527318
......@@ -496,7 +496,11 @@ Class: Native
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|type | enum('checkbox', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'note', 'password', 'radio', 'select', 'subrecord', |
| | 'textarea', 'timeJQW', 'upload', 'fieldset', 'pill', 'before_load', 'before_save', 'before_insert', 'before_update', |
<<<<<<< HEAD
| | 'before_delete', 'after_load', 'after_save', 'after_insert', 'after_update', 'after_delete', 'feGroup', 'sendmail' ). |
=======
| | 'before_delete', 'after_load', 'after_save', 'after_insert', 'after_update', 'after_delete', 'feGroup', 'sendmail') |
>>>>>>> origin/raos_work
+--------------+-----------------------------+---------------------------------------------------------------------------------------------------+
|checkType | enum('min|max', 'pattern', | |
| | 'number', 'email') | |
......@@ -1065,8 +1069,8 @@ Columns of the upper level result can be accessed via variables, eg. {{10.person
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Parent** |The level 20.25 has a parent **20** |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|**Example |**10** and **20** is a root level and will be executed independently. **10** doesn't have a sub level. **20.20** will be executed as many times as **20** has row numbers. **20.30.10** won't be executed because there |
|explanation**|is no **20.30** level |
|**Example |**10** and **20** are root level and will be executed independently. **10** don't have a sub level. **20.25** will be executed as many times as **20** has row numbers. **20.30.10** won't be executed because there isn't |
|explanation**|any **20.30** level |
+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
......
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
/* global $ */
if (!QfqNS) {
var QfqNS = {};
}
(function (n) {
'use strict';
n.FileUpload = function (formSelector, targetUrl, sip) {
this.formSelector = formSelector;
this.targetUrl = targetUrl;
this.sip = sip;
// TODO: Seriously, I'd like to have an event system.
this.fileUploadStartCallbacks = new n.Helper.FunctionList();
this.fileUploadEndCallbacks = new n.Helper.FunctionList();
this.fileUploadSuccessCallbacks = new n.Helper.FunctionList();
this.fileUploadErrorCallbacks = new n.Helper.FunctionList();
this.setupOnChangeHandler();
};
/**
* @public
* @param handler
*/
n.FileUpload.prototype.addFileUploadStartHandler = function (handler) {
this.fileUploadStartCallbacks.addFunction(handler);
};
/**
* @public
* @param handler
*/
n.FileUpload.prototype.addFileUploadEndHandler = function (handler) {
this.fileUploadEndCallbacks.addFunction(handler);
};
/**
* @public
* @param handler
*/
n.FileUpload.prototype.addFileUploadSuccessHandler = function (handler) {
this.fileUploadSuccessCallbacks.addFunction(handler);
};
/**
* @public
* @param handler
*/
n.FileUpload.prototype.addFileUploadErrorHandler = function (handler) {
this.fileUploadErrorCallbacks.addFunction(handler);
};
/**
*
* @private
*/
n.FileUpload.prototype.setupOnChangeHandler = function () {
$(this.formSelector + " :file").on('change', this.handleFileUpload.bind(this));
};
/**
* @private
* @param event
*/
n.FileUpload.prototype.handleFileUpload = function (event) {
this.fileUploadStartCallbacks.call(event);
var data = this.prepareData(event.target);
$.ajax({
url: this.targetUrl,
type: 'POST',
data: data,
cache: false,
processData: false,
contentType: false
})
.done(this.ajaxSuccessHandler.bind(this))
.fail(this.ajaxErrorHandler.bind(this));
};
n.FileUpload.prototype.prepareData = function (htmlFileInput) {
if (!htmlFileInput.hasAttribute("name")) {
throw new Error("File input element requires 'name' attribute");
}
var fileInputName = htmlFileInput.getAttribute('name');
var data = new FormData();
$.each(htmlFileInput.files, function (key, value) {
data.append(fileInputName + '_' + key, value);
});
data.append('s', this.sip);
return data;
};
/**
* @private
* @param data
* @param textStatus
* @param jqXHR
*/
n.FileUpload.prototype.ajaxSuccessHandler = function (data, textStatus, jqXHR) {
this.fileUploadSuccessCallbacks.call(data, textStatus);
this.fileUploadEndCallbacks.call(this);
};
/**
* @private
* @param jqXHR
* @param textStatus
* @param errorThrown
*/
n.FileUpload.prototype.ajaxErrorHandler = function (jqXHR, textStatus, errorThrown) {
this.fileUploadErrorCallbacks.call(textStatus, errorThrown);
this.fileUploadEndCallbacks.call(this);
};
})(QfqNS);
......@@ -11,12 +11,14 @@ if (!QfqNS) {
(function (n) {
'use strict';
n.QfqForm = function (formId, submitTo, deleteUrl, dataRefreshUrl) {
n.QfqForm = function (formId, submitTo, deleteUrl, dataRefreshUrl, fileUploadTo) {
this.formId = formId;
this.submitTo = submitTo;
this.deleteUrl = deleteUrl;
this.dataRefreshUrl = dataRefreshUrl;
this.fileUploadTo = fileUploadTo;
this.form = new n.Form(this.formId);
// This is required when displaying validation messages, in to activate the tab, which has validation issues
this.bsTabs = null;
this.lastButtonPress = null;
this.destroyFormUserCallbacks = new n.Helper.FunctionList();
......@@ -34,6 +36,8 @@ if (!QfqNS) {
this.getDeleteButton().click(this.handleDeleteClick.bind(this));
this.setupFormUpdateHandler();
this.fileUploader = new QfqNS.FileUpload('#' + this.formId, this.fileUploadTo, this.getSip());
};
n.QfqForm.prototype.setBsTabs = function (bsTabs) {
......@@ -463,7 +467,7 @@ if (!QfqNS) {
*/
n.QfqForm.prototype.setHelpBlockValidationMessage = function (formControlName, text) {
/*
* Why is this method here and not in FormGroup? Adding this particluar method to FormGroup is easy, however
* Why is this method here and not in FormGroup? Adding this particular method to FormGroup is easy, however
* QfqForm.clearAllValidationStates() would not find its proper place in FormGroup, since FormGroup operates
* on one element. We would end up having the responsibilities spread across several classes, which would be
* confusing.
......@@ -523,4 +527,13 @@ if (!QfqNS) {
}
};
/**
* Retrieve SIP as stored in hidden input field.
*
* @returns {string} sip
*/
n.QfqForm.prototype.getSip = function () {
return $('#' + this.formId + ' input[name=s]').val();
};
})(QfqNS);
\ No newline at end of file
......@@ -20,6 +20,7 @@ if (!QfqNS) {
submitTo: "typo3conf/ext/qfq/qfq/api/save.php",
deleteUrl: "typo3conf/ext/qfq/qfq/api/delete.php",
refreshUrl: "typo3conf/ext/qfq/qfq/api/load.php",
fileUploadTo: "typo3conf/ext/qfq/qfq/api/upload.php",
pageState: new QfqNS.PageState()
}, settings
);
......@@ -48,7 +49,8 @@ if (!QfqNS) {
this.settings.formId,
this.settings.submitTo,
this.settings.deleteUrl,
this.settings.refreshUrl);
this.settings.refreshUrl,
this.settings.fileUploadTo);
this.qfqForm.setBsTabs(this.bsTabs);
this.qfqForm.destroyFormUserCallbacks.addFunction(this.destroyFormHandler.bind(this));
} catch (e) {
......
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
var_dump($_POST);
foreach ($_FILES as $key => $value) {
echo "$key";
echo file_get_contents($value['tmp_name']);
}
......@@ -93,6 +93,7 @@
<form id="myForm" class="form-horizontal">
<input type="hidden" name="s" value="badcaffee1234">
<div class="tab-content">
<!--pill: Person-->
......@@ -624,6 +625,18 @@
<!--pill: Arbeitsgruppe-->
<div role="tabpanel" class="tab-pane" id="arbeitsgruppe">
<div class="form-group">
<div class="col-md-2">
<label for="fileupload" class="control-label">File upload</label>
</div>
<div class="col-md-6">
<input id="fileupload" type="file" name="fileupload" class="form-control">
</div>
<div class=" col-md-4">
<p class="help-block"></p>
</div>
</div>
<!--Sekretariat fuer Arbeitsgruppe (subrecord)-->
<!--Arbeitsgruppe (subrecord)-->
</div>
......@@ -959,7 +972,8 @@
tabsId: 'myTabs',
formId: 'myForm',
submitTo: 'api/' + $("#submitTo").val(),
deleteUrl: 'api/' + $("#deleteUrl").val()
deleteUrl: 'api/' + $("#deleteUrl").val(),
fileUploadTo: 'api/uploadhandler.php'
});
$("#submitTo").on("change", function (evt) {
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload</title>
</head>
<body>
<form id="myForm">
<label>File
<input name="fileupload" id="fileupload" type="file"></label>
</form>
<button id="submit">Submit</button>
<div id="progress"></div>
<pre id="display"></pre>
<script src="../js/jquery.min.js"></script>
<script src="../js/qfq.debug.js"></script>
<script>
var fileUpload = new QfqNS.FileUpload('#myForm', 'api/uploadhandler.php', 'the_sip');
fileUpload.addFileUploadStartHandler(function () {
$('#progress').empty().append('<p>Upload started</p>');
});
fileUpload.addFileUploadEndHandler(function () {
$('#progress').append('<p>Upload finished</p>');
});
fileUpload.addFileUploadSuccessHandler(function (data) {
$('#progress').append('<p>Upload success</p>');
$('#display').empty().append(data);
});
fileUpload.addFileUploadErrorHandler(function () {
$('#progress').append('<p>Upload made a booboo</p>');
});
$('#submit').click(function () {
$.post('upload.html', $('#myForm').serialize());
});
</script>
</body>
</html>
\ No newline at end of file
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