Skip to content

Commit

Permalink
Merge pull request #28 from Neovici/25-1
Browse files Browse the repository at this point in the history
19353, 25 - Set the query to the path in the filter to support hash parameter

Approved by nomego, JockeCK and Wurper, added tests also pass.
  • Loading branch information
dotpointer authored Sep 21, 2018
2 parents fe5c3c1 + 5561e0f commit 2f56858
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cosmoz-omnitable-treenode-column.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@
behaviors: [
Cosmoz.OmnitableColumnBehavior
],
observers: [
'_setQueryByPath(filter, ownerTree)'
],
/**
* Get a list of suggestions for the column header.
* @param {array} values Suggestion values.
Expand Down Expand Up @@ -366,11 +369,21 @@
_computeShowResultsOnFocus(filter) {
return !filter;
},

_serializeFilter(filter = this.filter) {
return filter || null;
},

/**
* Set the query by using a path, this sets the initial header filter text of the column.
* @param {string} path Path to set.
* @param {object} ownerTree Owner tree to get texts from.
* @returns {void}
*/
_setQueryByPath(path, ownerTree = this.ownerTree) {
if (path == null || ownerTree == null) {
return;
}
this.set('query', ownerTree.getPathStringByProperty(path, this.keyProperty, this.valueProperty, ' / '));
},
_deserializeFilter(obj) {
return obj || null;
},
Expand Down
14 changes: 14 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@
done();
}, 300);
});

test('_setQueryByPath(null, null) leaves query as an empty string', done => {
column._setQueryByPath(null, null);
assert.equal(column.query, '');
done();
});

test('_setQueryByPath(\'1.8.10\', tree) sets query to Root / Company Pjqcakmiyx / Company Dyzljcycik', done => {
column.keyProperty = 'pathLocator';
column.valueProperty = 'name';
column._setQueryByPath('1.8.10', tree);
assert.equal(column.query, 'Root / Company Pjqcakmiyx / Company Dyzljcycik');
done();
});
});
})();
</script>
Expand Down

0 comments on commit 2f56858

Please sign in to comment.