Skip to content

Commit

Permalink
Merge branch 'main' into SPSH-1013
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderUngefug committed Aug 30, 2024
2 parents 0d40778 + af721d7 commit 068a9c2
Show file tree
Hide file tree
Showing 14 changed files with 590 additions and 189 deletions.
6 changes: 6 additions & 0 deletions src/api-client/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ export interface DbiamCreatePersonWithContextBodyParams {
* @memberof DbiamCreatePersonWithContextBodyParams
*/
'vorname': string;
/**
*
* @type {string}
* @memberof DbiamCreatePersonWithContextBodyParams
*/
'personalnummer'?: string;
/**
*
* @type {string}
Expand Down
2 changes: 1 addition & 1 deletion src/api-client/openapispec.json

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/components/admin/personen/PersonenkontextCreate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ beforeEach(() => {
{
value: '54321',
title: 'Lern',
Rollenart: RollenArt.Lern,
rollenart: RollenArt.Lern,
},
{
value: '54329',
title: 'Lehr',
Rollenart: RollenArt.Lehr,
merkmale: new Set<RollenMerkmal>(['KOPERS_PFLICHT']),
rollenart: RollenArt.Lehr,
},
],
klassen: [
Expand Down Expand Up @@ -142,6 +143,7 @@ describe('PersonenkontextCreate', () => {
test('it renders the component', () => {
expect(wrapper?.find('[data-testid="organisation-select"]').isVisible()).toBe(true);
});

test('it updates search and sets values selected rolle, organisation and klasse', async () => {
const organisationAutocomplete: VueWrapper | undefined = wrapper?.findComponent({ ref: 'organisation-select' });
await organisationAutocomplete?.vm.$emit('update:search', '01');
Expand Down Expand Up @@ -306,6 +308,7 @@ describe('PersonenkontextCreate', () => {
expect(rolleAutocomplete?.text()).toEqual('');
expect(personenkontextStore.processWorkflowStep).toHaveBeenCalledWith({ organisationId: '1133', limit: 25 });
});

test('it sends a request if the newValue is empty and the selected Organisation is not defined', async () => {
const organisationAutocomplete: VueWrapper | undefined = wrapper?.findComponent({ ref: 'organisation-select' });

Expand All @@ -323,6 +326,7 @@ describe('PersonenkontextCreate', () => {

expect(organisationAutocomplete?.text()).toEqual('');
});

test('it sends a request if the newValue is empty and the selected Organisation is defined', async () => {
const organisationAutocomplete: VueWrapper | undefined = wrapper?.findComponent({ ref: 'organisation-select' });

Expand All @@ -337,6 +341,7 @@ describe('PersonenkontextCreate', () => {

expect(organisationAutocomplete?.text()).toEqual('orga');
});

test('Do nothing with Klassen if the orga was reset', async () => {
const organisationAutocomplete: VueWrapper | undefined = wrapper?.findComponent({ ref: 'organisation-select' });
await organisationAutocomplete?.setValue('O1');
Expand Down
17 changes: 6 additions & 11 deletions src/components/admin/personen/PersonenkontextCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { useOrganisationStore, type OrganisationStore } from '@/stores/OrganisationStore';
import { type TranslatedObject } from '@/types.d';
import type { BaseFieldProps } from 'vee-validate';
import type { TranslatedRolleWithAttrs } from '@/composables/useRollen';
useI18n({ useScope: 'global' });
Expand All @@ -16,21 +17,14 @@
const timerId: Ref<ReturnType<typeof setTimeout> | undefined> = ref<ReturnType<typeof setTimeout>>();
const canCommit: Ref<boolean> = ref(false);
const hasAutoselectedSchule: Ref<boolean> = ref(false);
const searchInputOrganisation: Ref<string> = ref('');
const searchInputRolle: Ref<string> = ref('');
let isSearching: boolean = false;
type RolleWithRollenart = {
value: string;
title: string;
Rollenart: RollenArt;
};
type Props = {
organisationen: TranslatedObject[] | undefined;
rollen: RolleWithRollenart[] | undefined;
rollen: TranslatedRolleWithAttrs[] | undefined;
klassen: TranslatedObject[] | undefined;
selectedOrganisationProps: BaseFieldProps & { error: boolean; 'error-messages': Array<string> };
selectedRolleProps: BaseFieldProps & { error: boolean; 'error-messages': Array<string> };
Expand Down Expand Up @@ -72,10 +66,10 @@
});
function isLernRolle(selectedRolleId: string | undefined): boolean {
const rolle: RolleWithRollenart | undefined = props.rollen?.find(
(r: RolleWithRollenart) => r.value === selectedRolleId,
const rolle: TranslatedRolleWithAttrs | undefined = props.rollen?.find(
(r: TranslatedRolleWithAttrs) => r.value === selectedRolleId,
);
return !!rolle && rolle.Rollenart === RollenArt.Lern;
return !!rolle && rolle.rollenart === RollenArt.Lern;
}
// Watcher for selectedOrganisation to fetch roles and classes
Expand Down Expand Up @@ -309,6 +303,7 @@
v-model:search="searchInputRolle"
></v-autocomplete>
</FormRow>

<!-- Klasse zuordnen -->
<FormRow
v-if="isLernRolle(selectedRolle) && selectedOrganisation"
Expand Down
7 changes: 4 additions & 3 deletions src/components/form/FormRow.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<script setup lang="ts">
type Props = {
errorLabel: string | boolean;
labelForId: string;
isRequired?: boolean;
label: string;
isRequired?: boolean;
labelForId: string;
noTopMargin?: boolean;
};
defineProps<Props>();
</script>

<template>
<v-row class="align-center mt-8">
<v-row :class="`${noTopMargin ? 'align-center' : 'align-center mt-8'}`">
<v-col
class="py-0 pb-sm-8 pt-sm-3 text-sm-right"
cols="12"
Expand Down
14 changes: 8 additions & 6 deletions src/composables/useRollen.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { usePersonenkontextStore, type PersonenkontextStore } from '@/stores/PersonenkontextStore';
import type { RollenArt, RolleResponse } from '@/stores/RolleStore';
import type { RollenArt, RollenMerkmal, RolleResponse } from '@/stores/RolleStore';
import { computed, type ComputedRef } from 'vue';

type RolleWithRollenart = {
export type TranslatedRolleWithAttrs = {
value: string;
title: string;
Rollenart: RollenArt;
merkmale?: Set<RollenMerkmal>;
rollenart: RollenArt;
};
export function useRollen(): ComputedRef<RolleWithRollenart[] | undefined> {
export function useRollen(): ComputedRef<TranslatedRolleWithAttrs[] | undefined> {
const personenkontextStore: PersonenkontextStore = usePersonenkontextStore();

return computed(() => {
return personenkontextStore.workflowStepResponse?.rollen
.map((rolle: RolleResponse) => ({
value: rolle.id,
title: rolle.name,
Rollenart: rolle.rollenart, // Include Rollenart in the object
merkmale: new Set(rolle.merkmale),
rollenart: rolle.rollenart, // Include Rollenart in the object
}))
.sort((a: RolleWithRollenart, b: RolleWithRollenart) => a.title.localeCompare(b.title));
.sort((a: TranslatedRolleWithAttrs, b: TranslatedRolleWithAttrs) => a.title.localeCompare(b.title));
});
}
21 changes: 15 additions & 6 deletions src/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
}
},
"mandatoryFieldsNotice": "Mit * markierte Felder sind Pflichtangaben.",
"backToForm": "Zurück zum Formular",
"followingDataCreated": "Folgende Daten wurden gespeichert:",
"headline": "Administrationsbereich",
"koPers": {
"koPersNumber": "KoPers-Nr",
"noKoPersNumber": "Keine KoPers-Nr vorhanden"
"koPersNumber": "KoPers.-Nr.",
"noKoPersNumber": "Keine KoPers.-Nr. vorhanden"
},
"klasse": {
"addNew": "Neue Klasse hinzufügen",
Expand Down Expand Up @@ -85,6 +84,7 @@
"person": {
"addedSuccessfully": "{firstname} {lastname} wurde erfolgreich hinzugefügt.",
"addNew": "Neuen Benutzer hinzufügen",
"backToCreatePerson": "Zurück zur Benutzeranlage",
"changePassword": "Passwort ändern",
"twoFactorAuthentication": {
"setUpShort": "2FA einrichten",
Expand Down Expand Up @@ -113,6 +113,8 @@
"discard": "Benutzer verwerfen",
"edit": "Benutzer bearbeiten",
"generatedPassword": "Generiertes Passwort",
"noKopersNr": "KoPers.-Nr. nicht vorhanden",
"noKopersNrConfirmationDialogMessage": "Bitte beachten Sie, dass ein Benutzerkonto ohne KoPers.-Nr. nach 8 Wochen automatisch gesperrt wird. Tragen Sie daher die KoPers.-Nr. bitte in der Gesamtübersicht des Benutzers nach, sobald diese Ihnen vorliegt.",
"loadingErrorText": "Es konnten keine Benutzerdaten geladen werden.",
"loadingErrorTitle": "Fehler beim Laden des Benutzers",
"management": "Benutzerverwaltung",
Expand All @@ -132,6 +134,9 @@
"noLeadingTrailingSpaces": "Der Familienname darf nicht mit Leerzeichen beginnen oder enden.",
"min": "Der Familienname muss mindestens 2 Zeichen lang sein.",
"required": "Der Familienname ist erforderlich."
},
"kopersNr": {
"required": "Die KoPers.-Nr. ist erforderlich."
}
},
"showAll": "Alle Benutzer anzeigen",
Expand All @@ -143,6 +148,7 @@
"title": {
"COUNT_MISMATCHING": "Geänderte Daten.",
"NEWER_VERSION_OF_PERSONENKONTEXTE_AVAILABLE": "Geänderte Daten.",
"PERSONALNUMMER_NICHT_EINDEUTIG": "KoPers.-Nr. nicht eindeutig",
"PERSONENKONTEXTE_UPDATE_ERROR": "Geänderte Daten.",
"PERSON_NOT_FOUND": "Benutzer gelöscht."
},
Expand All @@ -151,6 +157,7 @@
"NEWER_VERSION_OF_PERSONENKONTEXTE_AVAILABLE": "Der Benutzer wurde zwischenzeitlich durch einen anderen Administrator bearbeitet. Bitte aktualisieren Sie die Daten und versuchen Sie es erneut.",
"GLEICHE_ROLLE_AN_KLASSE_WIE_SCHULE": "Mindestens eine Rolle des Benutzers ist an der Schule nicht bekannt.",
"NUR_LEHR_UND_LERN_AN_KLASSE": "Nur Schüler dürfen einer Klasse zugeordnet werden.",
"PERSONALNUMMER_NICHT_EINDEUTIG": "Die eingegebene KoPers.-Nr. ist bereits vergeben. Bitte korrigieren Sie Ihre Eingabe.",
"PERSONENKONTEXT_SPECIFICATION_ERROR": "Die Zuordnung konnte nicht angelegt werden.",
"PERSONENKONTEXTE_UPDATE_ERROR": "Die Zuordnung konnte nicht aktualisiert werden. Bitte versuchen Sie es später erneut.",
"PERSON_NOT_FOUND": "Der Benutzer wurde seit Ihrer letzten Änderung gelöscht und kann nicht mehr bearbeitet werden."
Expand Down Expand Up @@ -207,7 +214,7 @@
},
"merkmale": {
"BEFRISTUNG_PFLICHT": "Befristung ist Pflichtangabe",
"KOPERS_PFLICHT": "KoPers-Nr. ist Pflichtangabe"
"KOPERS_PFLICHT": "KoPers.-Nr. ist Pflichtangabe"
}
},
"merkmale": "Merkmale",
Expand Down Expand Up @@ -338,6 +345,7 @@
"password": "Passwort",
"username": "Benutzername"
},
"missing": "fehlt",
"nav": {
"admin": "Schulportal-Administration",
"backToDetails": "Zurück zur Gesamtübersicht",
Expand Down Expand Up @@ -382,13 +390,14 @@
"editZuordnungen": "Schulzuordnungen bearbeiten",
"email": "E-Mail",
"enterFirstName": "Vorname eingeben",
"enterKopersNr": "KoPers.-Nr. eingeben",
"enterLastName": "Nachname eingeben",
"firstName": "Vorname",
"firstNameLastNameReferrerKopersNr": "Vor-/Nachname/Benutzername/KoPers-Nr.",
"firstNameLastNameReferrerKopersNr": "Vor-/Nachname/Benutzername/KoPers.-Nr.",
"firstAndLastName": "Vor- und Nachname",
"finishEditFirst": "Bitte beenden Sie zunächst Ihre aktuelle Bearbeitung.",
"klasse": "Klasse",
"kopersnr": "Kopers-Nr",
"kopersNr": "KoPers.-Nr.",
"lastName": "Nachname",
"modifyBefristung": "Befristung bearbeiten",
"modifyBefristungDescription": "Ändert die Befristung der Zuordnung des Benutzers zu dieser Schule.",
Expand Down
4 changes: 2 additions & 2 deletions src/stores/PersonenkontextStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ describe('PersonenkontextStore', () => {
});

it('should handle error code', async () => {
mockadapter.onPost('/api/personenkontext-workflow').replyOnce(500, { code: 'some mock server error' });
mockadapter.onPost('/api/personenkontext-workflow').replyOnce(500, { i18nKey: 'SOME_MOCK_SERVER_ERROR' });
const createPersonPromise: Promise<PersonendatensatzResponse> = personenkontextStore.createPersonWithKontext({
familienname: 'Copeland',
vorname: 'Christian',
Expand All @@ -668,7 +668,7 @@ describe('PersonenkontextStore', () => {
});
expect(personenkontextStore.loading).toBe(true);
await rejects(createPersonPromise);
expect(personenkontextStore.errorCode).toEqual('some mock server error');
expect(personenkontextStore.errorCode).toEqual('SOME_MOCK_SERVER_ERROR');
expect(personenkontextStore.loading).toBe(false);
});
});
Expand Down
5 changes: 4 additions & 1 deletion src/stores/PersonenkontextStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
type PersonendatensatzResponse,
type PersonAdministrationApiInterface,
PersonAdministrationApiFactory,
RollenMerkmal,
} from '../api-client/generated/api';
import axiosApiInstance from '@/services/ApiService';

Expand Down Expand Up @@ -62,6 +63,7 @@ export type Zuordnung = {
administriertVon: string;
typ: OrganisationsTyp;
editable: boolean;
merkmale?: Array<RollenMerkmal>;
};

export type Uebersicht =
Expand All @@ -81,6 +83,7 @@ export type Uebersicht =
administriertVon: string;
typ: OrganisationsTyp;
editable: boolean;
merkmale?: Array<RollenMerkmal>;
}[];
}
| undefined;
Expand Down Expand Up @@ -344,7 +347,7 @@ export const usePersonenkontextStore: StoreDefinition<
} catch (error: unknown) {
this.errorCode = 'UNSPECIFIED_ERROR';
if (isAxiosError(error)) {
this.errorCode = error.response?.data.code || 'UNSPECIFIED_ERROR';
this.errorCode = error.response?.data.i18nKey || 'UNSPECIFIED_ERROR';
}
return await Promise.reject(this.errorCode);
} finally {
Expand Down
Loading

0 comments on commit 068a9c2

Please sign in to comment.