fixed bug ##258

This commit is contained in:
Tim Gröger 2020-06-04 20:56:03 +02:00
parent f99bacbc33
commit e7eb37c7bc
4 changed files with 166 additions and 108 deletions

View File

@ -3,10 +3,10 @@
<v-dialog v-model="dialog" max-width="290"> <v-dialog v-model="dialog" max-width="290">
<v-card> <v-card>
<v-card-title class="headline" <v-card-title class="headline"
>Transaktion ist länger als 5 Minuten her!</v-card-title >Transaktion ist länger als 1 Minute her!</v-card-title
> >
<v-card-text> <v-card-text>
Da die Transaktion länger als 5 Minutern her ist, kann eine Da die Transaktion länger als 1 Minuter her ist, kann eine
Stornierung nicht durchgeführt werden. Wende dich bitte an den Stornierung nicht durchgeführt werden. Wende dich bitte an den
Finanzer. Finanzer.
</v-card-text> </v-card-text>
@ -39,11 +39,11 @@
<v-list-item-content> <v-list-item-content>
<v-progress-linear indeterminate v-if="message.loading" /> <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>{{ createMessage(message) }}</v-list-item-subtitle>
<v-list-item-subtitle class="red--text" v-if="message.storno" <v-list-item-subtitle class="red--text" v-if="message.storno"
>STORNIERT!!!</v-list-item-subtitle >STORNIERT!!!</v-list-item-subtitle
> >
<v-list-item-action-text <v-list-item-action-text v-if="under5minutes(message.date)"
>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>
@ -55,11 +55,14 @@
<div v-if="isFiltered(user)"> <div v-if="isFiltered(user)">
<v-container> <v-container>
<v-card :loading="user.loading"> <v-card :loading="user.loading">
<v-list-item> <v-card-title>
<v-list-item-title class="title" <v-list-item-title class="title"
>{{ user.firstname }} {{ user.lastname }}</v-list-item-title >{{ user.firstname }} {{ user.lastname }}</v-list-item-title
> >
</v-list-item> </v-card-title>
<v-card-subtitle v-if="user.limit + user.amount > 0">
Nur noch {{ ((user.limit + user.amount)/100).toFixed(2)}} übrig!!
</v-card-subtitle>
<v-card-text> <v-card-text>
<v-row> <v-row>
<v-col cols="10"> <v-col cols="10">
@ -206,11 +209,11 @@
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
:color="message.error ? 'error' : 'success'" :color="message.error ? 'error' : 'success'"
bottom bottom
:timeout="3000" :timeout="0"
:multi-line="true" :multi-line="true"
v-model="message.visible" v-model="message.visible"
> >
{{ message.message }} {{ createMessage(message) }}
</v-snackbar> </v-snackbar>
</v-container> </v-container>
</div> </div>
@ -273,9 +276,10 @@ export default {
} }
}, },
addAmountMore(user) { addAmountMore(user) {
console.log(user.value * 100)
this.addAmount({ this.addAmount({
username: user.username, username: user.username,
amount: Math.abs(user.value * 100), amount: Math.round(Math.abs(user.value * 100)),
user: user user: user
}) })
setTimeout(() => { setTimeout(() => {
@ -293,6 +297,29 @@ export default {
}) })
} }
} }
},
createMessage(message) {
var text = ''
if (message.error) {
text =
'Konnte ' +
(message.amount / 100).toFixed(2) +
'€ zu ' +
message.user.firstname +
' ' +
message.user.lastname +
' hinzufügen.'
} else {
text =
'' +
(message.amount / 100).toFixed(2) +
'€ wurde zu ' +
message.user.firstname +
' ' +
message.user.lastname +
' hinzugefügt.'
}
return text
} }
}, },
computed: { computed: {
@ -306,18 +333,7 @@ export default {
under5minutes() { under5minutes() {
return now => { return now => {
var actual = new Date() var actual = new Date()
var zero = new Date(0) return actual - now < 60000
var date = new Date(actual - now)
if (
date.getFullYear() === zero.getFullYear() &&
date.getMonth() === zero.getMonth() &&
date.getDate() === zero.getDate()
) {
if (date.getMinutes() < 6) {
return true
}
}
return false
} }
}, },
now() { now() {

View File

@ -3,10 +3,10 @@
<v-dialog v-model="dialog" max-width="290"> <v-dialog v-model="dialog" max-width="290">
<v-card> <v-card>
<v-card-title class="headline" <v-card-title class="headline"
>Transaktion ist länger als 5 Minuten her!</v-card-title >Transaktion ist länger als 15 Sekunden her!</v-card-title
> >
<v-card-text> <v-card-text>
Da die Transaktion länger als 5 Minutern her ist, kann eine Da die Transaktion länger als 15 Sekunden her ist, kann eine
Stornierung nicht durchgeführt werden. Wende dich bitte an den Stornierung nicht durchgeführt werden. Wende dich bitte an den
Finanzer. Finanzer.
</v-card-text> </v-card-text>
@ -32,19 +32,23 @@
three-line three-line
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
> >
<v-list-item three-line inactive @click="storno(message)"> <div v-if="message">
<v-list-item-content> <v-list-item three-line inactive @click="storno(message)">
<v-progress-linear indeterminate v-if="message.loading" /> <v-list-item-content>
<v-list-item-title>{{ now(message.date) }}</v-list-item-title> <v-progress-linear indeterminate v-if="message.loading" />
<v-list-item-subtitle>{{ message.message }}</v-list-item-subtitle> <v-list-item-title>{{ now(message.date) }}</v-list-item-title>
<v-list-item-subtitle class="red--text" v-if="message.storno" <v-list-item-subtitle>
>STORNIERT!!!</v-list-item-subtitle {{ createMessage(message) }}
> </v-list-item-subtitle>
<v-list-item-action-text <v-list-item-subtitle class="red--text" v-if="message.storno"
>Klicken um zu Stornieren >STORNIERT!!!
</v-list-item-action-text> </v-list-item-subtitle>
</v-list-item-content> <v-list-item-action-text v-if="under5minutes(message.date)"
</v-list-item> >Klicken um zu Stornieren
</v-list-item-action-text>
</v-list-item-content>
</v-list-item>
</div>
</div> </div>
</v-list-item-group> </v-list-item-group>
</v-navigation-drawer> </v-navigation-drawer>
@ -121,11 +125,22 @@
> >
</v-col> </v-col>
<v-col cols="8"> <v-col cols="8">
<v-text-field outlined type="number" v-model="value" label="Benutzerdefinierter Betrag" :disabled="user.locked"></v-text-field> <v-text-field
outlined
type="number"
v-model="value"
label="Benutzerdefinierter Betrag"
:disabled="user.locked"
></v-text-field>
</v-col> </v-col>
<v-col cols="4"> <v-col cols="4">
<v-btn fab :color="color" @click="addAmountMore()" :disabled="user.locked"> <v-btn
<v-icon>{{plus}}</v-icon> fab
:color="color"
@click="addAmountMore()"
:disabled="user.locked"
>
<v-icon>{{ plus }}</v-icon>
</v-btn> </v-btn>
</v-col> </v-col>
</v-row> </v-row>
@ -151,22 +166,35 @@
</v-card-text> </v-card-text>
</v-card> </v-card>
<v-snackbar <v-snackbar
v-for="message in messages" v-for="message in messages"
:key="messages.indexOf(message)" :key="messages.indexOf(message)"
:color="message.error ? 'error' : 'success'" :color="message.error ? 'error' : 'success'"
bottom bottom
:timeout="3000" :timeout="0"
:multi-line="true" :multi-line="true"
v-model="message.visible" v-model="message.visible"
vertical
> >
{{ message.message }} <div class="title">
{{ createMessage(message) }}
</div>
<div>
{{now(message.date)}}
</div>
<v-btn color="white" icon @click="message.visible = false">
<v-icon>
{{close}}
</v-icon>
</v-btn>
</v-snackbar> </v-snackbar>
</v-container> </v-container>
</template> </template>
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import { mdiMenu, mdiPlus } from '@mdi/js' // eslint-disable-next-line no-unused-vars
import { mdiMenu, mdiPlus, mdiClose } from '@mdi/js'
import AddAmountSkeleton from './Skeleton/AddAmountSkeleton' import AddAmountSkeleton from './Skeleton/AddAmountSkeleton'
export default { export default {
name: 'AddAmount', name: 'AddAmount',
@ -180,7 +208,8 @@ export default {
dialog: false, dialog: false,
componentRenderer: 0, componentRenderer: 0,
timer: '', timer: '',
menuIcon: mdiMenu menuIcon: mdiMenu,
close: mdiClose
} }
}, },
created() { created() {
@ -221,6 +250,29 @@ export default {
setTimeout(() => { setTimeout(() => {
this.value = null this.value = null
}, 300) }, 300)
},
createMessage(message) {
var text = ''
if (message.error) {
text =
'Konnte ' +
(message.amount / 100).toFixed(2) +
'€ zu ' +
message.user.firstname +
' ' +
message.user.lastname +
' hinzufügen.'
} else {
text =
'' +
(message.amount / 100).toFixed(2) +
'€ wurde zu ' +
message.user.firstname +
' ' +
message.user.lastname +
' hinzugefügt.'
}
return text
} }
}, },
computed: { computed: {
@ -234,18 +286,7 @@ export default {
under5minutes() { under5minutes() {
return now => { return now => {
var actual = new Date() var actual = new Date()
var zero = new Date(0) return actual - now < 15000
var date = new Date(actual - now)
if (
date.getFullYear() === zero.getFullYear() &&
date.getMonth() === zero.getMonth() &&
date.getDate() === zero.getDate()
) {
if (date.getMinutes() < 6) {
return true
}
}
return false
} }
}, },
now() { now() {

View File

@ -7,7 +7,7 @@ const state = {
filter: '', filter: '',
usersLoading: false, usersLoading: false,
allUsersLoading: false, allUsersLoading: false,
message: [], messages: [],
menu: false, menu: false,
locked: false locked: false
} }
@ -34,6 +34,7 @@ const mutations = {
existuser.locked = users[user].locked existuser.locked = users[user].locked
existuser.amount = users[user].amount existuser.amount = users[user].amount
existuser.type = users[user].type existuser.type = users[user].type
existuser.limit = users[user].limit
} else { } else {
state.users.push({ state.users.push({
username: users[user].username, username: users[user].username,
@ -42,7 +43,8 @@ const mutations = {
locked: users[user].locked, locked: users[user].locked,
amount: users[user].amount, amount: users[user].amount,
type: users[user].type, type: users[user].type,
loading: false loading: false,
limit: users[user].limit
}) })
} }
} }
@ -75,39 +77,38 @@ const mutations = {
state.allUsersLoading = value state.allUsersLoading = value
}, },
addMessage: (state, data) => { addMessage: (state, data) => {
var message = '' var message = null
if (data.error) { if (state.messages.length > 0) {
message = if (state.messages[0].user.id === data.user.id && !data.error) {
'Konnte ' + message = state.messages[0]
(data.amount / 100).toFixed(2) + if ((new Date() - state.messages[0].date) / 1000 < 2) {
'€ zu ' + clearTimeout(message.timeout)
data.user.firstname + console.log('done')
' ' + message.amount = message.amount + data.amount
data.user.lastname + message.visible = true
' hinzufügen.' message.date = new Date()
} else { message.timeout = setTimeout(() => {message.visible = false}, 5000)
message = return
'' + }
(data.amount / 100).toFixed(2) + else {
'€ wurde zu ' + message.visible = false
data.user.firstname + }
' ' + }
data.user.lastname +
' hinzugefügt.'
} }
state.message.unshift({ let message2 = {
message: message,
user: data.user, user: data.user,
error: data.error, error: data.error,
storno: false, storno: false,
loading: false, loading: false,
visible: true, visible: true,
amount: data.amount, amount: data.amount,
date: new Date() date: new Date(),
}) timeout: setTimeout(() => {message2.visible = false}, 5000)
}
state.messages.unshift(message2)
}, },
updateMessage: (state, data) => { updateMessage: (state, data) => {
var message = state.message.find(msg => { var message = state.messages.find(msg => {
return msg.date - data.date === 0 ? true : false return msg.date - data.date === 0 ? true : false
}) })
if (message) { if (message) {
@ -328,7 +329,7 @@ const getters = {
return state.allUsersLoading return state.allUsersLoading
}, },
messages: state => { messages: state => {
return state.message return state.messages
}, },
menu: state => { menu: state => {
return state.menu return state.menu

View File

@ -8,7 +8,7 @@ const state = {
addLoading: false, addLoading: false,
error: '', error: '',
days: [], days: [],
message: [], messages: [],
status: [] status: []
} }
@ -159,39 +159,39 @@ const mutations = {
} }
}, },
addMessage: (state, data) => { addMessage: (state, data) => {
var message = '' var message = null
if (data.error) { if (state.messages.length > 0) {
message = if (state.messages[0].user.id === data.user.id && !data.error) {
'Konnte ' + message = state.messages[0]
(data.amount / 100).toFixed(2) + if ((new Date() - state.messages[0].date) / 1000 < 2) {
'€ zu ' + clearTimeout(message.timeout)
data.user.firstname + console.log('done')
' ' + message.amount = message.amount + data.amount
data.user.lastname + message.visible = true
' hinzufügen.' message.date = new Date()
} else { message.timeout = setTimeout(() => {message.visible = false}, 300000)
message = return
'' + }
(data.amount / 100).toFixed(2) + else {
'€ wurde zu ' + message.visible = false
data.user.firstname + }
' ' + }
data.user.lastname +
' hinzugefügt.'
} }
state.message.unshift({ let message2 = {
message: message,
user: data.user, user: data.user,
error: data.error, error: data.error,
storno: false, storno: false,
loading: false, loading: false,
visible: true, visible: true,
amount: data.amount, amount: data.amount,
date: new Date() date: new Date(),
}) timeout: setTimeout(() => {message2.visible = false}, 300000)
}
state.messages.unshift(message2)
}, },
updateMessage: (state, data) => { updateMessage: (state, data) => {
var message = state.message.find(msg => { var message = state.messages.find(msg => {
return msg.date - data.date === 0 ? true : false return msg.date - data.date === 0 ? true : false
}) })
if (message) { if (message) {
@ -346,7 +346,7 @@ const getters = {
return state.days return state.days
}, },
messages: state => { messages: state => {
return state.message return state.messages
}, },
status: state => { status: state => {
return state.status return state.status