-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
639 additions
and
309 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"@ngqp/core": { | ||
"root": "projects/ngqp/core", | ||
"sourceRoot": "projects/ngqp/core/src", | ||
"projectType": "library", | ||
"prefix": "lib", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-ng-packagr:build", | ||
"options": { | ||
"tsConfig": "projects/ngqp/core/tsconfig.lib.json", | ||
"project": "projects/ngqp/core/ng-package.json" | ||
} | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"main": "projects/ngqp/core/src/test.ts", | ||
"tsConfig": "projects/ngqp/core/tsconfig.spec.json", | ||
"karmaConfig": "projects/ngqp/core/karma.conf.js" | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": [ | ||
"projects/ngqp/core/tsconfig.lib.json", | ||
"projects/ngqp/core/tsconfig.spec.json" | ||
], | ||
"exclude": [ | ||
"**/node_modules/**" | ||
] | ||
} | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"@ngqp/core": { | ||
"root": "projects/ngqp/core", | ||
"sourceRoot": "projects/ngqp/core/src", | ||
"projectType": "library", | ||
"prefix": "lib", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-ng-packagr:build", | ||
"options": { | ||
"tsConfig": "projects/ngqp/core/tsconfig.lib.json", | ||
"project": "projects/ngqp/core/ng-package.json" | ||
} | ||
}, | ||
"test": { | ||
"builder": "@angular-devkit/build-angular:karma", | ||
"options": { | ||
"main": "projects/ngqp/core/src/test.ts", | ||
"tsConfig": "projects/ngqp/core/tsconfig.spec.json", | ||
"karmaConfig": "projects/ngqp/core/karma.conf.js" | ||
} | ||
}, | ||
"lint": { | ||
"builder": "@angular-devkit/build-angular:tslint", | ||
"options": { | ||
"tsConfig": [ | ||
"projects/ngqp/core/tsconfig.lib.json", | ||
"projects/ngqp/core/tsconfig.spec.json" | ||
], | ||
"exclude": [ | ||
"**/node_modules/**" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"defaultProject": "@ngqp/core" | ||
}, | ||
"defaultProject": "@ngqp/core" | ||
} |
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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
// Karma configuration file, see link for more information | ||
// https://karma-runner.github.io/1.0/config/configuration-file.html | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['jasmine', '@angular-devkit/build-angular'], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage-istanbul-reporter'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
coverageIstanbulReporter: { | ||
dir: require('path').join(__dirname, '../../../coverage'), | ||
reports: ['html', 'lcovonly'], | ||
fixWebpackSourcePaths: true | ||
}, | ||
reporters: ['progress', 'kjhtml'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: ['Chrome'], | ||
singleRun: false | ||
}); | ||
module.exports = function(config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: [ 'jasmine', '@angular-devkit/build-angular' ], | ||
plugins: [ | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-jasmine-html-reporter'), | ||
require('karma-coverage-istanbul-reporter'), | ||
require('@angular-devkit/build-angular/plugins/karma') | ||
], | ||
client: { | ||
clearContext: false // leave Jasmine Spec Runner output visible in browser | ||
}, | ||
coverageIstanbulReporter: { | ||
dir: require('path').join(__dirname, '../../../coverage'), | ||
reports: [ 'html', 'lcovonly' ], | ||
fixWebpackSourcePaths: true | ||
}, | ||
reporters: [ 'progress', 'kjhtml' ], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: true, | ||
browsers: [ 'Chrome' ], | ||
singleRun: false | ||
}); | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "../../../dist/ngqp/core", | ||
"lib": { | ||
"entryFile": "src/public_api.ts" | ||
} | ||
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "../../../dist/ngqp/core", | ||
"lib": { | ||
"entryFile": "src/public_api.ts" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
{ | ||
"name": "@ngqp/core", | ||
"version": "0.0.1", | ||
"peerDependencies": { | ||
"@angular/common": "^7.x.x", | ||
"@angular/core": "^7.x.x", | ||
"@angular/router": "^7.x.x" | ||
} | ||
"name": "@ngqp/core", | ||
"version": "0.0.1", | ||
"peerDependencies": { | ||
"@angular/common": "^7.x.x", | ||
"@angular/core": "^7.x.x", | ||
"@angular/forms": "^7.x.x", | ||
"@angular/router": "^7.x.x", | ||
"rxjs": "^6.x.x" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
export { QueryParamGroup, QueryParamControl, QueryParamControlOpts } from './model'; | ||
export { QueryParamNameDirective } from './query-param-name.directive'; | ||
export { QueryParamGroupDirective } from './query-param-group.directive'; | ||
export { QueryParamBuilder } from './query-param-builder.service'; | ||
export { QueryParamModule } from './query-param.module'; |
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,101 @@ | ||
import { Observable, Subject } from 'rxjs'; | ||
import { isOptionalFunction } from './util'; | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
export class QueryParamGroup { | ||
|
||
/** @internal Maps each control name to the corresponding control. */ | ||
public controls: {[controlName: string]: QueryParamControl<any>} = {}; | ||
|
||
constructor(controls: {[controlName: string]: QueryParamControl<any>}) { | ||
this.controls = controls; | ||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
public setValue(/* TODO { emitEvent? } */): void { | ||
// TODO | ||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
public patchValue(/* TODO { emitEvent? } */): void { | ||
// TODO | ||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
public get valueChanges(): Observable<any> { | ||
// TODO Implement and turn into a property | ||
return null; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
export class QueryParamControl<T> { | ||
|
||
/** TODO Documentation */ | ||
public value: T = null; | ||
|
||
/** TODO Documentation */ | ||
// @ts-ignore | ||
public readonly valueChanges$ = this._valueChanges$.asObservable(); | ||
|
||
/** TODO Documentation */ | ||
public name: string | null = null; | ||
|
||
/** TODO Documentation */ | ||
public initialValue!: T | null; | ||
|
||
/** TODO Documentation */ | ||
public serialize: (model: T) => string; | ||
|
||
/** TODO Documentation */ | ||
public deserialize: (value: string) => T; | ||
|
||
// TODO Add combineWith(previousValue: T, currentValue: T): Params | ||
|
||
// TODO Who completes this? | ||
private _valueChanges$ = new Subject<T>(); | ||
|
||
constructor(config: QueryParamControlOpts<T>) { | ||
const { | ||
name = null, | ||
initialValue = null, | ||
serialize = model => '' + model, | ||
deserialize = value => value as any, | ||
} = config; | ||
|
||
if (!isOptionalFunction(serialize)) { | ||
throw new Error(`serialize must be a function, but received ${serialize}`); | ||
} | ||
|
||
if (!isOptionalFunction(deserialize)) { | ||
throw new Error(`deserialize must be a function, but received ${deserialize}`); | ||
} | ||
|
||
this.name = name; | ||
this.initialValue = initialValue; | ||
this.serialize = serialize; | ||
this.deserialize = deserialize; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
export interface QueryParamControlOpts<T> { | ||
name?: string; | ||
initialValue?: T; | ||
serialize?: (model: T) => string; | ||
deserialize?: (value: string) => T; | ||
} |
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,39 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { QueryParamControl, QueryParamControlOpts, QueryParamGroup } from './model'; | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class QueryParamBuilder { | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
public group(config: { [ name: string ]: QueryParamControl<any> | string }): QueryParamGroup { | ||
const controls: { [ controlName: string ]: QueryParamControl<any> } = {}; | ||
Object.keys(config).forEach(controlName => { | ||
controls[ controlName ] = this.createControl(config[ controlName ]); | ||
}); | ||
|
||
return new QueryParamGroup(controls); | ||
} | ||
|
||
/** | ||
* TODO Documentation | ||
*/ | ||
public param<T>(config: QueryParamControlOpts<T> = {}): QueryParamControl<T> { | ||
return new QueryParamControl(config); | ||
} | ||
|
||
private createControl<T>(controlConfig: QueryParamControl<T> | string): QueryParamControl<T> { | ||
if (controlConfig instanceof QueryParamControl) { | ||
return controlConfig; | ||
} | ||
|
||
return this.param(); | ||
} | ||
|
||
} |
Oops, something went wrong.