diff --git a/src/app.js b/src/app.js index 2fac32971e..68b6a35191 100644 --- a/src/app.js +++ b/src/app.js @@ -159,32 +159,19 @@ var run = function () { // ---------------- FilePanel -------------------- /**************************************************************************** - @TODO's - 1. I would put a virtual file called Summary as the root entry of the treeview, which displays the list of the files with the size in bytes of each - - 2. drag'n'drop to enable to rename files&folders in the file explorer into different sub folders - - 3. I would put a virtual file called `Summary` as the root entry of the treeview, which displays the list of the files with the size in bytes of each. - - 4. add maybe more tape tests - - 5. gist imports + copy to the browser => phase of writing - - 6. add filemanagement from righthand panel to filepanel compoennt (editing/imports/exports, public gist, load from github, create new project, ... setup load and modify files) - */ - // var sources = { - // 'test/client/credit.sol': '', - // 'src/voting.sol': '', - // 'src/leasing.sol': '', - // 'src/gmbh/contract.sol': false, - // 'src/gmbh/test.sol': false, - // 'src/gmbh/company.sol': false, - // 'src/gmbh/node_modules/ballot.sol': false, - // 'src/ug/finance.sol': false, - // 'app/solidity/mode.sol': true, - // 'app/ethereum/constitution.sol': true - // } - // Object.keys(sources).forEach(function (key) { files.set(key, sources[key]) }) + var sources = { + 'test/client/credit.sol': '', + 'src/voting.sol': '', + 'src/leasing.sol': '', + 'src/gmbh/contract.sol': false, + 'src/gmbh/test.sol': false, + 'src/gmbh/company.sol': false, + 'src/gmbh/node_modules/ballot.sol': false, + 'src/ug/finance.sol': false, + 'app/solidity/mode.sol': true, + 'app/ethereum/constitution.sol': true + } + Object.keys(sources).forEach(function (key) { files.set(key, sources[key]) }) /****************************************************************************/ var css = csjs` .filepanel { @@ -232,7 +219,9 @@ var run = function () { if (span.innerText === oldName) span.innerText = newName }) }) - + files.event.register('fileRemoved', function (path) { + if (path === currentFile) currentFile = null + }) // ------------------ gist publish -------------- $('#gist').click(function () { diff --git a/src/app/execution-context.js b/src/app/execution-context.js index fbb2351bf9..a965a5cd71 100644 --- a/src/app/execution-context.js +++ b/src/app/execution-context.js @@ -147,7 +147,7 @@ function ExecutionContext () { selectExEnv.value = executionContext } }) - + selectExEnv.value = executionContext } diff --git a/src/app/file-explorer.js b/src/app/file-explorer.js index 800afde400..095e288fb3 100755 --- a/src/app/file-explorer.js +++ b/src/app/file-explorer.js @@ -140,10 +140,8 @@ function fileExplorer (appAPI, files) { var label = getLabelFrom(li) var path = label.dataset.path var isFolder = !!~label.className.indexOf('folder') - if (confirm(` - Do you really want to delete "${path}" ? - ${isFolder ? '(and all contained files and folders)' : ''} - `)) { + if (isFolder) path += '/' + if (confirm(`Do you really want to delete "${path}" ?`)) { li.parentElement.removeChild(li) removeSubtree(files, path) } @@ -297,8 +295,10 @@ function getLabelFrom (li) { } function removeSubtree (files, path) { - var allPaths = Object.keys(files.list()) // @TODO: change `files` - var removePaths = allPaths.filter(function (p) { return ~p.indexOf(path) }) + var parts = path.split('/') + var isFile = parts[parts.length - 1].length + var removePaths = isFile ? [path] : Object.keys(files.list()).filter(keep) + function keep (p) { return ~p.indexOf(path) } removePaths.forEach(function (path) { [...window.files.querySelectorAll('.file .name')].forEach(function (span) { if (span.innerText === path) {