Permalink
Browse files

Site editor: dirty state was sometimes incorrect

  • Loading branch information...
Mark Macdonald
Mark Macdonald committed Mar 5, 2012
1 parent 88a0253 commit fd7bb9505b6211ab4cefbfb650d8f4fd931a1861
Showing with 13 additions and 12 deletions.
  1. +13 −12 bundles/org.eclipse.orion.client.core/web/orion/widgets/SiteEditor.js
@@ -380,13 +380,11 @@ dojo.declare("orion.widgets.SiteEditor", [dijit.layout.ContentPane, dijit._Templ
},
_setSiteConfiguration: function(siteConfiguration) {
- this._detachListeners(this._siteConfiguration);
+ this._detachListeners();
this._siteConfiguration = siteConfiguration;
this._fetchProjects(siteConfiguration);
this._refreshFields();
- setTimeout(dojo.hitch(this, function() {
- this._attachListeners(this._siteConfiguration);
- }), 0);
+ this.setDirty(false);
},
setDirty: function(value) {
@@ -397,7 +395,7 @@ dojo.declare("orion.widgets.SiteEditor", [dijit.layout.ContentPane, dijit._Templ
},
isDirty: function() {
- return this._isDirty || this.mappings.isDirty();
+ return this._isDirty;
},
_refreshFields: function() {
@@ -420,14 +418,19 @@ dojo.declare("orion.widgets.SiteEditor", [dijit.layout.ContentPane, dijit._Templ
dojo.empty(this._commandsContainer);
this._commandService.renderCommands(this._commandsContainer.id, this._commandsContainer, this._siteConfiguration, {},
"button", null, this._siteConfiguration /*userData*/);
+
+ setTimeout(dojo.hitch(this, function() {
+ this._attachListeners(this._siteConfiguration);
+ }), 0);
},
/**
* Hook up listeners that perform form widget -> model updates.
* @param site {SiteConfiguration}
*/
_attachListeners: function(site) {
- this._modelListeners = [];
+ this._detachListeners();
+ this._modelListeners = this._modelListeners || [];
var editor = this;
function bindText(widget, modelField) {
@@ -443,18 +446,17 @@ dojo.declare("orion.widgets.SiteEditor", [dijit.layout.ContentPane, dijit._Templ
bindText(this.name, "Name");
bindText(this.hostHint, "HostHint");
- this._modelListeners.push(dojo.connect(this.mappings, "setDirty", this, function(value) {
- if (value) {
- this.setDirty(true);
- }
- }));
+ this._modelListeners.push(dojo.connect(this.mappings, "setDirty", this, function(dirty) {
+ this.setDirty(dirty);
+ }));
},
_detachListeners: function() {
if (this._modelListeners) {
for (var i=0; i < this._modelListeners.length; i++) {
dojo.disconnect(this._modelListeners[i]);
}
+ this._modelListeners.splice(0);
}
},
@@ -485,7 +487,6 @@ dojo.declare("orion.widgets.SiteEditor", [dijit.layout.ContentPane, dijit._Templ
var deferred = this._siteService.updateSiteConfiguration(siteConfig.Location, siteConfig).then(
function(updatedSiteConfig) {
editor._setSiteConfiguration(updatedSiteConfig);
- editor.setDirty(false);
return { Result: "Saved \"" + updatedSiteConfig.Name + "\"." };
});
this._busyWhile(deferred, "Saving...");

0 comments on commit fd7bb95

Please sign in to comment.