@@ -203,10 +203,11 @@
import authTypes from './models/authTypes'
import swEvents from './ServiceWorker/events'
+ import Notification from "./components/global/notification";
export default {
name: 'app',
-
+ components: {Notification},
data() {
return {
user: auth.user,
diff --git a/src/components/global/notification.vue b/src/components/global/notification.vue
new file mode 100644
index 00000000..36c2b60a
--- /dev/null
+++ b/src/components/global/notification.vue
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/components/tasks/ShowListTasks.vue b/src/components/tasks/ShowListTasks.vue
index 86a517bb..5b6a5e7c 100644
--- a/src/components/tasks/ShowListTasks.vue
+++ b/src/components/tasks/ShowListTasks.vue
@@ -259,7 +259,14 @@
this.taskService.update(task)
.then(() => {
this.sortTasks()
- this.success({message: 'The task was successfully ' + (task.done ? '' : 'un-') + 'marked as done.'}, this)
+ this.success(
+ {message: 'The task was successfully ' + (task.done ? '' : 'un-') + 'marked as done.'},
+ this,
+ [{
+ title: 'Undo',
+ callback: () => this.markAsDone({target: {id: e.target.id, checked: !e.target.checked}}),
+ }]
+ )
})
.catch(e => {
this.error(e, this)
diff --git a/src/components/tasks/TaskDetailView.vue b/src/components/tasks/TaskDetailView.vue
index e7c0c558..0f36bdb1 100644
--- a/src/components/tasks/TaskDetailView.vue
+++ b/src/components/tasks/TaskDetailView.vue
@@ -414,7 +414,7 @@
this.taskTitle = taskTitle
}
},
- saveTask() {
+ saveTask(undoCallback = null) {
// If no end date is being set, but a start date and due date,
// use the due date as the end date
@@ -425,7 +425,14 @@
this.taskService.update(this.task)
.then(r => {
this.$set(this, 'task', r)
- this.success({message: 'The task was saved successfully.'}, this)
+ let actions = []
+ if (undoCallback !== null) {
+ actions = [{
+ title: 'Undo',
+ callback: undoCallback,
+ }]
+ }
+ this.success({message: 'The task was saved successfully.'}, this, actions)
this.setActiveFields()
})
.catch(e => {
@@ -460,7 +467,7 @@
},
toggleTaskDone() {
this.task.done = !this.task.done
- this.saveTask()
+ this.saveTask(() => this.toggleTaskDone())
},
setDescriptionChanged(e) {
if (e.key === 'Enter' || e.key === 'Control') {
diff --git a/src/main.js b/src/main.js
index a3eccf5a..10240121 100644
--- a/src/main.js
+++ b/src/main.js
@@ -138,8 +138,8 @@ Vue.mixin({
methods: {
formatDateSince: date => moment(date).fromNow(),
formatDate: date => moment(date).format('LLL'),
- error: (e, context) => message.error(e, context),
- success: (s, context) => message.success(s, context),
+ error: (e, context, actions = []) => message.error(e, context, actions),
+ success: (s, context, actions = []) => message.success(s, context, actions),
}
})
diff --git a/src/message/index.js b/src/message/index.js
index 8cbf9dad..308c31c5 100644
--- a/src/message/index.js
+++ b/src/message/index.js
@@ -8,36 +8,40 @@ export default {
context.loading = false
};
},
- error(e, context) {
- // Build the notification text from error response
- let err = e.message
- if (e.response && e.response.data && e.response.data.message) {
- err += '
' + e.response.data.message
- }
+ error(e, context, actions = []) {
+ // Build the notification text from error response
+ let err = e.message
+ if (e.response && e.response.data && e.response.data.message) {
+ err += '
' + e.response.data.message
+ }
- // Fire a notification
- context.$notify({
- type: 'error',
- title: 'Error',
- text: err
- })
+ // Fire a notification
+ context.$notify({
+ type: 'error',
+ title: 'Error',
+ text: err,
+ actions: actions,
+ })
context.loading = false
- },
- success(e, context) {
- // Build the notification text from error response
- let err = e.message
- if (e.response && e.response.data && e.response.data.message) {
- err += '
' + e.response.data.message
- }
+ },
+ success(e, context, actions = []) {
+ // Build the notification text from error response
+ let err = e.message
+ if (e.response && e.response.data && e.response.data.message) {
+ err += '
' + e.response.data.message
+ }
- // Fire a notification
- context.$notify({
- type: 'success',
- title: 'Success',
- text: err
- })
+ // Fire a notification
+ context.$notify({
+ type: 'success',
+ title: 'Success',
+ text: err,
+ data: {
+ actions: actions,
+ },
+ })
context.loading = false
- },
+ },
}
\ No newline at end of file