From e0bf720884cb0f106f5e9c5dd6e1ec19a64ff038 Mon Sep 17 00:00:00 2001 From: iLuxa142 Date: Sun, 21 Mar 2021 17:08:06 +0300 Subject: [PATCH 01/20] refactor: methods spaces --- todolist-app-5-v2/src/router/index.js | 29 +-------------------------- todolist-app-5-v2/src/store/index.js | 4 ++++ todolist-app-5-v2/src/views/List.vue | 1 + todolist-app-5-v2/src/views/Task.vue | 7 ++++--- 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/todolist-app-5-v2/src/router/index.js b/todolist-app-5-v2/src/router/index.js index 0d5116f..a408fa2 100644 --- a/todolist-app-5-v2/src/router/index.js +++ b/todolist-app-5-v2/src/router/index.js @@ -23,31 +23,4 @@ const router = createRouter({ routes }) -export default router - -// import Vue from 'vue' -// import Router from 'vue-router' - -// Vue.use(Router) - -// export default new Router({ -// mode: 'history', -// base: process.env.BASE_URL, -// routes: [ -// { -// path: '/', -// name: 'create', -// component: () => import('@/views/Create.vue') -// }, -// { -// path: '/list', -// name: 'list', -// component: () => import('@/views/List.vue') -// }, -// { -// path: '/task/:id', -// name: 'task', -// component: () => import('@/views/Task.vue') -// } -// ] -// }) +export default router \ No newline at end of file diff --git a/todolist-app-5-v2/src/store/index.js b/todolist-app-5-v2/src/store/index.js index ffa7ef9..a79f1e4 100644 --- a/todolist-app-5-v2/src/store/index.js +++ b/todolist-app-5-v2/src/store/index.js @@ -15,6 +15,7 @@ export default createStore({ state.tasks.push(task); localStorage.setItem('tasks', JSON.stringify(state.tasks)); }, + updateTask(state, {id, desc, date}) { const tasks = state.tasks.concat(); @@ -28,6 +29,7 @@ export default createStore({ state.tasks = tasks; localStorage.setItem('tasks', JSON.stringify(state.tasks)); }, + completeTask(state, id) { const idx = state.tasks.findIndex(t => t.id === id); @@ -39,9 +41,11 @@ export default createStore({ createTask({commit}, task) { commit('createTask', task); }, + updateTask({commit}, task) { commit('updateTask', task); }, + completeTask({commit}, id) { commit('completeTask', id); } diff --git a/todolist-app-5-v2/src/views/List.vue b/todolist-app-5-v2/src/views/List.vue index 1fd1310..8ad9f62 100644 --- a/todolist-app-5-v2/src/views/List.vue +++ b/todolist-app-5-v2/src/views/List.vue @@ -56,6 +56,7 @@ export default { tasks() { return this.$store.getters.tasks; }, + displayTasks() { return this.tasks.filter(t => { if (!this.filter) { diff --git a/todolist-app-5-v2/src/views/Task.vue b/todolist-app-5-v2/src/views/Task.vue index 482a651..7740adb 100644 --- a/todolist-app-5-v2/src/views/Task.vue +++ b/todolist-app-5-v2/src/views/Task.vue @@ -43,14 +43,14 @@ export default { placeholder: 'Task tags', data: this.task.tags, }); + this.date = M.Datepicker.init(this.$refs.datepicker, { format: 'dd.mm.yyyy', defaultDate: new Date(this.task.date), setDefaultDate: true }); - setTimeout(() => { - M.updateTextFields() - }, 0) + + setTimeout(() => {M.updateTextFields()}, 0); }, methods: { submitHandler() { @@ -61,6 +61,7 @@ export default { }); this.$router.push('/list'); }, + completeTask() { this.$store.dispatch('completeTask', this.task.id); this.$router.push('/list'); From 462d556a75d3c14160bb963d7b3283b0238a08e7 Mon Sep 17 00:00:00 2001 From: iLuxa142 Date: Sun, 21 Mar 2021 17:16:39 +0300 Subject: [PATCH 02/20] refactor: remove arrow func style from data --- todolist-app-5-v2/src/views/Create.vue | 14 ++++++++------ todolist-app-5-v2/src/views/List.vue | 8 +++++--- todolist-app-5-v2/src/views/Task.vue | 12 +++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/todolist-app-5-v2/src/views/Create.vue b/todolist-app-5-v2/src/views/Create.vue index 8083f40..bf56ae2 100644 --- a/todolist-app-5-v2/src/views/Create.vue +++ b/todolist-app-5-v2/src/views/Create.vue @@ -30,12 +30,14 @@ \ No newline at end of file From 87b4ee65c8b3bb076e211402c88d56e57d6b2253 Mon Sep 17 00:00:00 2001 From: iLuxa142 Date: Sun, 21 Mar 2021 18:18:04 +0300 Subject: [PATCH 04/20] feat: dbclick task edit --- todolist-app-5-v2/src/views/List.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/todolist-app-5-v2/src/views/List.vue b/todolist-app-5-v2/src/views/List.vue index d8a7878..e1c678c 100644 --- a/todolist-app-5-v2/src/views/List.vue +++ b/todolist-app-5-v2/src/views/List.vue @@ -27,12 +27,16 @@ Date Description Status - Open + Edit Delete - + {{ index + 1 }} {{ task.title }} {{ new Date(task.date).toLocaleDateString() }} @@ -46,7 +50,7 @@ class="btn btn-small" :to="'/task/' + task.id" > - Open + Edit From 296c2abc91029d387ed0f40f1ffe22ac72e63025 Mon Sep 17 00:00:00 2001 From: iLuxa142 Date: Tue, 23 Mar 2021 21:10:06 +0300 Subject: [PATCH 05/20] feat: filter buttons; quick add task --- todolist-app-5-v2/src/App.vue | 10 +-- todolist-app-5-v2/src/components/Navbar.vue | 23 +++--- todolist-app-5-v2/src/store/index.js | 4 +- todolist-app-5-v2/src/views/Create.vue | 55 +++++++------ todolist-app-5-v2/src/views/List.vue | 85 +++++++++++++++------ todolist-app-5-v2/src/views/Task.vue | 69 +++++++++++------ 6 files changed, 158 insertions(+), 88 deletions(-) diff --git a/todolist-app-5-v2/src/App.vue b/todolist-app-5-v2/src/App.vue index 72ccdf2..637233b 100644 --- a/todolist-app-5-v2/src/App.vue +++ b/todolist-app-5-v2/src/App.vue @@ -8,14 +8,14 @@ diff --git a/todolist-app-5-v2/src/components/Navbar.vue b/todolist-app-5-v2/src/components/Navbar.vue index 14bb6a4..ca43365 100644 --- a/todolist-app-5-v2/src/components/Navbar.vue +++ b/todolist-app-5-v2/src/components/Navbar.vue @@ -1,23 +1,28 @@ \ No newline at end of file diff --git a/todolist-app-5-v2/src/store/index.js b/todolist-app-5-v2/src/store/index.js index b5a36fa..aea9a8b 100644 --- a/todolist-app-5-v2/src/store/index.js +++ b/todolist-app-5-v2/src/store/index.js @@ -22,13 +22,13 @@ export default createStore({ localStorage.setItem('tasks', JSON.stringify(state.tasks)); }, - updateTask(state, {id, desc, date}) { + updateTask(state, {id, title, desc, date}) { const tasks = state.tasks.concat(); const idx = tasks.findIndex(t => t.id === id); const task = tasks[idx]; const status = new Date(date) > new Date() ? 'active' : 'outdated'; - tasks[idx] = {...task, date, desc, status }; + tasks[idx] = {...task, date, title, desc, status }; state.tasks = tasks; localStorage.setItem('tasks', JSON.stringify(state.tasks)); diff --git a/todolist-app-5-v2/src/views/Create.vue b/todolist-app-5-v2/src/views/Create.vue index bf56ae2..e103292 100644 --- a/todolist-app-5-v2/src/views/Create.vue +++ b/todolist-app-5-v2/src/views/Create.vue @@ -5,7 +5,13 @@
- +
@@ -13,40 +19,45 @@
- - - {{desc.length}}/1024 + + + {{ desc.length }}/1024
- +
- diff --git a/todolist-app-5-v2/src/views/List.vue b/todolist-app-5-v2/src/views/List.vue index e1c678c..4d1b482 100644 --- a/todolist-app-5-v2/src/views/List.vue +++ b/todolist-app-5-v2/src/views/List.vue @@ -1,28 +1,38 @@ @@ -69,12 +89,27 @@ export default { data() { return { + addTaskTitle: "", filter: null, }; }, methods: { - clearFillter() { - this.filter = null; + quickAddTask() { + const task = { + title: this.addTaskTitle, + desc: "", + id: Date.now(), + status: "active", + tags: "", + date: Date.now(), + }; + + this.$store.dispatch("createTask", task); + this.addTaskTitle = ""; + }, + + changeFilter(filter) { + this.filter = filter; }, deleteTask(id) { @@ -96,9 +131,6 @@ export default { }); }, }, - mounted() { - M.FormSelect.init(this.$refs.select); - }, }; @@ -109,4 +141,7 @@ export default { text-overflow: ellipsis; max-width: 400px; } +button { + margin-left: 5px; +} \ No newline at end of file diff --git a/todolist-app-5-v2/src/views/Task.vue b/todolist-app-5-v2/src/views/Task.vue index 1bac1e9..a20c857 100644 --- a/todolist-app-5-v2/src/views/Task.vue +++ b/todolist-app-5-v2/src/views/Task.vue @@ -1,23 +1,37 @@