release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
3 changed files with 74 additions and 52 deletions
Showing only changes of commit 7b1a1c3656 - Show all commits

View File

@ -1,8 +1,16 @@
<template> <template>
<div>
<q-card class="col-12"> <q-card class="col-12">
<q-form @submit="save" @reset="reset"> <q-form @submit="save" @reset="reset">
<q-linear-progress indeterminate rounded color="primary" v-if="loading" /> <q-linear-progress
<q-card-section class="fit row justify-start content-center items-center"> indeterminate
rounded
color="primary"
v-if="loading"
/>
<q-card-section
class="fit row justify-start content-center items-center"
>
<span class="col-xs-12 col-sm-6 text-center text-h6"> <span class="col-xs-12 col-sm-6 text-center text-h6">
Rollen und Berechtigungen Rollen und Berechtigungen
</span> </span>
@ -19,6 +27,8 @@
map-options map-options
@new-value="createRole" @new-value="createRole"
@input="updateRole" @input="updateRole"
@clear="removeRole"
clearable
/> />
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
@ -43,6 +53,7 @@
</q-card-actions> </q-card-actions>
</q-form> </q-form>
</q-card> </q-card>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -89,6 +100,10 @@ export default defineComponent({
done(name, 'add-unique'); done(name, 'add-unique');
} }
function removeRole(): void {
role.value = null;
}
function updatePermissions(permissions: string[]) { function updatePermissions(permissions: string[]) {
if (role.value) { if (role.value) {
role.value.permissions = permissions; role.value.permissions = permissions;
@ -139,12 +154,13 @@ export default defineComponent({
return { return {
roles, roles,
role, role,
createRole,
permissions, permissions,
createRole,
updateRole, updateRole,
updatePermissions, updatePermissions,
save, save,
reset, reset,
removeRole,
remove, remove,
loading loading
}; };

View File

@ -36,7 +36,7 @@
<q-tab-panels <q-tab-panels
v-model="tab" v-model="tab"
style="background-color: transparent;" style="background-color: transparent;"
class="q-ma-none q-pa-none" class="q-ma-none q-pa-none fit row justify-center content-start items-start"
animated animated
> >
<q-tab-panel name="user"> <q-tab-panel name="user">

View File

@ -45,6 +45,13 @@ const mutations: MutationTree<UserStateInterface> = {
setRoles(state, data: FG.Role[]) { setRoles(state, data: FG.Role[]) {
state.roles = data; state.roles = data;
}, },
updateRole(state, data: FG.Role) {
const idx = state.roles.findIndex(role => role.id === data.id);
if (idx != undefined || idx != null) {
state.roles[idx].name = data.name;
state.roles[idx].permissions = data.permissions;
}
},
setPermissions(state, data: FG.Permission[]) { setPermissions(state, data: FG.Permission[]) {
state.permissions = data; state.permissions = data;
}, },
@ -136,22 +143,18 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
axios axios
.put(`/roles/${data.id}`, data) .put(`/roles/${data.id}`, data)
.then(() => { .then(() => {
const idx = state.roles.findIndex(role => role.id === data.id); commit('updateRole', data);
if (idx) {
state.roles[idx].name = data.name;
state.roles[idx].permissions = data.permissions;
}
}) })
.finally(() => { .finally(() => {
commit('setLoading', false); commit('setLoading', false);
}); });
}, },
newRole({ commit }, data: FG.Role) { newRole({ commit, dispatch }, data: FG.Role) {
commit('setLoading'); commit('setLoading');
axios axios
.post('/roles', data) .post('/roles', data)
.then(() => commit('getRoles')) .then(() => dispatch('getRoles', true))
.finally(() => { .finally(() => {
commit('setLoading', false); commit('setLoading', false);
}); });
@ -162,7 +165,10 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
axios axios
.delete(`/roles/${data.id}`) .delete(`/roles/${data.id}`)
.then(() => { .then(() => {
state.roles = state.roles.filter(value => value.id !== data.id); commit(
'setRoles',
state.roles.filter(value => value.id !== data.id)
);
}) })
.finally(() => { .finally(() => {
commit('setLoading', false); commit('setLoading', false);