-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve autocomplete serialize, deserialize #149
Improve autocomplete serialize, deserialize #149
Conversation
8041680
to
bb148c8
Compare
2562c91
to
9c3f1e0
Compare
@@ -158,6 +158,34 @@ | |||
} | |||
return true; | |||
}); | |||
}, | |||
|
|||
_serializeFilter: function (obj = this.filter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use es6 syntax and skip
: function
- Why
obj
(more generic, harder to follow) and not something like justfilter
?
(same below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nomego Fixed that.
return obj.split('~').map(item => this.values.find(v => { | ||
const property = this.valueProperty; | ||
if (!property) { | ||
const vv = typeof v === 'number' ? v.toString() : v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Numbers should be able to compare directly, 3 === 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nomego I changed to a _normalizeValue
function because numbers from hash params are strings sometimes. If possible we convert to numbers.
9c3f1e0
to
5cc6c9e
Compare
if (!Array.isArray(this.values) || this._pendingFilterString) { | ||
return; | ||
} | ||
this.setFilterFromHash(this._pendingFilterString); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_pendingFilterString
can only be falsy? Intended? Where does that property even come from? New in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nomego The problem is that when we set filter (from deserializeFilter
) values
might not be set if data
property is not set so it can't set selection in paper-autocomplete-chips.
Because of that I set the param from url as _pendingFilterString
and next time values are set it will update filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another solution would be to able to set an array of values in cosmoz-autocomplete-chips
.
5cc6c9e
to
4cad5d1
Compare
4cad5d1
to
39fc3d8
Compare
_serializeFilter for example if valueProperty is id then in url will be only ids separated by ~
deserializeFilter splits ids and searches in column values for them and returns the items array.
Iulian: The problem is that when we set filter (from deserializeFilter) values might not be set if data property is not set so it can't set selection in paper-autocomplete-chips.
version 1: Because of that I set the param from url as _pendingFilterString and next time values are set it will update filter.
version 2: ( without flag ) set an array of values in paper-autocomplete-chips. [WIP]