Skip to content

Commit 3f30355

Browse files
committed
fix(core): Remove string shorthand syntax
fixes #63
1 parent ee2c473 commit 3f30355

8 files changed

Lines changed: 11 additions & 27 deletions

File tree

projects/ngqp-demo/src/app/docs-items/examples/patch-set-value-example/patch-set-value-example.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export class PatchSetValueExampleComponent {
1616

1717
constructor(private qpb: QueryParamBuilder) {
1818
this.paramGroup = qpb.group({
19-
p1: 'p1',
20-
p2: 'p2',
19+
p1: qpb.stringParam({ param: 'p1' }),
20+
p2: qpb.stringParam({ param: 'p2' }),
2121
});
2222
}
2323

projects/ngqp-demo/src/app/docs-items/examples/replace-url-example/replace-url-example.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export class ReplaceUrlExampleComponent {
1717

1818
constructor(private qpb: QueryParamBuilder) {
1919
this.replaceParamGroup = this.qpb.group({
20-
text: 'q1',
20+
text: qpb.stringParam({ param: 'q1' }),
2121
}, { replaceUrl: true });
2222

2323
this.noReplaceParamGroup = this.qpb.group({
24-
text: 'q2',
24+
text: qpb.stringParam({ param: 'q2' }),
2525
}, { replaceUrl: false });
2626
}
2727

projects/ngqp-demo/src/app/docs-items/introduction/introduction-docs.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class IntroductionDocsComponent {
2727
param: 'q',
2828
debounceTime: 300,
2929
}),
30-
manufacturer: 'manufacturer',
30+
manufacturer: qpb.stringParam({ param: 'manufacturer' }),
3131
priceCap: qpb.numberParam({
3232
param: 'costsLessThan',
3333
emptyOn: 0,

projects/ngqp-demo/src/app/docs-items/model-usage/snippets/queryparamgroup-get.example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ export class ExampleComponent {
88

99
constructor(private qpb: QueryParamBuilder) {
1010
this.paramGroup = qpb.group({
11-
myParam: 'q',
11+
myParam: qpb.stringParam({ param: 'q' }),
1212
});
1313

14-
const myParam: QueryParam = this.paramGroup.get('myParam');
14+
const myParam: QueryParam<string> = this.paramGroup.get('myParam');
1515
}
1616

1717
}

projects/ngqp-demo/src/app/docs-items/model-usage/snippets/queryparamgroup-value.example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class ExampleComponent {
88

99
constructor(private qpb: QueryParamBuilder) {
1010
this.paramGroup = qpb.group({
11-
myParam: 'q',
11+
myParam: qpb.stringParam({ param: 'q' }),
1212
});
1313

1414
const value = this.paramGroup.value;

projects/ngqp-demo/src/app/docs-items/model-usage/snippets/queryparamgroup-valuechanges.example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ExampleComponent implements OnDestroy {
1111

1212
constructor(private qpb: QueryParamBuilder) {
1313
this.paramGroup = qpb.group({
14-
myParam: 'q',
14+
myParam: qpb.stringParam({ param: 'q' }),
1515
});
1616

1717
this.paramGroup.valueChanges.pipe(

projects/ngqp-demo/src/app/docs-items/usage-guide/snippets/define-model.example.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export class ExampleComponent {
88

99
constructor(private qpb: QueryParamBuilder) {
1010
this.paramGroup = qpb.group({
11-
simple: 'p1',
1211
stringParam: qpb.stringParam({
1312
param: 'p2'
1413
}),

projects/ngqp/core/src/lib/query-param-builder.service.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ export class QueryParamBuilder {
3535
* @returns The new {@link QueryParamGroup}.
3636
*/
3737
public group(
38-
queryParams: { [ name: string ]: QueryParam<any> | string },
38+
queryParams: { [ name: string ]: QueryParam<any> },
3939
extras: RouterOptions = {}
4040
): QueryParamGroup {
41-
const mappedQueryParams: { [ queryParamName: string ]: QueryParam<any> } = {};
42-
Object.keys(queryParams).forEach(queryParamName => {
43-
mappedQueryParams[ queryParamName ] = this.createQueryParam(queryParams[ queryParamName ]);
44-
});
45-
4641
// TODO Maybe we should first validate that no two queryParams defined the same "param".
47-
return new QueryParamGroup(mappedQueryParams, extras);
42+
return new QueryParamGroup(queryParams, extras);
4843
}
4944

5045
/** @ignore */
@@ -117,14 +112,4 @@ export class QueryParamBuilder {
117112
});
118113
}
119114

120-
private createQueryParam<T>(queryParam: QueryParam<T> | string): QueryParam<T> | QueryParam<string> {
121-
if (queryParam instanceof QueryParam) {
122-
return queryParam;
123-
}
124-
125-
return this.stringParam({
126-
param: queryParam,
127-
});
128-
}
129-
130115
}

0 commit comments

Comments
 (0)