chore: programmatically convert filter values to snake_case
This commit is contained in:
parent
aac777e286
commit
204e94aa74
2 changed files with 29 additions and 24 deletions
|
@ -45,6 +45,10 @@ export function objectToCamelCase(object) {
|
||||||
*/
|
*/
|
||||||
export function objectToSnakeCase(object) {
|
export function objectToSnakeCase(object) {
|
||||||
|
|
||||||
|
if (object instanceof Date) {
|
||||||
|
return object.toISOString()
|
||||||
|
}
|
||||||
|
|
||||||
// When calling recursively, this can be called without being and object or array in which case we just return the value
|
// When calling recursively, this can be called without being and object or array in which case we just return the value
|
||||||
if (typeof object !== 'object') {
|
if (typeof object !== 'object') {
|
||||||
return object
|
return object
|
||||||
|
|
|
@ -45,21 +45,22 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList.vue'
|
|
||||||
import {useStore} from 'vuex'
|
|
||||||
import {computed, ref, watchEffect} from 'vue'
|
import {computed, ref, watchEffect} from 'vue'
|
||||||
|
import {useStore} from 'vuex'
|
||||||
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
|
import {useI18n} from 'vue-i18n'
|
||||||
|
|
||||||
|
import TaskModel from '@/models/task'
|
||||||
|
import {formatDate} from '@/helpers/time/formatDate'
|
||||||
|
import {setTitle} from '@/helpers/setTitle'
|
||||||
|
import {objectToSnakeCase} from '@/helpers/case'
|
||||||
|
|
||||||
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
|
import Fancycheckbox from '@/components/input/fancycheckbox.vue'
|
||||||
import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
|
import SingleTaskInList from '@/components/tasks/partials/singleTaskInList.vue'
|
||||||
|
|
||||||
import LlamaCool from '@/assets/llama-cool.svg?component'
|
|
||||||
import DatepickerWithRange from '@/components/date/datepickerWithRange.vue'
|
import DatepickerWithRange from '@/components/date/datepickerWithRange.vue'
|
||||||
import TaskModel from '@/models/task'
|
|
||||||
import {useRoute, useRouter} from 'vue-router'
|
|
||||||
import {formatDate} from '@/helpers/time/formatDate'
|
|
||||||
import {useI18n} from 'vue-i18n'
|
|
||||||
import {setTitle} from '@/helpers/setTitle'
|
|
||||||
import {DATE_RANGES} from '@/components/date/dateRanges'
|
import {DATE_RANGES} from '@/components/date/dateRanges'
|
||||||
|
import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
|
||||||
|
import LlamaCool from '@/assets/llama-cool.svg?component'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
@ -179,31 +180,31 @@ async function loadPendingTasks(from: string, to: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
sort_by: ['due_date', 'id'],
|
sortBy: ['due_date', 'id'],
|
||||||
order_by: ['desc', 'desc'],
|
orderBy: ['desc', 'desc'],
|
||||||
filter_by: ['done'],
|
filterBy: ['done'],
|
||||||
filter_value: ['false'],
|
filterValue: ['false'],
|
||||||
filter_comparator: ['equals'],
|
filterComparator: ['equals'],
|
||||||
filter_concat: 'and',
|
filterConcat: 'and',
|
||||||
filter_include_nulls: showNulls,
|
filterIncludeNulls: showNulls,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!showAll) {
|
if (!showAll) {
|
||||||
params.filter_by.push('due_date')
|
params.filterBy.push('due_date')
|
||||||
params.filter_value.push(to)
|
params.filterValue.push(to)
|
||||||
params.filter_comparator.push('less')
|
params.filterComparator.push('less')
|
||||||
|
|
||||||
// NOTE: Ideally we could also show tasks with a start or end date in the specified range, but the api
|
// NOTE: Ideally we could also show tasks with a start or end date in the specified range, but the api
|
||||||
// is not capable (yet) of combining multiple filters with 'and' and 'or'.
|
// is not capable (yet) of combining multiple filters with 'and' and 'or'.
|
||||||
|
|
||||||
if (!showOverdue) {
|
if (!showOverdue) {
|
||||||
params.filter_by.push('due_date')
|
params.filterBy.push('due_date')
|
||||||
params.filter_value.push(from)
|
params.filterValue.push(from)
|
||||||
params.filter_comparator.push('greater')
|
params.filterComparator.push('greater')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.value = await store.dispatch('tasks/loadTasks', params)
|
tasks.value = await store.dispatch('tasks/loadTasks', objectToSnakeCase(params))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this modification should happen in the store
|
// FIXME: this modification should happen in the store
|
||||||
|
|
Loading…
Reference in a new issue