Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPSH-1070 #355

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 85 additions & 8 deletions src/components/admin/personen/PersonLock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
const { mdAndDown }: { mdAndDown: Ref<boolean> } = useDisplay();

const dialogIsActive: Ref<boolean> = ref(false);
const isEditMode: Ref<boolean> = ref(false);

type Props = {
errorCode: string;
Expand Down Expand Up @@ -65,7 +66,7 @@
] = formContext.defineField('selectedBefristung', vuetifyConfig);

type Emits = {
(event: 'onLockUser', schule: string, date: string | undefined): void;
(event: 'onLockUser', schule: string, date: string | undefined, isExistingLockToBeEdited: boolean): void;
};
const props: Props = defineProps<Props>();
const emit: Emits = defineEmits<Emits>();
Expand Down Expand Up @@ -107,6 +108,7 @@
function closeLockPersonDialog(): void {
resetBefristungFields();
dialogIsActive.value = false;
isEditMode.value = false;
}

async function handleOnLockUser(): Promise<void> {
Expand All @@ -124,7 +126,9 @@
// Format date if provided
const dateISO: string | undefined = formatDateToISO(selectedBefristung.value);

emit('onLockUser', lockingOrgId, dateISO);
const isExistingLockToBeEdited: boolean = isEditMode.value;

emit('onLockUser', lockingOrgId, dateISO, isExistingLockToBeEdited);
closeLockPersonDialog();
}

Expand Down Expand Up @@ -186,7 +190,7 @@
{{ !person.person.isLocked ? $t('person.lockUser') : $t('person.unlockUser') }}
</v-btn>
</SpshTooltip>
<SpshTooltip
<!-- <SpshTooltip
v-else
:enabledCondition="!disabled"
:disabledText="$t('person.finishEditFirst')"
Expand All @@ -206,17 +210,38 @@
: $t('person.lockUser')
}}
</v-btn>
</SpshTooltip> -->
<SpshTooltip
v-else
:enabledCondition="!disabled"
:disabledText="$t('person.finishEditFirst')"
:enabledText="$t('admin.person.editLock')"
position="start"
>
<v-btn
class="primary"
data-testid="open-lock-dialog-button"
:disabled="disabled"
:block="mdAndDown"
v-bind="props"
>
{{
person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
? $t('admin.person.editLock')
: $t('person.lockUser')
}}
</v-btn>
</SpshTooltip>
</v-col>
</template>

<!-- Benutzer sperren Dialog -->
<LayoutCard
data-testid="person-lock-card"
:closable="true"
:header="
!props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
? $t('person.lockUser')
: $t('person.unlockUser')
: $t('admin.person.editLock')
"
@onCloseClicked="closeLockPersonDialog"
>
Expand All @@ -240,7 +265,8 @@
</v-row>
<v-row
v-if="
!props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
!props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
|| props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && isEditMode
"
class="align-center justify-center w-full"
>
Expand Down Expand Up @@ -286,6 +312,7 @@
class="justify-center w-full"
v-if="
!props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
|| props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && isEditMode
"
>
<v-col
Expand Down Expand Up @@ -324,7 +351,7 @@
{{
!props.person.person.userLock?.some(
(lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT,
)
) || props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && isEditMode
? $t('person.lockUserInfoText')
: $t('person.unLockUserInfoText')
}}
Expand Down Expand Up @@ -352,6 +379,56 @@
cols="12"
sm="6"
md="4"
>
<v-btn
v-if="
props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && !isEditMode
"
:block="mdAndDown"
class="primary button"
:disabled="
!props.person.person.userLock?.some(
(lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT,
DeFi3298 marked this conversation as resolved.
Show resolved Hide resolved
) && !selectedOrganisation
"
@click.stop="isEditMode = true"
data-testid="lock-user-button"
>
{{ $t('admin.person.editLock') }}
</v-btn>
<v-btn
v-if="
!props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT)
he-meyer marked this conversation as resolved.
Show resolved Hide resolved
|| props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && isEditMode
"
:block="mdAndDown"
class="primary button"
:disabled="
!props.person.person.userLock?.some(
(lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT,
) && !selectedOrganisation
"
@click.stop="onSubmit"
data-testid="lock-user-button"
>
<!-- {{
props.person.person.userLock?.some(
(lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT,
)
// ? $t('admin.person.editLock')
? "Nur wenn Sperre bearbeiten"
: $t('person.lockUser')
he-meyer marked this conversation as resolved.
Show resolved Hide resolved
}} -->
he-meyer marked this conversation as resolved.
Show resolved Hide resolved
{{ $t('person.lockUser') }}
</v-btn>
</v-col>
<v-col
v-if="
props.person.person.userLock?.some((lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT) && !isEditMode
he-meyer marked this conversation as resolved.
Show resolved Hide resolved
"
cols="12"
sm="6"
md="4"
>
<v-btn
:block="mdAndDown"
Expand All @@ -368,7 +445,7 @@
props.person.person.userLock?.some(
(lock) => lock.lock_occasion === PersonLockOccasion.MANUELL_GESPERRT,
)
? $t('person.unlockUser')
? $t('admin.person.removeLock')
: $t('person.lockUser')
}}
</v-btn>
Expand Down
2 changes: 2 additions & 0 deletions src/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
"deletePersonSuccessMessage": "{firstname} {lastname} wurde erfolgreich gelöscht.",
"discard": "Benutzer verwerfen",
"disableUser": "Benutzer sperren",
"editLock": "Sperre bearbeiten",
"removeLock": "Sperre aufheben",
"edit": "Benutzer bearbeiten",
"editPersonalInfo": "Persönliche Informationen bearbeiten",
"errors": {
Expand Down
12 changes: 10 additions & 2 deletions src/views/admin/PersonDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,19 @@
password.value = personStore.newPassword || '';
}

async function onLockUser(lockedBy: string, date: string | undefined): Promise<void> {
async function onLockUser(
lockedBy: string,
date: string | undefined,
isExistingLockToBeEdited: boolean,
): Promise<void> {
if (!personStore.currentPerson) return;

let lock: boolean;
if (isExistingLockToBeEdited) lock = isManuallyLocked.value;
else lock = !isManuallyLocked.value;

let bodyParams: LockUserBodyParams = {
lock: !isManuallyLocked.value,
lock: lock,
locked_by: lockedBy,
locked_until: date,
};
Expand Down
Loading