added feature to lock barview

fixed bug, that you can send negative amount.
This commit is contained in:
Tim Gröger 2020-05-11 23:03:16 +02:00
parent 53676763ea
commit e502e3f334
5 changed files with 96 additions and 12 deletions

View File

@ -275,7 +275,7 @@ export default {
addAmountMore(user) {
this.addAmount({
username: user.username,
amount: user.value * 100,
amount: Math.abs(user.value * 100),
user: user
})
setTimeout(() => {

View File

@ -20,11 +20,28 @@
</template>
</v-autocomplete>
<v-btn text @click="addUser">Hinzufügen</v-btn>
<v-btn v-if="!locked" text @click="lock">Sperren</v-btn>
<v-btn v-else text @click="overlay = true">Entsperren</v-btn>
<v-btn @click="clickMenu" icon>
<v-icon>{{ menuIcon }}</v-icon>
</v-btn>
</v-toolbar-items>
</v-toolbar>
<v-dialog v-model="overlay">
<v-container>
<v-card>
<v-card-title>Entsperre Baransicht</v-card-title>
<v-card-text>
<v-text-field outlined type="password" label="Passwort" v-model="password"></v-text-field>
</v-card-text>
<v-card-actions>
<v-spacer/>
<v-btn @click="overlay = false">Abbrechen</v-btn>
<v-btn @click="doUnlock">Entsperren</v-btn>
</v-card-actions>
</v-card>
</v-container>
</v-dialog>
</div>
</template>
@ -40,11 +57,14 @@ export default {
user: null,
filter: '',
search_person: mdiAccountSearch,
menuIcon: mdiMenu
menuIcon: mdiMenu,
overlay: false,
password: ''
}
},
created() {
this.getAllUsers()
this.getLocked()
},
methods: {
...mapActions({
@ -52,7 +72,10 @@ export default {
addCreditList: 'barUsers/addCreditList',
setFilter: 'barUsers/setFilter',
activateMenu: 'barUsers/activateMenu',
deactivateMenu: 'barUsers/deactivateMenu'
deactivateMenu: 'barUsers/deactivateMenu',
lock: 'barUsers/setLocked',
unlock: 'barUsers/unlock',
getLocked: 'barUsers/getLocked'
}),
addUser() {
this.addCreditList(this.user)
@ -61,13 +84,19 @@ export default {
clickMenu() {
if (this.menu) this.deactivateMenu()
else this.activateMenu()
},
doUnlock() {
this.unlock(this.password)
this.password = ''
this.overlay = false
}
},
computed: {
...mapGetters({
allUsers: 'barUsers/allUsers',
loading: 'barUsers/allUsersLoading',
menu: 'barUsers/menu'
menu: 'barUsers/menu',
locked: 'barUsers/locked'
})
},
watch: {

View File

@ -54,10 +54,12 @@ const url = {
deleteTransactJobs: main + 'user/deleteTransactJob',
storno: main + 'user/storno',
getAllStatus: main + 'getAllStatus',
getStatus: main + 'getStatus'
getStatus: main + 'getStatus',
valid: main + 'valid'
},
barU: {
storno: main + 'bar/storno'
storno: main + 'bar/storno',
lock: main + 'bar/lock'
},
gastro: {
setDrink: main + 'gastro/setDrink',

View File

@ -8,7 +8,8 @@ const state = {
usersLoading: false,
allUsersLoading: false,
message: [],
menu: false
menu: false,
locked: false
}
const mutations = {
@ -116,6 +117,9 @@ const mutations = {
},
setMenu: (state, value) => {
state.menu = value
},
setLocked: (satet, value) => {
state.locked = value
}
}
@ -227,6 +231,51 @@ const actions = {
}
commit('updateMessage', { date: data.date, loading: false })
},
async getLocked({ commit, rootState, dispatch }) {
try {
const response = await axios.get(url.barU.lock, {
headers: { Token: rootState.login.user.accessToken }
})
console.log(response.data.value)
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setLocked({ commit, rootState, dispatch }) {
try {
const response = await axios.post(
url.barU.lock,
{ value: true },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setLocked', response.data.value)
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async unlock({ commit, rootState, dispatch }, password) {
try {
const valid = await axios.post(
url.user.valid,
{ password: password },
{ headers: { Token: rootState.login.user.accessToken } }
)
if (valid.data.ok === 'ok') {
const response = await axios.post(
url.barU.lock,
{ value: false },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('setLocked', response.data.value)
}
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
setFilter({ commit }, data) {
commit('setFilter', data)
},
@ -259,6 +308,9 @@ const getters = {
},
menu: state => {
return state.menu
},
locked: state => {
return state.locked
}
}

View File

@ -18,7 +18,7 @@
{{user.firstname}} {{user.lastname}}
</v-list-item-title>
</v-list-item>
<v-list-item v-if="isUser" class="title" link to="/main/user/add">
<v-list-item :disabled="lockedBar" v-if="isUser" class="title" link to="/main/user/add">
<v-list-item-icon>
<v-icon>{{person}}</v-icon>
</v-list-item-icon>
@ -32,7 +32,7 @@
Bar
</v-list-item-title>
</v-list-item>
<v-list-item v-if="isManagement" class="title" link to="/main/management/servicemanagement">
<v-list-item :disabled="lockedBar" v-if="isManagement" class="title" link to="/main/management/servicemanagement">
<v-list-item-icon>
<v-icon>{{king}}</v-icon>
</v-list-item-icon>
@ -40,7 +40,7 @@
Vorstand
</v-list-item-title>
</v-list-item>
<v-list-item v-if="isGastro" class="title" link to="/main/gastro/pricelist">
<v-list-item :disabled="lockedBar" v-if="isGastro" class="title" link to="/main/gastro/pricelist">
<v-list-item-icon>
<v-icon>{{gastro}}</v-icon>
</v-list-item-icon>
@ -48,7 +48,7 @@
Gastro
</v-list-item-title>
</v-list-item>
<v-list-item v-if="isFinanzer" class="title" link to="/main/finanzer/overview">
<v-list-item :disabled="lockedBar" v-if="isFinanzer" class="title" link to="/main/finanzer/overview">
<v-list-item-icon>
<v-icon>{{attach_money}}</v-icon>
</v-list-item-icon>
@ -107,7 +107,8 @@ export default {
isManagement: 'isManagement',
isLoggedIn: 'isLoggedIn',
isExtern: 'isExtern',
user: 'user'
user: 'user',
lockedBar: 'barUsers/locked'
})
}
}