|
1 {% extends "base.html" %} |
|
2 |
|
3 {% block title %}{{ application_name }} Development Console - Datastore Viewer - {% if key %}Edit Entity{% else %}New Entity{% endif %}{% endblock %} |
|
4 |
|
5 {% block head %} |
|
6 <style type="text/css">{% include "css/form.css" %}</style> |
|
7 <style type="text/css"> |
|
8 |
|
9 .field_type { |
|
10 color: gray; |
|
11 font-weight: normal; |
|
12 } |
|
13 |
|
14 </style> |
|
15 <script type="text/javascript"> |
|
16 |
|
17 function load() { |
|
18 var elements = document.getElementsByTagName("input"); |
|
19 for (var i = 0; i < elements.length; i++) { |
|
20 var element = elements[i]; |
|
21 var hint = null; |
|
22 if (element.className == "time") { |
|
23 hint = "e.g., 2006-30-05 23:56:04"; |
|
24 } |
|
25 if (hint) registerHint(element, hint); |
|
26 } |
|
27 } |
|
28 |
|
29 function registerHint(element, hint) { |
|
30 function showDefault() { |
|
31 if (element.value.length == 0 || element.value == hint) { |
|
32 element.style.color = "gray"; |
|
33 element.value = hint; |
|
34 } |
|
35 } |
|
36 function clearDefault() { |
|
37 if (element.style.color == "gray" || element.value == hint) { |
|
38 element.value = ""; |
|
39 element.style.color = "black"; |
|
40 } |
|
41 } |
|
42 element.onblur = showDefault; |
|
43 element.onfocus = clearDefault; |
|
44 showDefault(); |
|
45 } |
|
46 |
|
47 function clearHints(form) { |
|
48 var elements = form.getElementsByTagName("input"); |
|
49 for (var i = 0; i < elements.length; i++) { |
|
50 var element = elements[i]; |
|
51 if (element.type == "text" && element.style.color == "gray") { |
|
52 element.onblur = null; |
|
53 element.onfocus = null; |
|
54 element.value = ""; |
|
55 } |
|
56 } |
|
57 return true; |
|
58 } |
|
59 |
|
60 </script> |
|
61 {% endblock %} |
|
62 |
|
63 {% block bodyattributes %}onload="load()"{% endblock %} |
|
64 |
|
65 {% block body %} |
|
66 <h3>{% if key %}Edit Entity{% else %}New Entity{% endif %}</h3> |
|
67 |
|
68 <form action="{{ request.path }}" method="post" onsubmit="return clearHints(this)"> |
|
69 <div><input type="hidden" name="next" value="{{ next }}"/></div> |
|
70 <table class="form"> |
|
71 <tr> |
|
72 <td class="name">Entity Kind</td> |
|
73 <td class="value text"> |
|
74 {{ kind }} |
|
75 <input type="hidden" name="kind" value="{{ kind }}"/> |
|
76 </td> |
|
77 </tr> |
|
78 {% if key %} |
|
79 <tr> |
|
80 <td class="name">Entity Key</td> |
|
81 <td class="value text"> |
|
82 {{ key }} |
|
83 <input type="hidden" name="key" value="{{ key }}"/> |
|
84 </td> |
|
85 </tr> |
|
86 {% endif %} |
|
87 {% if key_name %} |
|
88 <tr> |
|
89 <td class="name">Key Name</td> |
|
90 <td class="value text"> |
|
91 {{ key_name }} |
|
92 </td> |
|
93 </tr> |
|
94 {% endif %} |
|
95 {% if key_id %} |
|
96 <tr> |
|
97 <td class="name">ID</td> |
|
98 <td class="value text"> |
|
99 {{ key_id }} |
|
100 </td> |
|
101 </tr> |
|
102 {% endif %} |
|
103 {% if parent_key %} |
|
104 <tr> |
|
105 <td class="name">Parent</td> |
|
106 <td class="value text"> |
|
107 <a href="?key={{parent_key}}&kind={{parent_kind}}">{{ parent_key }}</a> |
|
108 </td> |
|
109 </tr> |
|
110 {% endif %} |
|
111 {% for field in fields %} |
|
112 <tr> |
|
113 <td class="name"> |
|
114 <span class="field_name">{{ field.0|escape }}</span> |
|
115 <span class="field_type">({{ field.1|escape }})</span> |
|
116 </td> |
|
117 <td class="value"><div style="position: relative">{{ field.2|safe }}</div></td> |
|
118 </tr> |
|
119 {% endfor %} |
|
120 <tr> |
|
121 <td></td> |
|
122 <td class="buttons"> |
|
123 <input type="submit" value="Save Changes"/> |
|
124 {% if key %} |
|
125 <input type="submit" name="action" value="Delete" onclick="return confirm('Are you sure you want to permanently delete this entity?');"/> |
|
126 {% endif %} |
|
127 </td> |
|
128 </tr> |
|
129 </table> |
|
130 </form> |
|
131 |
|
132 <div id="datepicker"></div> |
|
133 {% endblock %} |
|
134 |
|
135 {% block final %} |
|
136 <script type="text/javascript"> |
|
137 //<![CDATA[ |
|
138 |
|
139 // Sets the focus on the field with the given name in the given array (if any) |
|
140 function setFocus(fields, fieldName) { |
|
141 for (var i = 0; i < fields.length; i++) { |
|
142 var field = fields[i]; |
|
143 var name = field.name; |
|
144 if (field.focus && name.length > focus.length && |
|
145 name.substring(name.length - focus.length - 1) == '|' + focus) { |
|
146 field.focus(); |
|
147 break; |
|
148 } |
|
149 } |
|
150 } |
|
151 |
|
152 // Focus on the appropriate field in the form based on the "focus" argument |
|
153 // in the URL |
|
154 var focus = "{{ focus|addslashes }}"; |
|
155 if (focus) { |
|
156 setFocus(document.getElementsByTagName("input"), focus); |
|
157 setFocus(document.getElementsByTagName("textarea"), focus); |
|
158 } |
|
159 |
|
160 //]]> |
|
161 </script> |
|
162 {% endblock %} |