Fixes: U4-3576 When editing file based items and changing the file name - we need to change the route location

This commit is contained in:
Shannon
2013-11-21 17:23:48 +11:00
parent 6fd5eee4f6
commit ffeed58f5d
4 changed files with 101 additions and 33 deletions

View File

@@ -48,18 +48,30 @@
submitSucces: function(t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', 'Saving scripting file failed', t);
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
}
}
var newFilePath = this._opts.nameTxtBox.val();
UmbClientMgr.mainTree().setActiveTreeType('python');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
//if the filename changes, we need to redirect since the file name is used in the url
if (this._opts.originalFileName != newFilePath) {
var newLocation = window.location.pathname + "?" + "&file=" + newFilePath;
UmbClientMgr.contentFrame(newLocation);
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Scripting file saved', '');
UmbClientMgr.mainTree().setActiveTreeType('python');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
}
},
submitFailure: function(t) {

View File

@@ -44,20 +44,32 @@
},
submitSucces: function(t) {
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', this._opts.text.fileErrorHeader, this._opts.text.fileErrorText);
}
else {
top.UmbSpeechBubble.ShowMessage('save', this._opts.text.fileSavedHeader, this._opts.text.fileSavedText);
}
var newFilePath = this._opts.nameTxtBox.val();
UmbClientMgr.mainTree().setActiveTreeType('scripts');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
//if the filename changes, we need to redirect since the file name is used in the url
if (this._opts.originalFileName != newFilePath) {
var newLocation = window.location.pathname + "?" + "&file=" + newFilePath;
UmbClientMgr.contentFrame(newLocation);
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
top.UmbSpeechBubble.ShowMessage('save', this._opts.text.fileSavedHeader, this._opts.text.fileSavedText);
}
else {
top.UmbSpeechBubble.ShowMessage('save', this._opts.text.fileSavedHeader, this._opts.text.fileSavedText);
UmbClientMgr.mainTree().setActiveTreeType('scripts');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
}
},
submitFailure: function(t) {

View File

@@ -125,11 +125,12 @@
path = args.path;
}
top.UmbSpeechBubble.ShowMessage('save', header, msg);
UmbClientMgr.mainTree().setActiveTreeType(this._opts.currentTreeType);
if (this._opts.editorType == "Template") {
top.UmbSpeechBubble.ShowMessage('save', header, msg);
//templates are different because they are ID based, whereas view files are file based without a static id
if (pathChanged) {
@@ -143,10 +144,40 @@
}
else {
var newFilePath = this._opts.nameTxtBox.val();
//then we need to update our current tree sync path to represent the new one
this._updateNewFileProperties(newFilePath);
UmbClientMgr.mainTree().syncTree(path, true, null, newFilePath.split("/")[1]);
function trimStart(str, trim) {
if (str.startsWith(trim)) {
return str.substring(trim.length);
}
return str;
}
//if the filename changes, we need to redirect since the file name is used in the url
if (this._opts.originalFileName != newFilePath) {
var queryParts = trimStart(window.location.search, "?").split('&');
var notFileParts = [];
for (var i = 0; i < queryParts.length; i++) {
if (queryParts[i].substr(0, "file=".length) != "file=") {
notFileParts.push(queryParts[i]);
}
}
var newLocation = window.location.pathname + "?" + notFileParts.join("&") + "&file=" + newFilePath;
UmbClientMgr.contentFrame(newLocation);
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
top.UmbSpeechBubble.ShowMessage('save', header, msg);
}
else {
top.UmbSpeechBubble.ShowMessage('save', header, msg);
//then we need to update our current tree sync path to represent the new one
this._updateNewFileProperties(newFilePath);
UmbClientMgr.mainTree().syncTree(path, true, null, newFilePath.split("/")[1]);
}
}
},

View File

@@ -47,16 +47,29 @@
if (t != 'true') {
top.UmbSpeechBubble.ShowMessage('error', 'Saving Xslt file failed',"<pre>" + t + "</pre>");
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Xslt file saved', '');
}
var newFilePath = this._opts.nameTxtBox.val();
UmbClientMgr.mainTree().setActiveTreeType('xslt');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
//if the filename changes, we need to redirect since the file name is used in the url
if (this._opts.originalFileName != newFilePath) {
var newLocation = window.location.pathname + "?" + "&file=" + newFilePath;
UmbClientMgr.contentFrame(newLocation);
//we need to do this after we navigate otherwise the navigation will wait unti lthe message timeout is done!
top.UmbSpeechBubble.ShowMessage('save', 'Xslt file saved', '');
}
else {
top.UmbSpeechBubble.ShowMessage('save', 'Xslt file saved', '');
UmbClientMgr.mainTree().setActiveTreeType('xslt');
//we need to pass in the newId parameter so it knows which node to resync after retreival from the server
UmbClientMgr.mainTree().syncTree("-1,init," + this._opts.originalFileName, true, null, newFilePath);
//set the original file path to the new one
this._opts.originalFileName = newFilePath;
}
},
submitFailure: function (t) {