Commit 990b7394 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

Fixed bug in Workspace onconnect handling. This resolved problem with...

Fixed bug in Workspace onconnect handling. This resolved problem with reconstructing workspace state and URL fragment interference. fix #2266
parent a4b4720d
/**
* .. _workspaces:
*
*
* WorkspaceManager
* ================
*
......@@ -62,10 +62,10 @@ define([
callback: function() {
var workspace = this.getWorkspace();
if (!workspace) return;
var instance = workspace.getCurrentCenterInstance();
if (!instance) return
instance.close();
}
}
......@@ -123,7 +123,7 @@ define([
// fired prior to connecting workspaces so fragments have priority over cookies
self.emit("ready");
for(var i=0; i<ids.length; i++) {
self.connectWorkspace(ids[i]);
}
......@@ -133,7 +133,7 @@ define([
self.logger.info("started");
});
if (vispa.extensions.extensionsLoading) {
vispa.extensions.once("ready", cb);
} else {
......@@ -250,7 +250,7 @@ define([
return isNaN(id) ? null : (this.workspaces[id] || null);
},
getWorkspaceByName: function(name) {
var workspace = null;
for (var i in this.workspaces) {
......@@ -396,7 +396,7 @@ define([
/**
*
*
* Workspace
* =========
*
......@@ -478,10 +478,10 @@ define([
getCenterJuggler: function() {
return this._centerJuggler;
},
getCurrentCenterInstance: function() {
if (!this._centerJuggler) return null;
return this._centerJuggler.focusInstance;
},
......@@ -621,9 +621,12 @@ define([
self.varData.passwordDialog.close();
}
var wasNotConnected = !self.connected();
self._state = "connected";
self.logger.debug("connected");
self.finishConnect(null);
if (wasNotConnected) {
self.finishConnect(null);
}
});
this.on("disconnecting", function() {
......@@ -853,7 +856,7 @@ define([
self.nodes.views.center.$tabs,
self.nodes.views.center.$content,
".vispa-centerview-tab-label", self);
// also register state changes on juggler events
self._centerJuggler
.on('juggler.*' , self.saveState.bind(self, 20))
......@@ -926,7 +929,7 @@ define([
self.loadDefaultInstances();
}
}
switch(vispa.workspaces.preferences.continueSession || "never") {
case "ask":
var dialog = new Dialog();
......@@ -936,7 +939,7 @@ define([
opts.body = "Do you want to load the last saved session?";
opts.wrapBody = true;
opts.footer = [
$('<div class="checkbox"><label><input type="checkbox"> Remember choice</label></div>').css({
display: "inline-block",
......@@ -960,14 +963,14 @@ define([
})
];
opts.wrapFooter = true;
dialog.on("show", function() {
dialog.$footer.find("button.btn-primary").focus();
});
dialog.setOptions(opts);
dialog.show();
break;
case "always":
loader(true);
......@@ -977,19 +980,19 @@ define([
loader(false);
break;
}
} else {
self.loadDefaultInstances();
}
},
loadDefaultInstances: function() {
if (vispa.workspaces.varData.workspaceAction) {
vispa.callbacks.emit(vispa.workspaces.varData.workspaceAction, self.getId());
}
this.emit("ready");
},
connect: function(callback) {
var self = this;
......@@ -1038,12 +1041,12 @@ define([
return this;
},
finishConnect: function (err) {
var self = this;
this.varData.invokedConnect = false;
var callback = self.varData.connectCallback;
self.varData.connectCallback = [];
......@@ -1055,7 +1058,7 @@ define([
callback.unshift(null);
return vispa.applyFirst.apply(callback);
}
var cb = function() {
self.loadUI(function(err) {
self.setLoading(false);
......@@ -1072,7 +1075,7 @@ define([
return vispa.applyFirst.apply(callback);
});
}
var dfd = self.varData.lastStateDfd;
if (dfd) {
dfd.done(cb);
......@@ -1091,7 +1094,7 @@ define([
this.connect(this.focus.bind(this, callback));
return this;
}
if (this.isFocused()) {
callback(null);
return this;
......@@ -1271,7 +1274,7 @@ define([
var iconClass = "glyphicon glyphicon-" + (loading ? "refresh" : "ok");
this.nodes.$mainMenuButtonIcon.removeClass().addClass(iconClass);
}
this.emit("loadingDone");
return this;
......@@ -1311,7 +1314,7 @@ define([
} else {
delay *= 1000;
}
if (delay) {
if (this.varData.stateTimeout ? (this.varData.stateTimeoutTime > Date.now()+delay) : true){
if (this.varData.stateTimeout) {
......@@ -1326,7 +1329,7 @@ define([
this.varData.stateTimeout = null;
this.varData.stateTimeoutTime = 0;
}
var state = {
centerView: this._centerJuggler.getState().map(function(subState){
var instance = subState[0]
......@@ -1334,7 +1337,7 @@ define([
return [instance.getExtension().getName(), instance.getName(), instance.getState(), focusIndex];
}),
}
vispa.POST(vispa.url.dynamic("ajax/setworkspacestate"), {
wid : this.getId(),
state : JSON.stringify(state),
......@@ -1345,13 +1348,13 @@ define([
});
}
},
saveFragment: function() {
if (this.isFocused()) {
vispa.saveFragment();
}
},
applyFragment: function(fragment, data) {
if (!this.connected()) {
this.once("ready", this.applyFragment.bind(this, fragment, data));
......@@ -1366,7 +1369,7 @@ define([
vispa.extensions.once("ready", this.applyFragment.bind(this, fragment, data));
return;
}
if (fragment) {
fragment = fragment.split(':');
fragment[2] = fragment.splice(2, fragment.length).join(':');
......@@ -1391,26 +1394,26 @@ define([
}
}
}
// create instance
if (!instance) {
instance = vispa.extensions.createInstance(this.getId(),
fragment[0], fragment[1], 0);
}
// no such extension (not loaded?)
if (!instance) {
this.alert("Could not create Instance '" + fragment[1] +
"' for extension '" + fragment[0] + "'!")
return;
}
instance.applyFragment(fragment[2]);
instance.focus();
}
}
},
getFragmentTuple: function() { // returns fragment, data & title at once
if (!this.isManaged()) return ["",{},""];
if (!this._centerJuggler) return ["",{},""];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment