--- a/server/src/main/webapp/WEB-INF/templates/fragment/userForm.html Mon Oct 28 18:20:56 2013 +0100
+++ b/server/src/main/webapp/WEB-INF/templates/fragment/userForm.html Mon Nov 04 15:56:44 2013 +0100
@@ -23,11 +23,11 @@
var passwordConf = $('#passwordConfirm').val();
var objId = $('#id').val();
- if(objId && !password) {
+ if(!objId && !password) {
errors['password'] = /*[[#{renkan.error.password.missing}]]*/"renkan.error.passwsord.missing";
valid = false;
}
- if(password !== passwordConf) {
+ if(valid && password !== passwordConf) {
errors['password'] = /*[[#{renkan.error.password.equals}]]*/"renkan.error.passwsord.equals";
valid = false;
}
@@ -40,15 +40,33 @@
$(function(){
var regionalValue = /*[[${#ctx.getLocale().getLanguage()}]]*/"";
+ var dateFormat = /*[[#{date.date.datePicker.format}]]*/"yy/mm/dd";
$.datepicker.setDefaults($.datepicker.regional[ "" ]);
- $('.datepicker').datepicker($.datepicker.regional[regionalValue]);
+ $('.datepicker').each(function (i,elt) {
+ var picker_options = $.extend({},$.datepicker.regional[regionalValue=="en"?"":regionalValue]);
+ picker_options.dateFormat = dateFormat;
+ picker_options.altFormat = $.datepicker.ISO_8601;
+ var elt = $(elt);
+ picker_options.altField = '#'+elt.attr('id').replace('-disp', '');
+ elt.datepicker(picker_options);
+ });
+
$('#color').spectrum({
showInput: true,
showAlpha: true,
showPalette: true,
- showInitial: true
+ showInitial: true,
+ preferredFormat: 'hex'
});
$("#model-form").submit(function(e) {
+ $('.datepicker').each(function (i,elt) {
+ var elt = $(elt);
+ elt_val = elt.val();
+ console.log(elt.attr('id'),elt_val);
+ if(!elt_val) {
+ $('#'+elt.attr('id').replace('-disp', '')).val("");
+ }
+ });
return userFormSubmit();
});
@@ -90,12 +108,15 @@
<div th:if="${#fields.hasErrors('passwordConfirm')}" th:errors="*{passwordConfirm}" class="form-error"></div>
</div>
<div>
- <label for="credentialExpirationDate" th:text="#{renkanAdmin.form.credentialExpirationDate}">Credential expiration date: </label>
- <input type="text" th:field="*{credentialExpirationDate}" class="datepicker"/>
+ <label for="credentialExpirationDate" th:text="#{renkanAdmin.form.credentialExpirationDate}">Credential expiration date: </label>
+ <input type="hidden" name="credentialExpirationDate" th:field="*{credentialExpirationDate}"/>
+ <input type="date" id="credentialExpirationDate-disp" class="datepicker" value="01/01/1970" th:value="${user.credentialExpirationDate != null}?${#dates.format(user.credentialExpirationDate, #messages.msg('date.date.format'))}:''"/>
+
</div>
<div>
- <label for="expirationDate" th:text="#{renkanAdmin.form.expirationDate}">Expiration date: </label>
- <input type="text" th:field="*{expirationDate}" class="datepicker"/>
+ <label for="expirationDate" th:text="#{renkanAdmin.form.expirationDate}">Expiration date: </label>
+ <input type="hidden" name="expirationDate" th:field="*{expirationDate}" />
+ <input type="date" id="expirationDate-disp" class="datepicker" value="01/01/1970" th:value="${user.expirationDate != null}?${#dates.format(user.expirationDate, #messages.msg('date.date.format'))}:''"/>
</div>
<div>
<label for="email" th:text="#{renkanAdmin.form.email}">Email: </label>