add confirmation popups to admin interface
All checks were successful
delpoy / build-and-deploy (push) Successful in 49s
All checks were successful
delpoy / build-and-deploy (push) Successful in 49s
This commit is contained in:
parent
e30446598c
commit
332089228e
@ -8,9 +8,12 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
import { adminCount } from '$lib/stores';
|
import { adminCount } from '$lib/stores';
|
||||||
|
import { getPopupModalShowFn } from '$lib/context';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
|
let showPopupModal = getPopupModalShowFn();
|
||||||
|
|
||||||
let admins = $state(data.admins);
|
let admins = $state(data.admins);
|
||||||
|
|
||||||
let allPermissionBadges = {
|
let allPermissionBadges = {
|
||||||
@ -136,17 +139,29 @@
|
|||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={async (e) => {
|
onclick={async (e) => {
|
||||||
await buttonTriggeredRequest(
|
showPopupModal({
|
||||||
e,
|
title: 'Speichern',
|
||||||
updateAdmin(
|
text: `Sollen die Änderungen für den Admin '${admin.username}' gespeichert werden?`,
|
||||||
admin.id,
|
actions: [
|
||||||
admin.username,
|
{
|
||||||
admin.password,
|
text: 'Speichern',
|
||||||
new Permissions(admin.permissions)
|
action: async () => {
|
||||||
)
|
await buttonTriggeredRequest(
|
||||||
);
|
e,
|
||||||
admin.password = '';
|
updateAdmin(
|
||||||
admin.edit = false;
|
admin.id,
|
||||||
|
admin.username,
|
||||||
|
admin.password,
|
||||||
|
new Permissions(admin.permissions)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
admin.password = '';
|
||||||
|
admin.edit = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ text: 'Abbrechen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Check size="18" />
|
<Check size="18" />
|
||||||
@ -156,8 +171,29 @@
|
|||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
admin.edit = false;
|
if (
|
||||||
admins[i] = admin.before;
|
admin.username === admin.before.username &&
|
||||||
|
admin.password === admin.before.password &&
|
||||||
|
JSON.stringify(admin.permissions) === JSON.stringify(admin.before.permissions)
|
||||||
|
) {
|
||||||
|
admin.edit = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showPopupModal({
|
||||||
|
title: 'Abbrechen',
|
||||||
|
text: 'Soll die Adminbearbeitung abgebrochen werden?',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
text: 'Abbrechen',
|
||||||
|
action: () => {
|
||||||
|
admin.edit = false;
|
||||||
|
admins[i] = admin.before;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ text: 'Schließen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NoSymbol size="18" />
|
<NoSymbol size="18" />
|
||||||
@ -178,7 +214,19 @@
|
|||||||
<span class="w-min" class:cursor-not-allowed={!permissions.admin()}>
|
<span class="w-min" class:cursor-not-allowed={!permissions.admin()}>
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={(e) => buttonTriggeredRequest(e, deleteAdmin(admin.id))}
|
onclick={(e) => {
|
||||||
|
showPopupModal({
|
||||||
|
title: 'Admin löschen',
|
||||||
|
text: `Soll der Admin ${admin.username} wirklich gelöscht werden?`,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
text: 'Löschen',
|
||||||
|
action: () => buttonTriggeredRequest(e, deleteAdmin(admin.id))
|
||||||
|
},
|
||||||
|
{ text: 'Abbrechen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Trash size="18" />
|
<Trash size="18" />
|
||||||
</button>
|
</button>
|
||||||
@ -199,13 +247,29 @@
|
|||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
disabled={!newAdminUsername || !newAdminPassword}
|
disabled={!newAdminUsername || !newAdminPassword}
|
||||||
onclick={async (e) => {
|
onclick={async (e) => {
|
||||||
await buttonTriggeredRequest(
|
showPopupModal({
|
||||||
e,
|
title: 'Admin hinzugügen',
|
||||||
addAdmin(newAdminUsername, newAdminPassword, new Permissions(newAdminPermissions))
|
text: `Soll der neue Admin ${newAdminUsername} hinzugefügt werden?`,
|
||||||
);
|
actions: [
|
||||||
newAdminUsername = '';
|
{
|
||||||
newAdminPassword = '';
|
text: 'Hinzufügen',
|
||||||
newAdminPermissions = [];
|
action: async () => {
|
||||||
|
await buttonTriggeredRequest(
|
||||||
|
e,
|
||||||
|
addAdmin(
|
||||||
|
newAdminUsername,
|
||||||
|
newAdminPassword,
|
||||||
|
new Permissions(newAdminPermissions)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
newAdminUsername = '';
|
||||||
|
newAdminPassword = '';
|
||||||
|
newAdminPermissions = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ text: 'Abbrechen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<UserPlus size="18" />
|
<UserPlus size="18" />
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
import SortableTh from '$lib/components/Table/SortableTh.svelte';
|
import SortableTh from '$lib/components/Table/SortableTh.svelte';
|
||||||
import NewUserModal from './NewUserModal.svelte';
|
import NewUserModal from './NewUserModal.svelte';
|
||||||
import PaginationTableBody from '$lib/components/PaginationTable/PaginationTableBody.svelte';
|
import PaginationTableBody from '$lib/components/PaginationTable/PaginationTableBody.svelte';
|
||||||
|
import { getPopupModalShowFn } from '$lib/context';
|
||||||
|
|
||||||
|
let showPopupModal = getPopupModalShowFn();
|
||||||
|
|
||||||
let users: (typeof User.prototype.dataValues)[] = $state([]);
|
let users: (typeof User.prototype.dataValues)[] = $state([]);
|
||||||
let usersPerRequest = 25;
|
let usersPerRequest = 25;
|
||||||
@ -154,8 +157,20 @@
|
|||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={async (e) => {
|
onclick={async (e) => {
|
||||||
await buttonTriggeredRequest(e, updateUser(user));
|
showPopupModal({
|
||||||
user.edit = false;
|
title: 'Speichern',
|
||||||
|
text: `Sollen die Änderungen für den Nutzer '${user.username}' gespeichert werden?`,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
text: 'Speichern',
|
||||||
|
action: async () => {
|
||||||
|
await buttonTriggeredRequest(e, updateUser(user));
|
||||||
|
user.edit = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ text: 'Abbrechen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Check size="18" />
|
<Check size="18" />
|
||||||
@ -163,8 +178,34 @@
|
|||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={() => {
|
onclick={() => {
|
||||||
user.edit = false;
|
if (
|
||||||
users[i] = user.before;
|
user.firstname === user.before.firstname &&
|
||||||
|
user.lastname === user.before.lastname &&
|
||||||
|
user.birthday === user.before.birthday &&
|
||||||
|
user.telephone === user.before.telephone &&
|
||||||
|
user.username === user.before.username &&
|
||||||
|
user.playertype === user.before.playertype &&
|
||||||
|
user.password === user.before.password &&
|
||||||
|
user.uuid === user.before.uuid
|
||||||
|
) {
|
||||||
|
user.edit = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showPopupModal({
|
||||||
|
title: 'Abbrechen',
|
||||||
|
text: 'Soll die Nutzerbearbeitung abgebrochen werden?',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
text: 'Abbrechen',
|
||||||
|
action: () => {
|
||||||
|
user.edit = false;
|
||||||
|
users[i] = user.before;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ text: 'Schließen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NoSymbol size="18" />
|
<NoSymbol size="18" />
|
||||||
@ -181,7 +222,19 @@
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn-sm btn-square"
|
class="btn btn-sm btn-square"
|
||||||
onclick={(e) => buttonTriggeredRequest(e, deleteUser(user.id))}
|
onclick={(e) => {
|
||||||
|
showPopupModal({
|
||||||
|
title: 'Nutzer löschen',
|
||||||
|
text: `Soll der Nutzer '${user.username}' wirklich gelöscht werden?`,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
text: 'Löschen',
|
||||||
|
action: () => buttonTriggeredRequest(e, deleteUser(user.id))
|
||||||
|
},
|
||||||
|
{ text: 'Abbrechen' }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Trash size="18" />
|
<Trash size="18" />
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user