<button class="btn btn-high btn-info btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-leave').click()">Save</button>
<button class="btn btn-high btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-continue').click()">Save and continue editing</button>
<button class="btn btn-high btn-xos-contentButtonPanel" onclick="$('button.btn-xos-save-another').click()">Save and add another</button>
+<button class="btn btn-danger btn-xos-contentButtonPanel" onclick="$('button.btn-xos-delete').click()">Delete</button>
</div>
<div class="box save-box" id="xos-listview-button-box">
+<button class="btn btn-high btn-primary btn-xos-contentButtonPanel" onclick="$('button.btn-xos-refresh').click()">Refresh</button>
<button class="btn btn-high btn-success btn-xos-contentButtonPanel" onclick="$('button.btn-xos-add').click()">Add</button>
</div>
<div class="box" id="logPanel">
text-decoration:none;
}
+/* these are for the inline list and detail titles */
+
.xos-list-title {
display: none;
}
display: none;
}
+/* this one goes with contenttitle */
+
+#xos-list-title-spinner {
+ display: none;
+}
+
/* undo what planetstack.css does to the progressbar */
#xos-startup-progress .ui-progressbar-value {
background-color: rgb(204,204,204) !important;
XOSAdminApp.Router.navigate(detailNavLink + "/" + model.id, {trigger: true});
};\r
\r
+XOSAdminApp.navigate = function(what, modelName, modelId) {\r
+ collection_name = modelName + "s";\r
+ if (what=="list") {\r
+ XOSAdminApp.Router.navigate(collection_name, {trigger: true})\r
+ } else if (what=="detail") {\r
+ XOSAdminApp.Router.navigate(collection_name + "/" + modelId, {trigger: true})\r
+ } else if (what=="add") {\r
+ XOSAdminApp.Router.navigate("add" + firstCharUpper(modelName), {trigger: true})\r
+ }\r
+}\r
+\r
ICON_CLASSES = {home: "icon-home", deployments: "icon-deployment", sites: "icon-site", slices: "icon-slice", users: "icon-user"};\r
\r
XOSAdminApp.updateNavigationPanel = function() {\r
collection_name = name + "s";
region_name = name + "List";
detailNavLink = collection_name;
- listNavLink = collection_name;
detailClass = XOSDetailView.extend({
template: detail_template,\r
app: XOSAdminApp,\r
- listNavLink: listNavLink,\r
});\r
XOSAdminApp[collection_name + "DetailView"] = detailClass;\r
},\r
\r
fetchSuccess: function(collection, response, options) {\r
+ //console.log("fetch succeeded " + collection.modelName);\r
this.failedLoad = false;\r
+ this.fetching = false;\r
if (!this.isLoaded) {\r
this.isLoaded = true;\r
Backbone.trigger("xoslib:collectionLoadChange", this);\r
}\r
+ this.trigger("fetchStateChange");\r
if (options["orig_success"]) {\r
options["orig_success"](collection, response, options);\r
}\r
},\r
\r
fetchFailure: function(collection, response, options) {\r
+ //console.log("fetch failed " + collection.modelName);\r
+ this.fetching = false;\r
if ((!this.isLoaded) && (!this.failedLoad)) {\r
this.failedLoad=true;\r
Backbone.trigger("xoslib:collectionLoadChange", this);\r
}\r
+ this.trigger("fetchStateChange");\r
if (options["orig_failure"]) {\r
options["orig_failure"](collection, response, options);\r
}\r
\r
fetch: function(options) {\r
var self=this;\r
+ this.fetching=true;\r
+ //console.log("fetch " + this.modelName);\r
if (!this.startedLoad) {\r
this.startedLoad=true;\r
Backbone.trigger("xoslib:collectionLoadChange", this);\r
}\r
+ this.trigger("fetchStateChange");\r
if (options == undefined) {\r
options = {};\r
}\r
}
},
+ refresh: function(refreshRelated) {
+ if (!this.fetching) {
+ this.fetch();
+ }
+ if (refreshRelated) {
+ for (related in this.relatedCollections) {
+ related = xos[related];
+ if (!related.fetching) {
+ related.fetch();
+ }
+ }
+ }
+ },
+
maybeFetch: function(options){
// Helper function to fetch only if this collection has not been fetched before.
if(this._fetched){
return function() {\r
model = new xos[collection_name].model();\r
detailViewClass = app[detailName];\r
- detailView = new detailViewClass({model: model});\r
+ detailView = new detailViewClass({model: model, collection:xos[collection_name]});\r
app[regionName].show(detailView);\r
$("#xos-detail-button-box").show();\r
$("#xos-listview-button-box").hide();\r
console.log("saveLeave");
e.preventDefault();
this.save();
- this.app.Router.navigate(this.listNavLink, {trigger: true});
- console.log("route to " + this.listNavLink);
+ this.app.navigate("list", this.model.modelName);
},
submitAddAnotherClicked: function(e) {
console.log("saveAnother");
e.preventDefault();
this.save();
+ this.app.navigate("add", this.model.modelName);
},
save: function() {
var infoMsgId = this.app.showInformational( {what: "save " + this.model.__proto__.modelName, status: "", statusText: "in progress..."} );\r
var data = Backbone.Syphon.serialize(this);\r
var that = this;\r
+ var isNew = !this.model.id;\r
this.model.save(data, {error: function(model, result, xhr) { that.saveError(model,result,xhr,infoMsgId);},\r
success: function(model, result, xhr) { that.saveSuccess(model,result,xhr,infoMsgId);}});\r
+ if (isNew) {\r
+ console.log(this.model);\r
+ this.collection.add(this.model);\r
+ this.collection.sort();\r
+ }\r
this.dirty = false;\r
},
childViewContainer: 'tbody',\r
\r
events: {"click button.btn-xos-add": "addClicked",\r
- },
-
+ "click button.btn-xos-refresh": "refreshClicked",\r
+ },\r
+\r
+ _fetchStateChange: function() {\r
+ if (this.collection.fetching) {\r
+ $("#xos-list-title-spinner").show();\r
+ } else {\r
+ $("#xos-list-title-spinner").hide();\r
+ }\r
+ },\r
+\r
addClicked: function(e) {
- console.log("add");
e.preventDefault();
this.app.Router.navigate("add" + firstCharUpper(this.collection.modelName), {trigger: true});
},
\r
- initialize: function() {\r
- this.listenTo(this.collection, 'change', this._renderChildren)
+\r refreshClicked: function(e) {
+\r e.preventDefault();
+\r this.collection.refresh(refreshRelated=true);
+\r },
+\r
+\r initialize: function() {
+\r this.listenTo(this.collection, 'change', this._renderChildren)
+ this.listenTo(this.collection, 'fetchStateChange', this._fetchStateChange);
// Because many of the templates use idToName(), we need to
// listen to the collections that hold the names for the ids
</script>
<script type="text/template" id="xos-title-list">
- <h3><%= title %></h3>
+ <h3><img src="/static/img/brokencircle.gif" height=16 width=16 id="xos-list-title-spinner"> <%= title %></h3>
</script>
<script type="text/template" id="xos-title-detail">
<td colspan=2><button class="btn js-submit btn-xos-detail btn-xos-save-leave">Save</button>
<button class="btn js-submit btn-xos-detail btn-xos-save-continue">Save and Continue Editing</button>
<button class="btn js-submit btn-xos-detail btn-xos-save-another">Save and Add Another</button>
+ <button class="btn js-submit btn-xos-detail btn-xos-delete">Delete</button>
</td>
</tr>
</script>
<script type="text/template" id="xos-inline-list-buttons-template">
<button class="btn js-submit btn-xos-list btn-xos-add">Add</button>
+ <button class="btn js-submit btn-xos-list btn-xos-refresh">Refresh</button>
</td>
</tr>
</script>
<td class="objectLink"><%= name %></td>
<td><%= backend_type %></td>
<td><%= admin_tenant %></td>
- <td><%= sites.length %></td>
+ <td><%= typeof sites != 'undefined' && sites.length || 0 %></td>
</script>
<script type="text/template" id="xosAdmin-deployment-detail-template">