blob: 99641c3bf3ac5505f34edd79cf594a05b2866464 [file] [log] [blame]
Scott Baker7ee32a02014-07-13 09:52:15 -07001DeveloperApp = new Marionette.Application();
2
3DeveloperApp.addRegions({
4 mainRegion: "#developerView"
5});
6
7DeveloperApp.SliceDetailView = Marionette.ItemView.extend({
8 template: "#developer-slicedetail-template",
9 tagName: 'tr',
10 className: 'developer_slicedetail'
11});
12
Scott Bakerb6e10662014-07-14 11:15:45 -070013DeveloperApp.SliceListView = Marionette.CompositeView.extend({
Scott Bakerdb236c32014-07-13 17:36:19 -070014 tagName: "table",
Scott Baker0393e5d2014-07-14 12:24:03 -070015 className: "table table-bordered table-striped",
Scott Baker7ee32a02014-07-13 09:52:15 -070016 template: "#developer-slicetable-template",
17 childView: DeveloperApp.SliceDetailView,
Scott Bakerdb236c32014-07-13 17:36:19 -070018 childViewContainer: "tbody",
Scott Bakerb6e10662014-07-14 11:15:45 -070019
20 events: {"click .sort": "changeSort"},
21
22 changeSort: function(e) {
23 parts=$(e.currentTarget).attr("id").split('-');
24 order=parts[1];
25 fieldName=parts[2];
26 console.log(fieldName);
27 this.collection.sortVar = fieldName;
28 this.collection.sortOrder = order;
29 this.collection.sort();
Scott Baker0393e5d2014-07-14 12:24:03 -070030 },
31
32 attachHtml: function(compositeView, childView, index) {
33 // The REST API will let admin users see everything. For the developer
34 // view we still want to hide slices we are not members of.
35 if (childView.model.get("sliceInfo").roles.length == 0) {
36 return;
37 }
38 DeveloperApp.SliceListView.__super__.attachHtml(compositeView, childView, index);
39 },
Scott Baker7ee32a02014-07-13 09:52:15 -070040});
41
42DeveloperApp.on("start", function() {
43 var developerSliceListView = new DeveloperApp.SliceListView({
Scott Bakerdb236c32014-07-13 17:36:19 -070044 collection: xos.slicesPlus
Scott Baker7ee32a02014-07-13 09:52:15 -070045 });
46 console.log(developerSliceListView);
47 DeveloperApp.mainRegion.show(developerSliceListView);
Scott Bakerb6e10662014-07-14 11:15:45 -070048 xos.slicesPlus.startPolling();
Scott Baker7ee32a02014-07-13 09:52:15 -070049});
50
51$(document).ready(function(){
52 DeveloperApp.start();
53});
54