Commit 3c0b15fd authored by Carsten  Rose's avatar Carsten Rose
Browse files

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

parents 2c9cbcbd f0c9e1b4
......@@ -90,6 +90,7 @@ Save Button
-----------
* User presses the button
* Reset all validation states
* Client validates HTML Form
* Form is submitted to server
* Success:
* Show message provided by server
......@@ -111,6 +112,8 @@ Close Button
* Yes: Client redirects to previous page.
* No: Client stays on current page.
* Save & Close:
* Client reset all validation states
* Client validates HTML Form
* Client submits form to server.
* Success: Process server response 'redirect':
* 'client': Client shows previous page.
......@@ -139,6 +142,8 @@ New Button
* Form not modified by user: Client redirects to href url.
* Form modified by user: Ask User 'You have unsaved changes. Do you want to save first?'
* Yes:
* Client reset all validation states
* Client validates HTML Form
* Form is submitted to server
* Success:
* Client: Ignore server reponse 'redirect'. Client redirects to href url.
......
......@@ -79,6 +79,28 @@ module.exports = function (grunt) {
}
]
},
bootstrap_validator: {
files: [
{
cwd: 'bower_components/bootstrap-validator/dist/',
src: [
'validator.min.js'
],
dest: 'js/',
expand: true,
flatten: true
},
{
cwd: 'bower_components/bootstrap-validator/dist/',
src: [
'validator.min.js'
],
dest: typo3_js,
expand: true,
flatten: true
}
]
},
jquery: {
files: [
{
......
......@@ -20,6 +20,7 @@
"bootstrap": "~3.3.6",
"jqwidgets": "*",
"tablesorter": "jquery.tablesorter#^2.25.6",
"eventEmitter": "^4.3.0"
"eventEmitter": "^4.3.0",
"bootstrap-validator": "^0.10.2"
}
}
......@@ -31,6 +31,16 @@ QfqNS.Element = QfqNS.Element || {};
case 'radio':
return new n.Radio($element);
case 'text':
case 'number':
case "email":
case "url":
case "passoword":
case "datetime":
case "datetime-local":
case "date":
case "month":
case "time":
case "week":
return new n.Text($element);
default:
throw new Error("Don't know how to handle <input> of type '" + type + "'");
......
......@@ -92,4 +92,17 @@ var QfqNS = QfqNS || {};
// REMOVE: this.userSubmitFailureHandlers.call(this, textStatus, jqXHR, errorThrown);
};
/**
* @public
* @returns {*}
*/
n.Form.prototype.validate = function () {
// uncommented because bootstrap-validator sets novalidate="true" on form.
//if (this.$form.attr('novalidate')) {
// return true;
//}
return document.forms[this.formId].checkValidity();
};
})(QfqNS);
......@@ -163,7 +163,7 @@ var QfqNS = QfqNS || {};
// First, remove all validation states, in case a previous submit has set a validation state, thus we're not
// stockpiling them.
this.clearAllValidationStates();
this.form.submitTo(this.submitTo);
this.submit();
};
/**
......@@ -175,7 +175,7 @@ var QfqNS = QfqNS || {};
var alert = new n.Alert("You have unsaved changes. Do you want to close?", "warning", "yesnosave");
var that = this;
alert.on('alert.save', function () {
that.form.submitTo(that.submitTo);
that.submit();
});
alert.on('alert.ok', function () {
window.history.back();
......@@ -186,6 +186,17 @@ var QfqNS = QfqNS || {};
}
};
n.QfqForm.prototype.submit = function () {
if (this.form.validate() !== true) {
this.form.$form.validator('validate');
var alert = new n.Alert("Form is incomplete.", "warning");
alert.show();
return;
}
this.form.submitTo(this.submitTo);
};
/**
* @private
*/
......@@ -197,7 +208,7 @@ var QfqNS = QfqNS || {};
var alert = new n.Alert("You have unsaved changes. Do you want to close?", "warning", "yesnosave");
var that = this;
alert.on('alert.save', function () {
that.form.submitTo(that.submitTo);
that.submit();
});
alert.on('alert.ok', function () {
var anchorTarget = that.getNewButtonTarget();
......
......@@ -100,7 +100,7 @@
</div>
<form id="myForm" class="form-horizontal">
<form id="myForm" class="form-horizontal" data-toggle="validator">
<input type="hidden" name="s" value="badcaffee1234">
<div class="tab-content">
......@@ -123,7 +123,7 @@
</div>
<div class="col-md-6">
<input id="name" type="text" class="form-control">
<input id="name" name="name" type="text" class="form-control">
</div>
</div>
......@@ -134,7 +134,9 @@
</div>
<div class="col-md-6">
<input id="firstname" type="text" class="form-control">
<input id="firstname" name="firstname" type="text" class="form-control" required>
<div class="help-block with-errors"></div>
</div>
</div>
......@@ -143,7 +145,10 @@
<label for="nameShort" class="control-label">Vorname Kurz</label>
</div>
<div class="col-md-6">
<input id="nameShort" type="text" class="form-control">
<input id="nameShort" name="shortname" type="text" class="form-control" required
data-error="Short name is required">
<div class="help-block with-errors"></div>
</div>
<div class="col-md-4">
......@@ -156,7 +161,7 @@
<label for="personHandle" class="control-label">Kurzform</label>
</div>
<div class="col-md-6">
<input id="personHandle" type="text" class="form-control">
<input id="personHandle" name="personhandle" type="text" class="form-control">
</div>
<div class="col-md-4">
......@@ -170,7 +175,7 @@
<label for="personTitle" class="control-label">Titel</label>
</div>
<div class="col-md-6">
<select id="personTitle" class="form-control">
<select id="personTitle" class="form-control" name="persontitle">
<option></option>
<option>Dr.</option>
<option>Prof. Dr.</option>
......@@ -771,6 +776,7 @@
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/validator.min.js"></script>
<script src="../js/jqx-all.js"></script>
<script src="../js/EventEmitter.min.js"></script>
<script src="../js/qfq.debug.js"></script>
......@@ -1013,6 +1019,10 @@
qfqPage.qfqForm.fileUploader.targetUrl = 'api/' + $(evt.target).val();
});
$('#myForm').on('invalid', function () {
console.log("Invalid event catched");
});
QfqNS.Log.level = 0;
});
</script>
......
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