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
def appendableChildren(value):
print(value)
print(value.node)
print(isUlohaZadani(value.node))
if isTemaVCisle(value.node):
return (NodeTypes.RESENI.value,
NodeTypes.ULOHAZADANI.value,
NodeTypes.ULOHAVZORAK.value,
NodeTypes.CAST.value,
NodeTypes.TEXT.value,
return (NodeTypes.RESENI.value[0],
NodeTypes.ULOHAZADANI.value[0],
NodeTypes.ULOHAVZORAK.value[0],
NodeTypes.CAST.value[0],
NodeTypes.TEXT.value[0],
)
if isOrgText(value.node) or isReseni(value.node) or isUlohaZadani(value.node) or isUlohaVzorak(value.node):
return (NodeTypes.CAST.value,
NodeTypes.TEXT.value,
print("Text/Cast")
return (NodeTypes.CAST.value[0],
NodeTypes.TEXT.value[0],
)
if isCast(value.node):
return appendableChildren(value.parent)
return None
return []
@register.simple_tag
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: "",
}),
props: {
item: Object
item: Object,
editorShow: Boolean,
create: Boolean,
},
mounted: function() {
console.log("mounted");
this.currentText = this.item.node.nadpis;
this.originalText = this.item.node.nadpis;
if (this.create){
this.currentText = "";
this.originalText = "";
this.editorShow = true;
}
else {
this.currentText = this.item.node.nadpis;
this.originalText = this.item.node.nadpis;
}
//this.getText();
},
methods: {
@ -36,7 +44,7 @@ export default {
// FIXME really save!
this.editorShow = false;
}
}
},
}
</script>

19
vue_frontend/src/components/TextNode.vue

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

21
vue_frontend/src/components/TreeNode.vue

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

11
vue_frontend/src/components/UlohaVzorakNode.vue

@ -1,7 +1,7 @@
<template>
<div class="ulohavzoraknode">
<!--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>
</template>
@ -9,7 +9,14 @@
export default {
name: 'UlohaVzorakNode',
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>

12
vue_frontend/src/components/UlohaZadaniNode.vue

@ -1,7 +1,7 @@
<template>
<div class="ulohazadaninode">
<!--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>
</template>
@ -9,7 +9,15 @@
export default {
name: 'UlohaZadaniNode',
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>

Loading…
Cancel
Save