Commit 39491d97 authored by serapath's avatar serapath

fix remove file bug

parent 448d4dab
...@@ -159,32 +159,19 @@ var run = function () { ...@@ -159,32 +159,19 @@ var run = function () {
// ---------------- FilePanel -------------------- // ---------------- FilePanel --------------------
/**************************************************************************** /****************************************************************************
@TODO's var sources = {
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 'test/client/credit.sol': '',
'src/voting.sol': '',
2. drag'n'drop to enable to rename files&folders in the file explorer into different sub folders 'src/leasing.sol': '',
'src/gmbh/contract.sol': false,
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. 'src/gmbh/test.sol': false,
'src/gmbh/company.sol': false,
4. add maybe more tape tests 'src/gmbh/node_modules/ballot.sol': false,
'src/ug/finance.sol': false,
5. gist imports + copy to the browser => phase of writing 'app/solidity/mode.sol': true,
'app/ethereum/constitution.sol': true
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) }
*/ 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` var css = csjs`
.filepanel { .filepanel {
...@@ -232,7 +219,9 @@ var run = function () { ...@@ -232,7 +219,9 @@ var run = function () {
if (span.innerText === oldName) span.innerText = newName if (span.innerText === oldName) span.innerText = newName
}) })
}) })
files.event.register('fileRemoved', function (path) {
if (path === currentFile) currentFile = null
})
// ------------------ gist publish -------------- // ------------------ gist publish --------------
$('#gist').click(function () { $('#gist').click(function () {
......
...@@ -140,10 +140,8 @@ function fileExplorer (appAPI, files) { ...@@ -140,10 +140,8 @@ function fileExplorer (appAPI, files) {
var label = getLabelFrom(li) var label = getLabelFrom(li)
var path = label.dataset.path var path = label.dataset.path
var isFolder = !!~label.className.indexOf('folder') var isFolder = !!~label.className.indexOf('folder')
if (confirm(` if (isFolder) path += '/'
Do you really want to delete "${path}" ? if (confirm(`Do you really want to delete "${path}" ?`)) {
${isFolder ? '(and all contained files and folders)' : ''}
`)) {
li.parentElement.removeChild(li) li.parentElement.removeChild(li)
removeSubtree(files, path) removeSubtree(files, path)
} }
...@@ -297,8 +295,10 @@ function getLabelFrom (li) { ...@@ -297,8 +295,10 @@ function getLabelFrom (li) {
} }
function removeSubtree (files, path) { function removeSubtree (files, path) {
var allPaths = Object.keys(files.list()) // @TODO: change `files` var parts = path.split('/')
var removePaths = allPaths.filter(function (p) { return ~p.indexOf(path) }) 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) { removePaths.forEach(function (path) {
[...window.files.querySelectorAll('.file .name')].forEach(function (span) { [...window.files.querySelectorAll('.file .name')].forEach(function (span) {
if (span.innerText === path) { if (span.innerText === path) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment