mamweb/vue_frontend/src/components/TreeNode.vue

169 lines
4.8 KiB
Vue
Raw Normal View History

2020-09-03 23:02:28 +02:00
<template>
2020-09-18 13:36:02 +02:00
<div :class="editorMode ? 'treenode-org' : 'treenode'">
<!--b v-if="v_tematu">v tematu</b>
<b v-if="visible">visible</b>
Force visible: {{String(force_visible)}}-->
<component :is='item.node.polymorphic_ctype.model' :item='item' :key='item.node.id'
:editorMode="editorMode"
:debugMode="debugMode"></component>
2020-09-21 10:58:54 +02: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">
<pre>{{ item.node.polymorphic_ctype.model }}</pre>
<pre>{{ item }}</pre>
</div>
2020-09-03 23:02:28 +02:00
<div v-if="item.children.length === 0">
<div v-if="item.appendable_children.length > 0" :class="editorMode ? 'org' : 'schovat'">
2020-09-18 13:36:02 +02:00
<b>Vložit jako syna: </b>
2020-09-21 10:56:38 +02:00
<addnewnode :types="item.appendable_children" :refnode="item.node" 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
<div v-else :class="editorMode ? 'children-org' : 'children'"> <!-- bude tu nějaký if na class="children" -->
<div v-if="item.children.length > 0 && item.children[0].appendable_siblings.length > 0" :class="editorMode ? 'org' : 'schovat'">
<b>Vložit před: </b>
<addnewnode :types="item.children[0].appendable_siblings" :refnode="item.children[0].node" where="pred" />
</div>
<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" >
<!--Hide: {{hideNode(chld)}}, v tematu: {{v_tematu}}, force_visible: {{force_visible}}-->
<div v-if="!hideNode(chld)">
<div v-if="chld.node.polymorphic_ctype.model==='ulohazadaninode'">
<button v-on:click="showChildren=!showChildren"> Tady možná něco je </button>
<TreeNode :item="chld" :v_tematu="true"
:force_visible="showChildren"
:editorMode="editorMode"
:debugMode="debugMode">
</TreeNode>
</div>
<div v-else>
<TreeNode :item="chld" :v_tematu="true"
:force_visible="showChildren"
:editorMode="editorMode"
:debugMode="debugMode">
</TreeNode>
</div>
<div v-if="chld.appendable_siblings.length > 0" :class="editorMode ? 'org' : 'schovat'" >
<b v-if="index < (item.children.length - 1)">Vložit mezi: </b>
<b v-else>Vložit za: </b>
<addnewnode :types="chld.appendable_siblings" :refnode="chld.node" where="za" />
</div>
</div>
</div>
<button v-on:click="showChildren=!showChildren"> Tady možná něco je </button>
</div>
<div v-else>
<div v-for="(chld, index) in item.children" v-bind:key="chld.nazev" >
<div v-if="v_tematu && chld.node.polymorphic_ctype.model==='ulohazadaninode'">
<div> Tady možná něco je </div>
<TreeNode :item="chld" :v_tematu="v_tematu"
:force_visible="force_visible"
:editorMode="editorMode"
:debugMode="debugMode">
</TreeNode>
</div>
<div v-else>
<TreeNode :item="chld" :v_tematu="v_tematu"
:force_visible="force_visible"
:editorMode="editorMode"
:debugMode="debugMode">
</TreeNode>
</div>
<div v-if="chld.appendable_siblings.length > 0" :class="editorMode ? 'org' : 'schovat'" >
<b v-if="index < (item.children.length - 1)">Vložit mezi: </b>
<b v-else>Vložit za: </b>
<addnewnode :types="chld.appendable_siblings" :refnode="chld.node" where="za" />
</div>
</div>
</div>
2020-09-03 23:02:28 +02:00
</div>
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'
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,
addnewnode
2020-09-03 23:02:28 +02:00
},
data: () => ({
debugShow: false,
showChildren: false,
editorMode: false
2020-09-03 23:02:28 +02:00
}),
computed: {
},
2020-09-03 23:02:28 +02:00
props: {
2020-09-21 10:58:54 +02:00
item: Object,
force_visible: Boolean,
v_tematu: Boolean,
editorMode: Boolean,
debugMode: Boolean,
},
methods: {
hideNode: function(chld){
if (this.showChildren || this.force_visible){
return false;
}
if (chld.node.polymorphic_ctype.model === 'ulohazadaninode'){
return false;
}
return true;
}
2020-09-03 23:02:28 +02:00
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
2020-09-21 10:58:54 +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
.children-org {
2020-09-18 13:36:02 +02:00
padding: 10px;
margin: 5px;
2020-09-18 13:36:02 +02:00
border: #6a0043 2px dashed;
2020-09-03 23:02:28 +02:00
}
.mam-org-only {
margin: 4px;
2020-09-03 23:02:28 +02:00
}
.nodebug {
2020-09-18 19:35:32 +02:00
/* display: none; */
2020-09-03 23:02:28 +02:00
}
.schovat {
display: none
}
2020-09-03 23:02:28 +02:00
</style>