| author | rougeronj |
| Mon, 22 Dec 2014 12:38:16 +0100 | |
| changeset 350 | 0b6f2883a67b |
| parent 316 | 242510015401 |
| permissions | -rw-r--r-- |
| 222 | 1 |
<!DOCTYPE html> |
|
224
0167b777ad15
remove deprecated warnings + fix date picker default langauge
ymh <ymh.work@gmail.com>
parents:
222
diff
changeset
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" th:lang="${#ctx.getLocale().toLanguageTag()}" > |
| 222 | 3 |
<head> |
4 |
<meta charset="utf-8"/> |
|
5 |
<title>User form</title> |
|
6 |
</head> |
|
7 |
<body> |
|
8 |
<div id="userForm" th:fragment="userFormFragment" > |
|
9 |
<script type="text/javascript" th:inline="javascript"> |
|
10 |
//<![CDATA[ |
|
11 |
||
12 |
function userFormSubmit() { |
|
13 |
||
| 225 | 14 |
var errors = {}; |
15 |
var valid = true; |
|
16 |
||
17 |
if(!$('#title').val()) { |
|
18 |
errors['title'] = /*[[#{renkan.error.title.empty}]]*/"renkan.error.title.empty"; |
|
19 |
valid = false; |
|
20 |
} |
|
21 |
||
22 |
var password = $('#password').val(); |
|
| 226 | 23 |
var passwordConf = $('#passwordConfirm').val(); |
| 225 | 24 |
var objId = $('#id').val(); |
| 222 | 25 |
|
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
26 |
if(!objId && !password) { |
| 225 | 27 |
errors['password'] = /*[[#{renkan.error.password.missing}]]*/"renkan.error.passwsord.missing"; |
28 |
valid = false; |
|
29 |
} |
|
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
30 |
if(valid && password !== passwordConf) { |
| 225 | 31 |
errors['password'] = /*[[#{renkan.error.password.equals}]]*/"renkan.error.passwsord.equals"; |
32 |
valid = false; |
|
33 |
} |
|
| 222 | 34 |
|
35 |
showformErrors(errors); |
|
36 |
||
37 |
return valid; |
|
38 |
} |
|
39 |
|
|
40 |
|
|
41 |
$(function(){ |
|
|
224
0167b777ad15
remove deprecated warnings + fix date picker default langauge
ymh <ymh.work@gmail.com>
parents:
222
diff
changeset
|
42 |
var regionalValue = /*[[${#ctx.getLocale().getLanguage()}]]*/""; |
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
43 |
var dateFormat = /*[[#{date.date.datePicker.format}]]*/"yy/mm/dd"; |
|
224
0167b777ad15
remove deprecated warnings + fix date picker default langauge
ymh <ymh.work@gmail.com>
parents:
222
diff
changeset
|
44 |
$.datepicker.setDefaults($.datepicker.regional[ "" ]); |
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
45 |
$('.datepicker').each(function (i,elt) { |
| 233 | 46 |
var picker_options = $.extend({showButtonPanel: true},$.datepicker.regional[regionalValue=="en"?"":regionalValue]); |
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
47 |
picker_options.dateFormat = dateFormat; |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
48 |
picker_options.altFormat = $.datepicker.ISO_8601; |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
49 |
var elt = $(elt); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
50 |
picker_options.altField = '#'+elt.attr('id').replace('-disp', ''); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
51 |
elt.datepicker(picker_options); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
52 |
}); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
53 |
|
| 222 | 54 |
$('#color').spectrum({ |
| 225 | 55 |
showInput: true, |
56 |
showAlpha: true, |
|
57 |
showPalette: true, |
|
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
58 |
showInitial: true, |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
59 |
preferredFormat: 'hex' |
| 222 | 60 |
}); |
| 225 | 61 |
$("#model-form").submit(function(e) { |
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
62 |
$('.datepicker').each(function (i,elt) { |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
63 |
var elt = $(elt); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
64 |
elt_val = elt.val(); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
65 |
console.log(elt.attr('id'),elt_val); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
66 |
if(!elt_val) { |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
67 |
$('#'+elt.attr('id').replace('-disp', '')).val(""); |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
68 |
} |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
69 |
}); |
| 225 | 70 |
return userFormSubmit(); |
71 |
}); |
|
72 |
|
|
| 222 | 73 |
}); |
74 |
//]]> |
|
75 |
</script> |
|
| 225 | 76 |
<form action="#" th:object="${user}" th:action="@{/admin/users/save}" method="post" id="model-form"> |
| 222 | 77 |
<fieldset class="form-fields"> |
78 |
<input type="hidden" th:field="*{id}" th:if="*{id}" /> |
|
79 |
<div> |
|
| 226 | 80 |
<label for="title" th:text="#{renkanAdmin.form.name}">Name: </label> |
| 222 | 81 |
<input type="text" th:field="*{title}" /> |
82 |
<div th:if="${#fields.hasErrors('title')}" th:errors="*{title}" class="form-error"></div> |
|
83 |
</div> |
|
84 |
<div> |
|
85 |
<label for="uri" th:text="#{renkanAdmin.form.uri}">Uri: </label> |
|
86 |
<input type="text" th:field="*{uri}" /> |
|
87 |
</div> |
|
88 |
<div> |
|
89 |
<label for="description" th:text="#{renkanAdmin.form.description}">Description: </label> |
|
90 |
<textarea th:field="*{description}"></textarea> |
|
91 |
</div> |
|
92 |
<div> |
|
93 |
<label for="color" th:text="#{renkanAdmin.form.color}">Color: </label> |
|
94 |
<input type="text" th:field="*{color}" /> |
|
95 |
</div> |
|
96 |
<div> |
|
97 |
<label for="avatar" th:text="#{renkanAdmin.form.avatar}">Avatar: </label> |
|
98 |
<input type="text" th:field="*{avatar}" /> |
|
99 |
</div> |
|
100 |
<div> |
|
| 225 | 101 |
<label for="password" th:text="#{renkanAdmin.form.password}">Password: </label> |
102 |
<input type="password" th:field="*{password}" /> |
|
|
227
0877747b0213
put password encoder where it can be injected
ymh <ymh.work@gmail.com>
parents:
226
diff
changeset
|
103 |
<div th:if="${#fields.hasErrors('password')}" th:errors="*{password}" class="form-error"></div> |
| 225 | 104 |
</div> |
105 |
<div> |
|
106 |
<label for="passwordConfirm" th:text="#{renkanAdmin.form.passwordConfirm}">Confirm password: </label> |
|
107 |
<input type="password" th:field="*{passwordConfirm}" /> |
|
|
227
0877747b0213
put password encoder where it can be injected
ymh <ymh.work@gmail.com>
parents:
226
diff
changeset
|
108 |
<div th:if="${#fields.hasErrors('passwordConfirm')}" th:errors="*{passwordConfirm}" class="form-error"></div> |
| 225 | 109 |
</div> |
110 |
<div> |
|
|
237
0e6c826a046e
Add group and user management on user and group repositories + unit tests
ymh <ymh.work@gmail.com>
parents:
234
diff
changeset
|
111 |
<label for="credentialsExpirationDate" th:text="#{renkanAdmin.form.credentialsExpirationDate}">Credential expiration date: </label> |
|
0e6c826a046e
Add group and user management on user and group repositories + unit tests
ymh <ymh.work@gmail.com>
parents:
234
diff
changeset
|
112 |
<input type="hidden" name="credentialsExpirationDate" th:field="*{credentialsExpirationDate}"/> |
|
0e6c826a046e
Add group and user management on user and group repositories + unit tests
ymh <ymh.work@gmail.com>
parents:
234
diff
changeset
|
113 |
<input type="text" id="credentialsExpirationDate-disp" class="datepicker" value="01/01/1970" th:value="${user.credentialsExpirationDate != null}?${user.credentialsExpirationDate.toString(#messages.msg('date.date.format'))}:''"/> |
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
114 |
|
| 222 | 115 |
</div> |
116 |
<div> |
|
|
230
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
117 |
<label for="expirationDate" th:text="#{renkanAdmin.form.expirationDate}">Expiration date: </label> |
|
793eece3691e
Corrected date management in users.
ymh <ymh.work@gmail.com>
parents:
227
diff
changeset
|
118 |
<input type="hidden" name="expirationDate" th:field="*{expirationDate}" /> |
| 234 | 119 |
<input type="text" id="expirationDate-disp" class="datepicker" value="01/01/1970" th:value="${user.expirationDate != null}?${user.expirationDate.toString(#messages.msg('date.date.format'))}:''"/> |
| 222 | 120 |
</div> |
121 |
<div> |
|
122 |
<label for="email" th:text="#{renkanAdmin.form.email}">Email: </label> |
|
123 |
<input type="email" th:field="*{email}" /> |
|
124 |
</div> |
|
125 |
<div> |
|
126 |
<label for="enabled" th:text="#{renkanAdmin.form.enabled}">Enabled: </label> |
|
127 |
<input type="checkbox" th:field="*{enabled}" /> |
|
128 |
</div> |
|
129 |
<div> |
|
130 |
<label for="locked" th:text="#{renkanAdmin.form.locked}">Locked: </label> |
|
131 |
<input type="checkbox" th:field="*{locked}" /> |
|
132 |
</div> |
|
|
239
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
133 |
<!-- todo: only user of admin group can see that --> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
134 |
<div> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
135 |
<label for="groups" th:text="#{renkanAdmin.form.groups}">Groups: </label> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
136 |
<select th:field="*{groups}" multiple="multiple"> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
137 |
<option th:each="group: ${allGroups}" th:value="${group.id}" th:text="${group.title}">GROUP</option> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
138 |
</select> |
|
67c2b0fb9b19
add user and group list in group and user edit pages
ymh <ymh.work@gmail.com>
parents:
237
diff
changeset
|
139 |
</div> |
| 231 | 140 |
<div> |
141 |
<label for="userAuthorities" th:text="#{renkanAdmin.form.roles}">Roles: </label> |
|
142 |
<select th:field="*{userAuthorities}" multiple="multiple"> |
|
143 |
<option th:each="role: ${T(org.iri_research.renkan.Constants).USER_ROLES_SELECT}" th:value="${role}" th:text="#{${'renkan.user.roles.'+role}}">USER_ROLE</option> |
|
144 |
</select> |
|
145 |
</div> |
|
| 222 | 146 |
<div class="submit"> |
147 |
<button type="submit" name="save" th:text="#{renkanAdmin.form.user.submit}">Save</button> |
|
148 |
<!--button type="button" name="cancel" th:text="#{renkanAdmin.form.user.cancel}" th:onclick="location">Cancel</button--> |
|
149 |
</div> |
|
150 |
||
151 |
</fieldset> |
|
152 |
</form> |
|
153 |
</div> |
|
154 |
</body> |
|
155 |
</html> |