Skip to content

Commit

Permalink
♻️ Review notes refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
sfi2022 committed Oct 2, 2024
1 parent 89acbee commit cc4018f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class Zuordnung extends BaseEntity {
@FutureOrPresent
private LocalDate gueltigAb;

@FutureOrPresent
private LocalDate gueltigBis;

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<v-text-field
ref="person"
v-model="zuordnung.benutzerkennung"
label="Person angeben"
label="Benutzerkennung"
hint="Welche Person soll der
Schnittstelle zugewiesen werden?"
:rules="textInputRules"
Expand All @@ -61,7 +61,7 @@
<v-text-field
ref="address"
v-model="zuordnung.funktionsadresse"
label="EMail"
label="Funktionspostfach"
hint="Welchem Gruppenpostfach gehört diese Person an?"
placeholder="[Ändere mich]@muenchen.de"
:counter="textMaxLength"
Expand Down Expand Up @@ -116,10 +116,10 @@
clearable
v-bind="props"
:rules="[
isGueltigAbBeforeGueltigBis(
validationRules.isGueltigAbBeforeGueltigBis(
zuordnung.gueltigAb,
zuordnung.gueltigBis,
'Datum ab muss <= Datum bis.'
'Gültig-ab muss kleiner gleich Gültig-bis sein.'
),
]"
@click="gueltigBisMenu = true"
Expand Down Expand Up @@ -208,36 +208,9 @@ const form = ref<VForm>();
async function saveTask() {
// eslint-disable-next-line no-unsafe-optional-chaining
const valid = (await form.value?.validate())?.valid;
{
if (valid) {
if (
isGueltigAbBeforeGueltigBis(
zuordnung.value.gueltigAb,
zuordnung.value.gueltigBis,
"Datum ab muss <= Datum bis."
)
) {
emit("zuordnung-saved", zuordnung.value);
closeDialog();
}
}
}
}

function isGueltigAbBeforeGueltigBis(
fromDate: string,
toDate: string | number | Date | undefined,
message: string
) {
if (!toDate && !fromDate) {
return true;
}
if (!toDate && fromDate) {
return true;
} else {
const to = new Date(toDate ?? "");
const from = new Date(fromDate);
return from <= to || message;
if (valid) {
emit("zuordnung-saved", zuordnung.value);
closeDialog();
}
}

Expand Down
24 changes: 18 additions & 6 deletions mobidam-sst-management-frontend/frontend/src/composables/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ export function useRules() {
(value && value.length <= length) || message;
}

function notEmptyDateRule(message = "error") {
return (value: string | null | undefined) =>
(value && value.trim() != "-") || message;
}

function notEmptyRule(message = "error") {
return (value: string | null | undefined) =>
(value && value.trim() != "") || message;
Expand All @@ -52,11 +47,28 @@ export function useRules() {
return to < today;
}

function isGueltigAbBeforeGueltigBis(
gueltigAb: string,
gueltigBis: string | number | Date | undefined,
message: string
) {
if (!gueltigBis && !gueltigAb) {
return true;
}
if (!gueltigBis && gueltigAb) {
return true;
} else {
const to = new Date(gueltigBis ?? "");
const from = new Date(gueltigAb);
return from <= to || message;
}
}

return {
maxLengthRule,
notEmptyDateRule,
notEmptyRule,
isValidEmail,
isExpiredGueltigBis,
isGueltigAbBeforeGueltigBis,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
{{ zuordnung.funktionsadresse }}</v-col
>
</template>
Gruppenpostfach
Funktionspostfach
</v-tooltip>
<v-tooltip location="top">
<template #activator="{ props }">
Expand Down

0 comments on commit cc4018f

Please sign in to comment.