feat(filters): parse date properties to enable datepicker button
This commit is contained in:
parent
4586e525ce
commit
1827102a0a
@ -22,17 +22,22 @@ watch(
|
|||||||
{immediate: true},
|
{immediate: true},
|
||||||
)
|
)
|
||||||
|
|
||||||
const availableFilterFields = [
|
const dateFields = [
|
||||||
'done',
|
|
||||||
'dueDate',
|
'dueDate',
|
||||||
'priority',
|
|
||||||
'usePriority',
|
|
||||||
'startDate',
|
'startDate',
|
||||||
'endDate',
|
'endDate',
|
||||||
|
'doneAt',
|
||||||
|
]
|
||||||
|
|
||||||
|
const availableFilterFields = [
|
||||||
|
'done',
|
||||||
|
'priority',
|
||||||
|
'usePriority',
|
||||||
'percentDone',
|
'percentDone',
|
||||||
'reminders',
|
'reminders',
|
||||||
'assignees',
|
'assignees',
|
||||||
'labels',
|
'labels',
|
||||||
|
...dateFields,
|
||||||
]
|
]
|
||||||
|
|
||||||
const filterOperators = [
|
const filterOperators = [
|
||||||
@ -56,6 +61,16 @@ const filterJoinOperators = [
|
|||||||
|
|
||||||
const highlightedFilterQuery = computed(() => {
|
const highlightedFilterQuery = computed(() => {
|
||||||
let highlighted = escapeHtml(filterQuery.value)
|
let highlighted = escapeHtml(filterQuery.value)
|
||||||
|
dateFields
|
||||||
|
.map(o => escapeHtml(o))
|
||||||
|
.forEach(o => {
|
||||||
|
const pattern = new RegExp(o + '\\s*(<|>|<=|>=|=|!=)\\s*([\'"]?)([^\'"\\s]+\\1?)?', 'ig');
|
||||||
|
highlighted = highlighted.replaceAll(pattern, (match, token, start, value, position) => {
|
||||||
|
console.log({match, token, value, position})
|
||||||
|
return `${o} ${token} <span class="filter-query__special_value">${value}</span><span class="filter-query__special_value_placeholder">${value}</span>`
|
||||||
|
// TODO: make special value a button with datepicker popup
|
||||||
|
})
|
||||||
|
})
|
||||||
filterOperators
|
filterOperators
|
||||||
.map(o => ` ${escapeHtml(o)} `)
|
.map(o => ` ${escapeHtml(o)} `)
|
||||||
.forEach(o => {
|
.forEach(o => {
|
||||||
@ -117,6 +132,20 @@ function escapeHtml(unsafe: string): string {
|
|||||||
&.filter-query__join-operator {
|
&.filter-query__join-operator {
|
||||||
color: var(--code-section);
|
color: var(--code-section);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.filter-query__special_value_placeholder {
|
||||||
|
padding: .125rem .25rem;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.filter-query__special_value {
|
||||||
|
background: var(--primary);
|
||||||
|
padding: .125rem .25rem;
|
||||||
|
color: white;
|
||||||
|
border-radius: $radius;
|
||||||
|
position: absolute;
|
||||||
|
margin-top: calc((0.25em - 0.125rem) * -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user