Skip to content

Commit

Permalink
fix reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Alex-K committed Jun 11, 2024
1 parent d2cab3f commit 0f2c035
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
19 changes: 12 additions & 7 deletions frontend/src/components/messstelle/MessquerschnittForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</template>

<script setup lang="ts">
import { computed, ComputedRef, onMounted, ref, Ref } from "vue";
import { computed, onMounted, ref, Ref, watch } from "vue";
import MessstelleEditDTO from "@/domain/dto/messstelle/MessstelleEditDTO";
import LhmTextField from "@/components/common/LhmTextField.vue";
import MessquerschnittEditDTO from "@/domain/dto/messstelle/MessquerschnittEditDTO";
Expand All @@ -120,13 +120,14 @@ import type { VForm } from "@/util/useVuetify";
const validationUtils = useValidationUtils();
onMounted(validate);
onMounted(() => validate());
interface Props {
height: string;
disabled: boolean;
value: MessstelleEditDTO;
valid: Map<string, boolean>;
reload: boolean;
}
const props = defineProps<Props>();
Expand Down Expand Up @@ -158,11 +159,15 @@ const selectedMessquerschnitt: Ref<MessquerschnittEditDTO> = ref(
editMessstelle.value.messquerschnitte[0]
);
const stadtbezirk: ComputedRef<string> = computed(() => {
return `${editMessstelle.value.stadtbezirkNummer} - ${editMessstelle.value.stadtbezirk}`;
});
function validate() {
if (messquerschnittform.value) messquerschnittform.value.validate();
}
</script>
watch(
() => props.reload,
() => {
selectedMessquerschnitt.value =
editMessstelle.value.messquerschnitte[0];
}
);
</script>
19 changes: 12 additions & 7 deletions frontend/src/components/messstelle/UpdateMessstelleForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<messquerschnitt-form
v-model="messstelleToEdit"
:valid.sync="validMqs"
:reload="reload"
:height="contentHeightVh"
:disabled="isMessstelleReadonly"
/>
Expand All @@ -89,7 +90,7 @@
v-model="messstelleToEdit"
:height="contentHeightVh"
:height-map="mapHeightVh"
:reset-marker="resetMarker"
:reset-marker="reload"
:draggable="!isMessstelleReadonly"
/>
</v-tab-item>
Expand Down Expand Up @@ -139,6 +140,7 @@ interface Props {
value: MessstelleEditDTO;
height: string;
contentHeight: number;
reload: boolean;
}
const props = defineProps<Props>();
Expand Down Expand Up @@ -190,12 +192,15 @@ function cancel(): void {
emits("reload");
}
watch(messstelleToEdit, () => {
messstelleToEdit.value.messquerschnitte.forEach((value) =>
validMqs.value.set(value.mqId, !!value.standort)
);
resetMarker.value = !resetMarker.value;
});
watch(
() => props.reload,
() => {
messstelleToEdit.value.messquerschnitte.forEach((value) =>
validMqs.value.set(value.mqId, !!value.standort)
);
resetMarker.value = !resetMarker.value;
}
);
function areAllFormsValid(): boolean {
const invalidMqs: Array<string> = [];
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/views/MessstelleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
:height="headerHeightVh"
:minheight="headerHeightVh"
show-marker="true"
:reload="reloadMessstelleMap"
:reload="reloadMessstelle"
width="100%"
/>
</v-col>
Expand All @@ -44,6 +44,7 @@
v-model="messstelle"
:height="heightVh"
:content-height="contentHeight"
:reload="reloadMessstelle"
@reload="loadMessstelle"
/>
</v-row>
Expand All @@ -60,7 +61,7 @@ import DefaultObjectCreator from "@/util/DefaultObjectCreator";
import UpdateMessstelleForm from "@/components/messstelle/UpdateMessstelleForm.vue";
import MessstelleEditDTO from "@/domain/dto/messstelle/MessstelleEditDTO";
const reloadMessstelleMap: Ref<boolean> = ref(false);
const reloadMessstelle: Ref<boolean> = ref(false);
const messstelle: Ref<MessstelleEditDTO> = ref(
DefaultObjectCreator.createDefaultMessstelleEditDTO()
);
Expand Down Expand Up @@ -139,7 +140,7 @@ function loadMessstelle(): void {
MessstelleService.getMessstelleToEdit(messstelleId).then(
(messstelleById) => {
messstelle.value = messstelleById;
reloadMessstelleMap.value = !reloadMessstelleMap.value;
reloadMessstelle.value = !reloadMessstelle.value;
}
);
}
Expand Down

0 comments on commit 0f2c035

Please sign in to comment.