Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js
index 0ab8e81..10e70e6 100644
--- a/planetstack/core/xoslib/static/js/xosTenant.js
+++ b/planetstack/core/xoslib/static/js/xosTenant.js
@@ -50,6 +50,20 @@
});
+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 @@
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 @@
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.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() {
diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
index a46fa40..6b6419c 100644
--- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
+++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js
@@ -475,7 +475,7 @@
*/
initialize: function() {
- this.on("saveSuccess", this.onAfterSave);
+ this.on("saveSuccess", this.onSaveSuccess);
this.synchronous = false;
},
@@ -485,11 +485,20 @@
});
},
- afterSave: function(e) {
+ saveSuccess: function(e) {
+ // always called after a save succeeds
},
- onAfterSave: function(e) {
- this.afterSave(e);
+ afterSave: function(e) {
+ // if this.synchronous, then called after the save succeeds
+ // if !this.synchronous, then called after save is initiated
+ },
+
+ onSaveSuccess: function(e) {
+ this.saveSuccess(e);
+ if (this.synchronous) {
+ this.afterSave(e);
+ }
},
inputChanged: function(e) {
@@ -559,9 +568,7 @@
this.model.save(data, {error: function(model, result, xhr) { that.app.saveError(model,result,xhr,infoMsgId);},
success: function(model, result, xhr) { that.app.saveSuccess(model,result,xhr,infoMsgId);
- if (that.synchronous) {
- that.trigger("saveSuccess");
- }
+ that.trigger("saveSuccess");
}});
this.dirty = false;