From 91a3fb4e3184087de47ce137a960261ce913a434 Mon Sep 17 00:00:00 2001 From: takuto Date: Sat, 5 Sep 2020 22:34:59 +0900 Subject: [PATCH] updaa --- apiv1/serializers.py | 8 + "frontend/src/views/\\" | 486 ------------- frontend/src/views/] | 675 ++++++++++++++++++ .../src/views/goal/giveup/BeforeGiveUp.vue | 30 +- frontend/src/views/goal/task/Kanban.vue | 2 + frontend/src/views/goal/task/Task.vue | 137 +++- .../views/goal/task/giveup/AfterGiveUp.vue | 79 +- .../views/goal/task/giveup/BeforeGiveUp.vue | 588 +++++++++++++++ .../goal/task/motivation/BeforeMotivation.vue | 504 +++++++++++++ .../views/goal/task/motivation/Motivation.vue | 9 + .../views/goal/task/task_info/AfterTask.vue | 63 +- .../views/goal/task/task_info/BeforeTask.vue | 190 +++++ woop/migrations/0007_auto_20200826_1610.py | 18 + woop/models.py | 2 +- 14 files changed, 2215 insertions(+), 576 deletions(-) delete mode 100644 "frontend/src/views/\\" create mode 100644 frontend/src/views/] create mode 100644 frontend/src/views/goal/task/giveup/BeforeGiveUp.vue create mode 100644 frontend/src/views/goal/task/motivation/BeforeMotivation.vue create mode 100644 frontend/src/views/goal/task/task_info/BeforeTask.vue create mode 100644 woop/migrations/0007_auto_20200826_1610.py diff --git a/apiv1/serializers.py b/apiv1/serializers.py index 3a04b79..6952edb 100644 --- a/apiv1/serializers.py +++ b/apiv1/serializers.py @@ -27,6 +27,10 @@ class SolutionSerializer(serializers.ModelSerializer): class Meta: model = Solution fields = ['solution_id', 'solution', 'created_at', 'hurdle'] + extra_kwargs = { + # This was key! + "hurdle":{"required": False} + } class HurdleSerializer(WritableNestedModelSerializer): @@ -145,6 +149,10 @@ class IdeaSerializer(serializers.ModelSerializer): class Meta: model = Idea fields = ['idea_id', 'idea', 'created_at', 'worry'] + extra_kwargs = { + # This was key! + "worry":{"required": False} + } class WorrySerializer(WritableNestedModelSerializer): diff --git "a/frontend/src/views/\\" "b/frontend/src/views/\\" deleted file mode 100644 index 9b61a7d..0000000 --- "a/frontend/src/views/\\" +++ /dev/null @@ -1,486 +0,0 @@ - - - - - diff --git a/frontend/src/views/] b/frontend/src/views/] new file mode 100644 index 0000000..c95911d --- /dev/null +++ b/frontend/src/views/] @@ -0,0 +1,675 @@ + + + + + diff --git a/frontend/src/views/goal/giveup/BeforeGiveUp.vue b/frontend/src/views/goal/giveup/BeforeGiveUp.vue index 2c6981c..a763c20 100644 --- a/frontend/src/views/goal/giveup/BeforeGiveUp.vue +++ b/frontend/src/views/goal/giveup/BeforeGiveUp.vue @@ -390,23 +390,43 @@ export default { if (!worry.worry_id) { // add new `ideas` ideaList = worry.ideas.map(idea => { - return { idea: idea.idea, worry: 1 }; + return { idea: idea.idea }; }); + console.log(ideaList) NewData.push({ worry: worry.worry, ideas: ideaList // ideaList = { idea: '', worry: 1}, { idea: '', worry:1}, ...... }); } - // edit + // edit Worry else if (worry.worry !== originalMo.worry) { ChangeData.push({ worry_id: worry.worry_id, worry: worry.worry }); + // and idea diff + if (worry.ideas !== originalMo.ideas) { + Array.from(worry.ideas).forEach((idea, index) => { + let original = originalMo.ideas[index]; + let currentWorryId = worry.worry_id; + if (!idea.idea_id) { + // idea = new input data, original = original + NewIdeaData.push({ + worry: worry.worry_id, + idea: idea.idea + }); + } else if (idea.idea !== original.idea) { + ChangeIdeaData.push({ + idea_id: original.idea_id, + idea: idea.idea, + worry: original.worry + }); + } + }); + } } - - // `idea` diff + // edit Idea ( Worry is still the same. ) else if (worry.ideas !== originalMo.ideas) { Array.from(worry.ideas).forEach((idea, index) => { let original = originalMo.ideas[index]; @@ -437,6 +457,8 @@ export default { useCredentails: true }); postPromises.push(newPostPromise); + console.log(item.ideas) + console.log(newPostPromise) }); // idea NewIdeaData.forEach(function (item, index) { diff --git a/frontend/src/views/goal/task/Kanban.vue b/frontend/src/views/goal/task/Kanban.vue index e02c0fa..048caf4 100644 --- a/frontend/src/views/goal/task/Kanban.vue +++ b/frontend/src/views/goal/task/Kanban.vue @@ -273,6 +273,8 @@ export default { showDialog(item) { this.$refs.task.open(); this.$refs.task.task_info = item; + // Deep copy + this.$refs.task.OriginalTaskInfo = JSON.parse(JSON.stringify(item)); }, // dynamic background boardColor(index) { diff --git a/frontend/src/views/goal/task/Task.vue b/frontend/src/views/goal/task/Task.vue index ebe7fd6..3348222 100644 --- a/frontend/src/views/goal/task/Task.vue +++ b/frontend/src/views/goal/task/Task.vue @@ -9,40 +9,72 @@

+ + + + + - - - - - -
+
- - - + + + + - - -
+ + + + +
@@ -53,22 +85,36 @@ import SoloStep from "../../../components/SoloStep"; import AfterExpectation from "./expectation/AfterExpectation"; import AfterTask from "./task_info/AfterTask"; +import BeforeTask from "./task_info/BeforeTask"; import Discover from "./discover/Discover"; import AfterGiveUp from "../task/giveup/AfterGiveUp"; +import BeforeGiveUp from "../task/giveup/BeforeGiveUp"; import AfterMotivation from "../task/motivation/Motivation"; +import BeforeMotivation from "../task/motivation/BeforeMotivation"; export default { components: { AfterExpectation, AfterTask, + BeforeTask, + SoloStep, Discover, AfterGiveUp, - AfterMotivation + BeforeGiveUp, + + AfterMotivation, + BeforeMotivation }, data: () => ({ isDisplay: false, - task_info: "" // from Kanban.vue. + task_info: {}, // from Kanban.vue. + OriginalTaskInfo: {}, // from Kanban.vue. Deep Copy + + // Component Switch + isTaskEditMode: false, + isGiveUpEditMode: false, + isMotiveEditMode: false }), methods: { open() { @@ -76,6 +122,25 @@ export default { }, close() { this.isDisplay = false; + }, + + startEdit: function () { + this.isTaskEditMode = true; + }, + endEdit: function () { + this.isTaskEditMode = false; + }, + startMotiveEdit: function () { + this.isMotiveEditMode = true; + }, + endMotiveEdit: function () { + this.isMotiveEditMode = false; + }, + startGiveUpEdit: function () { + this.isGiveUpEditMode = true; + }, + endGiveUpEdit: function () { + this.isGiveUpEditMode = false; } } }; @@ -138,4 +203,30 @@ export default { background: #f0f0f0f7; border-radius: 20px; } + +/* Transition */ +.v-enter { + transform: translate(-100px, 0); + opacity: 0; +} +.v-enter-to { + opacity: 1; +} +.v-enter-active { + transition: all 1s 0s ease; +} +.v-leave { + transform: translate(0, 0); + opacity: 1; + position: absolute; +} +.v-leave-to { + transform: translate(-100px, 0); + opacity: 0; + position: absolute; +} +.v-leave-active { + transition: all 0.5s 0s ease; + position: absolute; +} diff --git a/frontend/src/views/goal/task/giveup/AfterGiveUp.vue b/frontend/src/views/goal/task/giveup/AfterGiveUp.vue index 0598557..86c23cb 100644 --- a/frontend/src/views/goal/task/giveup/AfterGiveUp.vue +++ b/frontend/src/views/goal/task/giveup/AfterGiveUp.vue @@ -1,15 +1,20 @@