Compare commits
3 Commits
542f157b49
...
7d3e47494f
Author | SHA1 | Date |
---|---|---|
Ferdinand Thiessen | 7d3e47494f | |
Ferdinand Thiessen | 45e0defe7e | |
Ferdinand Thiessen | 28224960a0 |
|
@ -6,16 +6,23 @@
|
||||||
<UserSelector v-model="user" />
|
<UserSelector v-model="user" />
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<MainUserSettings :user="user" @update:user="updateUser" />
|
<MainUserSettings
|
||||||
|
:user="user"
|
||||||
|
:removeable="canDelete && !isCurrentUser"
|
||||||
|
@update:user="updateUser"
|
||||||
|
@remove="remove"
|
||||||
|
/>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, onMounted } from 'vue';
|
import { computed, defineComponent, ref, onMounted } from 'vue';
|
||||||
|
import { hasPermission, useMainStore, useUserStore } from '@flaschengeist/api';
|
||||||
|
import { Notify } from 'quasar';
|
||||||
|
import { PERMISSIONS } from '../permissions';
|
||||||
|
|
||||||
import MainUserSettings from './settings/MainUserSettings.vue';
|
import MainUserSettings from './settings/MainUserSettings.vue';
|
||||||
import UserSelector from './UserSelector.vue';
|
import UserSelector from './UserSelector.vue';
|
||||||
import { useMainStore, useUserStore } from '@flaschengeist/api';
|
|
||||||
import { Notify } from 'quasar';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'UpdateUser',
|
name: 'UpdateUser',
|
||||||
|
@ -23,7 +30,10 @@ export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const user = ref(mainStore.currentUser);
|
const user = ref(mainStore.currentUser);
|
||||||
|
const canDelete = computed(() => hasPermission(PERMISSIONS.DELETE));
|
||||||
|
const isCurrentUser = computed(() => user.value.userid === mainStore.currentUser.userid);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void userStore.getUsers(true);
|
void userStore.getUsers(true);
|
||||||
|
@ -42,7 +52,15 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function remove() {
|
||||||
|
await userStore.deleteUser(user.value);
|
||||||
|
user.value = mainStore.currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
canDelete,
|
||||||
|
isCurrentUser,
|
||||||
|
remove,
|
||||||
user,
|
user,
|
||||||
updateUser,
|
updateUser,
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,7 +103,10 @@
|
||||||
</q-file>
|
</q-file>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-separator v-if="!newUser" />
|
<q-separator v-if="!newUser" />
|
||||||
<q-card-section v-if="!newUser" class="fit row justify-start content-center items-center">
|
<q-card-section
|
||||||
|
v-if="!newUser"
|
||||||
|
class="fit row justify-start content-center items-center q-gutter-y-md"
|
||||||
|
>
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
v-if="isCurrentUser"
|
v-if="isCurrentUser"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
@ -122,9 +125,12 @@
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
/>
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-actions align="right">
|
<q-card-actions :align="removeable ? 'between' : 'right'">
|
||||||
<q-btn label="Reset" type="reset" />
|
<q-btn v-if="removeable" label="Löschen" color="negative" @click="remove" />
|
||||||
<q-btn color="primary" type="submit" label="Speichern" />
|
<div>
|
||||||
|
<q-btn label="Reset" type="reset" style="margin-right: 0.5em" />
|
||||||
|
<q-btn label="Speichern" type="submit" color="primary" />
|
||||||
|
</div>
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-form>
|
</q-form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -148,6 +154,10 @@ export default defineComponent({
|
||||||
name: 'MainUserSettings',
|
name: 'MainUserSettings',
|
||||||
components: { IsoDateInput, PasswordInput },
|
components: { IsoDateInput, PasswordInput },
|
||||||
props: {
|
props: {
|
||||||
|
removeable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
user: {
|
user: {
|
||||||
required: true,
|
required: true,
|
||||||
type: Object as PropType<FG.User>,
|
type: Object as PropType<FG.User>,
|
||||||
|
@ -156,6 +166,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
emits: {
|
emits: {
|
||||||
'update:user': (payload: FG.User) => !!payload,
|
'update:user': (payload: FG.User) => !!payload,
|
||||||
|
remove: () => true,
|
||||||
},
|
},
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
@ -236,7 +247,7 @@ export default defineComponent({
|
||||||
hasAvatar.value = true;
|
hasAvatar.value = true;
|
||||||
} else if (deleteAvatar.value) {
|
} else if (deleteAvatar.value) {
|
||||||
await userStore.deleteAvatar(changed);
|
await userStore.deleteAvatar(changed);
|
||||||
hasAvatar.value = false
|
hasAvatar.value = false;
|
||||||
}
|
}
|
||||||
password.value = '';
|
password.value = '';
|
||||||
}
|
}
|
||||||
|
@ -282,6 +293,7 @@ export default defineComponent({
|
||||||
onAvatarRejected,
|
onAvatarRejected,
|
||||||
password,
|
password,
|
||||||
preview,
|
preview,
|
||||||
|
remove: () => emit('remove'),
|
||||||
reset,
|
reset,
|
||||||
save,
|
save,
|
||||||
userModel,
|
userModel,
|
||||||
|
|
|
@ -1,12 +1,17 @@
|
||||||
export const PERMISSIONS = {
|
export const PERMISSIONS = {
|
||||||
// Kann andere Nutzer bearbeiten
|
/* User permissions */
|
||||||
|
// Can edit other users
|
||||||
EDIT_OTHER: 'users_edit_other',
|
EDIT_OTHER: 'users_edit_other',
|
||||||
// Kann Rollen von Nutzern setzen
|
// Can assign roles to users
|
||||||
SET_ROLES: 'users_set_roles',
|
SET_ROLES: 'users_set_roles',
|
||||||
// Kann Nutzer löschen
|
// Can delete users
|
||||||
DELETE: 'users_delete_other',
|
DELETE: 'users_delete',
|
||||||
// Kann neue Nutzer hinzufügen
|
// Can register new users
|
||||||
REGISTER: 'users_register',
|
REGISTER: 'users_register',
|
||||||
// Kann Rollen löschen oder bearbeiten, z.b. Rechte hinzufügen etc
|
|
||||||
|
/* Role permissions */
|
||||||
|
// Can edit roles, assign permissions to roles and change names
|
||||||
ROLES_EDIT: 'roles_edit',
|
ROLES_EDIT: 'roles_edit',
|
||||||
|
// Can delete roles
|
||||||
|
ROLES_DELETE: 'roles_delete',
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue