From 61193fcd6ac16d2c4c9470ab1900efb38c04d1de Mon Sep 17 00:00:00 2001 From: Kossie Coder Date: Mon, 29 Mar 2021 22:47:05 +1000 Subject: [PATCH 1/4] 79 --- db.json | 24 +++++++++++++++++++++ src/App.vue | 30 ++++++++++++++++++++------ src/components/TodoForm.vue | 9 -------- src/composables/toast.js | 8 +++---- src/pages/todos/index.vue | 7 ------ src/store/index.js | 36 ++----------------------------- src/store/modules/index.js | 5 +++++ src/store/modules/toast/index.js | 37 ++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 60 deletions(-) create mode 100644 src/store/modules/index.js create mode 100644 src/store/modules/toast/index.js diff --git a/db.json b/db.json index ea69e0d..adec3e1 100644 --- a/db.json +++ b/db.json @@ -140,6 +140,30 @@ "completed": false, "body": "asdfasdf", "id": 31 + }, + { + "subject": "asdf", + "completed": false, + "body": "asdf", + "id": 32 + }, + { + "subject": "asdf", + "completed": false, + "body": "asdf", + "id": 33 + }, + { + "subject": "adsf", + "completed": false, + "body": "asdf", + "id": 34 + }, + { + "subject": "adsf", + "completed": false, + "body": "asdf", + "id": 35 } ] } \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 4290292..7e19f00 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,11 +15,13 @@
- + + + - \ No newline at end of file diff --git a/src/components/TodoForm.vue b/src/components/TodoForm.vue index c1413e6..eaffa34 100644 --- a/src/components/TodoForm.vue +++ b/src/components/TodoForm.vue @@ -51,13 +51,6 @@ Cancel - - - \ No newline at end of file diff --git a/src/components/Toast.vue b/src/components/Toast.vue index a3b69bb..b0bc090 100644 --- a/src/components/Toast.vue +++ b/src/components/Toast.vue @@ -1,32 +1,53 @@ - \ No newline at end of file diff --git a/src/composables/toast.js b/src/composables/toast.js index 415a000..46433f1 100644 --- a/src/composables/toast.js +++ b/src/composables/toast.js @@ -3,18 +3,17 @@ import { useStore } from 'vuex'; export const useToast = () => { const store = useStore(); - const toastMessage = computed(() => store.getters['toast/toastMessageWithSmile']); - const toastAlertType = computed(() => store.state.toast.toastAlertType); - const showToast = computed(() => store.state.toast.showToast); + const toasts = computed(() => store.state.toast.toasts); + // const toastMessage = computed(() => store.getters['toast/toastMessageWithSmile']); + // const toastAlertType = computed(() => store.state.toast.toastAlertType); + // const showToast = computed(() => store.state.toast.showToast); const triggerToast = (message, type = 'success') => { store.dispatch('toast/triggerToast', message, type); } return { - toastMessage, - toastAlertType, - showToast, + toasts, triggerToast } } \ No newline at end of file diff --git a/src/store/modules/toast/index.js b/src/store/modules/toast/index.js index db60c20..39446b9 100644 --- a/src/store/modules/toast/index.js +++ b/src/store/modules/toast/index.js @@ -1,32 +1,45 @@ export default { namespaced: true, state: { - toastMessage: '', - toastAlertType: '', - showToast: false, + toasts: [], + // toastMessage: '', + // toastAlertType: '', + // showToast: false, }, mutations: { - UPDATE_TOAST_MESSAGE (state, payload) { - state.toastMessage = payload; + // UPDATE_TOAST_MESSAGE (state, payload) { + // state.toastMessage = payload; + // }, + // UPDATE_TOAST_ALERT_TYPE (state, payload) { + // state.toastAlertType = payload; + // }, + // UPDATE_TOAST_STATUS (state, payload) { + // state.showToast = payload; + // }, + ADD_TOAST(state, payload) { + state.toasts.push(payload); }, - UPDATE_TOAST_ALERT_TYPE (state, payload) { - state.toastAlertType = payload; + REMOVE_TOAST(state) { + state.toasts.shift(); }, - UPDATE_TOAST_STATUS (state, payload) { - state.showToast = payload; - } }, actions: { triggerToast({ commit }, message, type = 'success') { - commit('UPDATE_TOAST_MESSAGE', message) - commit('UPDATE_TOAST_ALERT_TYPE', type) - commit('UPDATE_TOAST_STATUS', true) + // commit('UPDATE_TOAST_MESSAGE', message) + // commit('UPDATE_TOAST_ALERT_TYPE', type) + // commit('UPDATE_TOAST_STATUS', true) + commit('ADD_TOAST', { + id: Date.now(), + message, + type, + }); setTimeout(() => { - commit('UPDATE_TOAST_MESSAGE', '') - commit('UPDATE_TOAST_ALERT_TYPE', '') - commit('UPDATE_TOAST_STATUS', false) - }, 5000) + // commit('UPDATE_TOAST_MESSAGE', '') + // commit('UPDATE_TOAST_ALERT_TYPE', '') + // commit('UPDATE_TOAST_STATUS', false) + commit('REMOVE_TOAST'); + }, 10000) } }, getters: { From 4a0a5316d82334a61c78c5e53921ec0646fcfa88 Mon Sep 17 00:00:00 2001 From: Kossie Coder Date: Wed, 31 Mar 2021 22:23:09 +1000 Subject: [PATCH 3/4] home title --- src/pages/index.vue | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/index.vue b/src/pages/index.vue index 504f464..6b8da35 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -1,7 +1,5 @@ diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue new file mode 100644 index 0000000..a7b13b1 --- /dev/null +++ b/src/components/Navbar.vue @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/src/components/Pagination.vue b/src/components/Pagination.vue new file mode 100644 index 0000000..a012918 --- /dev/null +++ b/src/components/Pagination.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/src/pages/todos/index.vue b/src/pages/todos/index.vue index 51cd302..c36701d 100644 --- a/src/pages/todos/index.vue +++ b/src/pages/todos/index.vue @@ -28,26 +28,12 @@ @delete-todo="deleteTodo" />
- + @@ -57,10 +43,12 @@ import TodoList from '@/components/TodoList.vue'; import axios from '@/axios'; import { useToast } from '@/composables/toast'; import {useRouter} from 'vue-router'; +import Pagination from '@/components/Pagination.vue'; export default { components: { TodoList, + Pagination }, setup() { const router = useRouter();