From 5cff6c5ae3027890eec3d076a36151a2bde6fd43 Mon Sep 17 00:00:00 2001 From: Bruno Bottazzini Date: Thu, 31 Mar 2016 17:35:23 -0300 Subject: [PATCH] fix: changes being lost when switching files File that was not saved should warn to be saved before changing to another directory or file. Signed-off-by: Bruno Bottazzini --- client/js/controllers/editor.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/client/js/controllers/editor.js b/client/js/controllers/editor.js index efef597..792d27d 100644 --- a/client/js/controllers/editor.js +++ b/client/js/controllers/editor.js @@ -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); @@ -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); } @@ -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); } }; @@ -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,