Skip to content

Commit 43fcae2

Browse files
authored
Merge pull request #25 from redlink-gmbh/MORE-Platform#420-bug-fixes-question-observation
MORE-Platform#430: fix fe bugs for question observations
2 parents c2c1f55 + e117094 commit 43fcae2

4 files changed

Lines changed: 27 additions & 17 deletions

File tree

src/components/dialog/shared/StringListPropertyInput.vue

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Prevention -- A research institute of the Ludwig Boltzmann Gesellschaft,
44
Oesterreichische Vereinigung zur Foerderung der wissenschaftlichen Forschung).
55
Licensed under the Elastic License 2.0. */
66
<script setup lang="ts">
7-
import { StringListProperty } from '../../../models/InputModels';
8-
import { PropType, watch } from 'vue';
7+
import { StringListProperty } from '@/models/InputModels';
8+
import { PropType, ref, watch } from 'vue';
99
import InputText from 'primevue/inputtext';
1010
import { useI18n } from 'vue-i18n';
1111
import PartOfTemplateBadge from './PartOfTemplateBadge.vue';
@@ -27,10 +27,17 @@ Licensed under the Elastic License 2.0. */
2727
},
2828
});
2929
30-
const update = (event: KeyboardEvent, index: number): void => {
31-
if (props.property.value) {
32-
props.property.value[index] = (event.target as HTMLInputElement).value;
33-
}
30+
const inputValues = ref<string[]>(
31+
Array.from(
32+
{ length: props.property.maxSize },
33+
(_, i) => props.property.value?.[i] ?? '',
34+
),
35+
);
36+
37+
const update = (value: string, index: number): void => {
38+
inputValues.value[index] = value;
39+
props.property.value = [...inputValues.value];
40+
emit('onInputChange', props.property);
3441
};
3542
3643
const emit = defineEmits<{
@@ -44,7 +51,7 @@ Licensed under the Elastic License 2.0. */
4451
emit('onInputChange', props.property);
4552
}
4653
},
47-
{ deep: true },
54+
{ deep: true, immediate: true },
4855
);
4956
</script>
5057

@@ -54,22 +61,24 @@ Licensed under the Elastic License 2.0. */
5461
<label>
5562
{{ $t(property.name) }}<span v-if="property.required">*</span>
5663
</label>
57-
<PartOfTemplateBadge :visible="isPartOfTemplate" :component-id="property.id" />
64+
<PartOfTemplateBadge
65+
:visible="isPartOfTemplate"
66+
:component-id="property.id"
67+
/>
5868
</h6>
5969
<div>{{ $t(props.property.description) }}</div>
6070
<div v-if="editable" class="flex w-full flex-col gap-1">
6171
<InputText
62-
v-for="index in property.maxSize"
72+
v-for="(_item, index) in inputValues"
6373
:key="index"
6474
class="w-full"
65-
:class="!editable && property.value?.[index - 1] ? 'w-fit' : 'hidden'"
66-
:value="property.value?.[index - 1]"
75+
:value="inputValues[index]"
6776
type="text"
6877
:required="property.required"
6978
:disabled="!editable || property.immutable"
70-
:placeholder="t('global.labels.option', { value: index })"
79+
:placeholder="t('global.labels.option', { value: index + 1 })"
7180
style="display: block"
72-
@keyup="update($event, index - 1)"
81+
@input="update(($event.target as HTMLInputElement).value, index)"
7382
/>
7483
</div>
7584
<div v-else-if="!editable" class="space-around flex flex-row">

src/i18n/de.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@
607607
},
608608
"showAsTodoItemState": {
609609
"name": "Verpflichtendes Ziel",
610-
"description": "Dies ist ein verpflichtendes Ziel, das von den Teilnehmer:innen abgeschlossen werden muss."
610+
"description": "Wenn aktiviert, wird dieses Ziel in der Aktivitätenliste im Heute-Tab der Applikation angezeigt."
611611
},
612612
"customShowAsTodoItemState": {
613613
"name": "Benutzerdefiniertes verpflichtendes Ziel",

src/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@
607607
},
608608
"showAsTodoItemState": {
609609
"name": "Mendatory Goal",
610-
"description": "This is a mandatory goal that must be completed by the participant."
610+
"description": "When enabled, this goal will be displayed in the activity list of the Today tab in the app."
611611
},
612612
"customShowAsTodoItemState": {
613613
"name": "Custom Mendatory Goal",

src/utils/setPlaceholderText.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export function varifyPlaceholderText(descriptionVar: string, placeholderString: string): string | undefined {
2-
return descriptionVar ? `${descriptionVar.split('.description')[0]}.${placeholderString}` : undefined
1+
export function varifyPlaceholderText(descriptionVar: string, placeholderString: string): string {
2+
const split = descriptionVar.split('.description'); // only now splits when description is part of i18n variable, to ensure correct handling
3+
return descriptionVar && split.length > 1 ? `${split[0]}.${placeholderString}` : descriptionVar
34
}

0 commit comments

Comments
 (0)