Skip to content

Commit

Permalink
fix(nullBoolean): filter display in query if undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
AMontagu committed May 5, 2022
1 parent b66d04f commit f0f6e95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/utils/listPaginatedTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ const isValueDefault = (value: any, param: string, schema?: VDUSFormSchema): boo
let isValueDefault: boolean = value === "";

if (schema && schema[param]) {
// We have a special case for nullBoolean because we can have null value that is not the default
if(schema[param]?.type === "nullBoolean") {
return schema[param].default === extractNullBooleanValue(value, schema[param].default)
}
// if there is a defautl value we change the condition to is non equality
if (typeof(schema[param].default) !== "undefined") {
// We have a special case for nullBoolean because we can have null value that is not the default
if(schema[param]?.type === "nullBoolean") {
return schema[param].default === extractNullBooleanValue(value, schema[param].default)
}
// TODO default value for array need to be stringify ?
if (Array.isArray(value)) {
isValueDefault = isEqual(value, schema[param].default) || !value.length;
Expand Down
6 changes: 3 additions & 3 deletions vue3-example/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default defineComponent({
// --------------------- DATA ------------------------------------
const form = ref<GenericDictionnary>({
search: "",
is_answered: false
is_answered: null
})
const options = ref<VDUSDatatableOptions>({
page: 1,
Expand All @@ -66,7 +66,7 @@ export default defineComponent({
const items = ref<any>([])
const formSchema = ref<VDUSFormSchema>({
is_answered: { type: "nullBoolean", default: false }
is_answered: { type: "nullBoolean" }
})
// --------------------- METHODS ------------------------------------
Expand All @@ -85,7 +85,7 @@ export default defineComponent({
return respondToFilter
})
}
if (typeof queryAsObject.is_answered !== "undefined") {
if (typeof queryAsObject.is_answered !== "undefined" && queryAsObject.is_answered !== null) {
fakeData = fakeData.filter(data => {
return data.is_answered === queryAsObject.is_answered
})
Expand Down

0 comments on commit f0f6e95

Please sign in to comment.