Commit 7216a1f1 authored by Jacob Schatz's avatar Jacob Schatz

Remove children when closing folder.

parent 8f4850e1
......@@ -7,7 +7,6 @@ import Helper from './repo_helper'
export default class RepoBundle {
constructor() {
console.log(document.getElementById('ide'))
const url = document.getElementById('ide').dataset.url;
Store.service = Service;
Store.service.url = url;
......
......@@ -22,7 +22,6 @@ let RepoFile = {
methods: {
linkClicked(file) {
console.log(this.isTree)
this.$emit('linkclicked', file);
}
}
......
......@@ -84,6 +84,13 @@ let RepoHelper = {
}
},
setDirectoryOpen(tree) {
if(tree) {
tree.opened = true;
tree.icon = 'fa-folder-open';
}
},
// may be tree or file.
getContent(file) {
Service.getContent()
......@@ -98,9 +105,9 @@ let RepoHelper = {
data.url = file.url;
this.addToOpenedFiles(data);
this.setActiveFile(data);
console.log(data);
} else {
// it's a tree
this.setDirectoryOpen(file);
let newDirectory = this.dataToListOfFiles(data);
Store.files = this.insertNewFilesIntoParentDir(file, Store.files, newDirectory);
Store.prevURL = this.blobURLtoParent(Service.url);
......@@ -112,7 +119,25 @@ let RepoHelper = {
},
toFA(icon) {
return `fa-${icon}`
return `fa-${icon}`;
},
removeChildFilesOfTree(tree) {
let foundTree = false;
Store.files = Store.files.filter((file) => {
if(file.url === tree.url) {
foundTree = true;
}
if(foundTree) {
return file.level <= tree.level
} else {
return true;
}
});
tree.opened = false;
tree.icon = 'fa-folder';
},
dataToListOfFiles(data) {
......
......@@ -3,7 +3,6 @@ import Store from './repo_store'
let RepoMiniMixin = {
computed: {
isMini() {
console.log('checking', Store.openedFiles.length)
return !!Store.openedFiles.length;
}
},
......
......@@ -11,7 +11,6 @@ export default class RepoSidebar {
this.url = url;
this.initVue();
this.el = document.getElementById('ide');
console.log(document.getElementById('sidebar'))
}
initVue() {
......@@ -48,6 +47,10 @@ export default class RepoSidebar {
}
Service.url = url;
if(typeof file === 'object') {
if(file.type === 'tree' && file.opened) {
Helper.removeChildFilesOfTree(file);
return;
}
Helper.getContent(file);
}
}
......
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