Skip to content

Commit f0f6e95

Browse files
committed
fix(nullBoolean): filter display in query if undefined
1 parent b66d04f commit f0f6e95

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/utils/listPaginatedTools.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ const isValueDefault = (value: any, param: string, schema?: VDUSFormSchema): boo
3232
let isValueDefault: boolean = value === "";
3333

3434
if (schema && schema[param]) {
35-
// We have a special case for nullBoolean because we can have null value that is not the default
36-
if(schema[param]?.type === "nullBoolean") {
37-
return schema[param].default === extractNullBooleanValue(value, schema[param].default)
38-
}
3935
// if there is a defautl value we change the condition to is non equality
4036
if (typeof(schema[param].default) !== "undefined") {
37+
// We have a special case for nullBoolean because we can have null value that is not the default
38+
if(schema[param]?.type === "nullBoolean") {
39+
return schema[param].default === extractNullBooleanValue(value, schema[param].default)
40+
}
4141
// TODO default value for array need to be stringify ?
4242
if (Array.isArray(value)) {
4343
isValueDefault = isEqual(value, schema[param].default) || !value.length;

vue3-example/src/components/HelloWorld.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default defineComponent({
5656
// --------------------- DATA ------------------------------------
5757
const form = ref<GenericDictionnary>({
5858
search: "",
59-
is_answered: false
59+
is_answered: null
6060
})
6161
const options = ref<VDUSDatatableOptions>({
6262
page: 1,
@@ -66,7 +66,7 @@ export default defineComponent({
6666
const items = ref<any>([])
6767
6868
const formSchema = ref<VDUSFormSchema>({
69-
is_answered: { type: "nullBoolean", default: false }
69+
is_answered: { type: "nullBoolean" }
7070
})
7171
7272
// --------------------- METHODS ------------------------------------
@@ -85,7 +85,7 @@ export default defineComponent({
8585
return respondToFilter
8686
})
8787
}
88-
if (typeof queryAsObject.is_answered !== "undefined") {
88+
if (typeof queryAsObject.is_answered !== "undefined" && queryAsObject.is_answered !== null) {
8989
fakeData = fakeData.filter(data => {
9090
return data.is_answered === queryAsObject.is_answered
9191
})

0 commit comments

Comments
 (0)