Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
fix: changes being lost when switching files
Browse files Browse the repository at this point in the history
File that was not saved should warn to be saved before changing to another
directory or file.

Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
  • Loading branch information
Bruno Bottazzini committed Mar 31, 2016
1 parent 48679a7 commit 5cff6c5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions client/js/controllers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
var _l = data.node.li_attr;
var repos = _l.id.split("repos")[1];
var rfinal = repos.split("/");
var previousContent = editor.getSession().getValue();
$scope.subFolder = rfinal[1];
$scope.folder = rfinal[2];
$scope.getConfigurationlist(_l.id);
Expand All @@ -83,7 +84,6 @@
if (_l.isLeaf) {
FetchFileFactory.fetchFile(_l.base).then(function(data) {
var _d = data.data;
var previousContent = editor.getSession().getValue();
if (typeof _d == 'object') {
_d = JSON.stringify(_d, undefined, 2);
}
Expand All @@ -108,25 +108,25 @@
});
$scope.root = false;
} else {
filePath = _l.id;
$scope.fileName = ': ' + filePath.split("/").pop(); //getting the selected node name
editor.setReadOnly(true);
editor.setHighlightActiveLine(false);
if (data.node.parent === "#") {
$scope.root = true;
$scope.setEditorContent('Please select a file to view its contents', null, null);
$scope.setEditorContent('Please select a file to view its contents', previousContent, filePath);
} else {
if (data.node.parents[1] === "#") {
$scope.root = true;
$scope.setEditorContent('Please select a file to view its contents', null, null);
$scope.setEditorContent('Please select a file to view its contents', previousContent, filePath);
} else {
if (!isLeaf) {
$scope.setEditorContent('Please select a file to view its contents', null, null);
$scope.setEditorContent('Please select a file to view its contents', previousContent, filePath);
}
$scope.root = false;
}
}
filePath = _l.id;
$scope.fileName = ': ' + filePath.split("/").pop(); //getting the selected node name
$scope.fbpType = false;
editor.setReadOnly(true);
editor.setHighlightActiveLine(false);
}
};

Expand Down Expand Up @@ -444,7 +444,7 @@
};

$scope.saveFile = function(path, body) {
if (body && path && isLeaf) {
if (body && path) {
$http.get('api/file/write',
{params: {
"file_path": path,
Expand Down

0 comments on commit 5cff6c5

Please sign in to comment.