-
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
Closed
programmer4web
wants to merge
5
commits into
Neovici:master
from
plumelo:feature/NEOV-118-autocomplete-hash-serialize
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cb29888
serialize, deserialize for autocomplete
programmer4web 2b941ed
tests for autocomplete serialize, deserialize
programmer4web 56036f7
Move deserialize part of _routeHashFilterChanged to columns
megheaiulian 27216a0
Refactor hash serialize/deserialize for autocomplete column
megheaiulian 39fc3d8
fix tests after rebase
programmer4web File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> | ||
<title>Autocomplete tests</title> | ||
|
||
<script src="../../webcomponentsjs/webcomponents-lite.js"></script> | ||
<script src="../../web-component-tester/browser.js"></script> | ||
<script src="../../test-fixture/test-fixture-mocha.js"></script> | ||
|
||
<link rel="import" href="../../test-fixture/test-fixture.html"> | ||
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html"> | ||
|
||
<link rel="import" href="../cosmoz-omnitable.html"> | ||
<link rel="import" href="../cosmoz-omnitable-columns.html"> | ||
<link rel="import" href="../demo/table-demo-behavior.html"> | ||
</head> | ||
<body> | ||
<test-fixture id="default"> | ||
<template> | ||
<cosmoz-omnitable id="omnitable" class="flex" selection-enabled> | ||
<cosmoz-omnitable-column-autocomplete name="elementName" title="name" value-path="element" text-property="name" value-property="id"> | ||
</cosmoz-omnitable-column-autocomplete> | ||
</cosmoz-omnitable> | ||
</template> | ||
</test-fixture> | ||
<script> | ||
/*global sinon chai flush */ | ||
(function () { | ||
'use strict'; | ||
|
||
sinon.assert.expose(chai.assert, { prefix: '' }); | ||
|
||
suite('basic', function () { | ||
var omnitable, | ||
data = [ | ||
{ element: { id: 'a', name: 'aa' } }, | ||
{ element: { id: 'b', name: 'bb' } }, | ||
{ element: { id: 'c', name: 'cc' } }, | ||
{ element: { id: 'd', name: 'dd' } }, | ||
{ element: { id: 'e', name: 'ee' } }, | ||
{ element: { id: 'f', name: 'ff' } }, | ||
{ element: { id: 'g', name: 'gg' } } | ||
]; | ||
|
||
setup(function (done) { | ||
omnitable = fixture('default'); | ||
omnitable.data = data; | ||
|
||
flush(function () { | ||
Polymer.Base.async(done, 90); | ||
}); | ||
}); | ||
|
||
test('serialize and deserialize one filter', function (done) { | ||
assert.equal(omnitable.is, 'cosmoz-omnitable'); | ||
const column = omnitable.columns[0]; | ||
column.filter = [{ id: 'c', name: 'cc' }]; | ||
|
||
const serialized = column._serializeFilter(column.filter); | ||
assert.equal(serialized, 'c', 'Expected valueProperty to be serialized'); | ||
|
||
const deserialized = column._deserializeFilter(serialized); | ||
assert.deepEqual(deserialized[0], { id: 'c', name: 'cc' }); | ||
done(); | ||
}); | ||
|
||
test('serialize and deserialize two filters', function (done) { | ||
assert.equal(omnitable.is, 'cosmoz-omnitable'); | ||
const column = omnitable.columns[0]; | ||
column.filter = [{ id: 'b', name: 'bb' }, { id: 'g', name: 'gg' }]; | ||
|
||
const serialized = column._serializeFilter(column.filter); | ||
assert.equal(serialized, 'b~g', 'Expected valueProperty to be serialized'); | ||
|
||
const deserialized = column._deserializeFilter(serialized); | ||
assert.deepEqual(deserialized[0], { id: 'b', name: 'bb' }); | ||
assert.deepEqual(deserialized[1], { id: 'g', name: 'gg' }); | ||
done(); | ||
}); | ||
}); | ||
}()); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ifdata
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
.