Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

feat: Add node table filter #823

Merged
merged 10 commits into from
Nov 11, 2020
Merged

Conversation

ahochsteger
Copy link
Contributor

This PR is a merged and improved version of #582 and #800 and adds the possibility to filter nodes by their column values.

Filtering can done by the following ways:

  • Search for a sub-string
  • Select from a list of values
  • Set min/max number values
  • Set min/max date values

Screenshots:

Icons have been added to activate the filter options and to indicate a filtered column:
image

Example of a substring and list selection filter:
image

Example of min/max number value filter:
image

Example of min/max date value filter:
image

@lgtm-com
Copy link

lgtm-com bot commented Nov 10, 2020

This pull request introduces 1 alert when merging eb21f5d into a6664ce - view on LGTM.com

new alerts:

  • 1 for Unknown directive

* NOTE: A VSCode setting for correct formatting OOTB would be great
src/modules/NodeCollection.js Outdated Show resolved Hide resolved
<v-text-field type="datetime-local" label="Until" v-model="value.max" clearable></v-text-field>
</v-col>
</v-row>
<v-row v-if="value && (value.type=='string' || value.type=='number' || value.type=='boolean')">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about use v-switch for booleans?

Copy link
Contributor Author

@ahochsteger ahochsteger Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, if this will work here, since the secure property filter - while being a boolean - can have multiple states:

  • Do not filter
  • Filter for true values
  • Filter for false values
  • Filter for undefined values

That's why I kept v-select here.
Or do you have a better idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahochsteger Aren't states: indeterminate true and false? For filtering bools usually checkboxes are used and them can have an indeterminate state (that equals to undefined).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea - will change it to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A consequence of changing to 3-state v-switch would be that it would not possible anymore to just show nodes where the secure flag is undefined.
Do you still think, it's better to change it from v-select to v-switch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all filter checks skip when switch is indeterminate (so the value undefined ) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, that this would be inconsistent with other data types.
The only use case where filtering for undefined values might be for debugging Zwave2Mqtt itself but this may not be something a typical user would need.
If you think we don't need it, I will change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think we don't need it, I will change it.

Ok!

Copy link
Contributor Author

@ahochsteger ahochsteger Nov 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's done, but I'm not really happy with the resulting layout spacing (caused by v-menu > v-card > v-card-text > v-row > v-col > v-checkbox):
image

I tried to reduce the nesting (at least for v-checkbox) down to v-menu > v-card > v-checkbox but that resulted in missing padding on the left that I was not able to add using CSS spacing helpers (e.g. pa-.. or ma-...) since they had no effect.
Being a first time Vuetify user I could need some help here.
If you have a better suggestion for the checkbox label, please let me know.

@lgtm-com
Copy link

lgtm-com bot commented Nov 10, 2020

This pull request introduces 1 alert when merging 82f1d53 into a6664ce - view on LGTM.com

new alerts:

  • 1 for Unknown directive

@robertsLando
Copy link
Member

@ahochsteger Could you fix lint errors?

Copy link
Member

@chrisns chrisns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really happy there's tests ❤️
I do wonder though if we've introduced a lot of alot of rigidity on the table, and how much harder it'll be to say add additional columns

@ahochsteger
Copy link
Contributor Author

@ahochsteger Could you fix lint errors?

Sorry, but I don't find the reason for the following lint errors:

prettier-standard --check
Code style issues found in following files:
docker/store/nodes.json
docker/store/settings.json
src/components/nodes-table/filter-options.vue
src/components/nodes-table/index.vue
src/components/nodes-table/nodes-table.js
src/modules/NodeCollection.js
src/modules/NodeCollection.test.js
store/nodes.json
store/settings.json

It doesn't tell me what's wrong.
Do you have an idea?

@chrisns
Copy link
Member

chrisns commented Nov 11, 2020

@ahochsteger Run without the --check it'll do the fixes for you

@robertsLando
Copy link
Member

I do wonder though if we've introduced a lot of rigidity on the table, and how much harder it'll be to say add additional columns

Not that harder, just a little bit

@ahochsteger
Copy link
Contributor Author

@ahochsteger Run without the --check it'll do the fixes for you

Thanks, it's done.
That was easy :-)

@ahochsteger
Copy link
Contributor Author

really happy there's tests
I do wonder though if we've introduced a lot of alot of rigidity on the table, and how much harder it'll be to say add additional columns

Kudos for tests go to @mrwho, who did the hard work in #582 on which this PR is based on.
But there seems to be a problem with the coverage/coveralls test that does not see see the new tests.
It reports 0% for NodeCollection.js which has many tests.

Concerning your comment on adding columns:
I tried to be as generic as possible for the table filter so it should be straight forward to extend for more columns.
You are right though, that you have to touch code on a few locations which may be able to encapsulate, but I guess it's out-of-scope for now and could be done, if more demand is here (e.g. if the feature to make it possible to dynamically choose the columns to be shown by the user).

@chrisns
Copy link
Member

chrisns commented Nov 11, 2020

But there seems to be a problem with the coverage/coveralls test that does not see see the new tests.
It reports 0% for NodeCollection.js which has many tests.

yeah, we need to fix the coverage collector, don't worry about that for now.
will pick it up as a separate exercise

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @ahochsteger ! :)

@robertsLando robertsLando merged commit 33994c0 into OpenZWave:master Nov 11, 2020
@ahochsteger
Copy link
Contributor Author

@robertsLando you are welcome - I'm looking forward to the next release :-).
I guess, #582 is now obsolete and may be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants