@@ -4,8 +4,8 @@ Prevention -- A research institute of the Ludwig Boltzmann Gesellschaft,
44Oesterreichische Vereinigung zur Foerderung der wissenschaftlichen Forschung).
55Licensed 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" >
0 commit comments