Skip to content
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

Conversation

programmer4web
Copy link
Contributor

@programmer4web programmer4web commented Jan 26, 2018

_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]

@programmer4web programmer4web force-pushed the feature/NEOV-118-autocomplete-hash-serialize branch from 8041680 to bb148c8 Compare January 29, 2018 13:02
@programmer4web programmer4web changed the title [WIP] Improve autocomplete serialize, deserialize Improve autocomplete serialize, deserialize Feb 2, 2018
@programmer4web programmer4web force-pushed the feature/NEOV-118-autocomplete-hash-serialize branch 2 times, most recently from 2562c91 to 9c3f1e0 Compare February 7, 2018 12:28
@@ -158,6 +158,34 @@
}
return true;
});
},

_serializeFilter: function (obj = this.filter) {
Copy link
Contributor

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 just filter ?

(same below)

Copy link
Collaborator

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;
Copy link
Contributor

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

Copy link
Collaborator

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.

@megheaiulian megheaiulian force-pushed the feature/NEOV-118-autocomplete-hash-serialize branch from 9c3f1e0 to 5cc6c9e Compare February 13, 2018 11:31
if (!Array.isArray(this.values) || this._pendingFilterString) {
return;
}
this.setFilterFromHash(this._pendingFilterString);
Copy link
Contributor

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?

Copy link
Collaborator

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.

Copy link
Collaborator

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.

@programmer4web programmer4web force-pushed the feature/NEOV-118-autocomplete-hash-serialize branch from 5cc6c9e to 4cad5d1 Compare March 1, 2018 10:56
@programmer4web programmer4web force-pushed the feature/NEOV-118-autocomplete-hash-serialize branch from 4cad5d1 to 39fc3d8 Compare March 26, 2018 12:53
@programmer4web programmer4web changed the title Improve autocomplete serialize, deserialize [WIP] Improve autocomplete serialize, deserialize May 23, 2018
@programmer4web programmer4web changed the title [WIP] Improve autocomplete serialize, deserialize Improve autocomplete serialize, deserialize May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants