query builder boolean (0/1)

This commit is contained in:
Julian Krauser 2024-12-18 12:55:24 +01:00
parent 761d998edc
commit 8f4731e08a

View file

@ -24,15 +24,25 @@
:value="(value as any)?.start" :value="(value as any)?.start"
@input="(e) => ((value as any).start = (e.target as HTMLInputElement).value)" @input="(e) => ((value as any).start = (e.target as HTMLInputElement).value)"
:type="inputType" :type="inputType"
:min="columnType == 'boolean' ? 0 : undefined"
:max="columnType == 'boolean' ? 1 : undefined"
/> />
<p>-</p> <p>-</p>
<input <input
:value="(value as any)?.end" :value="(value as any)?.end"
@input="(e) => ((value as any).end = (e.target as HTMLInputElement).value)" @input="(e) => ((value as any).end = (e.target as HTMLInputElement).value)"
:type="inputType" :type="inputType"
:min="columnType == 'boolean' ? 0 : undefined"
:max="columnType == 'boolean' ? 1 : undefined"
/> />
</div> </div>
<input v-else v-model="value" :type="inputType" /> <input
v-else
v-model="value"
:type="inputType"
:min="columnType == 'boolean' ? 0 : undefined"
:max="columnType == 'boolean' ? 1 : undefined"
/>
</div> </div>
<div class="p-1 border border-gray-400 hover:bg-gray-200 rounded-md" @click="$emit('remove')"> <div class="p-1 border border-gray-400 hover:bg-gray-200 rounded-md" @click="$emit('remove')">
@ -79,16 +89,20 @@ export default defineComponent({
foreignColumns() { foreignColumns() {
return this.activeTable?.relations.map((r) => r.column); return this.activeTable?.relations.map((r) => r.column);
}, },
columnType() {
return this.activeTable?.columns.find((c) => c.column == this.column)?.type;
},
inputType() { inputType() {
let type = this.activeTable?.columns.find((c) => c.column == this.column)?.type;
if (this.operation.includes("timespan")) return "number"; if (this.operation.includes("timespan")) return "number";
switch (type) { switch (this.columnType) {
case "int": case "int":
return "number"; return "number";
case "varchar": case "varchar":
return "text"; return "text";
case "date": case "date":
return "date"; return "date";
case "boolean":
return "number"; // "checkbox";
default: default:
return "text"; return "text";
} }