add more responsiveness when updating self admin

This commit is contained in:
2023-08-28 18:46:41 +02:00
parent 90cb1fea87
commit 6d4ad29379
5 changed files with 51 additions and 29 deletions

View File

@ -4,7 +4,7 @@
export let id: string | null = null;
export let name: string | null = null;
export let disabled = true;
export let disabled = false;
export let available: string[] | { [key: string]: T } = {};
export let value: T[] = [];
</script>
@ -37,14 +37,17 @@
<div class="flex flow flex-wrap gap-2">
{#each value as badge, i}
{#if Object.values(available).indexOf(badge) !== -1}
<div class="badge badge-outline gap-1">
<button
{disabled}
on:click={() => {
value.splice(i, 1);
value = value;
}}>✕</button
>
<div class="badge badge-outline gap-1" class:brightness-[60%]={disabled}>
<span class:cursor-not-allowed={disabled}>
<button
{disabled}
class:pointer-events-none={disabled}
on:click={() => {
value.splice(i, 1);
value = value;
}}></button
>
</span>
{Object.keys(available)[Object.values(available).indexOf(badge)]}
</div>
{/if}

View File

@ -55,7 +55,7 @@ export class Admin extends Model {
@BeforeCreate
@BeforeUpdate
static hashPassword(instance: Admin) {
if (instance.password != null) {
if ((instance.changed() || []).indexOf('password') != -1) {
instance.password = bcrypt.hashSync(instance.password, 10);
}
}