X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fxoslib%2Fstatic%2Fjs%2FxosTenant.js;h=10e70e62907f3c7403f41ddd2ca331f64c6ec951;hb=a1298a8aec652145ba249b6f8ccea96dcbb96b75;hp=9c45460a3039fc6c3e036d06034d9e1c001a11c1;hpb=b4fcd4005bcebbafc988a2e6bc0d2da2b7ffc908;p=plstackapi.git diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index 9c45460..10e70e6 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -50,6 +50,20 @@ XOSEditUsersView = Marionette.ItemView.extend({ }); +XOSTenantSummaryView = XOSDetailView.extend({ + events: {"change": "onChange"}, + + onChange: function(e) { + XOSTenantApp.setDirty(true); + }, + + saveSuccess: function() { + console.log("saveSuccess!"); + XOSTenantApp.setDirty(false); + }, + + }); + XOSTenantButtonView = Marionette.ItemView.extend({ template: "#xos-tenant-buttons-template", @@ -76,7 +90,11 @@ XOSTenantButtonView = Marionette.ItemView.extend({ model = this.options.linkedView.model; model.tenantSiteCollection.putToSlice(model); model.attributes.users = model.usersBuffer; - this.options.linkedView.submitContinueClicked.call(this.options.linkedView, e); + + e.preventDefault(); + this.options.linkedView.save(); + //this.options.linkedView.submitContinueClicked.call(this.options.linkedView, e); + //XOSTenantApp.setDirty(false); }, }); @@ -96,10 +114,18 @@ XOSTenantApp.addRegions({ tenantEditUsersInterior: "#tenant-edit-users-interior", }); +XOSTenantApp.setDirty = function(dirty) { + if (dirty) { + $("button.btn-tenant-save").addClass("btn-success"); + } else { + $("button.btn-tenant-save").removeClass("btn-success"); + } +}; + XOSTenantApp.buildViews = function() { XOSTenantApp.tenantSites = new XOSTenantSiteCollection(); - tenantSummaryClass = XOSDetailView.extend({template: "#xos-detail-template", + tenantSummaryClass = XOSTenantSummaryView.extend({template: "#xos-detail-template", app: XOSTenantApp, detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports", "mount_data_sets"], fieldDisplayNames: {serviceClass: "Service Level", "default_flavor": "Flavor", "default_image": "Image", "mount_data_sets": "Data Sets"}, @@ -172,6 +198,7 @@ XOSTenantApp.navToSlice = function(id) { XOSTenantApp.adjustCollectionField = function(collectionName, id, fieldName, amount) { model = XOSTenantApp[collectionName].get(id); model.set(fieldName, Math.max(model.get(fieldName) + amount, 0)); + XOSTenantApp.setDirty(true); }; XOSTenantApp.addSlice = function() { @@ -183,11 +210,12 @@ XOSTenantApp.addSlice = function() { } model = new xos.slicesPlus.model({site: xos.tenant().current_user_site_id, - name: xos.tenant().current_user_login_base + "_"}); + name: xos.tenant().current_user_login_base + "_", + creator: xos.tenant().current_user_id}); console.log(model); var detailView = new XOSTenantApp.tenantAddView({model: model, - collection: xos.slicesPlus, - noSubmitButton: true, + collection: xos.slicesPlus, + noSubmitButton: true, }); detailView.dialog = $("#tenant-addslice-dialog"); app.tenantAddSliceInterior.show(detailView);