From 40e2b2bdfc4319d4c9357ad9c254c909286167d8 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 5 Sep 2020 22:30:45 +0200 Subject: [PATCH] TreeNode editor | pridavani novych polozek (WIP) --- seminar/templatetags/treenodes.py | 20 ++++++---- vue_frontend/src/components/AddNewNode.vue | 38 +++++++++++++++++++ vue_frontend/src/components/CastNode.vue | 18 ++++++--- vue_frontend/src/components/TextNode.vue | 19 +++++++--- vue_frontend/src/components/TreeNode.vue | 21 +++------- .../src/components/UlohaVzorakNode.vue | 11 +++++- .../src/components/UlohaZadaniNode.vue | 12 +++++- 7 files changed, 101 insertions(+), 38 deletions(-) create mode 100644 vue_frontend/src/components/AddNewNode.vue diff --git a/seminar/templatetags/treenodes.py b/seminar/templatetags/treenodes.py index a3160af4..d3da23ce 100644 --- a/seminar/templatetags/treenodes.py +++ b/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): diff --git a/vue_frontend/src/components/AddNewNode.vue b/vue_frontend/src/components/AddNewNode.vue new file mode 100644 index 00000000..e948f1cd --- /dev/null +++ b/vue_frontend/src/components/AddNewNode.vue @@ -0,0 +1,38 @@ + + + diff --git a/vue_frontend/src/components/CastNode.vue b/vue_frontend/src/components/CastNode.vue index 1ffff915..3eb9fb8f 100644 --- a/vue_frontend/src/components/CastNode.vue +++ b/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; } - } + }, } diff --git a/vue_frontend/src/components/TextNode.vue b/vue_frontend/src/components/TextNode.vue index 47c03278..2e6d689b 100644 --- a/vue_frontend/src/components/TextNode.vue +++ b/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: { diff --git a/vue_frontend/src/components/TreeNode.vue b/vue_frontend/src/components/TreeNode.vue index 0490395c..ad89764b 100644 --- a/vue_frontend/src/components/TreeNode.vue +++ b/vue_frontend/src/components/TreeNode.vue @@ -9,20 +9,12 @@
Vložit jako syna - +
Vložit před - +
@@ -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, diff --git a/vue_frontend/src/components/UlohaVzorakNode.vue b/vue_frontend/src/components/UlohaVzorakNode.vue index dde89654..398b3924 100644 --- a/vue_frontend/src/components/UlohaVzorakNode.vue +++ b/vue_frontend/src/components/UlohaVzorakNode.vue @@ -1,7 +1,7 @@ @@ -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); + } } } diff --git a/vue_frontend/src/components/UlohaZadaniNode.vue b/vue_frontend/src/components/UlohaZadaniNode.vue index 6bf34a27..eb4806b1 100644 --- a/vue_frontend/src/components/UlohaZadaniNode.vue +++ b/vue_frontend/src/components/UlohaZadaniNode.vue @@ -1,7 +1,7 @@ @@ -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); + } } } +}