feat: add date math for filters #1342
|
@ -53,7 +53,6 @@
|
|||
<ShowTasks
|
||||
v-if="hasLists"
|
||||
class="mt-4"
|
||||
:show-all="true"
|
||||
:key="showTasksKey"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -72,23 +72,22 @@ const showNothingToDo = ref<boolean>(false)
|
|||
|
||||
setTimeout(() => showNothingToDo.value = true, 100)
|
||||
|
||||
// NOTE: You MUST provide either dateFrom and dateTo OR showAll for the component to actually show tasks.
|
||||
// Linting disabled because we explicitely enabled destructuring in vite's config, this will work.
|
||||
konrad marked this conversation as resolved
Outdated
|
||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||
const {
|
||||
dateFrom,
|
||||
dateTo,
|
||||
showAll = false,
|
||||
showNulls = false,
|
||||
showOverdue = false,
|
||||
} = defineProps<{
|
||||
dateFrom?: Date | string,
|
||||
dateTo?: Date | string,
|
||||
showAll?: Boolean,
|
||||
showNulls?: Boolean,
|
||||
showOverdue?: Boolean,
|
||||
}>()
|
||||
konrad marked this conversation as resolved
Outdated
dpschen
commented
Readd route props Readd route props
dpschen
commented
get value from props to remove dependency on route. Removing dependency from router makes the components easier reusable nested inside another view (which is what we do). get value from props to remove dependency on route. Removing dependency from router makes the components easier reusable nested inside another view (which is what we do).
konrad
commented
Changed it to route props. However, we still have a dependency on the router: every time when seleting a date in ShowTasks it will push the change to the route. I don't know how to change that without massively overengeneering everything so I'd say we leave it at that. Changed it to route props.
However, we still have a dependency on the router: every time when seleting a date in ShowTasks it will push the change to the route. I don't know how to change that without massively overengeneering everything so I'd say we leave it at that.
dpschen
commented
I think it's fine for now. I thought a while about this but also don't have a better soltion for this at the moment (except the v-model version) I think it's fine for now. I thought a while about this but also don't have a better soltion for this at the moment (except the v-model version)
|
||||
|
||||
const showAll = computed(() => typeof dateFrom === 'undefined' || typeof dateTo === 'undefined')
|
||||
|
||||
const pageTitle = computed(() => {
|
||||
let title = ''
|
||||
|
||||
|
@ -190,7 +189,7 @@ async function loadPendingTasks(from: string, to: string) {
|
|||
filterIncludeNulls: showNulls,
|
||||
}
|
||||
|
||||
if (!showAll) {
|
||||
if (!showAll.value) {
|
||||
params.filterBy.push('due_date')
|
||||
params.filterValue.push(to)
|
||||
params.filterComparator.push('less')
|
||||
|
|
Reference in New Issue
Wouldn't it be better to make showAll a computed that gets autoset when dateFrom and dateTo doesn't contain a value?
Excellent idea. Changed it!