From 742b499d83b151f79677e9559d0b5737643d8f08 Mon Sep 17 00:00:00 2001 From: konrad Date: Thu, 23 Nov 2017 14:18:31 +0100 Subject: [PATCH] Added notifications + redirect instead of messages on top --- frontend/package.json | 1 + frontend/src/App.vue | 1 + frontend/src/components/AuthorOverview.vue | 25 +++---- frontend/src/components/Authors.vue | 45 ++++++------ frontend/src/components/AuthorsAddEdit.vue | 57 ++++++++++----- frontend/src/components/BookOverview.vue | 31 ++++---- frontend/src/components/Books.vue | 46 ++++++------ frontend/src/components/BooksAddEdit.vue | 70 ++++++++++++------- frontend/src/components/Grid.vue | 1 - frontend/src/components/PublisherOverview.vue | 26 +++---- frontend/src/components/Publishers.vue | 42 ++++++----- frontend/src/components/PublishersAddEdit.vue | 58 ++++++++++----- frontend/src/lang/en.js | 2 +- frontend/src/main.js | 6 ++ 14 files changed, 249 insertions(+), 162 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index d2a55c8..b02b3b0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,6 +17,7 @@ "vue-awesome": "^2.3.4", "vue-multilanguage": "^3.0.5", "vue-multiselect": "^2.0.6", + "vue-notification": "^1.3.4", "vue-paginate": "^3.5.1", "vue-resource": "^1.3.4", "vue-router": "^3.0.1" diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 7426bd7..e6fc6d3 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -20,6 +20,7 @@ + diff --git a/frontend/src/components/AuthorOverview.vue b/frontend/src/components/AuthorOverview.vue index fb684fd..5684d04 100644 --- a/frontend/src/components/AuthorOverview.vue +++ b/frontend/src/components/AuthorOverview.vue @@ -7,15 +7,7 @@ -
-
- {{ error.message }} -

- {{ error.response.data.Message }} -

-
- -
+
@@ -46,8 +38,6 @@ return { user: auth.user, author: {}, - error: '', - success: '', authorID: this.$route.params.id } }, @@ -69,7 +59,18 @@ }) .catch(e => { this.loading = false - this.error = e + // Build the notification text from error response + let err = e.message + if (e.response.data) { + err += '
' + e.response.data.Message + } + + // Fire a notification + this.$notify({ + type: 'error', + title: this.langGeneral.error, + text: err + }) }) } } diff --git a/frontend/src/components/Authors.vue b/frontend/src/components/Authors.vue index c284aad..8be307f 100644 --- a/frontend/src/components/Authors.vue +++ b/frontend/src/components/Authors.vue @@ -7,20 +7,7 @@
-
-
- {{ error.message }} -

- {{ error.response.data.Message }} -

-
- -
-
- {{ success }} -
- -
+
@@ -106,8 +93,6 @@ export default { ], loading: false, paginate: ['authors'], - error: '', - success: '', allStatus: [], showModal: false } @@ -144,6 +129,20 @@ export default { } }, methods: { + errorNotification (e) { + // Build the notification text from error response + let err = e.message + if (e.response.data) { + err += '
' + e.response.data.Message + } + + // Fire a notification + this.$notify({ + type: 'error', + title: this.langGeneral.error, + text: err + }) + }, loadAuthors () { this.loading = true this.authors = [] @@ -162,11 +161,12 @@ export default { // increment dat shit i++ } + this.loading = false }) .catch(e => { this.loading = false - this.error = e + this.errorNotification(e) }) }, gridBtnClicked (opt, gridObject) { @@ -180,14 +180,19 @@ export default { this.$on('delete-submit', function () { HTTP.delete('authors/' + obj.ID.content) .then(response => { - console.log(response) if (response.status === 200 && response.data.Message === 'success') { - this.success = this.translate('authors').deleteSuccess + // Fire a notification + this.$notify({ + type: 'success', + title: this.langGeneral.success, + text: this.translate('authors').deleteSuccess + }) this.loadAuthors() } }) .catch(e => { - this.error = e + this.errorNotification(e) + this.loadAuthors() }) this.showModal = false }) diff --git a/frontend/src/components/AuthorsAddEdit.vue b/frontend/src/components/AuthorsAddEdit.vue index 1259ee6..a1ce65e 100644 --- a/frontend/src/components/AuthorsAddEdit.vue +++ b/frontend/src/components/AuthorsAddEdit.vue @@ -1,13 +1,5 @@