cancel changes

sometimes resets new entry
This commit is contained in:
Julian Krauser 2024-09-10 17:11:51 +02:00
parent 0dd5ad09a8
commit 5e50b85631
21 changed files with 193 additions and 53 deletions

View file

@ -66,8 +66,8 @@
</div> </div>
</div> </div>
<div class="flex flex-row gap-2 self-end pt-4"> <div class="flex flex-row gap-2 self-end pt-4">
<button primary-outline class="!w-fit" @click="$emit('abortPermissions')">abbrechen</button> <button primary-outline class="!w-fit" @click="reset" :disabled="!detect_change">verwerfen</button>
<button primary class="!w-fit" @click="$emit('savePermissions', permissionUpdate)">speichern</button> <button primary class="!w-fit" @click="submit" :disabled="status != null">speichern</button>
<Spinner v-if="status == 'loading'" class="my-auto" /> <Spinner v-if="status == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="status?.status == 'success'" /> <SuccessCheckmark v-else-if="status?.status == 'success'" />
<FailureXMark v-else-if="status?.status == 'failed'" /> <FailureXMark v-else-if="status?.status == 'failed'" />
@ -111,13 +111,14 @@ export default defineComponent({
default: null, default: null,
}, },
}, },
emits: ["savePermissions", "abortPermissions"], emits: ["savePermissions", "resetStatus"],
data() { data() {
return { return {
isAdmin: false, isAdmin: false,
sections: [] as Array<PermissionSection>, sections: [] as Array<PermissionSection>,
permissionStructure: {} as SectionsAndModulesObject, permissionStructure: {} as SectionsAndModulesObject,
permissionUpdate: {} as PermissionObject, permissionUpdate: {} as PermissionObject,
detect_change: false as boolean,
}; };
}, },
computed: { computed: {
@ -132,11 +133,17 @@ export default defineComponent({
}, },
methods: { methods: {
toggleAdmin(e: Event) { toggleAdmin(e: Event) {
this.detect_change = true;
this.$emit("resetStatus");
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement;
this.isAdmin = target.checked ?? false; this.isAdmin = target.checked ?? false;
this.permissionUpdate.admin = this.isAdmin; this.permissionUpdate.admin = this.isAdmin;
}, },
togglePermission(type: PermissionType, section: PermissionSection, modul?: PermissionModule) { togglePermission(type: PermissionType, section: PermissionSection, modul?: PermissionModule) {
this.detect_change = true;
this.$emit("resetStatus");
let permissions = [] as Array<PermissionType> | "*"; let permissions = [] as Array<PermissionType> | "*";
if (!modul) { if (!modul) {
permissions = this.permissionUpdate[section]?.all ?? []; permissions = this.permissionUpdate[section]?.all ?? [];
@ -169,6 +176,17 @@ export default defineComponent({
this.permissionUpdate[section][modul] = permissions; this.permissionUpdate[section][modul] = permissions;
} }
}, },
reset() {
this.detect_change = false;
this.permissionUpdate = _cloneDeep(this.permissions);
this.isAdmin = this.permissions.admin ?? false;
},
submit() {
this.$emit("savePermissions", this.permissionUpdate);
this.detect_change = false;
},
}, },
}); });
</script> </script>

View file

@ -4,7 +4,7 @@
<p>{{ role.role }} <small v-if="role.permissions?.isAdmin">(Admin)</small></p> <p>{{ role.role }} <small v-if="role.permissions?.isAdmin">(Admin)</small></p>
<div class="flex flex-row"> <div class="flex flex-row">
<RouterLink <RouterLink
v-if="can('update', 'user', 'role')" v-if="can('admin', 'user', 'role')"
:to="{ name: 'admin-user-role-permission', params: { id: role.id } }" :to="{ name: 'admin-user-role-permission', params: { id: role.id } }"
> >
<WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" /> <WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" />

View file

@ -10,7 +10,7 @@
<UserGroupIcon class="w-5 h-5 p-1 box-content cursor-pointer" /> <UserGroupIcon class="w-5 h-5 p-1 box-content cursor-pointer" />
</RouterLink> </RouterLink>
<RouterLink <RouterLink
v-if="can('update', 'user', 'user')" v-if="can('admin', 'user') && false"
:to="{ name: 'admin-user-user-permission', params: { id: user.id } }" :to="{ name: 'admin-user-user-permission', params: { id: user.id } }"
> >
<WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" /> <WrenchScrewdriverIcon class="w-5 h-5 p-1 box-content cursor-pointer" />

View file

@ -71,7 +71,9 @@ a[button][primary-outline]:not([primary-outline="false"]) {
@apply border-2 border-primary text-black hover:bg-primary; @apply border-2 border-primary text-black hover:bg-primary;
} }
button:disabled { button:disabled,
a[button]:disabled,
a[button].disabled {
@apply opacity-75 pointer-events-none; @apply opacity-75 pointer-events-none;
} }

View file

@ -61,13 +61,15 @@ export const useAwardStore = defineStore("award", {
}, },
updateActiveAward(award: CreateOrUpdateAwardViewModel) { updateActiveAward(award: CreateOrUpdateAwardViewModel) {
if (this.award == null) return; if (this.award == null) return;
let id = this.award.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/award/${this.award.id}`, { .patch(`/admin/award/${id}`, {
award: award.award, award: award.award,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchAwardById(id);
this.fetchAwards(); this.fetchAwards();
}) })
.catch((err) => { .catch((err) => {

View file

@ -79,14 +79,16 @@ export const useCommunicationTypeStore = defineStore("communicationType", {
}, },
updateActiveCommunicationType(communicationType: CreateOrUpdateCommunicationTypeViewModel) { updateActiveCommunicationType(communicationType: CreateOrUpdateCommunicationTypeViewModel) {
if (this.communicationType == null) return; if (this.communicationType == null) return;
let id = this.communicationType.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/communicationType/${this.communicationType.id}`, { .patch(`/admin/communicationType/${id}`, {
communicationType: communicationType.type, communicationType: communicationType.type,
fields: communicationType.fields, fields: communicationType.fields,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchCommunicationTypeById(id);
this.fetchCommunicationTypes(); this.fetchCommunicationTypes();
}) })
.catch((err) => { .catch((err) => {

View file

@ -64,13 +64,15 @@ export const useExecutivePositionStore = defineStore("executivePosition", {
}, },
updateActiveExecutivePosition(executivePosition: CreateOrUpdateExecutivePositionViewModel) { updateActiveExecutivePosition(executivePosition: CreateOrUpdateExecutivePositionViewModel) {
if (this.executivePosition == null) return; if (this.executivePosition == null) return;
let id = this.executivePosition.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/executivePosition/${this.executivePosition.id}`, { .patch(`/admin/executivePosition/${id}`, {
executivePosition: executivePosition.position, executivePosition: executivePosition.position,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchExecutivePositionById(id);
this.fetchExecutivePositions(); this.fetchExecutivePositions();
}) })
.catch((err) => { .catch((err) => {

View file

@ -64,13 +64,15 @@ export const useMembershipStatusStore = defineStore("membershipStatus", {
}, },
updateActiveMembershipStatus(membershipStatus: CreateOrUpdateMembershipStatusViewModel) { updateActiveMembershipStatus(membershipStatus: CreateOrUpdateMembershipStatusViewModel) {
if (this.membershipStatus == null) return; if (this.membershipStatus == null) return;
let id = this.membershipStatus.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/membershipStatus/${this.membershipStatus.id}`, { .patch(`/admin/membershipStatus/${id}`, {
membershipStatus: membershipStatus.status, membershipStatus: membershipStatus.status,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchMembershipStatusById(id);
this.fetchMembershipStatuss(); this.fetchMembershipStatuss();
}) })
.catch((err) => { .catch((err) => {

View file

@ -65,14 +65,16 @@ export const useQualificationStore = defineStore("qualification", {
}, },
updateActiveQualification(qualification: CreateOrUpdateQualificationViewModel) { updateActiveQualification(qualification: CreateOrUpdateQualificationViewModel) {
if (this.qualification == null) return; if (this.qualification == null) return;
let id = this.qualification.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/qualification/${this.qualification.id}`, { .patch(`/admin/qualification/${id}`, {
qualification: qualification.qualification, qualification: qualification.qualification,
description: qualification.description, description: qualification.description,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchQualificationById(id);
this.fetchQualifications(); this.fetchQualifications();
}) })
.catch((err) => { .catch((err) => {

View file

@ -62,13 +62,15 @@ export const useRoleStore = defineStore("role", {
}, },
updateActiveRole(role: string) { updateActiveRole(role: string) {
if (this.role == null) return; if (this.role == null) return;
let id = this.role.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/role/${this.role.id}`, { .patch(`/admin/role/${id}`, {
role: role, role: role,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchRoleById(id);
this.fetchRoles(); this.fetchRoles();
}) })
.catch((err) => { .catch((err) => {
@ -77,13 +79,15 @@ export const useRoleStore = defineStore("role", {
}, },
updateActiveRolePermissions(permission: PermissionObject) { updateActiveRolePermissions(permission: PermissionObject) {
if (this.role == null) return; if (this.role == null) return;
let id = this.role.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/role/${this.role.id}/permissions`, { .patch(`/admin/role/${id}/permissions`, {
permissions: permission, permissions: permission,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchRoleById(id);
this.fetchRoles(); this.fetchRoles();
}) })
.catch((err) => { .catch((err) => {

View file

@ -48,9 +48,10 @@ export const useUserStore = defineStore("user", {
}, },
updateActiveUser(user: CreateOrUpdateUserViewModel) { updateActiveUser(user: CreateOrUpdateUserViewModel) {
if (this.user == null) return; if (this.user == null) return;
let id = this.user.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/user/${this.user.id}`, { .patch(`/admin/user/${id}`, {
username: user.username, username: user.username,
firstname: user.firstname, firstname: user.firstname,
lastname: user.lastname, lastname: user.lastname,
@ -58,6 +59,7 @@ export const useUserStore = defineStore("user", {
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchUserById(id);
this.fetchUsers(); this.fetchUsers();
}) })
.catch((err) => { .catch((err) => {
@ -66,13 +68,15 @@ export const useUserStore = defineStore("user", {
}, },
updateActiveUserPermissions(permission: PermissionObject) { updateActiveUserPermissions(permission: PermissionObject) {
if (this.user == null) return; if (this.user == null) return;
let id = this.user.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/user/${this.user.id}/permissions`, { .patch(`/admin/user/${id}/permissions`, {
permissions: permission, permissions: permission,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchUserById(id);
this.fetchUsers(); this.fetchUsers();
}) })
.catch((err) => { .catch((err) => {
@ -81,13 +85,15 @@ export const useUserStore = defineStore("user", {
}, },
updateActiveUserRoles(roles: Array<number>) { updateActiveUserRoles(roles: Array<number>) {
if (this.user == null) return; if (this.user == null) return;
let id = this.user.id;
this.updateStatus = "loading"; this.updateStatus = "loading";
http http
.patch(`/admin/user/${this.user.id}/roles`, { .patch(`/admin/user/${id}/roles`, {
roleIds: roles, roleIds: roles,
}) })
.then((result) => { .then((result) => {
this.updateStatus = { status: "success" }; this.updateStatus = { status: "success" };
this.fetchUserById(id);
this.fetchUsers(); this.fetchUsers();
}) })
.catch((err) => { .catch((err) => {

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,10 +14,12 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
<div> <div>
<label for="award">Bezeichnung</label> <label for="award">Bezeichnung</label>
<input type="text" id="award" required :value="award?.award" /> <input type="text" id="award" required :value="award?.award" @change="detectChange" />
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -45,6 +47,11 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
change_detect: false as boolean,
};
},
computed: { computed: {
...mapState(useAwardStore, ["award", "updateStatus", "loadingSingle"]), ...mapState(useAwardStore, ["award", "updateStatus", "loadingSingle"]),
}, },
@ -54,12 +61,17 @@ export default defineComponent({
}, },
methods: { methods: {
...mapActions(useAwardStore, ["fetchAwardById", "updateActiveAward", "resetStatus"]), ...mapActions(useAwardStore, ["fetchAwardById", "updateActiveAward", "resetStatus"]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerUpdate(e: any) { triggerUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let updateAward: CreateOrUpdateAwardViewModel = { let updateAward: CreateOrUpdateAwardViewModel = {
award: formData.award.value, award: formData.award.value,
}; };
this.updateActiveAward(updateAward); this.updateActiveAward(updateAward);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,7 +14,7 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
<div> <div>
<label for="communicationType">Bezeichnung</label> <label for="communicationType">Bezeichnung</label>
<input type="text" id="communicationType" required :value="communicationType?.type" /> <input type="text" id="communicationType" required :value="communicationType?.type" @change="detectChange" />
</div> </div>
<div> <div>
<Listbox v-model="selectedFields" multiple> <Listbox v-model="selectedFields" multiple>
@ -62,7 +62,9 @@
</Listbox> </Listbox>
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="reset">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -92,16 +94,20 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
selectedFields: [] as Array<string>,
};
},
watch: { watch: {
selectedFields() {
this.detectChange();
},
loadingSingle() { loadingSingle() {
if (this.loadingSingle == "fetched") this.selectedFields = this.communicationType?.fields ?? []; if (this.loadingSingle == "fetched") this.selectedFields = this.communicationType?.fields ?? [];
}, },
}, },
data() {
return {
change_detect: false as boolean,
selectedFields: [] as Array<string>,
};
},
computed: { computed: {
...mapState(useCommunicationTypeStore, ["communicationType", "updateStatus", "loadingSingle", "availableFields"]), ...mapState(useCommunicationTypeStore, ["communicationType", "updateStatus", "loadingSingle", "availableFields"]),
}, },
@ -117,6 +123,14 @@ export default defineComponent({
"resetStatus", "resetStatus",
"fetchAvailableFields", "fetchAvailableFields",
]), ]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
reset() {
this.change_detect = false;
this.selectedFields = this.communicationType?.fields ?? [];
},
triggerUpdate(e: any) { triggerUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let updateCommunicationType: CreateOrUpdateCommunicationTypeViewModel = { let updateCommunicationType: CreateOrUpdateCommunicationTypeViewModel = {
@ -124,6 +138,7 @@ export default defineComponent({
fields: this.selectedFields, fields: this.selectedFields,
}; };
this.updateActiveCommunicationType(updateCommunicationType); this.updateActiveCommunicationType(updateCommunicationType);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,10 +14,18 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
<div> <div>
<label for="executivePosition">Bezeichnung</label> <label for="executivePosition">Bezeichnung</label>
<input type="text" id="executivePosition" required :value="executivePosition?.position" /> <input
type="text"
id="executivePosition"
required
:value="executivePosition?.position"
@change="detectChange"
/>
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -45,6 +53,11 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
change_detect: false as boolean,
};
},
computed: { computed: {
...mapState(useExecutivePositionStore, ["executivePosition", "updateStatus", "loadingSingle"]), ...mapState(useExecutivePositionStore, ["executivePosition", "updateStatus", "loadingSingle"]),
}, },
@ -58,12 +71,17 @@ export default defineComponent({
"updateActiveExecutivePosition", "updateActiveExecutivePosition",
"resetStatus", "resetStatus",
]), ]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerUpdate(e: any) { triggerUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let updateExecutivePosition: CreateOrUpdateExecutivePositionViewModel = { let updateExecutivePosition: CreateOrUpdateExecutivePositionViewModel = {
position: formData.executivePosition.value, position: formData.executivePosition.value,
}; };
this.updateActiveExecutivePosition(updateExecutivePosition); this.updateActiveExecutivePosition(updateExecutivePosition);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,10 +14,12 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
<div> <div>
<label for="membershipStatus">Bezeichnung</label> <label for="membershipStatus">Bezeichnung</label>
<input type="text" id="membershipStatus" required :value="membershipStatus?.status" /> <input type="text" id="membershipStatus" required :value="membershipStatus?.status" @change="detectChange" />
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -45,6 +47,11 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
change_detect: false as boolean,
};
},
computed: { computed: {
...mapState(useMembershipStatusStore, ["membershipStatus", "updateStatus", "loadingSingle"]), ...mapState(useMembershipStatusStore, ["membershipStatus", "updateStatus", "loadingSingle"]),
}, },
@ -58,12 +65,17 @@ export default defineComponent({
"updateActiveMembershipStatus", "updateActiveMembershipStatus",
"resetStatus", "resetStatus",
]), ]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerUpdate(e: any) { triggerUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let updateMembershipStatus: CreateOrUpdateMembershipStatusViewModel = { let updateMembershipStatus: CreateOrUpdateMembershipStatusViewModel = {
status: formData.membershipStatus.value, status: formData.membershipStatus.value,
}; };
this.updateActiveMembershipStatus(updateMembershipStatus); this.updateActiveMembershipStatus(updateMembershipStatus);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,14 +14,16 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
<div> <div>
<label for="qualification">Bezeichnung</label> <label for="qualification">Bezeichnung</label>
<input type="text" id="qualification" required :value="qualification?.qualification" /> <input type="text" id="qualification" required :value="qualification?.qualification" @change="detectChange" />
</div> </div>
<div> <div>
<label for="description">Beschreibung (optional)</label> <label for="description">Beschreibung (optional)</label>
<input type="text" id="description" :value="qualification?.description" /> <input type="text" id="description" :value="qualification?.description" @change="detectChange" />
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -49,6 +51,11 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
change_detect: false as boolean,
};
},
computed: { computed: {
...mapState(useQualificationStore, ["qualification", "updateStatus", "loadingSingle"]), ...mapState(useQualificationStore, ["qualification", "updateStatus", "loadingSingle"]),
}, },
@ -58,6 +65,10 @@ export default defineComponent({
}, },
methods: { methods: {
...mapActions(useQualificationStore, ["fetchQualificationById", "updateActiveQualification", "resetStatus"]), ...mapActions(useQualificationStore, ["fetchQualificationById", "updateActiveQualification", "resetStatus"]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerUpdate(e: any) { triggerUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let updateQualification: CreateOrUpdateQualificationViewModel = { let updateQualification: CreateOrUpdateQualificationViewModel = {
@ -65,6 +76,7 @@ export default defineComponent({
description: formData.description.value, description: formData.description.value,
}; };
this.updateActiveQualification(updateQualification); this.updateActiveQualification(updateQualification);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,11 +14,13 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerRoleUpdate"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerRoleUpdate">
<div> <div>
<label for="role">Rollenbezeichnung</label> <label for="role">Rollenbezeichnung</label>
<input type="text" id="role" required :value="role?.role" /> <input type="text" id="role" required :value="role?.role" @change="detectChange" />
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus != null">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
<FailureXMark v-else-if="updateStatus?.status == 'failed'" /> <FailureXMark v-else-if="updateStatus?.status == 'failed'" />
@ -44,6 +46,11 @@ export default defineComponent({
props: { props: {
id: String, id: String,
}, },
data() {
return {
change_detect: false as boolean,
};
},
computed: { computed: {
...mapState(useRoleStore, ["role", "updateStatus", "loadingSingle"]), ...mapState(useRoleStore, ["role", "updateStatus", "loadingSingle"]),
}, },
@ -53,9 +60,14 @@ export default defineComponent({
}, },
methods: { methods: {
...mapActions(useRoleStore, ["fetchRoleById", "updateActiveRole", "resetStatus"]), ...mapActions(useRoleStore, ["fetchRoleById", "updateActiveRole", "resetStatus"]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerRoleUpdate(e: any) { triggerRoleUpdate(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
this.updateActiveRole(formData.role.value); this.updateActiveRole(formData.role.value);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -16,7 +16,7 @@
:permissions="role?.permissions" :permissions="role?.permissions"
:status="updateStatus" :status="updateStatus"
@savePermissions="triggerPermissionUpdate" @savePermissions="triggerPermissionUpdate"
@abortPermissions="$router.push('../')" @resetStatus="resetStatus"
/> />
</template> </template>
</MainTemplate> </MainTemplate>

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -14,22 +14,24 @@
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdateUser"> <form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdateUser">
<div> <div>
<label for="username">Nutzername</label> <label for="username">Nutzername</label>
<input type="text" id="username" required :value="user?.username" /> <input type="text" id="username" required :value="user?.username" @change="detectChange" />
</div> </div>
<div> <div>
<label for="firstname">Vorname</label> <label for="firstname">Vorname</label>
<input type="text" id="firstname" required :value="user?.firstname" /> <input type="text" id="firstname" required :value="user?.firstname" @change="detectChange" />
</div> </div>
<div> <div>
<label for="lastname">Nachname</label> <label for="lastname">Nachname</label>
<input type="text" id="lastname" required :value="user?.lastname" /> <input type="text" id="lastname" required :value="user?.lastname" @change="detectChange" />
</div> </div>
<div> <div>
<label for="mail">Mailadresse</label> <label for="mail">Mailadresse</label>
<input type="email" id="mail" required :value="user?.mail" /> <input type="email" id="mail" required :value="user?.mail" @change="detectChange" />
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline type="reset" class="!w-fit" :disabled="!change_detect" @click="change_detect = false">
verwerfen
</button>
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button> <button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
<Spinner v-if="updateStatus == 'loading'" class="my-auto" /> <Spinner v-if="updateStatus == 'loading'" class="my-auto" />
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" /> <SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
@ -59,7 +61,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
localUser: null as null | UserViewModel, change_detect: false as boolean,
}; };
}, },
computed: { computed: {
@ -71,6 +73,10 @@ export default defineComponent({
}, },
methods: { methods: {
...mapActions(useUserStore, ["fetchUserById", "updateActiveUser", "resetStatus"]), ...mapActions(useUserStore, ["fetchUserById", "updateActiveUser", "resetStatus"]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
triggerUpdateUser(e: any) { triggerUpdateUser(e: any) {
let formData = e.target.elements; let formData = e.target.elements;
let user: CreateOrUpdateUserViewModel = { let user: CreateOrUpdateUserViewModel = {
@ -80,6 +86,7 @@ export default defineComponent({
mail: formData.mail.value, mail: formData.mail.value,
}; };
this.updateActiveUser(user); this.updateActiveUser(user);
this.change_detect = false;
}, },
}, },
}); });

View file

@ -16,7 +16,7 @@
:permissions="user?.permissions" :permissions="user?.permissions"
:status="updateStatus" :status="updateStatus"
@savePermissions="triggerPermissionUpdate" @savePermissions="triggerPermissionUpdate"
@abortPermissions="$router.push('../')" @resetStatus="resetStatus"
/> />
</template> </template>
</MainTemplate> </MainTemplate>

View file

@ -1,7 +1,7 @@
<template> <template>
<MainTemplate> <MainTemplate>
<template #headerInsert> <template #headerInsert>
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink> <RouterLink to="../" class="text-primary">zurück zur Liste (abbrechen)</RouterLink>
</template> </template>
<template #topBar> <template #topBar>
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7"> <div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
@ -39,7 +39,7 @@
</div> </div>
</div> </div>
<div class="flex flex-row justify-end gap-2"> <div class="flex flex-row justify-end gap-2">
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink> <button primary-outline class="!w-fit" :disabled="!change_detect" @click="reset">verwerfen</button>
<button primary class="!w-fit" :disabled="updateStatus == 'loading'" @click="triggerRolesUpdate"> <button primary class="!w-fit" :disabled="updateStatus == 'loading'" @click="triggerRolesUpdate">
speichern speichern
</button> </button>
@ -79,6 +79,7 @@ export default defineComponent({
}, },
data() { data() {
return { return {
change_detect: false as boolean,
assigned: [] as Array<number>, assigned: [] as Array<number>,
}; };
}, },
@ -100,13 +101,24 @@ export default defineComponent({
methods: { methods: {
...mapActions(useUserStore, ["fetchUserById", "updateActiveUserRoles", "resetStatus"]), ...mapActions(useUserStore, ["fetchUserById", "updateActiveUserRoles", "resetStatus"]),
...mapActions(useRoleStore, ["fetchRoles"]), ...mapActions(useRoleStore, ["fetchRoles"]),
detectChange() {
this.resetStatus();
this.change_detect = true;
},
reset() {
this.change_detect = false;
this.assigned = this.user?.roles.map((r) => r.id) ?? [];
},
addAvailable(id: number) { addAvailable(id: number) {
this.detectChange();
this.assigned.push(id); this.assigned.push(id);
}, },
removeAssigned(id: number) { removeAssigned(id: number) {
this.detectChange();
this.assigned = this.assigned.filter((roleId) => roleId !== id); this.assigned = this.assigned.filter((roleId) => roleId !== id);
}, },
triggerRolesUpdate() { triggerRolesUpdate() {
this.change_detect = false;
this.updateActiveUserRoles(this.assigned); this.updateActiveUserRoles(this.assigned);
}, },
}, },