tenantview without navigation
diff --git a/planetstack/core/xoslib/dashboards/xosTenant.html b/planetstack/core/xoslib/dashboards/xosTenant.html
index 49236d4..42a41e0 100644
--- a/planetstack/core/xoslib/dashboards/xosTenant.html
+++ b/planetstack/core/xoslib/dashboards/xosTenant.html
@@ -37,6 +37,10 @@
Are you sure about this?
</div>
+<div id="tenant-addslice-dialog" title="Add Child">
+<div id="tenant-addslice-interior"></div>
+</div>
+
<div id="xos-error-dialog" title="Error Message">
</div>
diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js
index 5095505..6f73046 100644
--- a/planetstack/core/xoslib/static/js/xosTenant.js
+++ b/planetstack/core/xoslib/static/js/xosTenant.js
@@ -38,6 +38,7 @@
},
createClicked: function(e) {
+ XOSTenantApp.addSlice();
},
deleteClicked: function(e) {
@@ -55,7 +56,8 @@
XOSTenantApp = new XOSApplication({
logTableId: "#logTable",
statusMsgId: "#statusMsg",
- hideTabsByDefault: true
+ hideTabsByDefault: true,
+ varName: "XOSTenantApp",
});
XOSTenantApp.addRegions({
@@ -63,9 +65,10 @@
tenantSummary: "#tenantSummary",
tenantSiteList: "#tenantSiteList",
tenantButtons: "#tenantButtons",
+ tenantAddSliceInterior: "#tenant-addslice-interior",
});
-XOSTenantApp.buildViews = function() {
+XOSTenantApp.buildViews = function() {
XOSTenantApp.tenantSites = new XOSTenantSiteCollection();
tenantSummaryClass = XOSDetailView.extend({template: "#xos-detail-template",
@@ -74,6 +77,12 @@
XOSTenantApp.tenantSummaryView = tenantSummaryClass;
+ tenantAddClass = XOSDetailView.extend({template: "#xos-detail-template",
+ app: XOSTenantApp,
+ detailFields: ["name", "description"]});
+
+ XOSTenantApp.tenantAddView = tenantAddClass;
+
tenantSiteItemClass = XOSItemView.extend({template: "#xos-listitem-template",
app: XOSTenantApp});
@@ -92,8 +101,7 @@
XOSTenantApp.tenantSliceSelectorView = SliceSelectorView.extend( {
sliceChanged: function(id) {
- //console.log("navigate to " + id);
- XOSTenantApp.Router.navigate("slice/" + id, {trigger: true});
+ XOSTenantApp.navToSlice(id);
},
});
@@ -113,6 +121,41 @@
return result;
};
+XOSTenantApp.navToSlice = function(id) {
+ XOSTenantApp.viewSlice(xos.slicesPlus.get(id));
+};
+
+XOSTenantApp.adjustCollectionField = function(collectionName, id, fieldName, amount) {
+ model = XOSTenantApp[collectionName].get(id);
+ model.set(fieldName, Math.max(model.get(fieldName) + amount, 0));
+};
+
+XOSTenantApp.addSlice = function() {
+ var app=this;
+ model = new xos.slicesPlus.model({site: xos.tenant().current_user_site_id});
+ console.log(model);
+ var detailView = new XOSTenantApp.tenantAddView({model: model, collection: xos.slicesPlus});
+ detailView.dialog = $("tenant-addslice-dialog");
+ app.tenantAddSliceInterior.show(detailView);
+ $("#tenant-addslice-dialog").dialog({
+ autoOpen: false,
+ modal: true,
+ width: 640,
+ buttons : {
+ "Save" : function() {
+ var addDialog = this;
+ detailView.synchronous = true;
+ detailView.afterSave = function() { $(addDialog).dialog("close"); XOSTenantApp.navToSlice(detailView.model.id); }
+ detailView.save();
+ },
+ "Cancel" : function() {
+ $(this).dialog("close");
+ }
+ }
+ });
+ $("#tenant-addslice-dialog").dialog("open");
+};
+
XOSTenantApp.viewSlice = function(model) {
if (!model && xos.slicesPlus.models.length > 0) {
model = xos.slicesPlus.models[0];
@@ -142,42 +185,6 @@
linkedView: tenantSummary } ) );
};
-XOSTenantApp.initRouter = function() {
- router = XOSRouter;
- var api = {};
- var routes = {};
-
- nav_url = "slice/:id";
- api_command = "viewSlice";
- api[api_command] = function(id) { XOSTenantApp.viewSlice(xos.slicesPlus.get(id)); };
- routes[nav_url] = api_command;
-
- nav_url = "increase/:collectionName/:id/:fieldName";
- api_command = "increase";
- api[api_command] = function(collectionName, id, fieldName) {
- XOSTenantApp.Router.showPreviousURL();
- model = XOSTenantApp[collectionName].get(id);
- model.set(fieldName, model.get(fieldName) + 1);
- };
- routes[nav_url] = api_command;
-
- nav_url = "decrease/:collectionName/:id/:fieldName";
- api_command = "decrease";
- api[api_command] = function(collectionName, id, fieldName) {
- XOSTenantApp.Router.showPreviousURL();
- model = XOSTenantApp[collectionName].get(id);
- model.set(fieldName, Math.max(0, model.get(fieldName) - 1));
- };
- routes[nav_url] = api_command;
-
- nav_url = "*path";
- api_command = "defaultRoute";
- api[api_command] = function() { XOSTenantApp.viewSlice(undefined); };
- routes[nav_url] = api_command;
-
- XOSTenantApp.Router = new router({ appRoutes: routes, controller: api });
-};
-
XOSTenantApp.startNavigation = function() {
Backbone.history.start();
XOSTenantApp.navigationStarted = true;
@@ -188,11 +195,7 @@
if (!XOSTenantApp.navigationStarted) {
if (stats["isLoaded"] + stats["failedLoad"] >= stats["startedLoad"]) {
- XOSTenantApp.startNavigation();
-
- //if (xos.slicesPlus.models.length > 0) {
- // XOSTenantApp.Router.navigate("slice/" + xos.slicesPlus.models[0].id, {trigger:true});
- //}
+ XOSTenantApp.viewSlice(undefined);
} else {
$("#tenantSummary").html("<h3>Loading...</h3><div id='xos-startup-progress'></div>");
$("#xos-startup-progress").progressbar({value: stats["completedLoad"], max: stats["startedLoad"]});
@@ -203,8 +206,6 @@
XOSTenantApp.on("start", function() {
XOSTenantApp.buildViews();
- XOSTenantApp.initRouter();
-
// fire it once to initially show the progress bar
XOSTenantApp.collectionLoadChange();
diff --git a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
index 762a2b5..d359f36 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xos-backbone.js
@@ -398,8 +398,6 @@
if (!modelAttrs.defaults) {
modelAttrs.defaults = get_defaults(modelName);
}
- console.log(modelName);
- console.log(modelAttrs);
// if ((typeof xosdefaults !== "undefined") && xosdefaults[modelName]) {
// modelAttrs["defaults"] = xosdefaults[modelName];
@@ -694,6 +692,8 @@
detailFields: [],
});
+ this.tenant = function() { return this.tenantview.models[0].attributes; }
+
this.listObjects = function() { return this.allCollectionNames; };
this.getCollectionStatus = function() {
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index 0cadf79..4ec75a6 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -8,9 +8,6 @@
template: "#xos-sliceselector-option",
tagName: "option",
attributes: function() {
- console.log("XXX");
- console.log(this.options.selectedID);
- console.log(this.model.get("id"));
if (this.options.selectedID == this.model.get("id")) {
return { value: this.model.get("id"), selected: 1 };
} else {
@@ -881,7 +878,7 @@
var foreignCollection = view.collection.foreignFields[fieldName];
mSearchText = function(x) { return idToName(x, foreignCollection, "humanReadableName"); };
} else if (inputType[fieldName] == "spinner") {
- mRender = function(x,y,z) { return xosDataTableSpinnerTemplate( {value: x, collectionName: view.collection.collectionName, fieldName: fieldName, id: z.id} ); };
+ mRender = function(x,y,z) { return xosDataTableSpinnerTemplate( {value: x, collectionName: view.collection.collectionName, fieldName: fieldName, id: z.id, app: view.app} ); };
}
if ($.inArray(fieldName, view.collection.detailLinkFields)>=0) {
var collectionName = view.collection.collectionName;