fixed ##181

This commit is contained in:
Tim Gröger 2020-02-22 08:33:21 +01:00
parent 6f4980dfb5
commit 3125e00a2a
2 changed files with 48 additions and 12 deletions

View File

@ -23,18 +23,27 @@
<AddAmountSkeleton v-if="loading && users.length === 0" /> <AddAmountSkeleton v-if="loading && users.length === 0" />
</v-container> </v-container>
<v-navigation-drawer v-model="menu" right app clipped> <v-navigation-drawer v-model="menu" right app clipped>
<v-list-item-group> <v-list-item-group :key="componentRenderer">
<v-list-item inactive>
<v-list-item-title class="headline">
Verlauf
</v-list-item-title>
</v-list-item>
<v-divider />
<div <div
v-for="message in messages" v-for="message in messages"
three-line three-line
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
> >
<v-list-item three-line> <v-list-item three-line inactive @click="storno(message)">
<v-list-item-content> <v-list-item-content>
<v-progress-linear indeterminate v-if="message.loading" />
<v-list-item-title>{{ now(message.date) }}</v-list-item-title> <v-list-item-title>{{ now(message.date) }}</v-list-item-title>
<v-list-item-subtitle>{{ message.message }}</v-list-item-subtitle> <v-list-item-subtitle>{{ message.message }}</v-list-item-subtitle>
<v-list-item-subtitle class="red--text" v-if="message.storno">STORNIERT!!!</v-list-item-subtitle> <v-list-item-subtitle class="red--text" v-if="message.storno"
<v-list-item-action-text @click.stop="storno(message)" >STORNIERT!!!</v-list-item-subtitle
>
<v-list-item-action-text
>Klicken um zu Stornieren >Klicken um zu Stornieren
</v-list-item-action-text> </v-list-item-action-text>
</v-list-item-content> </v-list-item-content>
@ -204,12 +213,15 @@ export default {
return { return {
color: 'green accent-4', color: 'green accent-4',
menu: true, menu: true,
dialog: false dialog: false,
componentRenderer: 0,
timer: ''
} }
}, },
created() { created() {
this.menu = this.menu_from_store this.menu = this.menu_from_store
this.getUsers() this.getUsers()
this.timer = setInterval(this.forceRender, 1000)
}, },
methods: { methods: {
...mapActions({ ...mapActions({
@ -218,6 +230,9 @@ export default {
deactivate: 'barUsers/deactivateMenu', deactivate: 'barUsers/deactivateMenu',
commitStorno: 'barUsers/storno' commitStorno: 'barUsers/storno'
}), }),
forceRender() {
this.componentRenderer += 1
},
getColor(type) { getColor(type) {
return type === 'credit' ? 'title green--text' : 'title red--text' return type === 'credit' ? 'title green--text' : 'title red--text'
}, },
@ -232,10 +247,15 @@ export default {
} }
}, },
storno(message) { storno(message) {
console.log('storno')
if (!message.error) { if (!message.error) {
if (!this.under5minutes(message.date)) this.dialog = true if (!this.under5minutes(message.date)) this.dialog = true
else { else {
this.commitStorno({username: message.user.username, amount: message.amount, date: message.date}) this.commitStorno({
username: message.user.username,
amount: message.amount,
date: message.date
})
} }
} }
} }
@ -279,10 +299,22 @@ export default {
} else if (date.getMinutes() < 10) { } else if (date.getMinutes() < 10) {
return 'vor ' + date.getMinutes() + ' Minuten' return 'vor ' + date.getMinutes() + ' Minuten'
} else { } else {
return now.getHours() + ':' + now.getMinutes() return (
(now.getHours() < 10 ? '0' : '') +
now.getHours() +
':' +
(now.getMinutes() < 10 ? '0' : '') +
now.getMinutes()
)
} }
} else { } else {
return now.getHours() + ':' + now.getMinutes() return (
(now.getHours() < 10 ? '0' : '') +
now.getHours() +
':' +
(now.getMinutes() < 10 ? '0' : '') +
now.getMinutes()
)
} }
} }
} }
@ -294,8 +326,10 @@ export default {
'.' + '.' +
now.getFullYear() + now.getFullYear() +
' ' + ' ' +
(now.getHours() < 10 ? '0' : '') +
now.getHours() + now.getHours() +
':' + ':' +
(now.getMinutes() < 10 ? '0' : '') +
now.getMinutes() now.getMinutes()
) )
} }

View File

@ -99,6 +99,7 @@ const mutations = {
user: data.user, user: data.user,
error: data.error, error: data.error,
storno: false, storno: false,
loading: false,
visible: true, visible: true,
amount: data.amount, amount: data.amount,
date: new Date() date: new Date()
@ -110,7 +111,8 @@ const mutations = {
return msg.date - data.date === 0 ? true : false return msg.date - data.date === 0 ? true : false
}) })
if (message) { if (message) {
message.storno = true if (data.storno !== undefined) message.storno = data.storno
if (data.loading !== undefined) message.loading = data.loading
} }
}, },
setMenu: (state, value) => { setMenu: (state, value) => {
@ -189,7 +191,7 @@ const actions = {
commit('setAllUsersLoading', false) commit('setAllUsersLoading', false)
}, },
async storno({ commit, rootState, dispatch }, data) { async storno({ commit, rootState, dispatch }, data) {
commit('setUsersLoading', true) commit('updateMessage', { date: data.date, loading: true })
try { try {
const response = await axios.post( const response = await axios.post(
url.barU.storno, url.barU.storno,
@ -200,12 +202,12 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
commit('setUsers', { [response.data.username]: response.data }) commit('setUsers', { [response.data.username]: response.data })
commit('updateMessage', { date: data.date }) commit('updateMessage', { date: data.date, storno: true })
} catch (e) { } catch (e) {
if (e.response) if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true }) if (e.response.status === 401) dispatch('logout', null, { root: true })
} }
commit('setUsersLoading', false) commit('updateMessage', { date: data.date, loading: false })
}, },
setFilter({ commit }, data) { setFilter({ commit }, data) {
commit('setFilter', data) commit('setFilter', data)