Deal with boolean values for argument

This commit is contained in:
Antoine Nguyen
2024-06-22 19:44:47 +02:00
committed by Spitfireap
parent 5cb0f561f5
commit 39720bb44a
2 changed files with 13 additions and 7 deletions
+12 -2
View File
@@ -107,6 +107,8 @@
v-if="arg.type === 'boolean'"
v-model="action.args[arg.name]"
:label="arg.label"
color="primary"
:value="arg.value"
/>
</template>
</div>
@@ -265,12 +267,20 @@ async function submit() {
return
}
let msg
const data = JSON.parse(JSON.stringify(form.value))
for (const action of data.actions) {
for (const [key, value] of Object.entries(action.args)) {
if (typeof value === 'boolean' && !value) {
delete action.args[key]
}
}
}
try {
if (!props.filter) {
await accountApi.createFilter(props.filterSet, form.value)
await accountApi.createFilter(props.filterSet, data)
msg = $gettext('Filter added')
} else {
await accountApi.updateFilter(props.filterSet, originalFilterName, form.value)
await accountApi.updateFilter(props.filterSet, originalFilterName, data)
msg = $gettext('Filter updated')
}
} catch (err) {
+1 -5
View File
@@ -85,11 +85,7 @@ class FilterSerializer(serializers.Serializer):
for argtpl in tpl.get("args", []):
if argtpl["name"] not in c:
continue
value = c[argtpl["name"]]
if argtpl["type"] == "boolean":
value = True if value else False
else:
value = value.strip('"')
value = c[argtpl["name"]].strip('"')
action["args"][argtpl["name"]] = value
item["actions"] += [action]
result.append(item)