button panels done right
[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-list-header-template">
87     <button class="btn js-submit btn-xos-list btn-xos-add">Add</button>
88     <button class="btn js-submit btn-xos-list btn-xos-refresh">Refresh</button>
89 </script>
90
91 <script type="text/template" id="xos-list-footer-template">
92     <% if (addChildHash) { %>
93         <a href="<%= addChildHash %>">Add...</a>
94     <% } %>
95 </script>
96
97 <script type="text/template" id="xos-delete-button-template">
98     <a href="#delete<%= firstCharUpper(modelName) %>/<%= id %>">delete</a>
99 </script>
100
101 <script type="text/template" id="xos-detail-link-template">
102     <a href="#<%= collectionName %>/<%= id %>"><%= text %></a>
103 </script>
104
105 <script type="text/template" id="xos-add-template">
106   <h3 class="xos-detail-title">Add Object: <%= modelName %></h3>
107   <form>
108   <table>\r
109   <% _.each(addFields, function(fieldName) { %>\r
110      <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>\r
111         <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : "";  %>\r
112         <% if (fieldName in foreignFields) { %>\r
113             <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>\r
114         <% } else if (inputType[fieldName] == "checkbox") { %>\r
115             <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>\r
116         <% } else { %>\r
117             <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>\r
118         <% } %>\r
119      </tr>\r
120   <% }); %>\r
121   <%= xosInlineDetailButtonsTemplate() %>\r
122   </table>\r
123   </form>\r
124 </script>
125
126 <script type="text/template" id="xos-detail-template">
127   <h3 class="xos-detail-title">Edit Object: <%= modelName %></h3>
128   <form>
129   <table>\r
130   <% console.log(model); _.each(detailFields, function(fieldName) { %>\r
131      <tr><td><%= fieldNameToHumanReadable(fieldName) %>:</td>\r
132         <% readOnly = $.inArray(fieldName, model.readOnlyFields)>=0 ? " readonly" : "";  console.log(fieldName + " " + readOnly); console.log(model.readOnlyFields); %>\r
133         <% if (fieldName in foreignFields) { %>\r
134             <td><%= idToSelect(fieldName, model.attributes[fieldName], foreignFields[fieldName], "humanReadableName", readOnly) %></td>\r
135         <% } else if (inputType[fieldName] == "checkbox") { %>\r
136             <td><input type="checkbox" name="<%= fieldName %>" <% if (model.attributes[fieldName]) print("checked"); %><%= readOnly %>></td>\r
137         <% } else { %>\r
138             <td><input type="text" name="<%= fieldName %>" value="<%= model.attributes[fieldName] %>"<%= readOnly %>></td>\r
139         <% } %>\r
140      </tr>\r
141   <% }); %>\r
142   <%= xosInlineDetailButtonsTemplate() %>\r
143   </table>\r
144   </form>\r
145 </script>
146
147 <script type="text/template" id="xos-list-template">
148   <h3 class="xos-list-title"><%= title %></h3>
149   <%= xosListHeaderTemplate() %>
150   <table class="test-table">
151   <thead>
152   <tr>
153   <% _.each(listFields, function(fieldName) { %>
154       <th><%= fieldNameToHumanReadable(fieldName) %></th>
155   <% }); %>
156   <th>delete</th>
157   </tr></thead>
158   <tbody></tbody>
159   </table>
160   <%= xosListFooterTemplate({addChildHash: addChildHash}) %>
161 </script>
162
163 <script type="text/template" id="xos-listitem-template">
164   <% _.each(listFields, function(fieldName) { %>
165       <% if ($.inArray(fieldName, model.detailLinkFields)>=0) { %>
166           <td><%= xosDetailLinkTemplate({collectionName: collectionName, id: id, text: model.attributes[fieldName]}) %></td>
167       <% } else if (fieldName in foreignFields) { %>
168           <td><%= idToName(model.attributes[fieldName], foreignFields[fieldName], "humanReadableName") %></td>
169       <% } else { %>
170       <td><%= model.attributes[fieldName] %></td>
171       <% } %>
172   <% }); %>
173   <td><%= xosDeleteButtonTemplate({modelName: modelName, id: id}) %></td>
174 </script>
175
176 <script type="text/template" id="xos-savebuttons-template">
177   <div class="box save-box">
178     <button class="btn btn-high btn-info btn-xos-contentButtonPanel btn-xos-save-leave">Save</button>
179     <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-continue">Save and continue editing</button>
180     <button class="btn btn-high btn-xos-contentButtonPanel btn-xos-save-another">Save and add another</button>
181     <button class="btn btn-danger btn-xos-contentButtonPanel btn-xos-delete">Delete</button>
182   </div>
183 </script>
184
185 <script type="text/template" id="xos-listbuttons-template">
186   <div class="box save-box">
187     <button class="btn btn-high btn-primary btn-xos-contentButtonPanel btn-xos-refresh">Refresh</button>
188     <button class="btn btn-high btn-success btn-xos-contentButtonPanel btn-xos-add">Add</button>
189   </div>
190 </script>
191
192 <script>
193 xosInlineDetailButtonsTemplate = _.template($("#xos-inline-detail-buttons-template").html());
194 xosListHeaderTemplate = _.template($("#xos-list-header-template").html());
195 xosListFooterTemplate = _.template($("#xos-list-footer-template").html());
196 xosDeleteButtonTemplate = _.template($("#xos-delete-button-template").html());
197 xosDetailLinkTemplate = _.template($("#xos-detail-link-template").html());
198 </script>
199