|
123
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" |
|
|
3 |
xmlns:th="http://www.thymeleaf.org"> |
|
|
4 |
<head> |
|
127
|
5 |
<meta charset="utf-8"/> |
|
123
|
6 |
<title>Space form</title> |
|
|
7 |
</head> |
|
|
8 |
<body> |
|
127
|
9 |
<div id="spaceForm" th:fragment="spaceFormFragment" > |
|
|
10 |
<script type="text/javascript" th:inline="javascript"> |
|
|
11 |
//<![CDATA[ |
|
|
12 |
|
|
|
13 |
function showformErrors(errors) { |
|
|
14 |
$(".form-error").remove(); |
|
|
15 |
|
|
|
16 |
$.each(errors,function(k,v){ |
|
|
17 |
$("#"+k).after('<div class="form-error">'+v+'</div>'); |
|
|
18 |
}); |
|
|
19 |
$(".form-error").effect("highlight", {}, 1500); |
|
|
20 |
} |
|
|
21 |
|
|
|
22 |
function spaceFormSubmit() { |
|
|
23 |
|
|
|
24 |
var errors = {}; |
|
|
25 |
var valid = true; |
|
|
26 |
|
|
|
27 |
if(!$('#title').val()) { |
|
|
28 |
errors['title'] = /*[[#{renkan.error.title.empty}]]*/"renkan.error.title.empty"; |
|
|
29 |
valid = false; |
|
|
30 |
} |
|
|
31 |
|
|
|
32 |
try |
|
|
33 |
{ |
|
|
34 |
var json = JSON.parse($('#binConfig').val()); |
|
|
35 |
} |
|
|
36 |
catch(e) |
|
|
37 |
{ |
|
|
38 |
console.log(e); |
|
|
39 |
errors['binConfigDiv'] = /*[[#{renkan.error.bin_config.json}]]*/"renkan.error.bin_config.json"; |
|
|
40 |
valid = false; |
|
|
41 |
} |
|
|
42 |
|
|
|
43 |
showformErrors(errors); |
|
|
44 |
|
|
|
45 |
return valid; |
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
$(function(){ |
|
|
49 |
var editor = ace.edit("binConfigDiv"); |
|
|
50 |
editor.setTheme("ace/theme/xcode"); |
|
|
51 |
editor.getSession().setMode("ace/mode/json"); |
|
|
52 |
editor.getSession().on('change', function(e) { |
|
|
53 |
$('#binConfig').val(editor.getValue()); |
|
|
54 |
}); |
|
|
55 |
|
|
|
56 |
$('#color').spectrum({ |
|
|
57 |
showInput: true, |
|
|
58 |
showAlpha: true, |
|
|
59 |
showPalette: true, |
|
|
60 |
showInitial: true |
|
|
61 |
}); |
|
|
62 |
}); |
|
|
63 |
//]]> |
|
|
64 |
</script> |
|
|
65 |
<form action="#" th:object="${space}" th:action="@{/admin/spaces/save}" method="post" onsubmit="return spaceFormSubmit()"> |
|
|
66 |
<fieldset class="form-fields"> |
|
|
67 |
<input type="hidden" th:field="*{id}" th:if="*{id}" /> |
|
|
68 |
<input type="hidden" th:field="*{binConfig}"/> |
|
|
69 |
<div> |
|
|
70 |
<label for="title" th:text="#{renkanAdmin.form.title}">Title: </label> |
|
|
71 |
<input type="text" th:field="*{title}" /> |
|
|
72 |
<div th:if="${#fields.hasErrors('title')}" th:errors="*{title}" class="form-error"></div> |
|
|
73 |
</div> |
|
|
74 |
<div> |
|
|
75 |
<label for="uri" th:text="#{renkanAdmin.form.uri}">Uri: </label> |
|
|
76 |
<input type="text" th:field="*{uri}" /> |
|
|
77 |
</div> |
|
|
78 |
<div> |
|
|
79 |
<label for="description" th:text="#{renkanAdmin.form.description}">Description: </label> |
|
|
80 |
<textarea th:field="*{description}"></textarea> |
|
|
81 |
</div> |
|
|
82 |
<div> |
|
|
83 |
<label for="color" th:text="#{renkanAdmin.form.color}">Color: </label> |
|
|
84 |
<input type="text" th:field="*{color}" /> |
|
|
85 |
</div> |
|
|
86 |
<div> |
|
|
87 |
<label for="binConfigDiv" th:text="#{renkanAdmin.form.space.bin_config}">Bin config: </label> |
|
|
88 |
<div id="binConfigDiv" th:text="*{binConfig}"></div> |
|
|
89 |
<div th:if="${#fields.hasErrors('binConfig')}" th:errors="*{binConfig}" class="form-error"></div> |
|
|
90 |
</div> |
|
123
|
91 |
|
|
|
92 |
<div class="submit"> |
|
127
|
93 |
<button type="submit" name="save" th:text="#{renkanAdmin.form.space.submit}">Save</button> |
|
|
94 |
<!--button type="button" name="cancel" th:text="#{renkanAdmin.form.space.cancel}" th:onclick="location">Cancel</button--> |
|
123
|
95 |
</div> |
|
|
96 |
|
|
|
97 |
</fieldset> |
|
|
98 |
</form> |
|
|
99 |
</div> |
|
|
100 |
</body> |
|
|
101 |
</html> |