This commit is contained in:
les
2020-08-05 17:30:41 +02:00
parent 41e3e97af7
commit e7b214655f
9 changed files with 108 additions and 109 deletions

View File

@@ -1,6 +1,7 @@
<template lang='pug'>
v-container
v-subheader(v-html="$t('admin.place_description')")
v-card-title {{$t('common.places')}}
v-card-subtitle(v-html="$t('admin.place_description')")
v-dialog
v-form.mb-2
@@ -18,10 +19,11 @@
v-btn(@click='savePlace') {{$t('common.save')}}
v-data-table(
@click:row='selectPlace'
:headers='headers'
:items='places')
v-card-text
v-data-table(
@click:row='selectPlace'
:headers='headers'
:items='places')
</template>
<script>
import { mapState } from 'vuex'

View File

@@ -28,6 +28,7 @@
min-width="290px")
template(v-slot:activator='{ on }')
v-text-field(:value='colors[i]'
:label='i'
v-on='on' clearable readonly)
v-color-picker(light @update:color='c => updateColor(i, c)')

View File

@@ -1,11 +1,12 @@
<template lang="pug">
v-card
v-container
v-card-title {{$t('common.users')}}
v-spacer
v-text-field(v-model='search'
append-icon='mdi-magnify'
label='Search',
single-line hide-details)
v-btn(text color='primary' small @click='newUserDialog = true') <v-icon>mdi-plus-user</v-icon> {{$t('common.new_user')}}
//- ADD NEW USER
v-dialog(v-model='newUserDialog' width='500')
@@ -16,27 +17,27 @@
v-form
v-text-field(v-model='new_user.email'
:label="$t('common.email')"
:rules="[validators.required('Email')]")
:rules="[validators.required('email')]")
v-switch(v-model='new_user.is_admin' :label="$t('common.admin')" inset)
v-alert(type='info' :closable='false') {{$t('admin.user_add_help')}}
v-card-actions
v-spacer
v-btn(@click='newUserDialog=false' color='error') {{$t('common.cancel')}}
v-btn(@click='createUser' color='primary') {{$t('common.send')}}
v-btn(@click='newUserDialog=false' color='danger' plain) {{$t('common.close')}}
//- USERS LIST
v-data-table(
:headers='headers'
:items='users'
:search='search')
template(v-slot:item.actions='{item}')
v-btn(text small @click='toggle(item)'
:color='item.is_active?"warning":"success"') {{item.is_active?$t('common.deactivate'):$t('common.activate')}}
v-btn(text small @click='toggleAdmin(item)'
:color='item.is_admin?"warning":"error"') {{item.is_admin?$t('common.remove_admin'):$t('common.admin')}}
v-btn(text small @click='deleteUser(item)'
color='error') {{$t('admin.delete_user')}}
v-btn(text color='primary' small @click='newUserDialog = true') <v-icon>mdi-plus-user</v-icon> {{$t('common.new_user')}}
v-card-text
//- USERS LIST
v-data-table(
:headers='headers'
:items='users'
:search='search')
template(v-slot:item.actions='{item}')
v-btn(text small @click='toggle(item)'
:color='item.is_active?"warning":"success"') {{item.is_active?$t('common.deactivate'):$t('common.activate')}}
v-btn(text small @click='toggleAdmin(item)'
:color='item.is_admin?"warning":"error"') {{item.is_admin?$t('common.remove_admin'):$t('common.admin')}}
v-btn(text small @click='deleteUser(item)'
color='error') {{$t('admin.delete_user')}}
</template>
<script>
@@ -66,18 +67,14 @@ export default {
},
computed: mapState(['settings']),
methods: {
deleteUser (user) {
this.$root.$confirm(this.$t('admin.delete_user_confirm'),
this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'error'
})
.then(() => this.$axios.delete(`/user/${user.id}`))
.then(() => {
this.$root.$message({ message: this.$t('admin.user_remove_ok')})
this.users_ = this.users_.filter(u => u.id !== user.id)
})
async deleteUser (user) {
const ret = await this.$root.$confirm(this.$t('common.confirm'),
this.$t('admin.delete_user_confirm'),
{ type: 'error' })
if (!ret) { return }
await this.$axios.delete(`/user/${user.id}`)
this.$root.$message({ message: this.$t('admin.user_remove_ok') })
this.users_ = this.users_.filter(u => u.id !== user.id)
},
toggle (user) {
user.is_active = !user.is_active
@@ -88,7 +85,6 @@ export default {
user.is_admin = !user.is_admin
await this.$axios.$put('/user', user)
} catch (e) {
console.error(e)
}
},
async createUser () {
@@ -97,15 +93,13 @@ export default {
const user = await this.$axios.$post('/user', this.new_user)
this.new_user = { email: '', is_admin: false }
Message({
showClose: true,
this.$root.$message({
type: 'success',
message: this.$t('admin.user_create_ok')
})
this.users_.push(user)
} catch (e) {
Message({
showClose: true,
this.$root.$message({
type: 'error',
message: this.$t(e)
})