putToSlice: function(slice) {
slice.attributes.site_allocation = {};
for (index in this.models) {
- model = this.models[index];
+ var model = this.models[index];
slice.attributes.site_allocation[ model.attributes.name ] = model.attributes.allocated;
}
},
saveClicked: function(e) {
model = this.options.linkedView.model;
model.tenantSiteCollection.putToSlice(model);
+ model.attributes.users = model.usersBuffer;
this.options.linkedView.submitContinueClicked.call(this.options.linkedView, e);
},
});
modal: true,
width: 640,
buttons : {
- "Save" : function() {
+ "Create Slice" : function() {
var addDialog = this;
console.log("SAVE!!!");
detailView.synchronous = true;
modal: true,
width: 640,
buttons : {
- "Save" : function() {
+ "Ok" : function() {
var editDialog = this;
user_ids = all_options($("#tenant-edit-users-dialog").find(".select-picker-to"));
user_ids = user_ids.map( function(x) { return parseInt(x,10); } );
- model.attributes.users = user_ids;
+ model.usersBuffer = user_ids;
$(editDialog).dialog("close");
},
"Cancel" : function() {
model = xos.slicesPlus.models[0];\r
}\r
\r
- sliceSelector = new XOSTenantApp.tenantSliceSelectorView({collection: xos.slicesPlus,\r
- selectedID: model.id,\r
- } );\r
- XOSTenantApp.sliceSelector = sliceSelector;\r
- XOSTenantApp.tenantSliceSelector.show(sliceSelector);\r
+ if (model) {\r
+ sliceSelector = new XOSTenantApp.tenantSliceSelectorView({collection: xos.slicesPlus,\r
+ selectedID: model ? model.id : null,\r
+ } );\r
+ XOSTenantApp.sliceSelector = sliceSelector;\r
+ XOSTenantApp.tenantSliceSelector.show(sliceSelector);\r
\r
- tenantSummary = new XOSTenantApp.tenantSummaryView({model: model,\r
- choices: {mount_data_sets: make_choices(xos.tenant().public_volume_names, null),\r
- serviceClass: make_choices(xos.tenant().blessed_service_class_names, xos.tenant().blessed_service_classes),\r
- default_image: make_choices(xos.tenant().blessed_image_names, xos.tenant().blessed_images),\r
- default_flavor: make_choices(xos.tenant().blessed_flavor_names, xos.tenant().blessed_flavors),},\r
- });\r
- XOSTenantApp.tenantSummary.show(tenantSummary);\r
+ tenantSummary = new XOSTenantApp.tenantSummaryView({model: model,\r
+ choices: {mount_data_sets: make_choices(xos.tenant().public_volume_names, null),\r
+ serviceClass: make_choices(xos.tenant().blessed_service_class_names, xos.tenant().blessed_service_classes),\r
+ default_image: make_choices(xos.tenant().blessed_image_names, xos.tenant().blessed_images),\r
+ default_flavor: make_choices(xos.tenant().blessed_flavor_names, xos.tenant().blessed_flavors),},\r
+ });\r
+ XOSTenantApp.tenantSummary.show(tenantSummary);\r
\r
- tenantSites = new XOSTenantSiteCollection();\r
- tenantSites.getFromSlice(model);\r
- model.tenantSiteCollection = tenantSites;\r
- XOSTenantApp.tenantSites = tenantSites;\r
+ tenantSites = new XOSTenantSiteCollection();\r
+ tenantSites.getFromSlice(model);\r
+ model.usersBuffer = model.attributes.users; /* save a copy of 'users' that we can edit. This prevents another view (developer) from overwriting our copy with a fetch from the server */\r
+ model.tenantSiteCollection = tenantSites;\r
+ XOSTenantApp.tenantSites = tenantSites;\r
\r
- tenantSiteList = new XOSTenantApp.tenantSiteListView({collection: tenantSites });\r
- XOSTenantApp.tenantSiteList.show(tenantSiteList);\r
- // on xos.slicePlus.sort, need to update xostenantapp.tenantSites\r
+ tenantSiteList = new XOSTenantApp.tenantSiteListView({collection: tenantSites });\r
+ XOSTenantApp.tenantSiteList.show(tenantSiteList);\r
+ // on xos.slicePlus.sort, need to update xostenantapp.tenantSites\r
\r
- XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { app: XOSTenantApp,\r
- linkedView: tenantSummary } ) );\r
+ XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { app: XOSTenantApp,\r
+ linkedView: tenantSummary } ) );\r
+ } else {\r
+ XOSTenantApp.tenantSliceSelector.show(new HTMLView({html: ""}));\r
+ XOSTenantApp.tenantSummary.show(new HTMLView({html: "You have no slices"}));\r
+ XOSTenantApp.tenantSiteList.show(new HTMLView({html: ""}));\r
+ XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { template: "#xos-tenant-buttons-noslice-template",\r
+ app: XOSTenantApp,\r
+ linkedView: tenantSummary } ) );\r
+ }\r
};\r
\r
XOSTenantApp.sanityCheck = function() {\r