24.04 Add Notifications

This commit is contained in:
Fredrick W. Warren 2021-02-15 12:56:17 -08:00
parent 3b806cff18
commit 1438e11aad
2 changed files with 17 additions and 6 deletions

View File

@ -102,7 +102,8 @@ module.exports = function (/* ctx */) {
// Quasar plugins // Quasar plugins
plugins: [ plugins: [
'Dialog', 'Dialog',
'LocalStorage' 'LocalStorage',
'Notify'
] ]
}, },

View File

@ -1,11 +1,11 @@
import Vue from 'vue' import Vue from 'vue'
import { uid } from 'quasar' import { uid, Notify } from 'quasar'
import { firebaseDb, firebaseAuth } from 'boot/firebase' import { firebaseDb, firebaseAuth } from 'boot/firebase'
import { showErrorMessage } from 'src/functions/function-show-error-message' import { showErrorMessage } from 'src/functions/function-show-error-message'
const state = { const state = {
tasks: { tasks: {
/*
ID1: { ID1: {
name: 'Go to shop', name: 'Go to shop',
completed: false, completed: false,
@ -24,7 +24,7 @@ const state = {
dueDate: '2021/03/09', dueDate: '2021/03/09',
dueTime: '16:30' dueTime: '16:30'
} }
*/
}, },
search: '', search: '',
sort: 'name', sort: 'name',
@ -120,6 +120,8 @@ const actions = {
taskRef.set(payload.task, error => { taskRef.set(payload.task, error => {
if (error) { if (error) {
showErrorMessage(error.message) showErrorMessage(error.message)
} else {
Notify.create('Task added')
} }
}) })
}, },
@ -129,6 +131,11 @@ const actions = {
taskRef.update(payload.updates, error => { taskRef.update(payload.updates, error => {
if (error) { if (error) {
showErrorMessage(error.message) showErrorMessage(error.message)
} else {
const keys = Object.keys(payload.updates)
if (keys.includes('completed') && keys.length > 1) {
Notify.create('Task updated')
}
} }
}) })
}, },
@ -138,6 +145,8 @@ const actions = {
taskRef.remove(error => { taskRef.remove(error => {
if (error) { if (error) {
showErrorMessage(error.message) showErrorMessage(error.message)
} else {
Notify.create('Task deleted')
} }
}) })
} }
@ -149,8 +158,9 @@ const getters = {
const keysOrdered = Object.keys(state.tasks) const keysOrdered = Object.keys(state.tasks)
keysOrdered.sort((a, b) => { keysOrdered.sort((a, b) => {
const taskAProp = state.tasks[a].[state.sort].toLowerCase() const sort = state.sort
const taskBProp = state.tasks[b].[state.sort].toLowerCase() const taskAProp = state.tasks[a][sort].toLowerCase()
const taskBProp = state.tasks[b][sort].toLowerCase()
if (taskAProp > taskBProp) return 1 if (taskAProp > taskBProp) return 1
else if (taskAProp < taskBProp) return -1 else if (taskAProp < taskBProp) return -1
else return 0 else return 0