},
createClicked: function(e) {
+ XOSTenantApp.addSlice();
},
deleteClicked: function(e) {
XOSTenantApp = new XOSApplication({
logTableId: "#logTable",
statusMsgId: "#statusMsg",
- hideTabsByDefault: true
+ hideTabsByDefault: true,
+ varName: "XOSTenantApp",
});
XOSTenantApp.addRegions({
tenantSummary: "#tenantSummary",
tenantSiteList: "#tenantSiteList",
tenantButtons: "#tenantButtons",
+ tenantAddSliceInterior: "#tenant-addslice-interior",
});
-XOSTenantApp.buildViews = function() {\r
+XOSTenantApp.buildViews = function() {
XOSTenantApp.tenantSites = new XOSTenantSiteCollection();\r
\r
tenantSummaryClass = XOSDetailView.extend({template: "#xos-detail-template",\r
\r
XOSTenantApp.tenantSummaryView = tenantSummaryClass;\r
\r
+ tenantAddClass = XOSDetailView.extend({template: "#xos-detail-template",\r
+ app: XOSTenantApp,\r
+ detailFields: ["name", "description"]});\r
+\r
+ XOSTenantApp.tenantAddView = tenantAddClass;\r
+\r
tenantSiteItemClass = XOSItemView.extend({template: "#xos-listitem-template",\r
app: XOSTenantApp});\r
\r
\r
XOSTenantApp.tenantSliceSelectorView = SliceSelectorView.extend( {\r
sliceChanged: function(id) {\r
- //console.log("navigate to " + id);\r
- XOSTenantApp.Router.navigate("slice/" + id, {trigger: true});\r
+ XOSTenantApp.navToSlice(id);\r
},\r
});\r
\r
return result;\r
};\r
\r
+XOSTenantApp.navToSlice = function(id) {\r
+ XOSTenantApp.viewSlice(xos.slicesPlus.get(id));\r
+};\r
+\r
+XOSTenantApp.adjustCollectionField = function(collectionName, id, fieldName, amount) {\r
+ model = XOSTenantApp[collectionName].get(id);\r
+ model.set(fieldName, Math.max(model.get(fieldName) + amount, 0));\r
+};\r
+\r
+XOSTenantApp.addSlice = function() {\r
+ var app=this;\r
+ model = new xos.slicesPlus.model({site: xos.tenant().current_user_site_id});\r
+ console.log(model);\r
+ var detailView = new XOSTenantApp.tenantAddView({model: model, collection: xos.slicesPlus});\r
+ detailView.dialog = $("tenant-addslice-dialog");\r
+ app.tenantAddSliceInterior.show(detailView);\r
+ $("#tenant-addslice-dialog").dialog({\r
+ 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");\r
+};\r
+\r
XOSTenantApp.viewSlice = function(model) {\r
if (!model && xos.slicesPlus.models.length > 0) {\r
model = xos.slicesPlus.models[0];\r
linkedView: tenantSummary } ) );\r
};\r
\r
-XOSTenantApp.initRouter = function() {\r
- router = XOSRouter;\r
- var api = {};\r
- var routes = {};\r
-\r
- nav_url = "slice/:id";\r
- api_command = "viewSlice";\r
- api[api_command] = function(id) { XOSTenantApp.viewSlice(xos.slicesPlus.get(id)); };\r
- routes[nav_url] = api_command;\r
-\r
- nav_url = "increase/:collectionName/:id/:fieldName";\r
- api_command = "increase";\r
- api[api_command] = function(collectionName, id, fieldName) {\r
- XOSTenantApp.Router.showPreviousURL();\r
- model = XOSTenantApp[collectionName].get(id);\r
- model.set(fieldName, model.get(fieldName) + 1);\r
- };\r
- routes[nav_url] = api_command;\r
-\r
- nav_url = "decrease/:collectionName/:id/:fieldName";\r
- api_command = "decrease";\r
- api[api_command] = function(collectionName, id, fieldName) {\r
- XOSTenantApp.Router.showPreviousURL();\r
- model = XOSTenantApp[collectionName].get(id);\r
- model.set(fieldName, Math.max(0, model.get(fieldName) - 1));\r
- };\r
- routes[nav_url] = api_command;\r
-\r
- nav_url = "*path";\r
- api_command = "defaultRoute";\r
- api[api_command] = function() { XOSTenantApp.viewSlice(undefined); };\r
- routes[nav_url] = api_command;\r
-\r
- XOSTenantApp.Router = new router({ appRoutes: routes, controller: api });\r
-};\r
-\r
XOSTenantApp.startNavigation = function() {\r
Backbone.history.start();\r
XOSTenantApp.navigationStarted = true;\r
\r
if (!XOSTenantApp.navigationStarted) {\r
if (stats["isLoaded"] + stats["failedLoad"] >= stats["startedLoad"]) {\r
- XOSTenantApp.startNavigation();\r
-\r
- //if (xos.slicesPlus.models.length > 0) {\r
- // XOSTenantApp.Router.navigate("slice/" + xos.slicesPlus.models[0].id, {trigger:true});\r
- //}\r
+ XOSTenantApp.viewSlice(undefined);\r
} else {\r
$("#tenantSummary").html("<h3>Loading...</h3><div id='xos-startup-progress'></div>");\r
$("#xos-startup-progress").progressbar({value: stats["completedLoad"], max: stats["startedLoad"]});\r
XOSTenantApp.on("start", function() {\r
XOSTenantApp.buildViews();
- XOSTenantApp.initRouter();
-
// fire it once to initially show the progress bar
XOSTenantApp.collectionLoadChange();
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 {
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;