Many fixes n stuff
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<q-layout> <!-- Be sure to play with the Layout demo on docs -->
|
||||
<q-header class="no-shadow text-center">
|
||||
<q-layout v-if="!loading"> <!-- Be sure to play with the Layout demo on docs -->
|
||||
<q-header class="no-shadow text-center bg-white">
|
||||
<q-toolbar color="secondary" inverted style="border-bottom:1px solid rgba(0,0,0,0.1)">
|
||||
<q-btn
|
||||
flat
|
||||
size="18px"
|
||||
icon="menu"
|
||||
color="secondary"
|
||||
@click="leftDrawer = !leftDrawer"
|
||||
/>
|
||||
<q-toolbar-title class="text-center">
|
||||
@ -30,20 +31,20 @@
|
||||
no-border
|
||||
inset-separator
|
||||
>
|
||||
<q-item-label>Catégories</q-item-label>
|
||||
<q-item-label header>Catégories</q-item-label>
|
||||
<q-item v-for="category in categories"
|
||||
:key="category.code"
|
||||
:to="'/category/' + category.code"
|
||||
>
|
||||
<q-item-section>{{ category.name }}</q-item-section>
|
||||
<q-item-section>
|
||||
{{ category.name }}
|
||||
<q-chip square
|
||||
dense
|
||||
color="secondary"
|
||||
class="q-ml-md"
|
||||
text-color="white"
|
||||
>{{ counters[category.name] }}</q-chip>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-section side>
|
||||
<q-btn round
|
||||
flat
|
||||
size="md"
|
||||
@ -104,6 +105,7 @@ export default {
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.loading = true
|
||||
this.$q.loading.setDefaults({
|
||||
spinner: QSpinnerBars,
|
||||
message: 'OK, laisse moi juste le temps de charger...',
|
||||
@ -153,9 +155,10 @@ export default {
|
||||
methods: {
|
||||
loadAppData () {
|
||||
this.$q.loading.show()
|
||||
this.$store.dispatch('core/loadAppData').then(data => {
|
||||
return this.$store.dispatch('core/loadAppData').then(data => {
|
||||
console.log(data)
|
||||
this.$q.loading.hide()
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
unsetUser () {
|
||||
@ -166,12 +169,12 @@ export default {
|
||||
ok: 'Bah oui, FDP',
|
||||
cancel: 'Ah non en fait'
|
||||
})
|
||||
.then(() => {
|
||||
.onOk(() => {
|
||||
this.$q.localStorage.remove('username')
|
||||
this.$router.push('/')
|
||||
})
|
||||
},
|
||||
addItem (category) {
|
||||
async addItem (category) {
|
||||
this.$q.loading.show()
|
||||
let newItem = {
|
||||
available: true,
|
||||
@ -184,37 +187,37 @@ export default {
|
||||
system: null
|
||||
}
|
||||
newItem.ref = `${category.code}-${String(this.counters[category.name] + 1).padStart(4, '0')}`
|
||||
this.$store.dispatch('core/addToCollection', {
|
||||
await this.$store.dispatch('core/addToCollection', {
|
||||
collection: 'stock',
|
||||
data: newItem
|
||||
}).then(response => {
|
||||
// Insert history record
|
||||
this.$store.dispatch('core/addToCollection', {
|
||||
collection: 'history',
|
||||
data: {
|
||||
ref: newItem.ref,
|
||||
text: 'Entrée en stock',
|
||||
user: this.$store.state.core.username,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
})
|
||||
|
||||
// Process to new item
|
||||
this.$q.loading.hide()
|
||||
this.$q.dialog({
|
||||
title: `Item "${category.name}" créé`,
|
||||
message: 'Tu veux aller éditer les détails de cet item ?',
|
||||
color: 'primary',
|
||||
ok: 'Oui, STP',
|
||||
cancel: 'Osef'
|
||||
})
|
||||
.then(() => {
|
||||
this.$router.push(`/item/${newItem.ref}`)
|
||||
})
|
||||
.catch(() => {
|
||||
// Picked "Cancel" or dismissed
|
||||
})
|
||||
})
|
||||
// Insert history record
|
||||
await this.$store.dispatch('core/addToCollection', {
|
||||
collection: 'history',
|
||||
data: {
|
||||
ref: newItem.ref,
|
||||
text: 'Entrée en stock',
|
||||
user: this.$store.state.core.username,
|
||||
timestamp: Date.now()
|
||||
}
|
||||
})
|
||||
await this.loadAppData()
|
||||
|
||||
// Process to new item
|
||||
this.$q.loading.hide()
|
||||
this.$q.dialog({
|
||||
title: `Item "${category.name}" créé`,
|
||||
message: 'Tu veux aller éditer les détails de cet item ?',
|
||||
color: 'primary',
|
||||
ok: 'Oui, STP',
|
||||
cancel: 'Osef'
|
||||
})
|
||||
.then(() => {
|
||||
this.$router.push(`/item/${newItem.ref}`)
|
||||
})
|
||||
.catch(() => {
|
||||
// Picked "Cancel" or dismissed
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user