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