Skip to content

Commit

Permalink
fix(value-mapping): solve value mapping reactivity issue (#5451)
Browse files Browse the repository at this point in the history
Signed-off-by: samuel.park <[email protected]>
  • Loading branch information
piggggggggy authored Jan 7, 2025
1 parent ffb39cc commit 4f8f490
Showing 1 changed file with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,37 @@ const handleUpdateBasedOn = (key: string) => {
keyInfo.value = key;
};
const handleUpdateOperator = (idx: number, operator: 'eq'|'regex') => {
casesInfo.value[idx].operator = operator;
const prevCases = [...casesInfo.value];
casesInfo.value = [
...prevCases.slice(0, idx),
{
...prevCases[idx],
operator,
},
...prevCases.slice(idx + 1),
];
};
const handleUpdatePattern = (idx: number, pattern: string) => {
const prevCases = [...casesInfo.value];
casesInfo.value = [
...prevCases.slice(0, idx),
{
...prevCases[idx],
match: pattern,
},
...prevCases.slice(idx + 1),
];
};
const handleUpdateValue = (idx: number, value: string) => {
const prevCases = [...casesInfo.value];
casesInfo.value = [
...prevCases.slice(0, idx),
{
...prevCases[idx],
value,
},
...prevCases.slice(idx + 1),
];
};
// Update operator options
Expand Down Expand Up @@ -242,17 +272,19 @@ watch(() => state.invalid, (_invalid) => {
required
class="col-span-8"
>
<p-text-input v-model="_case.match"
<p-text-input :value="_case.match"
block
@update:value="handleUpdatePattern(cIdx, $event)"
/>
</p-field-group>
</div>
<p-field-group :label="$t('COMMON.WIDGETS.DATA_TABLE.FORM.VALUE')"
style-type="secondary"
required
>
<p-text-input v-model="_case.value"
<p-text-input :value="_case.value"
block
@update:value="handleUpdateValue(cIdx, $event)"
/>
</p-field-group>
</div>
Expand Down

0 comments on commit 4f8f490

Please sign in to comment.