Skip to content

Commit 0621217

Browse files
blackb1rdPrachya Saechua
authored andcommitted
fix: improve validation rules and refactor removeSelectedItem method in TaskParamsForm.vue
Signed-off-by: blackb1rd <[email protected]>
1 parent f5f24ff commit 0621217

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

web/src/components/TaskParamsForm.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
:hint="v.description"
2323
v-model="editedEnvironment[v.name]"
2424
:required="v.required"
25-
:rules="[(val) => !v.required || val != null || v.title + ' ' + $t('isRequired')]"
25+
:rules="[
26+
(val) => !v.required || val != null || v.title + ' ' + $t('isRequired'),
27+
]"
2628
:items="v.values"
2729
item-text="name"
2830
item-value="value"
@@ -32,8 +34,13 @@
3234
dense
3335
>
3436
<template v-slot:selection="{ item, index }">
35-
<v-chip v-if="v.type === 'select'" small close @click:close="removeSelectedItem(v.name, index)"
36-
>{{ item.name || item }}
37+
<v-chip
38+
v-if="v.type === 'select'"
39+
small
40+
close
41+
@click:close="removeSelectedItem(v.name, index)"
42+
>
43+
{{ item.name || item }}
3744
</v-chip>
3845
</template>
3946
</v-select>
@@ -346,13 +353,15 @@ export default {
346353
},
347354
348355
removeSelectedItem(varName, index) {
349-
if (!Object.prototype.hasOwnProperty.call(this.editedEnvironment, varName) || !Array.isArray(this.editedEnvironment[varName])) {
356+
const env = this.editedEnvironment;
357+
if (!Object.prototype.hasOwnProperty.call(env, varName) || !Array.isArray(env[varName])) {
350358
// Optionally, log a warning for debugging:
351359
// console.warn(`removeSelectedItem: '${varName}' is not a valid array key in editedEnvironment.`);
352360
return;
353361
}
354-
if (index < this.editedEnvironment[varName].length) {
355-
this.editedEnvironment[varName].splice(index, 1);
362+
363+
if (index < env[varName].length) {
364+
env[varName].splice(index, 1);
356365
}
357366
},
358367
},

0 commit comments

Comments
 (0)