Browse Source

TreeNode editor | pridavani novych polozek (WIP)

export_seznamu_prednasek
parent
commit
40e2b2bdfc
  1. 20
      seminar/templatetags/treenodes.py
  2. 38
      vue_frontend/src/components/AddNewNode.vue
  3. 18
      vue_frontend/src/components/CastNode.vue
  4. 19
      vue_frontend/src/components/TextNode.vue
  5. 21
      vue_frontend/src/components/TreeNode.vue
  6. 11
      vue_frontend/src/components/UlohaVzorakNode.vue
  7. 12
      vue_frontend/src/components/UlohaZadaniNode.vue

20
seminar/templatetags/treenodes.py

@ -173,20 +173,24 @@ class NodeTypes(Enum):
@register.simple_tag @register.simple_tag
def appendableChildren(value): def appendableChildren(value):
print(value)
print(value.node)
print(isUlohaZadani(value.node))
if isTemaVCisle(value.node): if isTemaVCisle(value.node):
return (NodeTypes.RESENI.value, return (NodeTypes.RESENI.value[0],
NodeTypes.ULOHAZADANI.value, NodeTypes.ULOHAZADANI.value[0],
NodeTypes.ULOHAVZORAK.value, NodeTypes.ULOHAVZORAK.value[0],
NodeTypes.CAST.value, NodeTypes.CAST.value[0],
NodeTypes.TEXT.value, NodeTypes.TEXT.value[0],
) )
if isOrgText(value.node) or isReseni(value.node) or isUlohaZadani(value.node) or isUlohaVzorak(value.node): if isOrgText(value.node) or isReseni(value.node) or isUlohaZadani(value.node) or isUlohaVzorak(value.node):
return (NodeTypes.CAST.value, print("Text/Cast")
NodeTypes.TEXT.value, return (NodeTypes.CAST.value[0],
NodeTypes.TEXT.value[0],
) )
if isCast(value.node): if isCast(value.node):
return appendableChildren(value.parent) return appendableChildren(value.parent)
return None return []
@register.simple_tag @register.simple_tag
def canAppendReseni(value): def canAppendReseni(value):

38
vue_frontend/src/components/AddNewNode.vue

@ -0,0 +1,38 @@
<template>
<div class="addnewnode">
<button v-if="types.includes('castNode')" v-on:click="selected='castNode'" :disabled="selected && selected !== 'castNode'">Část</button>
<button v-if="types.includes('textNode')" v-on:click="selected='textNode'" :disabled="selected && selected !== 'textNode'">Text</button>
<button v-if="types.includes('reseniNode')" v-on:click="selected='reseniNode'" :disabled="selected && selected !== 'reseniNode'">Řešení</button>
<button v-if="types.includes('ulohaZadaniNode')" v-on:click="selected='ulohaZadaniNode'" :disabled="selected && selected !== 'ulohaZadaniNode'">Zadání úlohy</button>
<button v-if="types.includes('ulohaVzorakNode')" v-on:click="selected='ulohaVzorakNode'" :disabled="selected && selected !== 'ulohaVzorakNode'">Vzorák</button>
<div v-if="selected">
<component :is='selected' :item='null' create></component>
</div>
</div>
</template>
<script>
import castNode from './CastNode.vue'
import textNode from './TextNode.vue'
import ulohaZadaniNode from './UlohaZadaniNode.vue'
import ulohaVzorakNode from './UlohaVzorakNode.vue'
//import reseniNode from './UlohaVzorakNode.vue'
export default {
name: 'AddNewNode',
props: {
types: Array,
where: String
},
data: () => ({
selected: null,
cast: 'castnode',
}),
components: {
castNode,
textNode,
ulohaZadaniNode,
ulohaVzorakNode,
}
}
</script>

18
vue_frontend/src/components/CastNode.vue

@ -21,12 +21,20 @@ export default {
originalText: "", originalText: "",
}), }),
props: { props: {
item: Object item: Object,
editorShow: Boolean,
create: Boolean,
}, },
mounted: function() { mounted: function() {
console.log("mounted"); if (this.create){
this.currentText = this.item.node.nadpis; this.currentText = "";
this.originalText = this.item.node.nadpis; this.originalText = "";
this.editorShow = true;
}
else {
this.currentText = this.item.node.nadpis;
this.originalText = this.item.node.nadpis;
}
//this.getText(); //this.getText();
}, },
methods: { methods: {
@ -36,7 +44,7 @@ export default {
// FIXME really save! // FIXME really save!
this.editorShow = false; this.editorShow = false;
} }
} },
} }
</script> </script>

19
vue_frontend/src/components/TextNode.vue

@ -38,7 +38,7 @@ export default {
}), }),
computed: { computed: {
changedObject: function () { changedObject: function () {
console.log(this.currentText); //console.log(this.currentText);
//console.log(this.originalText); //console.log(this.originalText);
return { return {
changed: this.currentText !== this.originalText, changed: this.currentText !== this.originalText,
@ -46,12 +46,21 @@ export default {
} }
}, },
props: { props: {
item: Object item: Object,
editorShow: Boolean,
create: Boolean
}, },
mounted: function() { mounted: function() {
console.log("mounted"); //console.log("mounted");
this.currentText = this.item.node.text.na_web; if (this.create){
this.originalText = this.item.node.text.na_web; this.currentText = "";
this.originalText = "";
this.editorShow = true;
} else {
this.currentText = this.item.node.text.na_web;
this.originalText = this.item.node.text.na_web;
}
//this.getText(); //this.getText();
}, },
methods: { methods: {

21
vue_frontend/src/components/TreeNode.vue

@ -9,20 +9,12 @@
<div v-if="item.children.length === 0"> <div v-if="item.children.length === 0">
<div v-if="item.appendable_children.length > 0"> <div v-if="item.appendable_children.length > 0">
<b>Vložit jako syna</b> <b>Vložit jako syna</b>
<ul> <addnewnode :types="item.appendable_siblings" where="syn" />
<li v-for="chld in item.appendable_children" :key="chld[0]">
<a href="">{{chld[1]}}</a>
</li>
</ul>
</div> </div>
</div> </div>
<div v-if="item.children.length > 0 && item.children[0].appendable_siblings.length > 0"> <div v-if="item.children.length > 0 && item.children[0].appendable_siblings.length > 0">
<b>Vložit před</b> <b>Vložit před</b>
<ul> <addnewnode :types="item.children[0].appendable_siblings" where="pred" />
<li v-for="sibl in item.children[0].appendable_siblings" :key="sibl[0]">
<a href="">{{sibl[1]}}</a>
</li>
</ul>
</div> </div>
<ul> <ul>
@ -32,11 +24,7 @@
<div v-if="chld.appendable_siblings.length > 0"> <div v-if="chld.appendable_siblings.length > 0">
<b v-if="index < (item.children.length - 1)">Vložit mezi</b> <b v-if="index < (item.children.length - 1)">Vložit mezi</b>
<b v-else>Vložit za</b> <b v-else>Vložit za</b>
<ul> <addnewnode :types="chld.appendable_siblings" where="za" />
<li v-for="sibl in chld.appendable_siblings" :key="sibl[0]">
<a href="">{{sibl[1]}}</a>
</li>
</ul>
</div> </div>
</li> </li>
</ul> </ul>
@ -52,7 +40,7 @@ import castnode from './CastNode.vue'
import textnode from './TextNode.vue' import textnode from './TextNode.vue'
import ulohazadaninode from './UlohaZadaniNode.vue' import ulohazadaninode from './UlohaZadaniNode.vue'
import ulohavzoraknode from './UlohaVzorakNode.vue' import ulohavzoraknode from './UlohaVzorakNode.vue'
import addnewnode from './AddNewNode.vue'
export default { export default {
name: 'TreeNode', name: 'TreeNode',
@ -64,6 +52,7 @@ export default {
textnode, textnode,
ulohazadaninode, ulohazadaninode,
ulohavzoraknode, ulohavzoraknode,
addnewnode
}, },
data: () => ({ data: () => ({
debugShow: false, debugShow: false,

11
vue_frontend/src/components/UlohaVzorakNode.vue

@ -1,7 +1,7 @@
<template> <template>
<div class="ulohavzoraknode"> <div class="ulohavzoraknode">
<!--pre>UlohaVzorakNode {{item}} {{typeof(item)}}</pre--> <!--pre>UlohaVzorakNode {{item}} {{typeof(item)}}</pre-->
<h5>Řešení {{item.node.uloha.cislo_zadani.poradi}}.{{ item.node.uloha.kod }}: {{ item.node.uloha.nazev }}</h5> <!--h5>Řešení {{item.node.uloha.cislo_zadani.poradi}}.{{ item.node.uloha.kod }}: {{ item.node.uloha.nazev }}</h5-->
</div> </div>
</template> </template>
@ -9,7 +9,14 @@
export default { export default {
name: 'UlohaVzorakNode', name: 'UlohaVzorakNode',
props: { props: {
item: Object item: Object,
create: Boolean
},
mounted: function(){
if (this.item.node.uloha === null){
console.log("Uloha je null!");
console.log(this.item);
}
} }
} }
</script> </script>

12
vue_frontend/src/components/UlohaZadaniNode.vue

@ -1,7 +1,7 @@
<template> <template>
<div class="ulohazadaninode"> <div class="ulohazadaninode">
<!--pre>UlohaZadaniNode {{item.node.uloha}} {{typeof(item)}}</pre--> <!--pre>UlohaZadaniNode {{item.node.uloha}} {{typeof(item)}}</pre-->
<h5>Zadání {{item.node.uloha.cislo_zadani.poradi}}.{{ item.node.uloha.kod }}: {{ item.node.uloha.nazev }}</h5> <!--h5>Zadání {{item.node.uloha.cislo_zadani.poradi}}.{{ item.node.uloha.kod }}: {{ item.node.uloha.nazev }}</h5-->
</div> </div>
</template> </template>
@ -9,7 +9,15 @@
export default { export default {
name: 'UlohaZadaniNode', name: 'UlohaZadaniNode',
props: { props: {
item: Object item: Object,
created: Boolean
,
mounted: function(){
if (this.item.node.uloha === null){
console.log("Uloha je null!");
console.log(this.item);
}
} }
} }
}
</script> </script>

Loading…
Cancel
Save