2020-09-03 23:02:28 +02:00
|
|
|
<template>
|
2020-09-18 13:36:02 +02:00
|
|
|
|
2020-11-03 21:10:48 +01:00
|
|
|
<div :class="editorMode ? 'treenode-org' : 'treenode'">
|
2020-12-02 01:42:15 +01:00
|
|
|
<!--b v-if="tema">v tematu</b>
|
2020-09-21 11:30:00 +02:00
|
|
|
<b v-if="visible">visible</b>
|
2020-09-21 13:59:28 +02:00
|
|
|
Force visible: {{String(force_visible)}}-->
|
2020-11-03 21:09:33 +01:00
|
|
|
<component :is='item.node.polymorphic_ctype.model' :item='item' :key='item.node.id'
|
2020-12-02 01:42:15 +01:00
|
|
|
:tema="temaOut"
|
2020-11-03 21:09:33 +01:00
|
|
|
:editorMode="editorMode"
|
|
|
|
:debugMode="debugMode"></component>
|
2020-09-21 10:58:54 +02:00
|
|
|
|
2020-09-16 17:55:30 +02:00
|
|
|
|
2020-11-03 21:09:33 +01:00
|
|
|
<button v-if="debugMode" v-on:click="debugShow = !debugShow" class="nodebug">Ladící data</button> <!-- bude tu nějaký if na class="nodebug", v debug módu bude tlačítko vidět, jinak ne -->
|
2020-09-03 23:02:28 +02:00
|
|
|
<div v-if="debugShow">
|
2020-12-02 01:42:15 +01:00
|
|
|
<pre>Tema: {{ tema }}</pre>
|
|
|
|
<pre>TemaOut: {{ temaOut }}</pre>
|
2020-09-03 23:02:28 +02:00
|
|
|
<pre>{{ item.node.polymorphic_ctype.model }}</pre>
|
|
|
|
<pre>{{ item }}</pre>
|
|
|
|
</div>
|
2020-09-16 17:55:30 +02:00
|
|
|
|
2020-09-03 23:02:28 +02:00
|
|
|
<div v-if="item.children.length === 0">
|
2020-11-03 21:42:15 +01:00
|
|
|
<div v-if="item.appendable_children.length > 0 && editorMode">
|
2020-09-18 13:36:02 +02:00
|
|
|
<b>Vložit jako syna: </b>
|
2020-12-02 01:42:15 +01:00
|
|
|
<addnewnode :types="item.appendable_children" :refnode="item.node" :tema="temaOut" where="syn" />
|
2020-09-18 13:36:02 +02:00
|
|
|
</div>
|
2020-09-03 23:02:28 +02:00
|
|
|
</div>
|
2020-09-18 13:36:02 +02:00
|
|
|
|
2020-11-03 21:10:48 +01:00
|
|
|
<div v-else :class="editorMode ? 'children-org' : 'children'"> <!-- bude tu nějaký if na class="children" -->
|
2020-11-03 21:42:15 +01:00
|
|
|
<div v-if="item.children.length > 0 && item.children[0].appendable_siblings.length > 0 && editorMode">
|
2020-09-16 17:55:30 +02:00
|
|
|
<b>Vložit před: </b>
|
2020-12-02 01:42:15 +01:00
|
|
|
<addnewnode :types="item.children[0].appendable_siblings" :refnode="item.children[0].node" :tema="temaOut" where="pred" />
|
2020-09-12 19:54:27 +02:00
|
|
|
</div>
|
2020-09-21 13:59:28 +02:00
|
|
|
<div v-if="item.node.polymorphic_ctype.model==='temavcislenode'">
|
|
|
|
<!--Children: {{String(showChildren)}}-->
|
|
|
|
<div v-for="(chld, index) in item.children" v-bind:key="chld.nazev" >
|
2020-12-02 01:42:15 +01:00
|
|
|
<!--Hide: {{hideNode(chld)}}, v tematu: {{tema}}, force_visible: {{force_visible}}-->
|
2020-09-21 13:59:28 +02:00
|
|
|
<div v-if="!hideNode(chld)">
|
|
|
|
<div v-if="chld.node.polymorphic_ctype.model==='ulohazadaninode'">
|
2020-11-03 21:42:15 +01:00
|
|
|
<button v-if="showChildren" v-on:click="showChildren=!showChildren"> Schovat </button>
|
|
|
|
<button v-else v-on:click="showChildren=!showChildren"> Rozbalit </button>
|
2020-12-02 01:42:15 +01:00
|
|
|
<TreeNode :item="chld" :tema="temaOut"
|
2020-11-03 21:09:33 +01:00
|
|
|
:force_visible="showChildren"
|
|
|
|
:editorMode="editorMode"
|
|
|
|
:debugMode="debugMode">
|
2020-09-21 13:59:28 +02:00
|
|
|
</TreeNode>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2020-12-02 01:42:15 +01:00
|
|
|
<TreeNode :item="chld" :tema="temaOut"
|
2020-11-03 21:09:33 +01:00
|
|
|
:force_visible="showChildren"
|
|
|
|
:editorMode="editorMode"
|
|
|
|
:debugMode="debugMode">
|
2020-09-21 13:59:28 +02:00
|
|
|
</TreeNode>
|
|
|
|
</div>
|
2020-11-03 21:42:15 +01:00
|
|
|
<div v-if="chld.appendable_siblings.length > 0 && editorMode" >
|
2020-09-21 13:59:28 +02:00
|
|
|
<b v-if="index < (item.children.length - 1)">Vložit mezi: </b>
|
|
|
|
<b v-else>Vložit za: </b>
|
2020-12-02 01:42:15 +01:00
|
|
|
<addnewnode :types="chld.appendable_siblings" :refnode="chld.node" :tema="temaOut" where="za" />
|
2020-09-21 13:59:28 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-03 21:42:15 +01:00
|
|
|
<button v-if="showChildren" v-on:click="showChildren=!showChildren"> Schovat </button>
|
|
|
|
<button v-else v-on:click="showChildren=!showChildren"> Rozbalit </button>
|
2020-09-21 13:59:28 +02:00
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<div v-for="(chld, index) in item.children" v-bind:key="chld.nazev" >
|
2020-12-02 01:42:15 +01:00
|
|
|
<div v-if="tema !== null && chld.node.polymorphic_ctype.model==='ulohazadaninode'">
|
2020-09-21 13:59:28 +02:00
|
|
|
<div> Tady možná něco je </div>
|
2020-12-02 01:42:15 +01:00
|
|
|
<TreeNode :item="chld" :tema="temaOut"
|
2020-11-03 21:09:33 +01:00
|
|
|
:force_visible="force_visible"
|
|
|
|
:editorMode="editorMode"
|
|
|
|
:debugMode="debugMode">
|
2020-09-21 13:59:28 +02:00
|
|
|
</TreeNode>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
2020-12-02 01:42:15 +01:00
|
|
|
<TreeNode :item="chld" :tema="temaOut"
|
2020-11-03 21:09:33 +01:00
|
|
|
:force_visible="force_visible"
|
|
|
|
:editorMode="editorMode"
|
|
|
|
:debugMode="debugMode">
|
2020-09-21 13:59:28 +02:00
|
|
|
</TreeNode>
|
|
|
|
</div>
|
2020-11-03 21:42:15 +01:00
|
|
|
<div v-if="chld.appendable_siblings.length > 0 && editorMode" >
|
2020-09-21 13:59:28 +02:00
|
|
|
<b v-if="index < (item.children.length - 1)">Vložit mezi: </b>
|
|
|
|
<b v-else>Vložit za: </b>
|
2020-12-02 01:42:15 +01:00
|
|
|
<addnewnode :types="chld.appendable_siblings" :refnode="chld.node" :tema="temaOut" where="za" />
|
2020-09-21 13:59:28 +02:00
|
|
|
</div>
|
2020-09-12 19:54:27 +02:00
|
|
|
</div>
|
2020-09-16 17:55:30 +02:00
|
|
|
</div>
|
2020-09-21 13:59:28 +02:00
|
|
|
|
2020-09-03 23:02:28 +02:00
|
|
|
</div>
|
2020-09-16 17:55:30 +02:00
|
|
|
|
2020-09-03 23:02:28 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import rocniknode from './RocnikNode.vue'
|
|
|
|
import cislonode from './CisloNode.vue'
|
|
|
|
import temavcislenode from './TemaVCisleNode.vue'
|
|
|
|
import castnode from './CastNode.vue'
|
|
|
|
import textnode from './TextNode.vue'
|
|
|
|
import ulohazadaninode from './UlohaZadaniNode.vue'
|
|
|
|
import ulohavzoraknode from './UlohaVzorakNode.vue'
|
2020-09-05 22:30:45 +02:00
|
|
|
import addnewnode from './AddNewNode.vue'
|
2020-09-03 23:02:28 +02:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'TreeNode',
|
|
|
|
components: {
|
|
|
|
rocniknode,
|
|
|
|
cislonode,
|
|
|
|
temavcislenode,
|
|
|
|
castnode,
|
|
|
|
textnode,
|
|
|
|
ulohazadaninode,
|
|
|
|
ulohavzoraknode,
|
2020-09-05 22:30:45 +02:00
|
|
|
addnewnode
|
2020-09-03 23:02:28 +02:00
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
debugShow: false,
|
2020-12-02 01:42:15 +01:00
|
|
|
showChildren: false,
|
|
|
|
temaOut: null,
|
2020-09-03 23:02:28 +02:00
|
|
|
}),
|
2020-09-21 13:59:28 +02:00
|
|
|
computed: {
|
|
|
|
},
|
2020-09-03 23:02:28 +02:00
|
|
|
props: {
|
2020-09-21 10:58:54 +02:00
|
|
|
item: Object,
|
2020-09-21 13:59:28 +02:00
|
|
|
force_visible: Boolean,
|
2020-12-02 01:42:15 +01:00
|
|
|
tema: Object,
|
2020-11-03 21:09:33 +01:00
|
|
|
editorMode: Boolean,
|
|
|
|
debugMode: Boolean,
|
2020-09-21 13:59:28 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
hideNode: function(chld){
|
|
|
|
if (this.showChildren || this.force_visible){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (chld.node.polymorphic_ctype.model === 'ulohazadaninode'){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2020-12-02 01:42:15 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted: function(){
|
|
|
|
if (this.item.node.polymorphic_ctype.model === 'temavcislenode'){
|
|
|
|
this.temaOut = this.item.node.tema;
|
|
|
|
console.log(this.temaOut);
|
|
|
|
} else {
|
|
|
|
this.temaOut = this.tema;
|
2020-09-21 13:59:28 +02:00
|
|
|
}
|
2020-12-02 01:42:15 +01:00
|
|
|
|
|
|
|
|
2020-09-03 23:02:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
|
|
<style scoped>
|
2020-09-16 17:55:30 +02:00
|
|
|
|
2020-09-21 10:58:54 +02:00
|
|
|
|
2020-09-16 17:55:30 +02:00
|
|
|
.treenode-org {
|
|
|
|
padding: 5px;
|
|
|
|
margin: 5px;
|
2020-09-21 10:58:54 +02:00
|
|
|
border: #6a0043 2px solid;
|
2020-09-03 23:02:28 +02:00
|
|
|
}
|
2020-09-21 10:58:54 +02:00
|
|
|
|
2020-09-16 17:55:30 +02:00
|
|
|
|
|
|
|
.children-org {
|
2020-09-18 13:36:02 +02:00
|
|
|
padding: 10px;
|
2020-09-16 17:55:30 +02:00
|
|
|
margin: 5px;
|
2020-09-18 13:36:02 +02:00
|
|
|
border: #6a0043 2px dashed;
|
2020-09-03 23:02:28 +02:00
|
|
|
}
|
2020-09-16 17:55:30 +02:00
|
|
|
|
|
|
|
.nodebug {
|
2020-09-18 19:35:32 +02:00
|
|
|
/* display: none; */
|
2020-09-03 23:02:28 +02:00
|
|
|
}
|
2020-09-05 06:57:54 +02:00
|
|
|
|
2020-09-03 23:02:28 +02:00
|
|
|
</style>
|