Added notifications + redirect instead of messages on top
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
d688d65939
commit
742b499d83
|
@ -17,6 +17,7 @@
|
||||||
"vue-awesome": "^2.3.4",
|
"vue-awesome": "^2.3.4",
|
||||||
"vue-multilanguage": "^3.0.5",
|
"vue-multilanguage": "^3.0.5",
|
||||||
"vue-multiselect": "^2.0.6",
|
"vue-multiselect": "^2.0.6",
|
||||||
|
"vue-notification": "^1.3.4",
|
||||||
"vue-paginate": "^3.5.1",
|
"vue-paginate": "^3.5.1",
|
||||||
"vue-resource": "^1.3.4",
|
"vue-resource": "^1.3.4",
|
||||||
"vue-router": "^3.0.1"
|
"vue-router": "^3.0.1"
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<button @click="language = 'en'">EN</button>
|
<button @click="language = 'en'">EN</button>
|
||||||
<button @click="language = 'de'">DE</button>
|
<button @click="language = 'de'">DE</button>
|
||||||
<button @click="language = 'fr'">FR</button>
|
<button @click="language = 'fr'">FR</button>
|
||||||
|
<notifications position="bottom left" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,7 @@
|
||||||
<span v-lang.general.loading></span>
|
<span v-lang.general.loading></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.general.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link :to="{ name: 'author-edit', params: { id: authorID} }" class="ui teal labeled icon button" style="float: right;">
|
<router-link :to="{ name: 'author-edit', params: { id: authorID} }" class="ui teal labeled icon button" style="float: right;">
|
||||||
<i class="edit icon"></i>
|
<i class="edit icon"></i>
|
||||||
|
@ -46,8 +38,6 @@
|
||||||
return {
|
return {
|
||||||
user: auth.user,
|
user: auth.user,
|
||||||
author: {},
|
author: {},
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
authorID: this.$route.params.id
|
authorID: this.$route.params.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -69,7 +59,18 @@
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,7 @@
|
||||||
<span v-lang.general.loading></span>
|
<span v-lang.general.loading></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.genral.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
|
||||||
<div class="header" v-lang.general.success></div>
|
|
||||||
{{ success }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link to="/authors/add" class="ui green labeled icon button" style="float: right;">
|
<router-link to="/authors/add" class="ui green labeled icon button" style="float: right;">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
|
@ -106,8 +93,6 @@ export default {
|
||||||
],
|
],
|
||||||
loading: false,
|
loading: false,
|
||||||
paginate: ['authors'],
|
paginate: ['authors'],
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
allStatus: [],
|
allStatus: [],
|
||||||
showModal: false
|
showModal: false
|
||||||
}
|
}
|
||||||
|
@ -144,6 +129,20 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
loadAuthors () {
|
loadAuthors () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.authors = []
|
this.authors = []
|
||||||
|
@ -162,11 +161,12 @@ export default {
|
||||||
// increment dat shit
|
// increment dat shit
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
gridBtnClicked (opt, gridObject) {
|
gridBtnClicked (opt, gridObject) {
|
||||||
|
@ -180,14 +180,19 @@ export default {
|
||||||
this.$on('delete-submit', function () {
|
this.$on('delete-submit', function () {
|
||||||
HTTP.delete('authors/' + obj.ID.content)
|
HTTP.delete('authors/' + obj.ID.content)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response)
|
|
||||||
if (response.status === 200 && response.data.Message === 'success') {
|
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()
|
this.loadAuthors()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
|
this.loadAuthors()
|
||||||
})
|
})
|
||||||
this.showModal = false
|
this.showModal = false
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="ui negative message" v-if="error">
|
|
||||||
<div class="header" v-lang.general.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<template v-if="error.response">
|
|
||||||
<br/>{{ error.response.data.Message }}
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
<div class="ui positive message" v-if="success">
|
||||||
<div class="header" v-lang.general.success></div>
|
<div class="header" v-lang.general.success></div>
|
||||||
{{ success }}
|
{{ success }}
|
||||||
|
@ -31,12 +23,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HTTP} from '../http-common'
|
import {HTTP} from '../http-common'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AuthorsAddEdit',
|
name: 'AuthorsAddEdit',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
error: '',
|
|
||||||
success: '',
|
success: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
authorID: this.$route.params.id,
|
authorID: this.$route.params.id,
|
||||||
|
@ -58,7 +50,7 @@
|
||||||
this.edit = true
|
this.edit = true
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
@ -69,9 +61,27 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
insertOrUpdateAuthor: function () {
|
insertOrUpdateAuthor: function () {
|
||||||
if (this.author.Lastname === '') {
|
if (this.author.Lastname === '') {
|
||||||
this.error = {message: this.translate('authors').errorNoTitle}
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'warn',
|
||||||
|
text: this.translate('authors').errorNoTitle
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
|
@ -81,25 +91,38 @@
|
||||||
HTTP.post('authors/' + this.author.ID, {author: this.author})
|
HTTP.post('authors/' + this.author.ID, {author: this.author})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('authors').updatedSuccess
|
|
||||||
this.error = ''
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('authors').updatedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
} else { // insert a new author
|
} else { // insert a new author
|
||||||
HTTP.put('authors', {author: this.author})
|
HTTP.put('authors', {author: this.author})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('authors').insertedSuccess
|
|
||||||
this.error = ''
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('authors').insertedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect to books list
|
||||||
|
router.push({ name: 'authors' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,7 @@
|
||||||
<span v-lang.general.loading></span>
|
<span v-lang.general.loading></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.general.error>
|
|
||||||
</div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link :to="{ name: 'book-edit', params: { id: bookID} }" class="ui teal labeled icon button" style="float: right;">
|
<router-link :to="{ name: 'book-edit', params: { id: bookID} }" class="ui teal labeled icon button" style="float: right;">
|
||||||
<i class="edit icon"></i>
|
<i class="edit icon"></i>
|
||||||
|
@ -71,8 +62,6 @@
|
||||||
return {
|
return {
|
||||||
user: auth.user,
|
user: auth.user,
|
||||||
book: {},
|
book: {},
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
allStatus: [],
|
allStatus: [],
|
||||||
bookID: this.$route.params.id
|
bookID: this.$route.params.id
|
||||||
}
|
}
|
||||||
|
@ -86,6 +75,20 @@
|
||||||
'$route': 'loadBook'
|
'$route': 'loadBook'
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
loadBook () {
|
loadBook () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.book = {}
|
this.book = {}
|
||||||
|
@ -108,7 +111,7 @@
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadStatus: function () {
|
loadStatus: function () {
|
||||||
|
@ -117,7 +120,7 @@
|
||||||
this.allStatus = response.data
|
this.allStatus = response.data
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getStatusByID: function (id) {
|
getStatusByID: function (id) {
|
||||||
|
|
|
@ -7,20 +7,7 @@
|
||||||
<template v-lang.general.loading></template>
|
<template v-lang.general.loading></template>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.general.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
|
||||||
<div class="header" v-lang.general.success></div>
|
|
||||||
{{ success }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link to="/books/add" class="ui green labeled icon button" style="float: right;">
|
<router-link to="/books/add" class="ui green labeled icon button" style="float: right;">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
|
@ -107,8 +94,6 @@ export default {
|
||||||
],
|
],
|
||||||
loading: false,
|
loading: false,
|
||||||
paginate: ['books'],
|
paginate: ['books'],
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
allStatus: [],
|
allStatus: [],
|
||||||
showModal: false
|
showModal: false
|
||||||
}
|
}
|
||||||
|
@ -160,6 +145,20 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
loadBooks () {
|
loadBooks () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.books = []
|
this.books = []
|
||||||
|
@ -201,7 +200,7 @@ export default {
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadStatus: function () {
|
loadStatus: function () {
|
||||||
|
@ -210,7 +209,7 @@ export default {
|
||||||
this.allStatus = response.data
|
this.allStatus = response.data
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getStatusByID: function (id) {
|
getStatusByID: function (id) {
|
||||||
|
@ -234,13 +233,18 @@ export default {
|
||||||
HTTP.delete('books/' + obj.ID.content)
|
HTTP.delete('books/' + obj.ID.content)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.status === 200 && response.data.Message === 'success') {
|
if (response.status === 200 && response.data.Message === 'success') {
|
||||||
this.success = this.langBook.deleteSuccess
|
// Fire a notification
|
||||||
this.loadBooks()
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.langGeneral.success,
|
||||||
|
text: this.langBook.deleteSuccess
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
|
this.loadBooks()
|
||||||
this.showModal = false
|
this.showModal = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,19 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="ui negative message" v-if="error">
|
<form class="ui form" :class="{ loading: loading }" @submit.prevent="insertNewBook">
|
||||||
<div class="header" v-lang.general.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<template v-if="error.response">
|
|
||||||
<br/>{{ error.response.data.Message }}
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
|
||||||
<div class="header" v-lang.general.success></div>
|
|
||||||
{{ success }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form class="ui form" :class="{ loading: loading }" v-if="!success" @submit.prevent="insertNewBook">
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label v-lang.books.gridColumns.title></label>
|
<label v-lang.books.gridColumns.title></label>
|
||||||
<input name="title" :placeholder="langBooks.gridColumns.title" type="text" v-model="book.Title" required v-focus>
|
<input name="title" :placeholder="langBooks.gridColumns.title" type="text" v-model="book.Title" required v-focus>
|
||||||
|
@ -103,13 +90,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HTTP} from '../http-common'
|
import {HTTP} from '../http-common'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BooksAddEdit',
|
name: 'BooksAddEdit',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
loading: false,
|
loading: false,
|
||||||
bookID: this.$route.params.id,
|
bookID: this.$route.params.id,
|
||||||
edit: false,
|
edit: false,
|
||||||
|
@ -170,19 +156,33 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
loadPublishers: function () {
|
loadPublishers: function () {
|
||||||
HTTP.get('publishers')
|
HTTP.get('publishers')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.publishers = response.data
|
this.publishers = response.data
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadAuthors: function () {
|
loadAuthors: function () {
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadStatus: function () {
|
loadStatus: function () {
|
||||||
|
@ -207,7 +207,7 @@
|
||||||
this.allStatus = response.data
|
this.allStatus = response.data
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleAddPublisher: function () {
|
toggleAddPublisher: function () {
|
||||||
|
@ -226,7 +226,11 @@
|
||||||
},
|
},
|
||||||
insertNewBook: function () {
|
insertNewBook: function () {
|
||||||
if (this.book.Title === '') {
|
if (this.book.Title === '') {
|
||||||
this.error = {message: this.translate('books').errorNoTitle}
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'warn',
|
||||||
|
text: this.translate('books').errorNoTitle
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
|
@ -270,25 +274,37 @@
|
||||||
HTTP.post('books/' + this.book.ID, {book: this.book})
|
HTTP.post('books/' + this.book.ID, {book: this.book})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('books').updatedSuccess
|
|
||||||
this.error = ''
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('books').updatedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
} else { // insert a new book
|
} else { // insert a new book
|
||||||
HTTP.put('books', {book: this.book})
|
HTTP.put('books', {book: this.book})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('books').insertedSuccess
|
// Fire a notification
|
||||||
this.error = ''
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('books').insertedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect to books list
|
||||||
|
router.push({ name: 'books' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@
|
||||||
for (const d in data) {
|
for (const d in data) {
|
||||||
let ii = 0
|
let ii = 0
|
||||||
for (const dd in d) {
|
for (const dd in d) {
|
||||||
console.log(dd)
|
|
||||||
if (dd.content === '') {
|
if (dd.content === '') {
|
||||||
this.data[i][ii] = dd
|
this.data[i][ii] = dd
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,16 +7,7 @@
|
||||||
<span v-lang.general.loading></span>
|
<span v-lang.general.loading></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.genral.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link :to="{ name: 'publisher-edit', params: { id: publisherID} }" class="ui teal labeled icon button" style="float: right;">
|
<router-link :to="{ name: 'publisher-edit', params: { id: publisherID} }" class="ui teal labeled icon button" style="float: right;">
|
||||||
<i class="edit icon"></i>
|
<i class="edit icon"></i>
|
||||||
<span v-lang.general.edit></span>
|
<span v-lang.general.edit></span>
|
||||||
|
@ -42,8 +33,6 @@
|
||||||
return {
|
return {
|
||||||
user: auth.user,
|
user: auth.user,
|
||||||
publisher: {},
|
publisher: {},
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
publisherID: this.$route.params.id
|
publisherID: this.$route.params.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -65,7 +54,18 @@
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,7 @@
|
||||||
<span v-lang.general.loading></span>
|
<span v-lang.general.loading></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui negative message" v-if="error">
|
<div v-if="!loading">
|
||||||
<div class="header" v-lang.genral.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
|
||||||
<div class="header" v-lang.general.success></div>
|
|
||||||
{{ success }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="!loading && !error">
|
|
||||||
|
|
||||||
<router-link to="/publishers/add" class="ui green labeled icon button" style="float: right;">
|
<router-link to="/publishers/add" class="ui green labeled icon button" style="float: right;">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
|
@ -106,8 +93,6 @@ export default {
|
||||||
],
|
],
|
||||||
loading: false,
|
loading: false,
|
||||||
paginate: ['publishers'],
|
paginate: ['publishers'],
|
||||||
error: '',
|
|
||||||
success: '',
|
|
||||||
allStatus: [],
|
allStatus: [],
|
||||||
showModal: false
|
showModal: false
|
||||||
}
|
}
|
||||||
|
@ -123,6 +108,20 @@ export default {
|
||||||
'$route': 'loadPublishers'
|
'$route': 'loadPublishers'
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
filteredData: function () {
|
filteredData: function () {
|
||||||
var filterKey = this.searchQuery && this.searchQuery.toLowerCase()
|
var filterKey = this.searchQuery && this.searchQuery.toLowerCase()
|
||||||
var data = this.publishers
|
var data = this.publishers
|
||||||
|
@ -166,7 +165,7 @@ export default {
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
gridBtnClicked (opt, gridObject) {
|
gridBtnClicked (opt, gridObject) {
|
||||||
|
@ -183,12 +182,17 @@ export default {
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log(response)
|
console.log(response)
|
||||||
if (response.status === 200 && response.data.Message === 'success') {
|
if (response.status === 200 && response.data.Message === 'success') {
|
||||||
this.success = this.translate('publishers').deleteSuccess
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.langGeneral.success,
|
||||||
|
text: this.translate('publishers').deleteSuccess
|
||||||
|
})
|
||||||
this.loadPublishers()
|
this.loadPublishers()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
this.showModal = false
|
this.showModal = false
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="ui negative message" v-if="error">
|
|
||||||
<div class="header" v-lang.genral.error></div>
|
|
||||||
{{ error.message }}
|
|
||||||
<p v-if="error.response.data">
|
|
||||||
{{ error.response.data.Message }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="ui positive message" v-if="success">
|
<div class="ui positive message" v-if="success">
|
||||||
<div class="header" v-lang.general.success></div>
|
<div class="header" v-lang.general.success></div>
|
||||||
{{ success }}
|
{{ success }}
|
||||||
|
@ -25,12 +17,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HTTP} from '../http-common'
|
import {HTTP} from '../http-common'
|
||||||
|
import router from '../router'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PublishersAddEdit',
|
name: 'PublishersAddEdit',
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
error: '',
|
|
||||||
success: '',
|
success: '',
|
||||||
loading: false,
|
loading: false,
|
||||||
publisherID: this.$route.params.id,
|
publisherID: this.$route.params.id,
|
||||||
|
@ -51,7 +43,7 @@
|
||||||
this.edit = true
|
this.edit = true
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
|
@ -62,9 +54,28 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
errorNotification (e) {
|
||||||
|
// Build the notification text from error response
|
||||||
|
let err = e.message
|
||||||
|
if (e.response.data) {
|
||||||
|
err += '<br/>' + e.response.data.Message
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'error',
|
||||||
|
title: this.langGeneral.error,
|
||||||
|
text: err
|
||||||
|
})
|
||||||
|
},
|
||||||
insertOrUpdatePublisher: function () {
|
insertOrUpdatePublisher: function () {
|
||||||
if (this.publisher.Lastname === '') {
|
if (this.publisher.Lastname === '') {
|
||||||
this.error = {message: this.translate('publishers').errorNoName}
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'warn',
|
||||||
|
title: this.translate('general').error,
|
||||||
|
text: this.translate('publishers').errorNoName
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
|
@ -74,25 +85,38 @@
|
||||||
HTTP.post('publishers/' + this.publisher.ID, {publisher: this.publisher})
|
HTTP.post('publishers/' + this.publisher.ID, {publisher: this.publisher})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('publishers').updatedSuccess
|
|
||||||
this.error = ''
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('publishers').updatedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
} else { // insert a new publisher
|
} else { // insert a new publisher
|
||||||
HTTP.put('publishers', {publisher: this.publisher})
|
HTTP.put('publishers', {publisher: this.publisher})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.success = this.translate('publishers').insertedSuccess
|
|
||||||
this.error = ''
|
// Fire a notification
|
||||||
|
this.$notify({
|
||||||
|
type: 'success',
|
||||||
|
title: this.translate('general').success,
|
||||||
|
text: this.translate('publishers').insertedSuccess
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.error = e
|
this.errorNotification(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect to books list
|
||||||
|
router.push({ name: 'publishers' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export default {
|
||||||
add: 'Add a book',
|
add: 'Add a book',
|
||||||
deleteHeader: 'Delete this book',
|
deleteHeader: 'Delete this book',
|
||||||
deleteMsg: 'Are you sure you want to delete this book? <b>This cannot be undone!</b>',
|
deleteMsg: 'Are you sure you want to delete this book? <b>This cannot be undone!</b>',
|
||||||
deleteSuccess: 'The book was deleted successfully',
|
deleteSuccess: 'The book was deleted successfully.',
|
||||||
gridColumns: {
|
gridColumns: {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
isbn: 'ISBN',
|
isbn: 'ISBN',
|
||||||
|
|
|
@ -28,6 +28,12 @@ import Multiselect from 'vue-multiselect'
|
||||||
import Multilanguage from 'vue-multilanguage'
|
import Multilanguage from 'vue-multilanguage'
|
||||||
import language from './lang/lang'
|
import language from './lang/lang'
|
||||||
|
|
||||||
|
// Notifications
|
||||||
|
import Notifications from 'vue-notification'
|
||||||
|
|
||||||
|
// Notifications
|
||||||
|
Vue.use(Notifications)
|
||||||
|
|
||||||
// Multiselect globally
|
// Multiselect globally
|
||||||
Vue.component('multiselect', Multiselect)
|
Vue.component('multiselect', Multiselect)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue