feat: add date math for filters #1342

Merged
konrad merged 88 commits from feature/date-math into main 2022-03-28 17:30:43 +00:00
2 changed files with 3 additions and 5 deletions
Showing only changes of commit 4ce9ac9c66 - Show all commits

View File

@ -53,7 +53,6 @@
<ShowTasks
v-if="hasLists"
class="mt-4"
:show-all="true"
:key="showTasksKey"
/>
</div>

View File

@ -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

Wouldn't it be better to make showAll a computed that gets autoset when dateFrom and dateTo doesn't contain a value?

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!

Excellent idea. Changed it!
// 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

Readd route props

Readd route props

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).

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.

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')