Skip to content

Commit 2d02b41

Browse files
committed
MORE-Platform#428: fix emits for propertyInputs, so intervention dialog gets correct values
1 parent 7e22819 commit 2d02b41

9 files changed

Lines changed: 109 additions & 100 deletions

src/components/dialog/InterventionDialog.vue

Lines changed: 84 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,22 @@ Licensed under the Elastic License 2.0. */
4343
const triggerData: Trigger = dialogRef.value.data?.triggerData;
4444
const groupStates: MoreTableChoice[] =
4545
dialogRef.value.data?.groupStates || [];
46-
const observationGroupStates: MoreTableChoice[] = observationGroupStore.observationGroups.map(
47-
(observationGroup) =>
48-
({
49-
label: observationGroup.title,
50-
value: observationGroup.observationGroupId?.toString(),
51-
}) as MoreTableChoice,
52-
);
46+
const observationGroupStates: MoreTableChoice[] =
47+
observationGroupStore.observationGroups.map(
48+
(observationGroup) =>
49+
({
50+
label: observationGroup.title,
51+
value: observationGroup.observationGroupId?.toString(),
52+
}) as MoreTableChoice,
53+
);
5354
const groupPlaceholder =
5455
dialogRef.value.data?.groupPlaceholder ||
5556
t('global.placeholder.entireStudy');
5657
const actionFactories = dialogRef.value.data?.actionFactories;
5758
const triggerFactories = dialogRef.value.data?.triggerFactories;
5859
const selectedObservationGroups = ref(
59-
intervention.observationGroupIds?.map((id: number) => id.toString()) ?? []
60-
)
60+
intervention.observationGroupIds?.map((id: number) => id.toString()) ?? [],
61+
);
6162
6263
let propInputError: string = '';
6364
@@ -244,7 +245,11 @@ Licensed under the Elastic License 2.0. */
244245
trigger: {},
245246
actions: [],
246247
studyGroupId: studyGroupId.value,
247-
observationGroupIds: selectedObservationGroups.value?.length ? selectedObservationGroups.value.map((id: string) => parseInt(id)) : [],
248+
observationGroupIds: selectedObservationGroups.value?.length
249+
? selectedObservationGroups.value.map((id: string) =>
250+
parseInt(id),
251+
)
252+
: [],
248253
schedule: intervention.schedule,
249254
} as Intervention;
250255
@@ -394,7 +399,7 @@ Licensed under the Elastic License 2.0. */
394399
:class="{ 'gap-y-2': !editable }"
395400
@submit.prevent="save()"
396401
>
397-
<div class="col-start-0 col-span-8 mt-2" :class="{ 'pb-4': !editable }">
402+
<div class="col-span-8 col-start-0 mt-2" :class="{ 'pb-4': !editable }">
398403
<h5>{{ $t('intervention.dialog.label.interventionTitle') }}*</h5>
399404
<div v-if="getError('title')" class="error error-label col-span-8 mb-2">
400405
{{ getError('title') }}
@@ -409,7 +414,7 @@ Licensed under the Elastic License 2.0. */
409414
></InputText>
410415
</div>
411416

412-
<div class="col-start-0 col-span-8">
417+
<div class="col-span-8 col-start-0">
413418
<h5 class="mb-2">{{ $t('study.props.purpose') }}</h5>
414419
<Textarea
415420
v-model="purpose"
@@ -420,7 +425,7 @@ Licensed under the Elastic License 2.0. */
420425
></Textarea>
421426
</div>
422427
<div
423-
class="section-group col-start-0 col-span-8 mt-4 grid grid-cols-2 items-end lg:grid-cols-3"
428+
class="section-group col-span-8 col-start-0 mt-4 grid grid-cols-2 items-end lg:grid-cols-3"
424429
>
425430
<h5 class="col-span-2">{{ $t('intervention.props.trigger') }}*</h5>
426431
<div class="col-span-3 col-start-3" :class="{ 'text-end': !editable }">
@@ -467,7 +472,7 @@ Licensed under the Elastic License 2.0. */
467472
>
468473
{{ getTriggerTypeDescription(triggerType) }}
469474
</div>
470-
<div class="col-start-0 col-span-3">
475+
<div class="col-span-3 col-start-0">
471476
<div v-if="triggerJsonError && editable" class="error mb-4">
472477
{{ triggerJsonError }}
473478
</div>
@@ -488,7 +493,7 @@ Licensed under the Elastic License 2.0. */
488493
</div>
489494
</div>
490495

491-
<div class="section-group col-start-0 col-span-8 mt-8 grid grid-cols-9">
496+
<div class="section-group col-span-8 col-start-0 mt-8 grid grid-cols-9">
492497
<div class="col-span-9 grid grid-cols-2 items-end lg:grid-cols-3">
493498
<h5 class="lg:col-span-2">{{ $t('intervention.props.action') }}*</h5>
494499
<Button
@@ -528,7 +533,7 @@ Licensed under the Elastic License 2.0. */
528533
<div
529534
v-for="(action, index) in actionsArray"
530535
:key="index"
531-
class="col-start-0 js-action col-span-9"
536+
class="js-action col-span-9 col-start-0"
532537
:class="{ 'mb-4': index < actionsArray.length - 1 }"
533538
>
534539
<hr v-if="index !== 0" class="my-4" />
@@ -570,38 +575,46 @@ Licensed under the Elastic License 2.0. */
570575
</div>
571576
</div>
572577

573-
<div class="col-start-0 col-span-8">
578+
<div class="col-span-8 col-start-0">
574579
<h5 v-if="editable" class="pb-2 font-bold">
575-
{{ editable ? $t('study.dialog.label.chooseGroups') : $t('study.props.groups') }}
580+
{{
581+
editable
582+
? $t('study.dialog.label.chooseGroups')
583+
: $t('study.props.groups')
584+
}}
576585
</h5>
577586
<div v-if="editable" class="mb-2">
578-
{{ $t('study.dialog.description.howToCreateGroups', {for: $t('intervention.plural')}) }}
587+
{{
588+
$t('study.dialog.description.howToCreateGroups', {
589+
for: $t('intervention.plural'),
590+
})
591+
}}
579592
</div>
580593
<div class="flex gap-5">
581-
<div>
582-
<div class="mb-1">{{ $t('studyGroup.plural')}}</div>
594+
<div>
595+
<div class="mb-1">{{ $t('studyGroup.plural') }}</div>
583596
<Dropdown
584-
v-model="studyGroupId"
585-
:options="groupStates"
586-
option-label="label"
587-
option-value="value"
588-
:disabled="!editable"
589-
class="w-fit"
590-
:class="{ 'dropdown-has-value': studyGroupId }"
591-
:placeholder="
592-
studyGroupId
593-
? getLabelForChoiceValue(studyGroupId as number, groupStates)
594-
: groupPlaceholder
595-
? (groupPlaceholder as string)
596-
: $t('global.placeholder.entireStudy')
597-
"
598-
>
599-
<template #option="optionProps">
600-
<div class="p-select-car-option">
601-
<span>{{ optionProps.option.label }}</span>
602-
</div>
603-
</template>
604-
</Dropdown>
597+
v-model="studyGroupId"
598+
:options="groupStates"
599+
option-label="label"
600+
option-value="value"
601+
:disabled="!editable"
602+
class="w-fit"
603+
:class="{ 'dropdown-has-value': studyGroupId }"
604+
:placeholder="
605+
studyGroupId
606+
? getLabelForChoiceValue(studyGroupId as number, groupStates)
607+
: groupPlaceholder
608+
? (groupPlaceholder as string)
609+
: $t('global.placeholder.entireStudy')
610+
"
611+
>
612+
<template #option="optionProps">
613+
<div class="p-select-car-option">
614+
<span>{{ optionProps.option.label }}</span>
615+
</div>
616+
</template>
617+
</Dropdown>
605618
</div>
606619
<div>
607620
<div class="mb-1">{{ $t('observationGroup.plural') }}</div>
@@ -611,27 +624,35 @@ Licensed under the Elastic License 2.0. */
611624
:disabled="!editable"
612625
option-label="label"
613626
option-value="value"
614-
:placeholder="$t('global.placeholder.chooseDropdownOptionDefault')"
627+
:placeholder="
628+
$t('global.placeholder.chooseDropdownOptionDefault')
629+
"
615630
:show-toggle-all="false"
616631
class="z-top custom-multiselect-root"
617632
:panel-class="'custom-multiselect-panel'"
618633
>
619634
<template #value="{ value }">
620-
<span v-if="value?.length > 0">{{ value.map((item: string) => observationGroupStates.find(
621-
(group: MoreTableChoice) => group.value === item
622-
)?.label).join(', ') }}</span>
635+
<span v-if="value?.length > 0">{{
636+
value
637+
.map(
638+
(item: string) =>
639+
observationGroupStates.find(
640+
(group: MoreTableChoice) => group.value === item,
641+
)?.label,
642+
)
643+
.join(', ')
644+
}}</span>
623645
<span v-else class="text-gray-400">
624-
{{ $t('global.placeholder.chooseDropdownOptionDefault') }}
625-
</span>
646+
{{ $t('global.placeholder.chooseDropdownOptionDefault') }}
647+
</span>
626648
</template>
627-
628649
</MultiSelect>
629650
</div>
630651
</div>
631652
</div>
632653

633654
<div
634-
class="col-start-0 buttons col-span-8 mt-1 flex flex-row items-center justify-end text-right"
655+
class="buttons col-span-8 col-start-0 mt-1 flex flex-row items-center justify-end text-right"
635656
>
636657
<Button class="btn-gray" @click="cancel()">
637658
<span v-if="editable">{{ $t('global.labels.cancel') }}</span>
@@ -650,22 +671,22 @@ Licensed under the Elastic License 2.0. */
650671
</template>
651672

652673
<style scoped>
653-
@import '../../styles/components/moreTable-dialogs.css';
674+
@import '../../styles/components/moreTable-dialogs.css';
654675
655-
:deep(.dropdown-btn .p-select-label) {
656-
color: white!important;
657-
}
676+
:deep(.dropdown-btn .p-select-label) {
677+
color: white !important;
678+
}
658679
659-
.dropdown-btn {
660-
background-color: var(--primary-color);
661-
color: white;
662-
:deep(.p-select-label),
663-
:deep(.p-select-trigger-icon) {
680+
.dropdown-btn {
681+
background-color: var(--primary-color);
664682
color: white;
683+
:deep(.p-select-label),
684+
:deep(.p-select-trigger-icon) {
685+
color: white;
686+
}
665687
}
666-
}
667688
668-
.dialog #interventionDialogForm .section-group .section-content {
669-
border: 1px solid var(--bluegray-50);
670-
}
689+
.dialog #interventionDialogForm .section-group .section-content {
690+
border: 1px solid var(--bluegray-50);
691+
}
671692
</style>

src/components/dialog/shared/BooleanPropertyInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ Licensed under the Elastic License 2.0. */
3131
watch(
3232
() => props.property.value,
3333
() => {
34-
if (props.isPartOfTemplate) {
35-
emit('onBooleanChange', props.property.value);
36-
}
34+
emit('onBooleanChange', props.property.value);
3735
},
3836
);
3937
</script>

src/components/dialog/shared/IntegerPropertyInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ Licensed under the Elastic License 2.0. */
3636
watch(
3737
() => props.property.value,
3838
() => {
39-
if (props.isPartOfTemplate) {
40-
emit('onInputChange', props.property);
41-
}
39+
emit('onInputChange', props.property);
4240
},
4341
);
4442
</script>

src/components/dialog/shared/IntegerRangePropertyInput.vue

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,34 @@
3636
watch(
3737
() => props.property.value?.lower,
3838
(newLower) => {
39-
if (
40-
newLower !== undefined &&
41-
newLower !== null &&
42-
props.property.value?.upper !== undefined &&
43-
props.property.value.upper !== null
44-
) {
45-
if (newLower > props.property.value.upper) {
46-
props.property.value.upper = newLower;
39+
if (newLower !== undefined && newLower !== null) {
40+
if (
41+
props.property.value?.upper !== undefined &&
42+
props.property.value.upper !== null
43+
) {
44+
if (newLower > props.property.value.upper) {
45+
props.property.value.upper = newLower;
46+
}
4747
}
4848
}
49-
if (props.isPartOfTemplate) {
50-
emit('onInputChange', props.property);
51-
}
49+
emit('onInputChange', props.property);
5250
},
5351
);
5452
5553
watch(
5654
() => props.property.value?.upper,
5755
(newUpper) => {
58-
if (
59-
newUpper !== undefined &&
60-
newUpper !== null &&
61-
props.property.value?.lower !== undefined &&
62-
props.property.value.lower !== null
63-
) {
64-
if (newUpper < props.property.value.lower) {
65-
props.property.value.lower = newUpper;
56+
if (newUpper !== undefined && newUpper !== null) {
57+
if (
58+
props.property.value?.lower !== undefined &&
59+
props.property.value.lower !== null
60+
) {
61+
if (newUpper < props.property.value.lower) {
62+
props.property.value.lower = newUpper;
63+
}
6664
}
6765
}
68-
if (props.isPartOfTemplate) {
69-
emit('onInputChange', props.property);
70-
}
66+
emit('onInputChange', props.property);
7167
},
7268
);
7369
</script>

src/components/dialog/shared/StringListPropertyInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ Licensed under the Elastic License 2.0. */
4747
watch(
4848
() => props.property.value,
4949
() => {
50-
if (props.isPartOfTemplate) {
51-
emit('onInputChange', props.property);
52-
}
50+
emit('onInputChange', props.property);
5351
},
5452
{ deep: true, immediate: true },
5553
);

src/components/dialog/shared/StringPropertyInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ Licensed under the Elastic License 2.0. */
4040
watch(
4141
() => props.property.value,
4242
() => {
43-
if (props.isPartOfTemplate) {
44-
emit('onInputChange', props.property);
45-
}
43+
emit('onInputChange', props.property);
4644
},
4745
);
4846
</script>

src/components/dialog/shared/StringTextPropertyInput.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ Licensed under the Elastic License 2.0. */
4343
watch(
4444
() => props.property.value,
4545
() => {
46-
if (props.isPartOfTemplate) {
47-
emit('onInputChange', props.property);
48-
}
46+
emit('onInputChange', props.property);
4947
},
5048
);
5149
</script>

src/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
"emptyTriggerConditions": "Bitte fügen Sie mindesetens eine Auslöserkondition zu ihrem Trigger hinzu.",
268268
"interventionRowIsOpen": "Bitte speichern Sie alle Konfigurationszeilen, bevor Sie die Intervention speichern.",
269269
"triggerProp": "Ein Trigger-Property hat einen Fehler.",
270+
"actionProp": "Ein Action-Property hat einen Fehler.",
270271
"observationDeleted": "Die verlinkte Datenerhebung (ID: {observationId}, Type: {observationType}) wurde gelöscht und kann nicht mehr referenziert werden. Bitte verlinke eine andere Datenerhebung, entferne diese Aktion oder lösche die Intervention komplett. Beachte, dass eine Intervention stets mindestens eine Aktion enthalten muss."
271272
},
272273
"factory": {

src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
"emptyTriggerConditions": "Please save at least one trigger condition to your trigger.",
268268
"interventionRowIsOpen": "Please save all trigger conditions before saving the intervention.",
269269
"triggerProp": "A Trigger property has an error.",
270+
"actionProp": "An Action property has an error.",
270271
"observationDeleted": "The linked observation (ID: {observationId}, Type: {observationType}) has been deleted and cannot be referenced. Please link a different data collection, remove this action or delete the intervention completely. Keep in mind that an intervention always requires at least one action."
271272
},
272273
"factory": {

0 commit comments

Comments
 (0)