fix remove file bug

pull/1/head
serapath 8 years ago
parent 448d4dab1e
commit 39491d97fe
  1. 43
      src/app.js
  2. 2
      src/app/execution-context.js
  3. 12
      src/app/file-explorer.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 () {

@ -147,7 +147,7 @@ function ExecutionContext () {
selectExEnv.value = executionContext
}
})
selectExEnv.value = executionContext
}

@ -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) {

Loading…
Cancel
Save