Standort Shop mit Unterauswahl; C-Level nur als Code; Sonstige im Import
Standort: locations.parent_id, eine Ebene. Neu "Shop" mit sechs Shops (Shop W17, Shop Wodo, Shop Parndorf, Shop Donaupark, Shop W1, Shop Wien Hauptbahnhof). Personen sitzen nur auf Standorten ohne Unterstandorte; zwei Trigger halten das auch fuer Import und Nachtlauf fest. Einstellung, Externe und Versetzung zeigen bei "Shop" eine zweite Auswahl (StandortAuswahl). Filter in Liste und Berichten und die Importliste bieten "Shop" selbst nicht an; der Import nennt bei "Shop" die Shops. rauchtest.sql und vertragsangaben.sql waehlen einen zuweisbaren Standort. C-Level: ueberall nur der Code (Formular, Akte, Zusammenfassung, Historie, Berichte, Import). Export ohne Spalte "C-Level Bezeichnung". Angehoerige und Notfallkontakte im Import wie im Formular: Auswahl als feste Liste und daneben "Verhaeltnis (Sonstige)" fuer den eigenen Text. Gespeichert wird bei "Sonstige" der Text; ein Text ohne "Sonstige" ist ein Fehler. Der Download teilt einen eigenen Text in beide Spalten. Geprueft: lint, tsc, types:check, npm test, waechter; Migrationen auf leerer Datenbank zweimal (Nichts anzuwenden), rauchtest.sql, vertragsangaben.sql; als alpenwerk_app: Einstellung auf "Shop" abgewiesen, auf "Shop W17" angenommen, Wechsel auf "Shop" abgewiesen, auf "Shop Wodo" angenommen, Unterstandort unter einem Shop abgewiesen.
This commit is contained in:
@@ -5,12 +5,14 @@ import { useEffect, useState } from "react";
|
||||
import { FILTER_SELECT_CLASS } from "@/components/ui/Field";
|
||||
import { SearchInput } from "@/components/ui/SearchInput";
|
||||
import { AUSTRITT_GEPLANT } from "@/lib/employee-status-filter";
|
||||
import { zuweisbareStandorte } from "@/lib/standorte";
|
||||
|
||||
type EmployeeFiltersProps = {
|
||||
/** Der ganze Baum, in Tiefensuche-Reihenfolge. */
|
||||
units: { id: string; name: string; unit_type: string }[];
|
||||
depthOf: Map<string, number>;
|
||||
locations: { id: string; name: string }[];
|
||||
/** Zur Auswahl kommen nur Standorte, auf denen jemand sitzen kann. */
|
||||
locations: { id: string; name: string; parent_id: string | null }[];
|
||||
};
|
||||
|
||||
// Aktiv and Langzeitabwesenheit are separate statuses — somebody on a
|
||||
@@ -107,7 +109,7 @@ export function EmployeeFilters({ units, depthOf, locations }: EmployeeFiltersPr
|
||||
className={FILTER_SELECT_CLASS}
|
||||
>
|
||||
<option value="">Alle Standorte</option>
|
||||
{locations.map((l) => (
|
||||
{zuweisbareStandorte(locations).map((l) => (
|
||||
<option key={l.id} value={l.id}>
|
||||
{l.name}
|
||||
</option>
|
||||
|
||||
63
components/employees/StandortAuswahl.tsx
Normal file
63
components/employees/StandortAuswahl.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { SelectField } from "@/components/ui/Field";
|
||||
import { kurzname, oberstandorte, oberstandortVon, unterstandorte, type StandortEintrag } from "@/lib/standorte";
|
||||
|
||||
type Standort = StandortEintrag & { country?: string };
|
||||
|
||||
// Standort in zwei Stufen: die oberste Ebene, und bei einem Standort mit
|
||||
// Unterstandorten („Shop") eine zweite Auswahl. Gemeldet wird nur ein
|
||||
// Standort, auf dem eine Person sitzen kann; solange die zweite Auswahl
|
||||
// fehlt, ist der Wert leer — ein Pflichtfeld bleibt damit offen.
|
||||
export function StandortAuswahl({
|
||||
value,
|
||||
onChange,
|
||||
standorte,
|
||||
required,
|
||||
mitLand,
|
||||
hint,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (id: string) => void;
|
||||
standorte: readonly Standort[];
|
||||
required?: boolean;
|
||||
/** Land in Klammern dahinter, wie bei der Einstellung. */
|
||||
mitLand?: boolean;
|
||||
hint?: string;
|
||||
}) {
|
||||
// Zustand, weil „Shop" gewählt sein kann, ohne dass schon ein Wert feststeht.
|
||||
const [ober, setOber] = useState(() => oberstandortVon(standorte, value));
|
||||
const unter = unterstandorte(standorte, ober);
|
||||
const oberEintrag = standorte.find((s) => s.id === ober);
|
||||
|
||||
const beschriftung = (s: Standort, name: string) => (mitLand && s.country ? `${name} (${s.country})` : name);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SelectField
|
||||
label="Standort"
|
||||
required={required}
|
||||
value={ober}
|
||||
onChange={(id) => {
|
||||
setOber(id);
|
||||
onChange(unterstandorte(standorte, id).length > 0 ? "" : id);
|
||||
}}
|
||||
placeholder="Bitte wählen…"
|
||||
options={oberstandorte(standorte).map((s) => ({ value: s.id, label: beschriftung(s, s.name) }))}
|
||||
hint={unter.length > 0 ? undefined : hint}
|
||||
/>
|
||||
{unter.length > 0 && (
|
||||
<SelectField
|
||||
label={oberEintrag?.name ?? "Standort"}
|
||||
required
|
||||
value={unter.some((s) => s.id === value) ? value : ""}
|
||||
onChange={onChange}
|
||||
placeholder="Bitte wählen…"
|
||||
options={unter.map((s) => ({ value: s.id, label: kurzname(s, oberEintrag) }))}
|
||||
hint={hint}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { useState } from "react";
|
||||
import { SelectField, TextField } from "@/components/ui/Field";
|
||||
import { anzeigeAuswahl } from "@/lib/anzeige";
|
||||
import { EMERGENCY_RELATIONS } from "@/lib/types";
|
||||
import { istFreiesVerhaeltnis, SONSTIGE } from "@/lib/verhaeltnis";
|
||||
|
||||
// Das Verhältnis zum Notfallkontakt: Auswahl, und unter „Sonstige" ein
|
||||
// Freifeld.
|
||||
@@ -23,12 +24,7 @@ import { EMERGENCY_RELATIONS } from "@/lib/types";
|
||||
// nimmt einen gespeicherten Wert, der nicht in der Liste steht, mit in die
|
||||
// Auswahl auf.
|
||||
|
||||
const SONSTIGE = "Sonstige";
|
||||
|
||||
/** Ob ein gespeicherter Wert frei eingetragen wurde. */
|
||||
export function istFreiesVerhaeltnis(wert: string): boolean {
|
||||
return wert.trim() !== "" && !(EMERGENCY_RELATIONS as readonly string[]).includes(wert);
|
||||
}
|
||||
export { istFreiesVerhaeltnis };
|
||||
|
||||
export function VerhaeltnisField({
|
||||
value,
|
||||
|
||||
@@ -5,7 +5,8 @@ import { useMemo, useState } from "react";
|
||||
import { geplantenVorgangErsetzen, transferEmployee } from "@/actions/employees";
|
||||
import { Button } from "@/components/ui/Button";
|
||||
import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl";
|
||||
import { DateField, SelectField } from "@/components/ui/Field";
|
||||
import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
|
||||
import { DateField } from "@/components/ui/Field";
|
||||
import { SlideOver } from "@/components/ui/SlideOver";
|
||||
import { useToast } from "@/components/ui/Toast";
|
||||
import { mitBisherigerStelle, type GeplanterVorgang } from "@/lib/geplanter-vorgang";
|
||||
@@ -23,7 +24,7 @@ type TransferPanelProps = {
|
||||
/** Eine geplante Versetzung, die geändert wird (lib/geplanter-vorgang.ts). */
|
||||
ersetzt?: GeplanterVorgang | null;
|
||||
/** Die Standorte zur Auswahl — mit der Versetzung kann auch der Standort wechseln. */
|
||||
locations?: { id: string; name: string }[];
|
||||
locations?: { id: string; name: string; parent_id: string | null }[];
|
||||
};
|
||||
|
||||
// Eine Versetzung ist der Wechsel auf eine andere Planstelle — nicht die
|
||||
@@ -58,6 +59,11 @@ export function TransferPanel({ open, onClose, employee, openPositions, ersetzt,
|
||||
showToast("Bitte Datum und Zielplanstelle angeben.", "error");
|
||||
return;
|
||||
}
|
||||
// Leer heisst hier: „Shop" gewählt, der einzelne Shop noch nicht.
|
||||
if (!ersetzt && !standort) {
|
||||
showToast("Bitte den Standort vollständig auswählen.", "error");
|
||||
return;
|
||||
}
|
||||
setPending(true);
|
||||
const result = ersetzt
|
||||
? await geplantenVorgangErsetzen({
|
||||
@@ -125,11 +131,10 @@ export function TransferPanel({ open, onClose, employee, openPositions, ersetzt,
|
||||
{/* Nur bei einer neuen Versetzung: an einer geplanten werden
|
||||
Planstelle und Datum geändert. */}
|
||||
{!ersetzt && locations.length > 0 && (
|
||||
<SelectField
|
||||
label="Standort"
|
||||
<StandortAuswahl
|
||||
value={standort}
|
||||
onChange={setStandort}
|
||||
options={locations.map((l) => ({ value: l.id, label: l.name }))}
|
||||
standorte={locations}
|
||||
hint="Wechselt mit der Versetzung zum selben Tag; sonst bleibt der bisherige."
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { hayGradeLabel } from "@/lib/hay-grade";
|
||||
import { ohneVorgabe } from "@/lib/extern-vorgaben";
|
||||
import { lehrzeitText } from "@/lib/lehrzeit";
|
||||
import { anzeige } from "@/lib/anzeige";
|
||||
import { cLevelText } from "@/lib/c-level";
|
||||
import type { Database } from "@/lib/types";
|
||||
import { bonusanspruchLabel, vlLabel } from "@/lib/vertragsangaben";
|
||||
|
||||
@@ -108,7 +107,7 @@ export function VertragTab({
|
||||
["Dienstwagen", ohneVorgabe(employee, ["has_dienstwagen"], employee.has_dienstwagen ? dienstwagenLabel(employee.dienstwagen_art) : "Nein")],
|
||||
["Betriebsrat", ohneVorgabe(employee, ["is_betriebsrat"], employee.is_betriebsrat ? "Ja" : "Nein")],
|
||||
["Laterale Führung", ohneVorgabe(employee, ["is_laterale_fuehrung"], employee.is_laterale_fuehrung ? "Ja" : "Nein")],
|
||||
["C-Level", cLevelText(employee.c_level) || "–"],
|
||||
["C-Level", employee.c_level || "–"],
|
||||
// Das Enddatum steht gleich dabei: „Ja" allein liesse offen, ob der
|
||||
// Schutz noch läuft, und genau danach fragt man.
|
||||
// Die Teilzeitvariante gehört neben die Stunden: sie erklärt, warum sie
|
||||
|
||||
@@ -60,7 +60,7 @@ type HireWizardProps = {
|
||||
/** Ein neuer Entwurf ist angelegt — er trägt bereits meine Sperre. */
|
||||
onEntwurfAngelegt: (id: string) => void;
|
||||
openPositions: OpenPositionResolved[];
|
||||
locations: { id: string; name: string; country: string }[];
|
||||
locations: { id: string; name: string; country: string; parent_id: string | null }[];
|
||||
resumeDraft: { id: string; step: number; payload: Record<string, unknown> } | null;
|
||||
initialPositionId?: string;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { Entwurf } from "@/lib/entwuerfe";
|
||||
import type { OpenPositionResolved } from "@/lib/positions";
|
||||
import { HireWizard } from "./HireWizard";
|
||||
|
||||
type Location = { id: string; name: string; country: string };
|
||||
type Location = { id: string; name: string; country: string; parent_id: string | null };
|
||||
|
||||
type OpenWizardOptions = { draftId?: string; positionId?: string };
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ type RehireWizardProps = {
|
||||
onClose: () => void;
|
||||
employee: EmployeeRow;
|
||||
openPositions: OpenPositionResolved[];
|
||||
locations: { id: string; name: string; country: string }[];
|
||||
locations: { id: string; name: string; country: string; parent_id: string | null }[];
|
||||
};
|
||||
|
||||
export function RehireWizard({ open, onClose, employee, openPositions, locations }: RehireWizardProps) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
|
||||
import { PlanstellenAuswahl } from "@/components/positions/PlanstellenAuswahl";
|
||||
import { DateField, SelectField, TextField } from "@/components/ui/Field";
|
||||
import { todayIso } from "@/lib/format";
|
||||
@@ -24,7 +25,7 @@ export function StepExternePerson({
|
||||
}: {
|
||||
draft: HireDraftData;
|
||||
update: (patch: Partial<HireDraftData>) => void;
|
||||
locations: { id: string; name: string; country: string }[];
|
||||
locations: { id: string; name: string; country: string; parent_id: string | null }[];
|
||||
openPositions: OpenPositionResolved[];
|
||||
stellenFehler?: string | null;
|
||||
onNummerBefund: (befund: { nummer: number; vergeben: boolean }) => void;
|
||||
@@ -78,13 +79,12 @@ export function StepExternePerson({
|
||||
onChange={(id) => update({ positionId: id })}
|
||||
/>
|
||||
|
||||
<SelectField
|
||||
label="Standort"
|
||||
<StandortAuswahl
|
||||
required
|
||||
mitLand
|
||||
value={draft.locationId}
|
||||
onChange={(locationId) => update({ locationId })}
|
||||
placeholder="Bitte wählen…"
|
||||
options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
|
||||
standorte={locations}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { StandortAuswahl } from "@/components/employees/StandortAuswahl";
|
||||
import { SvNummerField } from "@/components/employees/SvNummerField";
|
||||
import { TitleFields } from "@/components/employees/TitleFields";
|
||||
import { ZustaendigeHrField } from "@/components/employees/ZustaendigeHrField";
|
||||
@@ -14,7 +15,7 @@ import type { HireDraftData } from "./types";
|
||||
type StepPersonProps = {
|
||||
draft: HireDraftData;
|
||||
update: (patch: Partial<HireDraftData>) => void;
|
||||
locations: { id: string; name: string; country: string }[];
|
||||
locations: { id: string; name: string; country: string; parent_id: string | null }[];
|
||||
/** Meldet die geprüfte Personalnummer und ihr Ergebnis — steuert „Weiter". */
|
||||
onNummerBefund?: (befund: { nummer: number; vergeben: boolean }) => void;
|
||||
/**
|
||||
@@ -185,13 +186,12 @@ export function StepPerson({ draft, update, locations, onNummerBefund, nummerGes
|
||||
/>
|
||||
<TextField label="Private Telefonnummer" type="tel" value={draft.phone} onChange={(phone) => update({ phone })} />
|
||||
</div>
|
||||
<SelectField
|
||||
label="Standort"
|
||||
<StandortAuswahl
|
||||
required
|
||||
mitLand
|
||||
value={draft.locationId}
|
||||
onChange={(locationId) => update({ locationId })}
|
||||
placeholder="Bitte wählen…"
|
||||
options={locations.map((l) => ({ value: l.id, label: `${l.name} (${l.country})` }))}
|
||||
standorte={locations}
|
||||
/>
|
||||
<ZustaendigeHrField value={draft.zustaendigeHrId} onChange={(zustaendigeHrId) => update({ zustaendigeHrId })} />
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,6 @@ import { geschlechtLabel } from "@/lib/geschlecht";
|
||||
import { hayGradeLabel } from "@/lib/hay-grade";
|
||||
import { lehrzeitText } from "@/lib/lehrzeit";
|
||||
import { anzeige } from "@/lib/anzeige";
|
||||
import { cLevelText } from "@/lib/c-level";
|
||||
import type { OpenPositionResolved } from "@/lib/positions";
|
||||
import { bonusanspruchLabel } from "@/lib/vertragsangaben";
|
||||
import type { HireDraftData } from "./types";
|
||||
@@ -89,7 +88,7 @@ export function StepSummary({ draft, selectedPosition, locations, extern = false
|
||||
: []),
|
||||
["Anstellungs-/Beschäftigungsart", anzeige(draft.mitarbeiterart)],
|
||||
["Kollektivvertrag", draft.collectiveAgreement],
|
||||
["C-Level", cLevelText(draft.cLevel) || "–"],
|
||||
["C-Level", draft.cLevel || "–"],
|
||||
["Arbeitstage", draft.workDays.join(", ") || "–"],
|
||||
["Merkmale", flags.length > 0 ? flags.join(", ") : "–"],
|
||||
];
|
||||
|
||||
@@ -54,7 +54,7 @@ export function UebernahmeWizard({
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
employee: EmployeeRow;
|
||||
locations: { id: string; name: string; country: string }[];
|
||||
locations: { id: string; name: string; country: string; parent_id: string | null }[];
|
||||
}) {
|
||||
const { showToast } = useToast();
|
||||
const router = useRouter();
|
||||
|
||||
Reference in New Issue
Block a user