many changes to xoslib test
diff --git a/planetstack/core/xoslib/static/css/test.css b/planetstack/core/xoslib/static/css/test.css
index e5b1b80..dee32d8 100644
--- a/planetstack/core/xoslib/static/css/test.css
+++ b/planetstack/core/xoslib/static/css/test.css
@@ -6,6 +6,7 @@
position: fixed;
top: 1em;
right: 1em;
+ width: 450px;
}
#detailBox {
@@ -14,6 +15,8 @@
background-color: #f0f0f0;
margin-bottom:30px;
display:none;
+ overflow:auto;
+ max-height:80vh;
}
#errorBox {
@@ -32,3 +35,9 @@
display:none;
}
+.objectLink {
+ cursor:pointer;
+ color:blue;
+ text-decoration:underline;
+}
+
diff --git a/planetstack/core/xoslib/static/js/test.js b/planetstack/core/xoslib/static/js/test.js
index ff681e8..86de742 100644
--- a/planetstack/core/xoslib/static/js/test.js
+++ b/planetstack/core/xoslib/static/js/test.js
@@ -11,25 +11,11 @@
sliceList: "#sliceList",
sliverList: "#sliverList",
userList: "#userList",
- detail: "#detail"
-});
-
-// ---- Deployment ----
-
-TestApp.DeploymentListItemView = Marionette.ItemView.extend({
- template: '#test-deployment-listitem-template',
- tagName: 'tr',
- className: 'test-tablerow',
-});
-
-TestApp.DeploymentListView = Marionette.CompositeView.extend({
- childView: TestApp.DeploymentListItemView,
- childViewContainer: 'tbody',
- template: '#test-deployment-list-template',
-
- initialize: function() {
- this.listenTo(this.collection, 'change', this._renderChildren)
- },
+ detail: "#detail",
+ linkedObjs1: "#linkedObjs1",
+ linkedObjs2: "#linkedObjs2",
+ linkedObjs3: "#linkedObjs3",
+ linkedObjs4: "#linkedObjs4"
});
TestApp.hideError = function(result) {
@@ -53,8 +39,17 @@
});
};
+idToName = function(id, collectionName, fieldName) {
+ linkedObject = xos[collectionName].get(id);
+ if (linkedObject == undefined) {
+ return "#" + id;
+ } else {
+ return linkedObject.attributes[fieldName];
+ }
+};
+
TestApp.on("start", function() {
- var objs = ['deployment', 'image', 'networkTemplate', 'network', 'node', 'service', 'site', 'slice', 'sliver', 'user'];
+ var objs = ['deployment', 'image', 'networkTemplate', 'network', 'networkSliver', 'node', 'service', 'site', 'slice', 'sliceDeployment', 'slicePrivilege', 'sliver', 'user', 'sliceRole'];
for (var index in objs) {
name = objs[index];
@@ -112,6 +107,20 @@
e.preventDefault();
e.stopPropagation();
+ index=0;
+ for (relatedName in this.model.collection.relatedCollections) {
+ relatedField = this.model.collection.relatedCollections[relatedName];
+
+ relatedListViewClass = TestApp[relatedName + "ListView"].extend({collection: xos[relatedName].filterBy(relatedField,this.model.id)});
+ TestApp["linkedObjs" + (index+1)].show(new relatedListViewClass());
+ index = index + 1;
+ }
+
+ while (index<4) {
+ TestApp["linkedObjs" + (index+1)].empty();
+ index = index + 1;
+ }
+
var detailView = new this.detailClass({
model: this.model,
});
@@ -125,15 +134,32 @@
childViewContainer: 'tbody',
template: table_template,
collection: xos[collection_name],
+ title: name + "s",
initialize: function() {
this.listenTo(this.collection, 'change', this._renderChildren)
+
+ // Because many of the templates use idToName(), we need to
+ // listen to the collections that hold the names for the ids
+ // that we want to display.
+ for (i in this.collection.foreignCollections) {
+ foreignName = this.collection.foreignCollections[i];
+ this.listenTo(xos[foreignName], 'change', this._renderChildren);
+ this.listenTo(xos[foreignName], 'sort', this._renderChildren);
+ }
+ },
+
+ templateHelpers: function() {
+ return { title: this.title };
},
});
+ TestApp[collection_name + "ListView"] = listViewClass;
var listView = new listViewClass();
- TestApp[region_name].show(listView);
+ if (region_name in TestApp.getRegions()) {
+ TestApp[region_name].show(listView);
+ }
xos[collection_name].fetch(); //startPolling();
}