Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,20 @@ const activeZaehlung = computed<LadeZaehlungDTO>(() => {
return zaehlstelleStore.getAktiveZaehlung;
});

const isTeilzaehlungFussverkehr = computed(() => {
return (activeZaehlung.value.kategorien.length === 1 &&
activeZaehlung.value.kategorien[0] === Fahrzeug.FUSS &&
activeZaehlung.value.zaehldauer != Zaehldauer.DAUER_24_STUNDEN);
});

/**
* Setzt die Default-Einstellungen für das Optionsmenü je nach Zählung
*/
function setDefaultOptionsForZaehlung() {
const optionsCopy = {} as ZaehlstelleOptionsDTO;
Object.assign(optionsCopy, options.value);

if (activeZaehlung.value.zaehldauer === Zaehldauer.DAUER_13_STUNDEN) {
if (activeZaehlung.value.zaehldauer === Zaehldauer.DAUER_13_STUNDEN || isTeilzaehlungFussverkehr.value) {
optionsCopy.zeitauswahl = Zeitauswahl.BLOCK;
optionsCopy.zeitblock = Zeitblock.ZB_06_19;
}
Expand Down Expand Up @@ -192,11 +198,17 @@ function setDefaultOptionsForZaehlung() {
optionsCopy.gueterverkehrsanteilProzent = true;
break;
case Fahrzeug.RAD:
// Rad soll nur bei reinen Radzählungen aktiviert sein
optionsCopy.radverkehr = ["R", "QR"].includes(
// Rad soll nur bei best. Zählarten aktiviert sein
optionsCopy.radverkehr = [Zaehlart.R, Zaehlart.QR, Zaehlart.FJS, Zaehlart.QU, Zaehlart.QJS].includes(
activeZaehlung.value.zaehlart
);
break;
case Fahrzeug.FUSS:
// Fuss soll nur bei Zählarten FjS, Qu, QjS aktiviert sein
optionsCopy.fussverkehr = [Zaehlart.FJS, Zaehlart.QU, Zaehlart.QJS].includes(
activeZaehlung.value.zaehlart
);
break;
}
});
optionsCopy.beideRichtungen = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
start
icon="mdi-car-multiple"
/>
Fahrzeuge
Verkehrsarten & Fahrzeuge
</div>
</v-expansion-panel-title>
<v-expansion-panel-text class="mt-1">
Expand Down Expand Up @@ -256,7 +256,7 @@
<v-col cols="6">
<v-checkbox
v-model="chosenOptionsCopy.fussverkehr"
:label="'Fußgänger (Fuß)'"
:label="'Fußverkehr'"
:hint="getHintToDisplay('FUSS')"
:color="getCheckboxColor('FUSS')"
:persistent-hint="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<v-radio
label="Tageswert"
:value="Zeitauswahl.TAGESWERT"
:disabled="isTeilzaehlungFussverkehr || isOnlyFussgaengerSelected"
@mouseover="hoverTageswert = true"
@mouseleave="hoverTageswert = false"
/>
Expand Down Expand Up @@ -162,7 +163,7 @@ import type LadeZaehlungDTO from "@/types/zaehlung/LadeZaehlungDTO";
import type ZaehlstelleOptionsDTO from "@/types/zaehlung/ZaehlstelleOptionsDTO";

import { isEmpty } from "lodash";
import { computed, ref } from "vue";
import { computed, ref, watch } from "vue";

import PanelHeader from "@/components/common/PanelHeader.vue";
import { useZaehlstelleStore } from "@/store/ZaehlstelleStore";
Expand All @@ -174,6 +175,7 @@ import ZeitblockStuendlich, {
zeitblockStuendlichInfo,
} from "@/types/enum/ZeitblockStuendlich";
import { useZaehlstelleUtils } from "@/util/ZaehlstelleUtils";
import Fahrzeug from "@/types/enum/Fahrzeug";

const chosenOptionsCopy = defineModel<ZaehlstelleOptionsDTO>({
required: true,
Expand Down Expand Up @@ -325,6 +327,40 @@ const zaehldatenIntervalle = computed<Array<KeyVal>>(() => {
return ZaehldatenIntervallToSelect;
});

const isTeilzaehlungFussverkehr = computed(() => {
return (activeZaehlung.value.kategorien.length === 1 &&
activeZaehlung.value.kategorien[0] === Fahrzeug.FUSS &&
activeZaehlung.value.zaehldauer != Zaehldauer.DAUER_24_STUNDEN);
});

const isOnlyFussgaengerSelected = computed(() => {
return chosenOptionsCopy.value.fussverkehr && !(
chosenOptionsCopy.value.kraftfahrzeugverkehr ||
chosenOptionsCopy.value.schwerverkehr ||
chosenOptionsCopy.value.gueterverkehr ||
chosenOptionsCopy.value.radverkehr ||
chosenOptionsCopy.value.schwerverkehrsanteilProzent ||
chosenOptionsCopy.value.gueterverkehrsanteilProzent);
});

watch(
() => chosenOptionsCopy.value,
() => {
adaptOptionsUpdate();
},
{ deep: true }
);

/**
* Passt die Controls anhand ihrer Abhängigkeiten zu anderen Optionen an.
*/
function adaptOptionsUpdate(){
if (isOnlyFussgaengerSelected.value){
chosenOptionsCopy.value.zeitauswahl = Zeitauswahl.BLOCK;
chosenOptionsCopy.value.zeitblock = Zeitblock.ZB_06_19;
}
}
Comment on lines +346 to +362
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Hardcoded ZB_06_19 in adaptOptionsUpdate may be invalid for certain counting configurations.

adaptOptionsUpdate unconditionally sets zeitblock = Zeitblock.ZB_06_19 whenever only Fußgänger is selected, but ZB_06_19 may not exist in the active counting's zeitblockValues (e.g., a DAUER_2_X_4_STUNDEN or SONSTIGE counting). When the selected zeitblock is not in the dropdown's :items, the v-select will show nothing or an unresolvable value.

A safer approach mirrors what zeitauswahlChanged already does — pick the first entry from zeitblockValues:

🔧 Proposed fix
 function adaptOptionsUpdate(){
   if (isOnlyFussgaengerSelected.value){
     chosenOptionsCopy.value.zeitauswahl = Zeitauswahl.BLOCK;
-    chosenOptionsCopy.value.zeitblock = Zeitblock.ZB_06_19;
+    const preferredBlock = zeitblockValues.value.find(
+      (kv) => kv.value === Zeitblock.ZB_06_19
+    );
+    const firstBlock = zeitblockValues.value[0];
+    chosenOptionsCopy.value.zeitblock =
+      preferredBlock?.value ?? firstBlock?.value ?? Zeitblock.ZB_06_19;
   }
 }

Additionally, the { deep: true } watch on the entire chosenOptionsCopy.value object fires for every property change (including unrelated ones like intervall). Narrowing the watch source to only the relevant fields avoids unnecessary calls and the self-triggered re-run when adaptOptionsUpdate itself mutates the object:

♻️ Targeted watch (optional)
-watch(
-    () => chosenOptionsCopy.value,
-    () => {
-      adaptOptionsUpdate();
-    },
-    { deep: true }
-);
+watch(
+    () => [
+      chosenOptionsCopy.value.fussverkehr,
+      chosenOptionsCopy.value.kraftfahrzeugverkehr,
+      chosenOptionsCopy.value.schwerverkehr,
+      chosenOptionsCopy.value.gueterverkehr,
+      chosenOptionsCopy.value.radverkehr,
+      chosenOptionsCopy.value.schwerverkehrsanteilProzent,
+      chosenOptionsCopy.value.gueterverkehrsanteilProzent,
+    ],
+    adaptOptionsUpdate
+);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
watch(
() => chosenOptionsCopy.value,
() => {
adaptOptionsUpdate();
},
{ deep: true }
);
/**
* Passt die Controls anhand ihrer Abhängigkeiten zu anderen Optionen an.
*/
function adaptOptionsUpdate(){
if (isOnlyFussgaengerSelected.value){
chosenOptionsCopy.value.zeitauswahl = Zeitauswahl.BLOCK;
chosenOptionsCopy.value.zeitblock = Zeitblock.ZB_06_19;
}
}
watch(
() => [
chosenOptionsCopy.value.fussverkehr,
chosenOptionsCopy.value.kraftfahrzeugverkehr,
chosenOptionsCopy.value.schwerverkehr,
chosenOptionsCopy.value.gueterverkehr,
chosenOptionsCopy.value.radverkehr,
chosenOptionsCopy.value.schwerverkehrsanteilProzent,
chosenOptionsCopy.value.gueterverkehrsanteilProzent,
],
adaptOptionsUpdate
);
/**
* Passt die Controls anhand ihrer Abhängigkeiten zu anderen Optionen an.
*/
function adaptOptionsUpdate(){
if (isOnlyFussgaengerSelected.value){
chosenOptionsCopy.value.zeitauswahl = Zeitauswahl.BLOCK;
const preferredBlock = zeitblockValues.value.find(
(kv) => kv.value === Zeitblock.ZB_06_19
);
const firstBlock = zeitblockValues.value[0];
chosenOptionsCopy.value.zeitblock =
preferredBlock?.value ?? firstBlock?.value ?? Zeitblock.ZB_06_19;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/zaehlstelle/optionsmenue/panels/ZeitauswahlPanel.vue`
around lines 346 - 362, adaptOptionsUpdate currently forces
chosenOptionsCopy.value.zeitblock to the hardcoded Zeitblock.ZB_06_19 which can
be invalid; change adaptOptionsUpdate so when isOnlyFussgaengerSelected is true
it sets chosenOptionsCopy.value.zeitauswahl = Zeitauswahl.BLOCK and chooses the
zeitblock from the active counting's zeitblockValues (use the first entry like
zeitauswahlChanged does) instead of the hardcoded constant; also narrow the
watch so it only observes the relevant fields (e.g., isOnlyFussgaengerSelected /
chosenOptionsCopy.value.zeitauswahl or chosenOptionsCopy.value.zeitblock) rather
than deeply watching the whole chosenOptionsCopy object to avoid unnecessary
self-triggered updates.


/**
* Wird der Tageswert gewählt, so gibt es kein Dropdown Menü, da die Ansicht dann immer
* über den kompletten Tag geht. Deshalb muss hier auf das "Change" event der Checkbox
Expand Down