Expose existing qp serialization util as a helper

This commit is contained in:
Michael Lange 2020-05-19 17:28:23 -07:00
parent e611b6fcb9
commit 98933e12a0
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { helper } from '@ember/component/helper';
import { deserialize } from 'nomad-ui/utils/qp-serialize';
/**
* Query Param Serialize
*
* Usage: {{qp-deserialize string}}
*
* Turns a serialized query param value string back into
* an array of values.
*/
export function qpDeserialize([str]) {
return deserialize(str);
}
export default helper(qpDeserialize);

View File

@ -0,0 +1,16 @@
import { helper } from '@ember/component/helper';
import { serialize } from 'nomad-ui/utils/qp-serialize';
/**
* Query Param Serialize
*
* Usage: {{qp-serialize array}}
*
* Turns an array of values into a safe url encoded query param
* value. This serialization is used throughout the app for facets.
*/
export function qpSerialize([values]) {
return serialize(values);
}
export default helper(qpSerialize);