feat: add button to clear active filters #924
No reviewers
Labels
No Label
area/internal-code
changes requested
confirmed
dependencies
duplicate
good first issue
help wanted
hosting
invalid
kind/bug
kind/feature
question
wontfix
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/frontend#924
Loading…
Reference in New Issue
No description provided.
Delete Branch "feat/clear-active-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -9,0 +7,4 @@
{{ $t('filters.clear') }}
</x-button>
<filters
:class="{'is-open': visibleInternal}"
The watcher in the component won't ever trigger if the component does not exist at all (with
v-if
). This hides it visually only.Not sure which watcher you mean here. The one inside the
<Filters>
? If so => maybe adeep
watcher helps.I just realize that it also feels generally wrong to put this logic here:
Before the filter popup was just managing the filter and passing along the modelValue.
Probably this could have been easier if the FilterPopup would provide a slot for the popup.
Then maybe another one for the trigger … and then we basically can name the component just popup and integrate popper.js inside.
(that's kind of what my plan was for this anyway)
Exactly.
So that it would not pass along the filter state? I'm actually not sure if this could have been easier in that case - I want to have the same "clear filters" button in all places where the filter popup is being used. I think moving this whole thing in a component simplifies that.
I think I understand what you mean now. I meant something similar to this:
So basically moving the button and the open state to the filter popup component?
Both buttons, clear and toggle, that is
I put something together in
86efb07f09
. That seems to work. Is that what you had in mind?yes / no:
#content
would have been better.isOpen
can be used to control active classes at the buttonshowActiveColumnsFilter
inTable.vue
I did though move the reset button together with the other stuff from the current filters.vue.
So if you would have written:
Then the answer would be yes ✅
@ -43,0 +56,4 @@
}
const def = {...defaultParams(), s: null}
return JSON.stringify(filterParams) !== JSON.stringify(def)
This feels very hacky...
Here specifically:
You can remove a parameter by destructuring it and then just use the rest:
👆 this line is fine – in case you included that in what you meant feels hacky – as long as it works
All together my feeling is that
hasFilters
should be a computed that is defined where the filters state is saved.You mean in that case
value
would contain everything fromthis.value
withoutpage
?Changed.
@ -10,6 +10,17 @@ const DEFAULT_PARAMS = {
filter_concat: 'and',
}
export const defaultParams = () => {
I only got this working once I created this factory thing. Every time I'd use the constant directly, the params variable in the components and the value of this const were always the same. I suspect this is due to some JS-reference passing stuff.
Makes sense. I didn't use a getter function since it seemed to me more "JSONy".
How about:
I tried that, it did not work unfortunately. My theory is that the function only returns a reference to the const which is then changed. And because everything holds a copy to that same const reference, it is changed everywhere simultaniously.
Maybe:
That seems to work.
Actually, it does not seem to work. Reverted...
@ -467,3 +467,1 @@
if (foundDone === false) {
this.filters.done = true
}
this.filters.done = foundDone === false
Done.
5d399e05a9
todc02c09f19
@ -0,0 +54,4 @@
overflow: hidden;
position: absolute;
top: 1rem;
margin: 0 !important;
margin should be defined by the popup-content
Done.
@dpschen Could you give this another review?
@ -11,3 +30,3 @@
<script>
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
import Filters from '../../../components/list/partials/filters'
import {getDefaultParams} from '../../tasks/mixins/taskList'
use
@
Done. I think we should put this in the linter at some point, I keep forgetting it... and webstorm always seems to use relative paths by default.
@ -75,0 +89,4 @@
<style scoped lang="scss">
.filter-popup {
margin: 0 !important;
Why the
!important
?There was a margin set for
.filter-container .card
(inlist.scss
). I've removed that one and the!important
statements.@ -0,0 +16,4 @@
open.value = !open.value
}
const hidePopup = e => {
Picky: use
function
. Makes it more clear what a "method" is (now simply function) next to a ref.Done.
@ -200,10 +196,12 @@ import Sort from '../../../components/tasks/partials/sort'
import {saveListView} from '@/helpers/saveListView'
import FilterPopup from '@/components/list/partials/filter-popup.vue'
import Pagination from '@/components/misc/pagination.vue'
import Popup from '../../../components/misc/popup'
use
@
@ -325,1 +322,4 @@
}
.columns-filter {
margin: 0 !important;
why
!important
?@ -326,0 +324,4 @@
.columns-filter {
margin: 0 !important;
&.is-open {
we shouldn't style elements from outside.
Why do we need to position this from outside via margin?
Because by default, there's no margin. And that would let it flow in the other buttons instead.
How would you solve it? Where would you apply the margin instead?
Okay I just tried to fix what I meant but realized there are much more changes needed for that. I think that would be out of the scope of this branch and better fitted when we add a popper.js based popup =)
Sounds like a topic for another day :)
I think that was the last =)
Hi konrad!
Thank you for creating a PR!
I've deployed the changes of this PR on a preview environment under this URL: https://924-featclear-active-filter--vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.
Have a nice day!