Skip to content

Commit

Permalink
Mdas 516 sst management c optimierung frontend (#62)
Browse files Browse the repository at this point in the history
* ♻️ Eingabe GueltigBis Datum nicht mehr verpflichtend.

* ♻️ Eingabe GueltigBis Datum nicht mehr verpflichtend.

* ♻️ Tooltips for list elements and Email format check implemented. Additional check date gueltigAb <= gueltigBis implemented in the frontend.

* ♻️ Uniform naming cancel button. Back button to navigate to interface overview implemented. Width Zugewiesene Personen refactored/formated.

* ♻️ Uniform naming cancel button. Back button to navigate to interface overview implemented. Width Zugewiesene Personen refactored/formated.

* ♻️ Mark expired assignments. Set Anlage-/Aenderungsdatum readonly and remove tooltip.

* ♻️ Fixing  linter errors.

* Release notes complemented

* ♻️ Review notes refactored

* ♻️ More review notes refactored
  • Loading branch information
sfi2022 authored Oct 7, 2024
1 parent b3342e7 commit e628f14
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 85 deletions.
10 changes: 10 additions & 0 deletions docs/src/releasenotes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
## Sprint 17 (10.09.2024 - 01.10.2024)
## Hinzugefügt
- Vue 3 und Vuetify 3 Hebung
- SST-Management Optimierung (Frontend)
- Keine Eingabe GueltigBis Datum
- Tooltip
- Prüfung EMail Format
- Spaltenbreite
- Zurück Springen
- Abgelaufene Personen markieren
- Einheitliche Bennenung Abbrechen Button
- Anzeige Anlage-, Aenderungsdatum
- Prüfung GueltigAb < GueltigBis Datum

## Sprint 15 (30.07.2024 - 20.08.2024)
## Hinzugefügt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ public class Zuordnung extends BaseEntity {
@FutureOrPresent
private LocalDate gueltigAb;

@Column(nullable = false)
@NotNull
@FutureOrPresent
private LocalDate gueltigBis;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ public class ZuordnungCreateDTO {
private String funktionsadresse;
@NotNull
private LocalDate gueltigAb;
@NotNull
private LocalDate gueltigBis;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ public class ZuordnungDTO {
private String funktionsadresse;
@NotNull
private LocalDate gueltigAb;
@NotNull
private LocalDate gueltigBis;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
import de.muenchen.mobidam.service.ZuordnungService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.*;
import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -71,7 +68,8 @@ public ResponseEntity<Iterable<ZuordnungDTO>> getAllById(@PathVariable String id
List<ZuordnungDTO> personDTOList = new ArrayList<>();
zuordnungService.getAllById(id)
.forEach(task -> personDTOList.add(zuordnungMapper.toDTO(task)));
personDTOList.sort(Comparator.comparing(ZuordnungDTO::getGueltigBis));
personDTOList.sort(
Comparator.comparing(ZuordnungDTO::getGueltigBis, Comparator.nullsLast(Comparator.naturalOrder())).thenComparing(ZuordnungDTO::getGueltigAb));
return new ResponseEntity<>(personDTOList, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public boolean isValid(final Object o, final ConstraintValidatorContext constrai

final Method endDateGetter = o.getClass().getMethod(endDateFieldName);
final LocalDate endDate = (LocalDate) endDateGetter.invoke(o);
if (startDate != null && endDate == null)
return true;
if (endDate.isBefore(startDate)) {
throw new ValidationException(message);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,30 @@ void testSave() {
assertEquals(original, persisted);
}

@Test
@Transactional(propagation = Propagation.REQUIRED, noRollbackFor = Exception.class)
void testSaveGueltigBisNull() {

// initialize
Zuordnung original = new Zuordnung();
Schnittstelle schnittstelle = new Schnittstelle();
schnittstelle.setName("test");
schnittstelle.setAnlagedatum(LocalDate.now());
schnittstelle.setStatus(SchnittstellenStatus.AKTIVIERT);
schnittstelle.setId(UUID.randomUUID());
original.setSchnittstelle(schnittstelle);
original.setBenutzerkennung(UUID.randomUUID().toString());
original.setFachbereich("dep");
original.setFunktionsadresse("adr");
original.setGueltigAb(LocalDate.now());

// persist
original = repository.save(original);

// check
Zuordnung persisted = repository.findById(original.getId()).orElse(null);
assertNotNull(persisted);
assertEquals(original, persisted);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ void testIsValidWithValidObjects() {
}

@Test
void testIsValidWithInvalidObjectThrowingExceptionInValidator() {
void testIsValidWithValidObjectsEndDateNull() {
final LocalDate startDate = LocalDate.now();
final LocalDate endDate = null;

final TestClass testObject = new TestClass(
startDate,
endDate);

assertThrows(Exception.class, () -> validator.validate(testObject));
assertTrue(validator.validate(testObject).isEmpty());
}

@Test
Expand Down
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,12 +61,13 @@
<v-text-field
ref="address"
v-model="zuordnung.funktionsadresse"
label="Funktionsadresse"
hint="Welchem Gruppenpostfach gehört diese Person an?"
label="Funktionspostfach"
hint="Wie lautet das Funktionspostfach?"
placeholder="[Ändere mich]@muenchen.de"
:counter="textMaxLength"
:maxlength="textMaxLength"
:minlength="textMinLength"
:rules="textInputRules"
:rules="emailInputRules"
></v-text-field>
&nbsp;
<v-row>
Expand Down Expand Up @@ -112,8 +113,15 @@
label="Gültig bis"
readonly
variant="outlined"
:rules="textInputRules"
clearable
v-bind="props"
:rules="[
validationRules.isGueltigAbBeforeGueltigBis(
zuordnung.gueltigAb,
zuordnung.gueltigBis,
'Gültig-ab muss kleiner gleich Gültig-bis sein.'
),
]"
@click="gueltigBisMenu = true"
></v-text-field>
</template>
Expand All @@ -124,7 +132,7 @@
color="primary"
header-color="primary"
:min="today"
@update:model-value="updateGueltiBis"
@update:model-value="updateGueltigBis"
>
</v-date-picker>
</v-locale-provider>
Expand All @@ -134,7 +142,7 @@
&nbsp;
<v-divider class="divider"></v-divider>
<v-card-actions>
<v-btn @click="closeDialog">Schließen</v-btn>
<v-btn @click="closeDialog">Abbrechen</v-btn>
<v-spacer></v-spacer>
<v-btn
class="text-white"
Expand Down Expand Up @@ -170,6 +178,10 @@ const textInputRules = [
" Zeichen lang sein."
),
];
const emailInputRules = textInputRules.concat([
validationRules.isValidEmail("Kein gültiges EMail Format."),
]);

const gueltigBisMenu = ref(false);
const gueltigBis = ref(new Date());
const gueltigAbMenu = ref(false);
Expand Down Expand Up @@ -209,7 +221,7 @@ function closeDialog() {
form.value?.reset();
}

function updateGueltiBis(date: Date) {
function updateGueltigBis(date: Date) {
gueltigBisMenu.value = false;
zuordnung.value.gueltigBis = formatDate(date.toLocaleDateString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@
v-for="zuordnung in mutableZuordnungen"
:key="zuordnung.benutzerkennung"
closable
style="margin-right: 1%"
:style="[
'margin-right: 1%',
validationRules.isExpired(
zuordnung.gueltigBis
)
? { color: 'red' }
: {},
]"
@click:close="removeZuordnung(zuordnung)"
>
{{ zuordnung.benutzerkennung }}
Expand Down
39 changes: 34 additions & 5 deletions mobidam-sst-management-frontend/frontend/src/composables/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,48 @@ export function useRules() {
(value && value.length <= length) || message;
}

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

function notEmptyRule(message = "error") {
function isValidEmail(message = "error") {
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return (value: string | null | undefined) =>
(value && value.trim() != "") || message;
(value && emailPattern.test(value.trim())) || message;
}

function isExpired(toDate: string | undefined) {
if (!toDate) {
return false;
}
const today = new Date();
const to = new Date(toDate);
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,
isExpired,
isGueltigAbBeforeGueltigBis,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Zuordnung {
public fachbereich: string,
public funktionsadresse: string,
public gueltigAb: string,
public gueltigBis: string,
public gueltigBis?: string,
public id?: string
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
<v-tooltip location="top">
<template #activator="{ props }">
<v-col
cols="2"
cols="3"
md="3"
v-bind="props"
>
{{ schnittstelle.name }}
Expand Down
Loading

0 comments on commit e628f14

Please sign in to comment.