help text support for detail view, tenant view warnings about changing slivers
[plstackapi.git] / planetstack / core / xoslib / templates / xosAdmin.html
1 <!-- Error and Success templates -->
2
3 <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
19 <script type="text/template" id="xos-error-rawresponse">
20   <h5>Error</h5>
21   <pre>The server returned:
22 "<%= responseText %>"</pre>
23 </script>
24
25 <script type="text/template" id="xos-error-template">
26   <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
34 <script type="text/template" id="xos-success-template">
35   <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
43 <script type="text/template" id="xos-navbutton-old">
44   <button class="btn btn-default btn-xosnav" onclick="<%= router %>.navigate('<%= routeUrl %>', {trigger: true})"><%= name %></button><br>
45 </script>
46
47 <script type="text/template" id="xos-status-template">
48   <div class="xos-status xos-<%= statusclass %>"><%= what %>: <%= statusText %> (<%= status %>)</div>
49 </script>
50
51 <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">
60   <h3><img src="/static/img/brokencircle.gif" height=16 width=16 id="xos-list-title-spinner"> <%= title %></h3>
61 </script>
62
63 <script type="text/template" id="xos-title-detail">
64   <h3><%= title %></h3>
65 </script>
66
67 <script type="text/template" id="xos-navbutton">
68   <li>
69       <a href="<%= routeUrl %>">
70           <i class="<%= iconClass %>"></i>
71           <%= name %>
72       </a>
73   </li>
74 </script>
75
76 <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>
81            <button class="btn js-submit btn-xos-detail btn-xos-delete">Delete</button>
82        </td>
83     </tr>
84 </script>
85
86 <script type="text/template" id="xos-backend-status-icon-template">
87     <% if (! ("enacted" in arguments) ) { %>
88         <!-- enacted is undefined; this must be a new object -->
89     <% } else if ((enacted) && (enacted >= updated)) { %>
90         <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
100 <script type="text/template" id="xos-backend-status-text-template">
101     <%= xosBackendStatusIconTemplate.apply(this,arguments) %>
102     <% if (model.enacted === undefined) { %>
103         <!-- enacted is undefined; this must be a new object -->
104     <% } else if ((enacted) && (enacted >= updated)) { %>
105         Successfully enacted
106     <% } else { %>
107         <%= _.escape(backend_status) %>
108     <% } %>
109 </script>
110
111 <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">
117     <% if (addChildHash) { %>
118         <a href="<%= addChildHash %>">Add...</a>
119     <% } %>
120 </script>
121
122 <script type="text/template" id="xos-delete-button-template">
123     <a href="#delete<%= firstCharUpper(modelName) %>/<%= id %>">delete</a>
124 </script>
125
126 <script type="text/template" id="xos-detail-link-template">
127     <a href="#<%= collectionName %>/<%= id %>"><%= text %></a>
128 </script>
129
130 <script type="text/template" id="xos-add-template">
131   <h3 class="xos-detail-title">Add Object: <%= modelName %></h3>
132   <form>
133   <table>\r
134   <% args = arguments; %>\r
135   <% _.each(addFields, function(fieldName) { %>\r
136      <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>\r
137         <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : "";  %>\r
138         <% if (fieldName in foreignFields) { %>\r
139             <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>\r
140         <% } else if (inputType[fieldName] == "checkbox") { %>\r
141             <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>\r
142         <% } else if (fieldName=="backend_status") { %>\r
143             <td><%= xosBackendStatusTextTemplate.apply(this, args) %></td>\r
144         <% } else { %>\r
145             <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>\r
146         <% } %>\r
147      </tr>\r
148   <% }); %>\r
149   <%= xosInlineDetailButtonsTemplate() %>\r
150   </table>\r
151   </form>\r
152 </script>
153
154 <script type="text/template" id="xos-detail-template">
155   <h3 class="xos-detail-title">Edit Object: <%= modelName %></h3>
156   <form>
157   <table class="xos-detail-table">\r
158   <% args = arguments; %>\r
159   <% _.each(detailFields, function(fieldName) { %>\r
160      <tr><td class="xos-label-cell"><%= fieldName in fieldDisplayNames ? fieldDisplayNames[fieldName] : fieldNameToHumanReadable(fieldName) %>:</td>\r
161         <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : "";  %>\r
162         <% if (fieldName in choices) { %>\r
163             <td><%= choicesToSelect(fieldName, model.attributes[fieldName], choices[fieldName]) %></td>\r
164         <% } else if (fieldName in foreignFields) { %>\r
165             <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>\r
166         <% } else if (inputType[fieldName] == "spinner") { %>\r
167             <!-- note: I never finished working on this spinner stuff! -->\r
168             <td><%= xosSpinnerTemplate({id: "spinner_" + fieldName, fieldName: fieldName, value: model.attributes[fieldName]}) %></td>\r
169         <% } else if (inputType[fieldName] == "checkbox") { %>\r
170             <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>\r
171         <% } else if (inputType[fieldName] == "picker") { %>\r
172             <% lookupFunc = makeIdToName(model.m2mFields[fieldName], "humanReadableName"); %>\r
173             <td><%= xosPickerTemplate({pickedItems: model.attributes[fieldName], unpickedItems: model.getChoices(fieldName,true), id: "picker_" + fieldName, fieldName: fieldName, detailView: detailView, lookupFunc: lookupFunc}) %></td>\r
174         <% } else if (fieldName=="backend_status") { %>\r
175             <td><%= xosBackendStatusTextTemplate.apply(this, args) %></td>\r
176         <% } else { %>\r
177             <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>\r
178         <% } %>\r
179         <td  class="xos-help-cell"><%= helpText[fieldName] %></td>\r
180      </tr>\r
181   <% }); %>\r
182   <%= xosInlineDetailButtonsTemplate() %>\r
183   </table>\r
184   </form>\r
185 </script>
186
187 <script type="text/template" id="xos-list-template">
188   <h3 class="xos-list-title"><%= title %></h3>
189   <%= xosListHeaderTemplate() %>
190   <table class="test-table">
191   <thead>
192   <tr>
193   <% _.each(listFields, function(fieldName) { %>
194       <th><%= fieldNameToHumanReadable(fieldName) %></th>
195   <% }); %>
196   <th>delete</th>
197   </tr></thead>
198   <tbody></tbody>
199   </table>
200   <%= xosListFooterTemplate({addChildHash: addChildHash}) %>
201 </script>
202
203 <script type="text/template" id="xos-listitem-template">
204   <% _.each(listFields, function(fieldName) { %>
205       <% if ($.inArray(fieldName, model.detailLinkFields)>=0) { %>
206           <td><%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: model.attributes[fieldName]}) %></td>
207       <% } else if (fieldName in foreignFields) { %>
208           <td><%= idToName(model.attributes[fieldName], foreignFields[fieldName], "humanReadableName") %></td>
209       <% } else { %>
210       <td><%= model.attributes[fieldName] %></td>
211       <% } %>
212   <% }); %>
213   <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
214 </script>
215
216 <script type="text/template" id="xos-savebuttons-template">
217   <div class="box save-box">
218     <button class="btn btn-high btn-info btn-xos-contentButtonPanel btn-xos-save-leave">Save</button>
219     <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-continue">Save and continue editing</button>
220     <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-another">Save and add another</button>
221     <button class="btn btn-danger btn-xos-contentButtonPanel btn-xos-delete">Delete</button>
222   </div>
223 </script>
224
225 <script type="text/template" id="xos-listbuttons-template">
226   <div class="box save-box">
227     <button class="btn btn-high btn-primary btn-xos-contentButtonPanel btn-xos-refresh">Refresh</button>
228     <button class="btn btn-high btn-success btn-xos-contentButtonPanel btn-xos-add">Add</button>
229   </div>
230 </script>
231
232 <script type="text/template" id="xos-datatable-spinner-template">
233     <!-- arguments: value, id, collectionName, fieldName -->
234     <%= value %> <img style="cursor: pointer;" src="/static/img/plus_circle.png" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", 1)'>
235                  <img style="cursor: pointer;" src="/static/img/minus_circle.png" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", -1)'>
236 </script>
237
238 <script type="text/template" id="xos-datatable-spinner-template-old">
239     <!-- arguments: value, id, collectionName, fieldName -->
240     <%= value %> <a href="javascript:undefined" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", 1)'> more </a>
241                  <a href="javascript:undefined" onclick='<%= app.varName %>.adjustCollectionField("<%= collectionName %>", <%= id %>, "<%= fieldName %>", -1)'> less </a>
242 </script>
243
244 <script type="text/template" id="xos-spinner-template">
245     <!-- arguments: fieldName, id, value -->
246     <input name="<%= fieldName %>" class="xos-spinner" id="<%= id %>">
247     <% detailView.viewInitializers.push( function() { init_spinner("#" + id, value); } ); %>
248 </script>
249
250 <script type="text/template" id="xos-picker-template">
251     <!-- arguments: unpickedItems, pickedItems, fieldName, id -->
252     <div id="<%= id %>">
253     <div class="picker_row">
254     <div class="picker_column">\r
255     <div>Available</div>\r
256     <select name="pickerfrom" class="select-picker-from" multiple size="5">\r
257         <% _.each(unpickedItems, function(item) { %>\r
258            <option value="<%= item %>"><%= lookupFunc? lookupFunc(item) : item %></option>
259         <% });%>\r
260     </select>\r
261     </div>\r
262     <div class="picker_column">\r
263     <br>\r
264     <div class="btn btn-success btn-picker-add">Add &raquo;</div><br><br>\r
265     <div class="btn btn-success btn-picker-remove">&laquo; Remove</div>\r
266     </div>\r
267     <div class="picker_column">\r
268     <div>Selected</div>\r
269     <select name=<%= fieldName %> class="select-picker-to syphonall" multiple size="5">\r
270         <% _.each(pickedItems, function(item) { %>\r
271            <option value="<%= item %>"><%= lookupFunc ? lookupFunc(item) : item %></option>
272         <% }); %>\r
273     </select>\r
274     </div>\r
275     <div class="picker_column">\r
276     <br>\r
277     <div class="btn btn-success btn-picker-up">Up</div><br><br>\r
278     <div class="btn btn-success btn-picker-down">Down</div>\r
279     </div>\r
280     </div>
281     </div>
282     <% detailView.viewInitializers.push( function() { init_picker("#" + id); } ); %>
283 </script>
284
285 <script type="text/template" id="xos-sliceselector-option">
286    <%= name %>
287 </script>
288
289 <script type="text/template" id="xos-sliceselector-select">
290     <% if (caption) { %>
291     <table class="xos-detail-table"><tr><td class="xos-label-cell"><%= caption %>: </td><td><select></select></td></tr></table>
292     <% } else { %>
293     <select></select>
294     <% } %>
295 </script>
296
297 <script>
298 xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
299 xosListHeaderTemplate = _.template($("#xos-list-header-template").html());
300 xosListFooterTemplate = _.template($("#xos-list-footer-template").html());
301 xosDeleteButtonTemplate = _.template($("#xos-delete-button-template").html());
302 xosDetailLinkTemplate = _.template($("#xos-detail-link-template").html());
303 xosBackendStatusIconTemplate = _.template($("#xos-backend-status-icon-template").html());
304 xosBackendStatusTextTemplate = _.template($("#xos-backend-status-text-template").html());
305 xosPickerTemplate = _.template($("#xos-picker-template").html());
306 xosSpinnerTemplate = _.template($("#xos-spinner-template").html());
307 xosDataTableSpinnerTemplate = _.template($("#xos-datatable-spinner-template").html());
308 </script>
309