-DeveloperApp = new Marionette.Application();
+/* This is an example that uses xoslib + marionette to display the developer
+\r view.
+\r
+\r For an example that uses xoslib + datatables, see xosDeveloper_datatables.js
+\r*/
+\r
+\rDeveloperApp = new Marionette.Application();
\r
DeveloperApp.addRegions({\r
mainRegion: "#developerView"\r
className: 'developer_slicedetail'\r
});
-/*
-DeveloperApp.SliceListView = Marionette.CollectionView.extend({
+DeveloperApp.SliceListView = Marionette.CompositeView.extend({
tagName: "table",\r
- className: "table table-hover",\r
- template: "#developer-slicetable-template",\r
- childView: DeveloperApp.SliceDetailView,\r
-});\r
-*/\r
-\r
-DeveloperApp.SliceListView = Marionette.CompositeView.extend({\r
- tagName: "table",\r
- className: "table-striped table-bordered",\r
+ className: "table table-bordered table-striped",\r
template: "#developer-slicetable-template",\r
childView: DeveloperApp.SliceDetailView,\r
childViewContainer: "tbody",\r
+\r
+ events: {"click .sort": "changeSort"},\r
+\r
+ initialize: function() {\r
+ this.listenTo(this.collection, 'change', this._renderChildren);\r
+ },\r
+\r
+ changeSort: function(e) {\r
+ parts=$(e.currentTarget).attr("id").split('-');\r
+ order=parts[1];\r
+ fieldName=parts[2];\r
+ this.collection.sortVar = fieldName;\r
+ this.collection.sortOrder = order;\r
+ this.collection.sort();\r
+ },\r
+\r
+ attachHtml: function(compositeView, childView, index) {\r
+ // The REST API will let admin users see everything. For the developer\r
+ // view we still want to hide slices we are not members of.\r
+ if (childView.model.get("sliceInfo").roles.length == 0) {\r
+ return;\r
+ }\r
+ DeveloperApp.SliceListView.__super__.attachHtml(compositeView, childView, index);\r
+ },\r
});\r
DeveloperApp.on("start", function() {
var developerSliceListView = new DeveloperApp.SliceListView({
collection: xos.slicesPlus\r
});\r
- console.log(developerSliceListView);\r
DeveloperApp.mainRegion.show(developerSliceListView);\r
- xos.slicesPlus.fetch();\r
+ xos.slicesPlus.startPolling();\r
});
$(document).ready(function(){