blob: 700fd19272c66054be4d677387b9236141cc552e [file] [log] [blame]
Scott Bakerfdaee922014-11-03 09:43:23 -08001<!-- Error and Success templates -->
2
Scott Baker562d5952014-11-24 23:26:12 -08003<script type="text/template" id="xos-error-response">
4 <h5>Error</h5>
5 <table>
6 <tr><td>error:</td><td><%= error %></td></tr>
7 <tr><td>check:</td><td><%= specific_error %></td></tr>
8 </table>
9 <h5>Details:</h5>
10 <table>
11 <tbody>
12 <% _.each(reasons, function(element, index) { %>
13 <tr><td><%= index %></td><td><%= element %></td></tr>
14 <% }); %>
15 </tbody>
16 </table>
17</script>
18
Scott Baker92152752014-12-01 17:06:31 -080019<script type="text/template" id="xos-error-rawresponse">
20 <h5>Error</h5>
21 <pre>The server returned:
22"<%= responseText %>"</pre>
23</script>
24
Scott Baker416f0872014-11-03 23:54:59 -080025<script type="text/template" id="xos-error-template">
Scott Bakerfdaee922014-11-03 09:43:23 -080026 <button id="close-error-box">Close Error Message</button>
27 <h3>An error has occurred.</h3>
28 <table class="test-error-table">
29 <tr><td>Code:</td><td><%= status %></td></tr>
30 <tr><td>Message:</td><td><%= statusText %></td></tr>
31 </table>
32</script>
33
Scott Baker416f0872014-11-03 23:54:59 -080034<script type="text/template" id="xos-success-template">
Scott Bakerfdaee922014-11-03 09:43:23 -080035 <button id="close-success-box">Close Success Message</button>
36 <h3>Success!</h3>
37 <table class="test-success-table">
38 <tr><td>Code:</td><td><%= status %></td></tr>
39 <tr><td>Message:</td><td><%= statusText %></td></tr>
40 </table>
41</script>
42
Scott Baker90004d52014-11-04 09:34:17 -080043<script type="text/template" id="xos-navbutton-old">
Scott Baker416f0872014-11-03 23:54:59 -080044 <button class="btn btn-default btn-xosnav" onclick="<%= router %>.navigate('<%= routeUrl %>', {trigger: true})"><%= name %></button><br>
45</script>
46
Scott Bakere2e47fb2014-11-05 21:11:50 -080047<script type="text/template" id="xos-status-template">
Scott Baker01c9d612014-11-14 16:13:43 -080048 <div class="xos-status xos-<%= statusclass %>"><%= what %>: <%= statusText %> (<%= status %>)</div>
Scott Bakere2e47fb2014-11-05 21:11:50 -080049</script>
50
Scott Baker9d37d562014-11-04 23:20:48 -080051<script type="text/template" id="xos-tabs-template">
52 <ul class="xos-nav-list">
53 <% _.each(tabs, function(tab) { %>
54 <li class="xos-nav-item" id="xos-nav-<%= tab["region"] %>"><%= tab["name"] %></li>
55 <% }); %>
56 </ul>
57</script>
58
59<script type="text/template" id="xos-title-list">
Scott Baker13e6f0d2014-11-18 17:02:07 -080060 <h3><img src="/static/img/brokencircle.gif" height=16 width=16 id="xos-list-title-spinner"> <%= title %></h3>
Scott Baker9d37d562014-11-04 23:20:48 -080061</script>
62
63<script type="text/template" id="xos-title-detail">
64 <h3><%= title %></h3>
65</script>
66
Scott Baker90004d52014-11-04 09:34:17 -080067<script type="text/template" id="xos-navbutton">
68 <li>
69 <a href="<%= routeUrl %>">
70 <i class="<%= iconClass %>"></i>
71 <%= name %>
72 </a>
Scott Baker0bf96b22014-11-04 15:41:47 -080073 </li>
Scott Baker90004d52014-11-04 09:34:17 -080074</script>
75
Scott Bakere49f08c2014-11-07 13:01:43 -080076<script type="text/template" id="xos-inline-detail-buttons-template">
77 <tr>
78 <td colspan=2><button class="btn js-submit btn-xos-detail btn-xos-save-leave">Save</button>
79 <button class="btn js-submit btn-xos-detail btn-xos-save-continue">Save and Continue Editing</button>
80 <button class="btn js-submit btn-xos-detail btn-xos-save-another">Save and Add Another</button>
Scott Baker13e6f0d2014-11-18 17:02:07 -080081 <button class="btn js-submit btn-xos-detail btn-xos-delete">Delete</button>
Scott Bakere49f08c2014-11-07 13:01:43 -080082 </td>
83 </tr>
84</script>
85
Scott Baker5c4f2b62014-12-12 14:26:21 -080086<script type="text/template" id="xos-backend-status-icon-template">
Scott Baker94dcc412014-12-23 17:17:27 -080087 <% if (model.enacted === undefined) { %>
88 <!-- enacted is undefined; this must be a new object -->
89 <% } else if ((enacted) && (enacted >= updated)) { %>
Scott Baker5c4f2b62014-12-12 14:26:21 -080090 <span style="min-width:16px;"><img src="/static/admin/img/icon_success.gif"></span>
91 <% } else { %>
92 <% if ((backend_status == "Provisioning in progress") || (!backend_status)) { %>
93 <span style="min-width:16px;" title="<%= _.escape(backend_status) %>"><img src="/static/admin/img/icon_clock.gif"></span>
94 <% } else { %>
95 <span style="min-width:16px;" title="<%= _.escape(backend_status) %>"><img src="/static/admin/img/icon_error.gif"></span>
96 <% } %>
97 <% } %>
98</script>
99
Scott Baker15f09992014-12-12 14:46:24 -0800100<script type="text/template" id="xos-backend-status-text-template">
101 <%= xosBackendStatusIconTemplate.apply(this,arguments) %>
Scott Baker94dcc412014-12-23 17:17:27 -0800102 <% if (model.enacted === undefined) { %>
103 <!-- enacted is undefined; this must be a new object -->
104 <% } else if ((enacted) && (enacted >= updated)) { %>
Scott Baker15f09992014-12-12 14:46:24 -0800105 Successfully enacted
106 <% } else { %>
107 <%= _.escape(backend_status) %>
108 <% } %>
109</script>
110
Scott Baker250ba6e2014-12-04 17:23:27 -0800111<script type="text/template" id="xos-list-header-template">
112 <button class="btn js-submit btn-xos-list btn-xos-add">Add</button>
113 <button class="btn js-submit btn-xos-list btn-xos-refresh">Refresh</button>
114</script>
115
116<script type="text/template" id="xos-list-footer-template">
Scott Baker07b4a252014-12-08 23:54:18 -0800117 <% if (addChildHash) { %>
118 <a href="<%= addChildHash %>">Add...</a>
119 <% } %>
Scott Baker7ce23652014-11-07 16:40:30 -0800120</script>
121
Scott Bakerc91396e2014-12-02 10:49:04 -0800122<script type="text/template" id="xos-delete-button-template">
Scott Baker29e8a2c2014-12-02 17:59:02 -0800123 <a href="#delete<%= firstCharUpper(modelName) %>/<%= id %>">delete</a>
Scott Bakerc91396e2014-12-02 10:49:04 -0800124</script>
125
126<script type="text/template" id="xos-detail-link-template">
127 <a href="#<%= collectionName %>/<%= id %>"><%= text %></a>
128</script>
129
Scott Baker0a636cb2014-12-07 22:27:09 -0800130<script type="text/template" id="xos-add-template">
131 <h3 class="xos-detail-title">Add Object: <%= modelName %></h3>
132 <form>
133 <table>
Scott Baker15f09992014-12-12 14:46:24 -0800134 <% args = arguments; %>
Scott Baker0a636cb2014-12-07 22:27:09 -0800135 <% _.each(addFields, function(fieldName) { %>
Scott Baker8b1bda02014-12-07 22:31:18 -0800136 <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>
Scott Bakere68d37b2014-12-09 16:59:08 -0800137 <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : ""; %>
Scott Baker0a636cb2014-12-07 22:27:09 -0800138 <% if (fieldName in foreignFields) { %>
Scott Baker07b4a252014-12-08 23:54:18 -0800139 <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800140 <% } else if (inputType[fieldName] == "checkbox") { %>
Scott Baker07b4a252014-12-08 23:54:18 -0800141 <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>
Scott Baker15f09992014-12-12 14:46:24 -0800142 <% } else if (fieldName=="backend_status") { %>
143 <td><%= xosBackendStatusTextTemplate.apply(this, args) %></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800144 <% } else { %>
Scott Baker07b4a252014-12-08 23:54:18 -0800145 <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800146 <% } %>
147 </tr>
148 <% }); %>
149 <%= xosInlineDetailButtonsTemplate() %>
150 </table>
151 </form>
152</script>
153
154<script type="text/template" id="xos-detail-template">
Scott Baker07b4a252014-12-08 23:54:18 -0800155 <h3 class="xos-detail-title">Edit Object: <%= modelName %></h3>
Scott Baker0a636cb2014-12-07 22:27:09 -0800156 <form>
157 <table>
Scott Baker15f09992014-12-12 14:46:24 -0800158 <% args = arguments; %>
159 <% _.each(detailFields, function(fieldName) { %>
Scott Baker8b1bda02014-12-07 22:31:18 -0800160 <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>
Scott Bakere68d37b2014-12-09 16:59:08 -0800161 <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : ""; console.log(fieldName + " " + readOnly); console.log(model.readOnlyFields); %>
Scott Baker0a636cb2014-12-07 22:27:09 -0800162 <% if (fieldName in foreignFields) { %>
Scott Bakere68d37b2014-12-09 16:59:08 -0800163 <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800164 <% } else if (inputType[fieldName] == "checkbox") { %>
Scott Bakere68d37b2014-12-09 16:59:08 -0800165 <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>
Scott Baker2cbb6072014-12-16 22:49:42 -0800166 <% } else if (inputType[fieldName] == "picker") { %>
167 <% lookupFunc = makeIdToName(model.m2mFields[fieldName], "humanReadableName"); %>
Scott Bakerae6e1de2014-12-17 16:29:59 -0800168 <td><%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, fieldName: fieldName, detailView: detailView, lookupFunc: lookupFunc}) %></td>
Scott Baker15f09992014-12-12 14:46:24 -0800169 <% } else if (fieldName=="backend_status") { %>
170 <td><%= xosBackendStatusTextTemplate.apply(this, args) %></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800171 <% } else { %>
Scott Bakere68d37b2014-12-09 16:59:08 -0800172 <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>
Scott Baker0a636cb2014-12-07 22:27:09 -0800173 <% } %>
174 </tr>
175 <% }); %>
176 <%= xosInlineDetailButtonsTemplate() %>
177 </table>
178 </form>
179</script>
180
Scott Bakere68d37b2014-12-09 16:59:08 -0800181<script type="text/template" id="xos-list-template">
Scott Baker9d37d562014-11-04 23:20:48 -0800182 <h3 class="xos-list-title"><%= title %></h3>
Scott Baker250ba6e2014-12-04 17:23:27 -0800183 <%= xosListHeaderTemplate() %>
Scott Bakerfc61b012014-10-30 16:10:16 -0700184 <table class="test-table">
Scott Bakere68d37b2014-12-09 16:59:08 -0800185 <thead>
186 <tr>
187 <% _.each(listFields, function(fieldName) { %>
188 <th><%= fieldNameToHumanReadable(fieldName) %></th>
189 <% }); %>
190 <th>delete</th>
Scott Bakerfc61b012014-10-30 16:10:16 -0700191 </tr></thead>
192 <tbody></tbody>
193 </table>
Scott Baker07cdef02014-12-08 11:13:43 -0800194 <%= xosListFooterTemplate({addChildHash: addChildHash}) %>
Scott Bakerfc61b012014-10-30 16:10:16 -0700195</script>
196
Scott Bakere68d37b2014-12-09 16:59:08 -0800197<script type="text/template" id="xos-listitem-template">
198 <% _.each(listFields, function(fieldName) { %>
199 <% if ($.inArray(fieldName, model.detailLinkFields)>=0) { %>
200 <td><%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: model.attributes[fieldName]}) %></td>
201 <% } else if (fieldName in foreignFields) { %>
202 <td><%= idToName(model.attributes[fieldName], foreignFields[fieldName], "humanReadableName") %></td>
203 <% } else { %>
204 <td><%= model.attributes[fieldName] %></td>
205 <% } %>
206 <% }); %>
Scott Bakerf26fa592014-12-02 18:04:50 -0800207 <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
Scott Baker10badd32014-10-31 00:18:24 -0700208</script>
209
Scott Bakerca4bf922014-12-09 18:38:13 -0800210<script type="text/template" id="xos-savebuttons-template">
211 <div class="box save-box">
212 <button class="btn btn-high btn-info btn-xos-contentButtonPanel btn-xos-save-leave">Save</button>
213 <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-continue">Save and continue editing</button>
214 <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-another">Save and add another</button>
215 <button class="btn btn-danger btn-xos-contentButtonPanel btn-xos-delete">Delete</button>
216 </div>
217</script>
218
219<script type="text/template" id="xos-listbuttons-template">
220 <div class="box save-box">
221 <button class="btn btn-high btn-primary btn-xos-contentButtonPanel btn-xos-refresh">Refresh</button>
222 <button class="btn btn-high btn-success btn-xos-contentButtonPanel btn-xos-add">Add</button>
223 </div>
224</script>
225
Scott Baker2cbb6072014-12-16 22:49:42 -0800226
227<script type="text/template" id="xos-picker-template">
228 <!-- arguments: unpickedItems, pickedItems -->
229 <div id="<%= id %>">
230 <div class="picker_row">
231 <div class="picker_column">
232 <div>Available</div>
233 <select name="pickerfrom" class="select-picker-from" multiple size="5">
234 <% _.each(unpickedItems, function(item) { %>
235 <option value="<%= item %>"><%= lookupFunc? lookupFunc(item) : item %></option>
236 <% });%>
237 </select>
238 </div>
239 <div class="picker_column">
240 <br>
241 <div class="btn btn-success btn-picker-add">Add &raquo;</div><br><br>
242 <div class="btn btn-success btn-picker-remove">&laquo; Remove</div>
243 </div>
244 <div class="picker_column">
245 <div>Selected</div>
Scott Bakerae6e1de2014-12-17 16:29:59 -0800246 <select name=<%= fieldName %> class="select-picker-to syphonall" multiple size="5">
Scott Baker2cbb6072014-12-16 22:49:42 -0800247 <% _.each(pickedItems, function(item) { %>
248 <option value="<%= item %>"><%= lookupFunc ? lookupFunc(item) : item %></option>
249 <% }); %>
250 </select>
251 </div>
252 <div class="picker_column">
253 <br>
254 <div class="btn btn-success btn-picker-up">Up</div><br><br>
255 <div class="btn btn-success btn-picker-down">Down</div>
256 </div>
257 </div>
258 </div>
259 <% detailView.viewInitializers.push( function() { init_picker("#" + id); } ); %>
260</script>
261
Scott Bakere49f08c2014-11-07 13:01:43 -0800262<script>
263xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
Scott Baker250ba6e2014-12-04 17:23:27 -0800264xosListHeaderTemplate = _.template($("#xos-list-header-template").html());
265xosListFooterTemplate = _.template($("#xos-list-footer-template").html());
Scott Bakerc91396e2014-12-02 10:49:04 -0800266xosDeleteButtonTemplate = _.template($("#xos-delete-button-template").html());
267xosDetailLinkTemplate = _.template($("#xos-detail-link-template").html());
Scott Baker5c4f2b62014-12-12 14:26:21 -0800268xosBackendStatusIconTemplate = _.template($("#xos-backend-status-icon-template").html());
Scott Baker15f09992014-12-12 14:46:24 -0800269xosBackendStatusTextTemplate = _.template($("#xos-backend-status-text-template").html());
Scott Baker2cbb6072014-12-16 22:49:42 -0800270xosPickerTemplate = _.template($("#xos-picker-template").html());
Scott Bakere49f08c2014-11-07 13:01:43 -0800271</script>
Scott Baker07b4a252014-12-08 23:54:18 -0800272