Added append setting to trees
This commit is contained in:
parent
adf7d7a67c
commit
4f23e2a264
3 changed files with 14 additions and 5 deletions
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-frag>
|
<div v-frag>
|
||||||
<span class="row" v-for="(row, index) in rows" :key="index">
|
<span class="row" v-for="(row, index) in rows" :key="index">
|
||||||
<tree-node v-for="(node, nodeIndex) in row" :key="nodeIndex" :id="node" @show-modal="openModal" />
|
<tree-node v-for="(node, nodeIndex) in row" :key="nodeIndex" :id="node" @show-modal="openModal" :append="append" />
|
||||||
</span>
|
</span>
|
||||||
<span class="side-nodes" v-if="rows.side">
|
<span class="side-nodes" v-if="rows.side">
|
||||||
<tree-node v-for="(node, nodeIndex) in rows.side" :key="nodeIndex" :id="node" @show-modal="openModal" small />
|
<tree-node v-for="(node, nodeIndex) in rows.side" :key="nodeIndex" :id="node" @show-modal="openModal" :append="append" small />
|
||||||
</span>
|
</span>
|
||||||
<modal :show="showModal" @close="closeModal">
|
<modal :show="showModal" @close="closeModal">
|
||||||
<div slot="header"><h2 v-if="modalHeader">{{ modalHeader }}</h2></div>
|
<div slot="header"><h2 v-if="modalHeader">{{ modalHeader }}</h2></div>
|
||||||
|
@ -26,7 +26,8 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
nodes: Array
|
nodes: Array,
|
||||||
|
append: Boolean
|
||||||
},
|
},
|
||||||
inject: [ 'tab' ],
|
inject: [ 'tab' ],
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -31,7 +31,8 @@ export default {
|
||||||
name: 'tree-node',
|
name: 'tree-node',
|
||||||
props: {
|
props: {
|
||||||
id: [ String, Number ],
|
id: [ String, Number ],
|
||||||
small: Boolean
|
small: Boolean,
|
||||||
|
append: Boolean
|
||||||
},
|
},
|
||||||
inject: [ 'tab' ],
|
inject: [ 'tab' ],
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -94,6 +95,13 @@ export default {
|
||||||
this.layer.onClick();
|
this.layer.onClick();
|
||||||
} else if (this.layer.modal) {
|
} else if (this.layer.modal) {
|
||||||
this.$emit('show-modal', this.id);
|
this.$emit('show-modal', this.id);
|
||||||
|
} else if (this.append) {
|
||||||
|
if (player.tabs.includes(this.id)) {
|
||||||
|
const index = player.tabs.lastIndexOf(this.id);
|
||||||
|
player.tabs = [...player.tabs.slice(0, index), ...player.tabs.slice(index + 1)];
|
||||||
|
} else {
|
||||||
|
player.tabs = [...player.tabs, this.id];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.tabs = [...player.tabs.slice(0, this.tab.index + 1), this.id];
|
player.tabs = [...player.tabs.slice(0, this.tab.index + 1), this.id];
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ const spook = {
|
||||||
|
|
||||||
const main = {
|
const main = {
|
||||||
id: 'main',
|
id: 'main',
|
||||||
display: '<tree />'
|
display: '<tree append="true" />'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initialLayers = [ main, f, c, a, g, h, spook ];
|
export const initialLayers = [ main, f, c, a, g, h, spook ];
|
||||||
|
|
Loading…
Reference in a new issue