Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fixed/remotefilter-encode-value auto-commit #361

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [3.0.2] - 2023-01-20

## Fixed

- Fixed when filtering with an operator, object is added as a value ([#361](https://github.com/reyesoft/ngx-jsonapi/pull/361))

## [3.0.0] - 2021-12-23

## Changed
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-jsonapi",
"version": "3.0.0",
"version": "3.0.2",
"description": "JSON API library for Angular",
"module": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.es5.js",
"es2015": "ngx-jsonapi/@ngx-jsonapi/ngx-jsonapi.js",
5 changes: 5 additions & 0 deletions src/services/path-collection-builder.spec.ts
Original file line number Diff line number Diff line change
@@ -58,6 +58,11 @@ describe('Path Builder', () => {
expect(path_collection_builder.get().includes('filter[field]=foo%26bar')).toBeTruthy();
});

it('if filter with operator (ne) they should be formatted and included in get_params', () => {
path_collection_builder.applyParams(testService, { remotefilter: { status: { ne: 'archived' } } });
expect(path_collection_builder.get().includes('filter[status][ne]=archived')).toBeTruthy();
});

it('if page params are provided, applyParams should call addParam one or two times with the page number and size', () => {
Core.me.injectedServices.rsJsonapiConfig.parameters.page.number = 'page_index';
Core.me.injectedServices.rsJsonapiConfig.parameters.page.size = 'page_size';
3 changes: 2 additions & 1 deletion src/services/url-params-builder.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ export class UrlParamsBuilder {
let ret = '';
if (Array.isArray(params) || params instanceof Object) {
Base.forEach(params, (value, key) => {
ret += this.toparamsarray(encodeURIComponent(value), add + '[' + key + ']');
let valueEncodeOrNot = value instanceof Object ? value : encodeURIComponent(value);
ret += this.toparamsarray(valueEncodeOrNot, add + '[' + key + ']');
});
} else {
ret += add + '=' + params;