@coolon/angular-ui-powerups 12.3.0 → 12.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/coolon-angular-ui-powerups-cypress.umd.js +297 -93
- package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.js +410 -290
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/cypress/components/aup-command-face.d.ts +2 -5
- package/cypress/components/aup-command.d.ts +18 -4
- package/cypress/components/aup-navigation.d.ts +0 -1
- package/cypress/components/aup-popup-menu.d.ts +2 -0
- package/cypress/components/aup-table.d.ts +19 -0
- package/cypress/components/button-mixin.d.ts +17 -0
- package/cypress/components/button.d.ts +17 -3
- package/cypress/coolon-angular-ui-powerups-cypress.d.ts +1 -0
- package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
- package/cypress/exports.d.ts +3 -0
- package/cypress/page-element.d.ts +11 -2
- package/cypress/page.d.ts +16 -13
- package/cypress/path.d.ts +26 -0
- package/cypress/section.d.ts +8 -1
- package/esm2015/cypress/components/aup-command-face.js +20 -11
- package/esm2015/cypress/components/aup-command-face.js.map +1 -1
- package/esm2015/cypress/components/aup-command-face.metadata.json +1 -1
- package/esm2015/cypress/components/aup-command.js +10 -7
- package/esm2015/cypress/components/aup-command.js.map +1 -1
- package/esm2015/cypress/components/aup-command.metadata.json +1 -1
- package/esm2015/cypress/components/aup-more-menu.js +1 -2
- package/esm2015/cypress/components/aup-more-menu.js.map +1 -1
- package/esm2015/cypress/components/aup-more-menu.metadata.json +1 -1
- package/esm2015/cypress/components/aup-navigation.js +1 -5
- package/esm2015/cypress/components/aup-navigation.js.map +1 -1
- package/esm2015/cypress/components/aup-popup-menu.js +12 -3
- package/esm2015/cypress/components/aup-popup-menu.js.map +1 -1
- package/esm2015/cypress/components/aup-popup-menu.metadata.json +1 -1
- package/esm2015/cypress/components/aup-table.js +36 -0
- package/esm2015/cypress/components/aup-table.js.map +1 -0
- package/esm2015/cypress/components/aup-table.metadata.json +1 -0
- package/esm2015/cypress/components/button-mixin.js +15 -0
- package/esm2015/cypress/components/button-mixin.js.map +1 -0
- package/esm2015/cypress/components/button-mixin.metadata.json +1 -0
- package/esm2015/cypress/components/button.js +11 -7
- package/esm2015/cypress/components/button.js.map +1 -1
- package/esm2015/cypress/components/button.metadata.json +1 -1
- package/esm2015/cypress/coolon-angular-ui-powerups-cypress.js.map +1 -1
- package/esm2015/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
- package/esm2015/cypress/exports.js +3 -0
- package/esm2015/cypress/exports.js.map +1 -1
- package/esm2015/cypress/exports.metadata.json +1 -1
- package/esm2015/cypress/page-element.js +21 -5
- package/esm2015/cypress/page-element.js.map +1 -1
- package/esm2015/cypress/page-element.metadata.json +1 -1
- package/esm2015/cypress/page.js +32 -22
- package/esm2015/cypress/page.js.map +1 -1
- package/esm2015/cypress/page.metadata.json +1 -1
- package/esm2015/cypress/path.js +61 -0
- package/esm2015/cypress/path.js.map +1 -0
- package/esm2015/cypress/path.metadata.json +1 -0
- package/esm2015/cypress/section.js +20 -10
- package/esm2015/cypress/section.js.map +1 -1
- package/esm2015/lib/components/switch-case/switch-case.component.js +7 -0
- package/esm2015/lib/components/switch-case/switch-case.component.js.map +1 -1
- package/esm2015/lib/components/switch-case/switch-case.component.metadata.json +1 -1
- package/esm2015/lib/components/tables/abstract-table.component.js +1 -1
- package/esm2015/lib/components/tables/abstract-table.component.js.map +1 -1
- package/esm2015/lib/components/tables/table/table.component.js +1 -1
- package/esm2015/lib/components/tables/table/table.component.js.map +1 -1
- package/esm2015/lib/components/tables/table/table.component.metadata.json +1 -1
- package/esm2015/lib/components/tables/tree-table/tree-table-component.js +1 -1
- package/esm2015/lib/components/tables/tree-table/tree-table-component.js.map +1 -1
- package/esm2015/lib/components/tables/tree-table/tree-table-component.metadata.json +1 -1
- package/esm2015/lib/interaction/components/activity-actions/activity-actions.component.js +1 -1
- package/esm2015/lib/interaction/components/activity-actions/activity-actions.component.metadata.json +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
- package/esm2015/lib/place/guards/consolidated-param-map.js +7 -2
- package/esm2015/lib/place/guards/consolidated-param-map.js.map +1 -1
- package/esm2015/lib/place/guards/consolidated-param-map.metadata.json +1 -1
- package/esm2015/lib/place/guards/place.guard.js +1 -22
- package/esm2015/lib/place/guards/place.guard.js.map +1 -1
- package/esm2015/lib/place/navigation/place-component-deactivation-handler.js +24 -14
- package/esm2015/lib/place/navigation/place-component-deactivation-handler.js.map +1 -1
- package/esm2015/lib/place/navigation/place-component-deactivation-handler.metadata.json +1 -1
- package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.js.map +1 -1
- package/esm2015/lib/place/navigation/session/interactions/synchronise-interaction-context-ids-with-route.metadata.json +1 -1
- package/esm2015/lib/place/place-component.js +67 -5
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-component.metadata.json +1 -1
- package/esm2015/lib/place/place-definition.js +3 -3
- package/esm2015/lib/place/place-definition.js.map +1 -1
- package/esm2015/lib/place/place-router.js +9 -4
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-decorators.js +13 -14
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm2015/lib/place/route/parameter-decorators.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-definition.js +21 -3
- package/esm2015/lib/place/route/parameter-definition.js.map +1 -1
- package/esm2015/lib/place/route/parameter-definition.metadata.json +1 -1
- package/esm2015/lib/place/route/visit-sanitiser.js +1 -1
- package/esm2015/lib/place/route/visit-sanitiser.js.map +1 -1
- package/esm2015/lib/place/url-snapshot.js +30 -7
- package/esm2015/lib/place/url-snapshot.js.map +1 -1
- package/esm2015/lib/place/url-snapshot.metadata.json +1 -1
- package/esm2015/lib/place/visit.js +7 -7
- package/esm2015/lib/place/visit.js.map +1 -1
- package/esm2015/lib/place/visit.metadata.json +1 -1
- package/fesm2015/coolon-angular-ui-powerups-cypress.js +235 -74
- package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +369 -269
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/switch-case/switch-case.component.d.ts +7 -0
- package/lib/place/guards/consolidated-param-map.d.ts +2 -2
- package/lib/place/navigation/place-component-deactivation-handler.d.ts +3 -1
- package/lib/place/place-component.d.ts +26 -3
- package/lib/place/route/parameter-definition.d.ts +8 -0
- package/lib/place/url-snapshot.d.ts +1 -0
- package/lib/place/visit.d.ts +4 -4
- package/package.json +1 -1
- package/schematics/activity/schema.json +1 -1
- package/schematics/activity/templates/component/__name@dasherize__.component.html.template +1 -1
- package/schematics/activity/templates/component/__name@dasherize__.component.ts.template +2 -2
- package/schematics/aup-i18n/schema.json +1 -1
- package/schematics/bootstrap-app/schema.json +1 -1
- package/schematics/component/schema.json +1 -1
- package/schematics/place-add/schema.json +1 -1
- package/schematics/place-bootstrap/schema.json +1 -1
- package/schematics/place-routes/schema.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PlaceRouter":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@coolon/pectin","name":"GarbageCollector","line":47,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":44,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":68,"character":46},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":69,"character":48},{"__symbolic":"reference","module":"../interaction/services/interaction.service","name":"InteractionService","line":70,"character":51},{"__symbolic":"reference","module":"./url-service","name":"UrlService","line":71,"character":43},{"__symbolic":"reference","module":"./place-history","name":"PlaceHistory","line":72,"character":45}]}],"configureAuth":[{"__symbolic":"method"}],"getAuthenticationFailureRedirect":[{"__symbolic":"method"}],"isNavigating":[{"__symbolic":"method"}],"waitUntilIdle":[{"__symbolic":"method"}],"onPopState":[{"__symbolic":"method"}],"onRouterStarted":[{"__symbolic":"method"}],"onUrlChanged":[{"__symbolic":"method"}],"onRouterCancelled":[{"__symbolic":"method"}],"onRouterError":[{"__symbolic":"method"}],"onRouterEnd":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method"}],"doNavigation":[{"__symbolic":"method"}],"navigateByUrl":[{"__symbolic":"method"}],"pushVisitChangesToRoute":[{"__symbolic":"method"}],"createNavigationSession":[{"__symbolic":"method"}],"transitionTo":[{"__symbolic":"method"}],"routingSessionFinished":[{"__symbolic":"method"}],"runAfterRoutingSessionFinishes":[{"__symbolic":"method"}],"syncInteractionContextIdsWithRouter":[{"__symbolic":"method"}],"createRouteParameters":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"PlaceRouter":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@coolon/pectin","name":"GarbageCollector","line":47,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":44,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":68,"character":46},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":69,"character":48},{"__symbolic":"reference","module":"../interaction/services/interaction.service","name":"InteractionService","line":70,"character":51},{"__symbolic":"reference","module":"./url-service","name":"UrlService","line":71,"character":43},{"__symbolic":"reference","module":"./place-history","name":"PlaceHistory","line":72,"character":45}]}],"configureAuth":[{"__symbolic":"method"}],"getAuthenticationFailureRedirect":[{"__symbolic":"method"}],"isNavigating":[{"__symbolic":"method"}],"waitUntilIdle":[{"__symbolic":"method"}],"onPopState":[{"__symbolic":"method"}],"onRouterStarted":[{"__symbolic":"method"}],"onUrlChanged":[{"__symbolic":"method"}],"onRouterCancelled":[{"__symbolic":"method"}],"onRouterError":[{"__symbolic":"method"}],"onRouterEnd":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method"}],"doNavigation":[{"__symbolic":"method"}],"navigateByUrl":[{"__symbolic":"method"}],"pushVisitChangesToRoute":[{"__symbolic":"method"}],"createNavigationSession":[{"__symbolic":"method"}],"transitionTo":[{"__symbolic":"method"}],"routingSessionFinished":[{"__symbolic":"method"}],"runAfterRoutingSessionFinishes":[{"__symbolic":"method"}],"syncInteractionContextIdsWithRouter":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":350,"character":3}}]}],"createRouteParameters":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { Binding, DebugContext, Functions
|
|
1
|
+
import { Binding, DebugContext, Functions } from '@coolon/pectin';
|
|
2
2
|
import { Klass, Opts } from '@coolon/typescript-utilities';
|
|
3
3
|
import { ROUTE_PARAMETER_LIST_KEY } from '../place-component';
|
|
4
4
|
import { ParameterDefinition } from './parameter-definition';
|
|
5
|
-
function installMechanics(prototype, propertyKey,
|
|
5
|
+
function installMechanics(parameterDef, prototype, propertyKey, tagPrefix) {
|
|
6
|
+
Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, parameterDef);
|
|
6
7
|
function getMechanics(instance, propertyName) {
|
|
7
8
|
const key = `__mechanics_${propertyName.toString()}`;
|
|
8
9
|
if (!instance[key]) {
|
|
10
|
+
const backingModel = parameterDef.createBackingModel();
|
|
9
11
|
instance[key] = {
|
|
10
|
-
backingModel:
|
|
12
|
+
backingModel: backingModel,
|
|
11
13
|
binding: null
|
|
12
14
|
};
|
|
13
15
|
const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;
|
|
@@ -31,12 +33,12 @@ function installMechanics(prototype, propertyKey, backingModelFactory, tagPrefix
|
|
|
31
33
|
toLeft: Functions.identity,
|
|
32
34
|
toRight: Functions.identity
|
|
33
35
|
});
|
|
34
|
-
if (
|
|
36
|
+
if (parameterDef.isEmptyValue(userModel.value)) {
|
|
35
37
|
// console.log(`Push visit to model for ${tag}`, {value: mechanics.backingModel.value});
|
|
36
38
|
mechanics.binding.writeRight(); // push the visit into the user model;
|
|
37
39
|
}
|
|
38
40
|
else {
|
|
39
|
-
if (!
|
|
41
|
+
if (!parameterDef.isEmptyValue(mechanics.backingModel.value)) {
|
|
40
42
|
console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');
|
|
41
43
|
}
|
|
42
44
|
mechanics.binding.writeLeft(); // push the user model into the visit
|
|
@@ -47,25 +49,22 @@ function installMechanics(prototype, propertyKey, backingModelFactory, tagPrefix
|
|
|
47
49
|
}
|
|
48
50
|
export function RouteId(type, options) {
|
|
49
51
|
return (prototype, propertyKey) => {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
installMechanics(prototype, propertyKey, () => new MutableValueModel(), '@RouteId', m => m.query().isNil());
|
|
52
|
+
const parameterDef = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
|
|
53
|
+
installMechanics(parameterDef, prototype, propertyKey, '@RouteId');
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
56
|
export function VisitParameter(options) {
|
|
56
57
|
const opts = Opts.get(options);
|
|
57
58
|
return (prototype, propertyKey) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
installMechanics(prototype, propertyKey, () => new MutableValueModel(), '@VisitParameter', m => m.query().isNil());
|
|
59
|
+
const parameterDef = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
60
|
+
installMechanics(parameterDef, prototype, propertyKey, '@VisitParameter');
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
export function VisitParameterList(options) {
|
|
64
64
|
const opts = Opts.get(options);
|
|
65
65
|
return (prototype, propertyKey) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
installMechanics(prototype, propertyKey, () => new MutableListModel(), '@VisitParameterList', m => m.query().isEmpty());
|
|
66
|
+
const parameterDef = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));
|
|
67
|
+
installMechanics(parameterDef, prototype, propertyKey, '@VisitParameterList');
|
|
69
68
|
};
|
|
70
69
|
}
|
|
71
70
|
//# sourceMappingURL=parameter-decorators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-decorators.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/parameter-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parameter-decorators.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/parameter-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAY,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA8B7D,SAAS,gBAAgB,CAA0B,YAAsC,EAAE,SAAiB,EAAE,WAA4B,EAAE,SAAiB;IAE3J,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,YAAY,CAAC,CAAC;IAElF,SAAS,YAAY,CAAC,QAAW,EAAE,YAA6B;QAC9D,MAAM,GAAG,GAAG,eAAe,YAAY,CAAC,QAAQ,EAA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,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;QACnI,gBAAgB,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC;IAChF,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Binding, DebugContext, Functions, HasValue } from '@coolon/pectin';\nimport { Klass, Opts } from '@coolon/typescript-utilities';\nimport { ROUTE_PARAMETER_LIST_KEY } from '../place-component';\nimport { Formatter } from './formatter';\nimport { ParameterDefinition } from './parameter-definition';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\n\nfunction installMechanics<M extends HasValue<any>>(parameterDef: ParameterDefinition<any>, prototype: Object, propertyKey: string | symbol, tagPrefix: string) {\n\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, parameterDef);\n\n function getMechanics(instance: M, propertyName: string | symbol) {\n const key = `__mechanics_${propertyName.toString()}`;\n if (!instance[key]) {\n const backingModel = parameterDef.createBackingModel();\n instance[key] = {\n backingModel: backingModel,\n binding: null as Binding<any, any>\n };\n const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.getOrCreate(instance[key].backingModel).tag(tag);\n }\n return instance[key];\n }\n\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return getMechanics(this, propertyKey).backingModel;\n },\n set: function(userModel: M) {\n const mechanics = getMechanics(this, propertyKey);\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel, {\n toLeft: Functions.identity,\n toRight: Functions.identity\n });\n if (parameterDef.isEmptyValue(userModel.value)) {\n // console.log(`Push visit to model for ${tag}`, {value: mechanics.backingModel.value});\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!parameterDef.isEmptyValue(mechanics.backingModel.value)) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const parameterDef = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n installMechanics(parameterDef, prototype, propertyKey, '@RouteId');\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const parameterDef = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n installMechanics(parameterDef, prototype, propertyKey, '@VisitParameter');\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const parameterDef = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n installMechanics(parameterDef, prototype, propertyKey, '@VisitParameterList');\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"RouteIdOptions":{"__symbolic":"interface"},"RouteParameterOptions":{"__symbolic":"interface"},"RouteListParameterOptions":{"__symbolic":"interface"},"RouteId":{"__symbolic":"function","parameters":["type","options"],"value":{"__symbolic":"error","message":"Lambda not supported","line":83,"character":9}},"VisitParameter":{"__symbolic":"function"},"VisitParameterList":{"__symbolic":"function"}}}]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
2
|
+
import { MutableListModel, MutableValueModel } from '@coolon/pectin';
|
|
3
|
+
import { lang, Opts } from '@coolon/typescript-utilities';
|
|
3
4
|
import _ from 'lodash';
|
|
5
|
+
const PARAMETER_DEFINITION_KEY = Symbol("parameterDefinition");
|
|
4
6
|
export class ParameterDefinition {
|
|
5
7
|
constructor(propertyName, options, urlFormat) {
|
|
6
8
|
this.propertyName = propertyName;
|
|
@@ -16,6 +18,11 @@ export class ParameterDefinition {
|
|
|
16
18
|
get isRouteParameter() {
|
|
17
19
|
return !!this.urlFormat;
|
|
18
20
|
}
|
|
21
|
+
createBackingModel() {
|
|
22
|
+
const model = this.backingModelFactory();
|
|
23
|
+
model[PARAMETER_DEFINITION_KEY] = this;
|
|
24
|
+
return model;
|
|
25
|
+
}
|
|
19
26
|
getOptionValue(key) {
|
|
20
27
|
return this.options.getOptional(key, null);
|
|
21
28
|
}
|
|
@@ -27,7 +34,7 @@ export class ParameterDefinition {
|
|
|
27
34
|
if (returningFromSomewhereElse) {
|
|
28
35
|
const lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);
|
|
29
36
|
if (this.remember && lastKnownVisit) {
|
|
30
|
-
value = lastKnownVisit.
|
|
37
|
+
value = lastKnownVisit.getParameterValue(this);
|
|
31
38
|
}
|
|
32
39
|
return this.isEmptyValue(value) ? this.defaultValue : value;
|
|
33
40
|
}
|
|
@@ -37,7 +44,7 @@ export class ParameterDefinition {
|
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
isMissingFrom(visit) {
|
|
40
|
-
return !visit.hasParameter(this
|
|
47
|
+
return !visit.hasParameter(this);
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
(function (ParameterDefinition) {
|
|
@@ -46,6 +53,7 @@ export class ParameterDefinition {
|
|
|
46
53
|
super(...arguments);
|
|
47
54
|
this.isRouteId = true;
|
|
48
55
|
this.isArray = false;
|
|
56
|
+
this.backingModelFactory = () => new MutableValueModel();
|
|
49
57
|
}
|
|
50
58
|
isEmptyValue(value) {
|
|
51
59
|
return _.isNil(value);
|
|
@@ -60,6 +68,7 @@ export class ParameterDefinition {
|
|
|
60
68
|
super(...arguments);
|
|
61
69
|
this.isRouteId = false;
|
|
62
70
|
this.isArray = false;
|
|
71
|
+
this.backingModelFactory = () => new MutableValueModel();
|
|
63
72
|
}
|
|
64
73
|
isEmptyValue(value) {
|
|
65
74
|
return _.isNil(value);
|
|
@@ -74,6 +83,7 @@ export class ParameterDefinition {
|
|
|
74
83
|
super(parameterName, options, urlFormat);
|
|
75
84
|
this.isRouteId = false;
|
|
76
85
|
this.isArray = true;
|
|
86
|
+
this.backingModelFactory = () => new MutableListModel();
|
|
77
87
|
}
|
|
78
88
|
isEmptyValue(value) {
|
|
79
89
|
return _.isNil(value) || value.length < 1;
|
|
@@ -83,5 +93,13 @@ export class ParameterDefinition {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
ParameterDefinition.ArrayParameter = ArrayParameter;
|
|
96
|
+
function get(model) {
|
|
97
|
+
const parameterDefinition = model[PARAMETER_DEFINITION_KEY];
|
|
98
|
+
if (!parameterDefinition) {
|
|
99
|
+
lang.illegalArgument("model hasn't been annotated with @VisitParameter, @VisitParameterList or @RouteId");
|
|
100
|
+
}
|
|
101
|
+
return parameterDefinition;
|
|
102
|
+
}
|
|
103
|
+
ParameterDefinition.get = get;
|
|
86
104
|
})(ParameterDefinition || (ParameterDefinition = {}));
|
|
87
105
|
//# sourceMappingURL=parameter-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-definition.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/parameter-definition.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"parameter-definition.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/parameter-definition.ts"],"names":[],"mappings":";AACA,OAAO,EAAuB,gBAAgB,EAAE,iBAAiB,EAAc,MAAM,gBAAgB,CAAC;AACtG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,CAAC,MAAM,QAAQ,CAAC;AAKvB,MAAM,wBAAwB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAE9D,MAAM,OAAgB,mBAAmB;IAUvC,YAAqB,YAAoB,EAAE,OAAuC,EAAW,SAAwB;QAAhG,iBAAY,GAAZ,YAAY,CAAQ;QAAoD,cAAS,GAAT,SAAS,CAAe;QACnH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3D,CAAC;IAED,WAAW;IACX,IAAI,gBAAgB;QAClB,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1B,C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CAAC;QAC5D,IAAI,CAAC,mBAAmB,EAAE;YACxB,IAAI,CAAC,eAAe,CAAC,mFAAmF,CAAC,CAAC;SAC3G;QACD,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IANe,uBAAG,MAMlB,CAAA;AAGH,CAAC,EArEgB,mBAAmB,KAAnB,mBAAmB,QAqEnC","sourcesContent":["import { Injector } from '@angular/core';\nimport { HasValue, ListModel, MutableListModel, MutableValueModel, ValueModel } from '@coolon/pectin';\nimport { lang, Opts } from '@coolon/typescript-utilities';\nimport _ from 'lodash';\nimport { PlaceHistory } from '../place-history';\nimport { Visit } from '../visit';\nimport { Formatter } from './formatter';\n\nconst PARAMETER_DEFINITION_KEY = Symbol(\"parameterDefinition\")\n\nexport abstract class ParameterDefinition<T, E = T> {\n\n abstract readonly isRouteId: boolean;\n abstract readonly isArray: boolean;\n\n readonly remember: boolean;\n readonly defaultValue: T;\n private options: Opts<ParameterDefinition.Options<T>>;\n protected abstract backingModelFactory: () => HasValue<T>;\n\n constructor(readonly propertyName: string, options: ParameterDefinition.Options<T>, readonly urlFormat?: Formatter<E>) {\n this.options = Opts.get(options);\n this.remember = this.options.getOptional('remember', false);\n this.defaultValue = this.options.getOptional('defaultValue', null);\n }\n\n get name() {\n return this.options.getOptional('as', this.propertyName);\n }\n\n // @Trace()\n get isRouteParameter(): boolean {\n return !!this.urlFormat;\n }\n\n abstract isEmptyValue(value: T): boolean;\n\n abstract hasChanged(a: any, b: any): boolean;\n\n createBackingModel(): HasValue<T> {\n const model = this.backingModelFactory();\n model[PARAMETER_DEFINITION_KEY] = this;\n return model;\n }\n\n protected getOptionValue<K extends keyof ParameterDefinition.Options<T>>(key: K): ParameterDefinition.Options<T>[K] {\n return this.options.getOptional(key, null);\n }\n\n // @Trace()\n async sanitise(value: T, visit: Visit, placeHistory: PlaceHistory, injector: Injector, isPopState: boolean) {\n if (this.isMissingFrom(visit)) {\n const returningFromSomewhereElse = !placeHistory.lastVisitIncluded(visit.placeDefinition);\n if (returningFromSomewhereElse) {\n const lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);\n if (this.remember && lastKnownVisit) {\n value = lastKnownVisit.getParameterValue(this);\n }\n return this.isEmptyValue(value) ? this.defaultValue : value;\n }\n }\n // todo: add custom sanitiser\n return value;\n }\n\n private isMissingFrom(visit: Visit) {\n return !visit.hasParameter(this);\n }\n}\n\nexport namespace ParameterDefinition {\n\n export interface Options<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser.Options<T>;\n }\n\n export class RouteId<T> extends ParameterDefinition<T> {\n readonly isRouteId = true;\n readonly isArray = false;\n protected backingModelFactory = () => new MutableValueModel<T>();\n\n isEmptyValue(value: T): boolean {\n return _.isNil(value);\n }\n\n hasChanged(a: any, b: any): boolean {\n return a !== b;\n }\n\n }\n\n export class ValueParameter<T> extends ParameterDefinition<T> {\n readonly isRouteId = false;\n readonly isArray = false;\n protected backingModelFactory = () => new MutableValueModel<T>();\n\n isEmptyValue(value: T): boolean {\n return _.isNil(value);\n }\n\n hasChanged(a: any, b: any): boolean {\n return a !== b;\n }\n }\n\n export class ArrayParameter<T> extends ParameterDefinition<T[], T> {\n readonly isRouteId = false;\n readonly isArray = true;\n protected backingModelFactory = () => new MutableListModel<T>();\n\n constructor(parameterName: string, options: Options<T[]>, urlFormat: Formatter<T>) {\n super(parameterName, options, urlFormat);\n }\n\n isEmptyValue(value: T[]): boolean {\n return _.isNil(value) || value.length < 1;\n }\n\n hasChanged(a: T[], b: T[]): boolean {\n return !_.isEqual(a, b);\n }\n\n }\n\n export function get<T>(model: ValueModel<T>): ParameterDefinition.ValueParameter<T>\n export function get<T>(model: ListModel<T>): ParameterDefinition.ArrayParameter<T>\n export function get<T>(model: ValueModel<T> | ListModel<T>): ParameterDefinition.ValueParameter<T> | ParameterDefinition.ArrayParameter<T> {\n const parameterDefinition = model[PARAMETER_DEFINITION_KEY];\n if (!parameterDefinition) {\n lang.illegalArgument(\"model hasn't been annotated with @VisitParameter, @VisitParameterList or @RouteId\");\n }\n return parameterDefinition;\n }\n\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"ParameterDefinition":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"select","expression":{"__symbolic":"reference","name":"ParameterDefinition"},"member":"Options","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"ParameterDefinition":{"__symbolic":"class","arity":2,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"select","expression":{"__symbolic":"reference","name":"ParameterDefinition"},"member":"Options","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":82,"context":{"typeName":"T"}}]},{"__symbolic":"reference","module":"./formatter","name":"Formatter","line":20,"character":107,"arguments":[{"__symbolic":"error","message":"Could not resolve type","line":20,"character":117,"context":{"typeName":"E"}}]}]}],"isEmptyValue":[{"__symbolic":"method"}],"hasChanged":[{"__symbolic":"method"}],"createBackingModel":[{"__symbolic":"method"}],"getOptionValue":[{"__symbolic":"method"}],"sanitise":[{"__symbolic":"method"}],"isMissingFrom":[{"__symbolic":"method"}]}}}}]
|
|
@@ -31,7 +31,7 @@ export class VisitSanitiser {
|
|
|
31
31
|
let sanitisedVisit = visit;
|
|
32
32
|
for (let i = 0; i < parameterDefs.length; i++) {
|
|
33
33
|
const def = parameterDefs[i];
|
|
34
|
-
const value = visit.
|
|
34
|
+
const value = visit.getParameterValue(def);
|
|
35
35
|
const sanitisedValue = yield def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState);
|
|
36
36
|
if (def.hasChanged(value, sanitisedValue)) {
|
|
37
37
|
sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
|
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Aa,GAAG,QAAQ,CAAC,qBAAqB,CAAC;gBACnD,sBAAsB,EAAE,IAAI;gBAC5B,yBAAyB,EAAE,IAAI;aAChC,CAAC,CAAC;YACH,IAAI,cAAc,GAAU,KAAK,CAAC;YAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC7C,MAAM,GAAG,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;gBAC3C,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBACtI,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE;oBACzC,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;iBAC9D;aACF;YAED,OAAO,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;QACvE,CAAC;KAAA;CAEF","sourcesContent":["import { Injector } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { Trace } from '@coolon/pectin';\nimport { NavigationSession } from '../navigation/session/navigation-session';\nimport { PlaceHistory } from '../place-history';\nimport { Visit } from '../visit';\n\nexport class VisitSanitiser {\n constructor(private navigationSession: NavigationSession, private activatedRoute: ActivatedRouteSnapshot, private router: Router, private placeHistory: PlaceHistory, private injector: Injector) {\n\n }\n\n // @Trace()\n async sanitise(visit: Visit): Promise<Visit> {\n const placeDef = visit.placeDefinition;\n if (placeDef.hasRouteId()) {\n const routeIdDef = placeDef.getRouteIdParameterDef();\n const routeId = visit.getRouteId();\n const sanitisedValue = await routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector, this.navigationSession.isPopState);\n // console.log({routeId, sanitisedValue});\n // ###------- EARLY EXIT --------###\n if (routeIdDef.hasChanged(routeId, sanitisedValue)) {\n // if the route id has changed we redirect immediately as other\n // parameter sanitisers might use it.\n return visit.replace(routeIdDef, sanitisedValue);\n }\n }\n\n // if we didn't replace the routeId we continue the url present parameters.\n const parameterDefs = placeDef.getVisitParameterDefs({\n includeRouteParameters: true,\n includeNonRouteParameters: true\n });\n let sanitisedVisit: Visit = visit;\n for (let i = 0; i < parameterDefs.length; i++) {\n const def = parameterDefs[i];\n const value = visit.getParameterValue(def);\n const sanitisedValue = await def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState);\n if (def.hasChanged(value, sanitisedValue)) {\n sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);\n }\n }\n\n return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;\n }\n\n}\n"]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
1
2
|
import { UrlSegment } from '@angular/router';
|
|
3
|
+
import { Trace } from '@coolon/pectin';
|
|
4
|
+
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
2
5
|
import _ from 'lodash';
|
|
6
|
+
import { ConsolidatedParameterMap } from './guards/consolidated-param-map';
|
|
7
|
+
import { Visit } from './visit';
|
|
8
|
+
function extractPrimarySegments(urlTree) {
|
|
9
|
+
return urlTree.root.children.primary.segments;
|
|
10
|
+
}
|
|
3
11
|
export class UrlSnapshot {
|
|
4
12
|
// TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
|
|
5
13
|
constructor(urlSerializer, url) {
|
|
@@ -8,18 +16,18 @@ export class UrlSnapshot {
|
|
|
8
16
|
this.urlTree = urlSerializer.parse(url);
|
|
9
17
|
}
|
|
10
18
|
updateVisitSegments(visit) {
|
|
11
|
-
const
|
|
19
|
+
const newUrlTree = this.urlSerializer.parse(this.url);
|
|
12
20
|
// Ugly, but it works for now.
|
|
13
|
-
const segments = [...
|
|
21
|
+
const segments = [...extractPrimarySegments(newUrlTree)];
|
|
14
22
|
const visitSegments = this.getSegmentsFor(visit);
|
|
15
23
|
const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);
|
|
16
24
|
// do not use the return value, it's the items that were removed!
|
|
17
25
|
segments.splice(replaceAt, visitSegments.length, ...visitSegments);
|
|
18
|
-
|
|
19
|
-
return new UrlSnapshot(this.urlSerializer,
|
|
26
|
+
newUrlTree.root.children.primary.segments = segments;
|
|
27
|
+
return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());
|
|
20
28
|
}
|
|
21
|
-
getPrimarySegments(
|
|
22
|
-
return this.urlTree
|
|
29
|
+
getPrimarySegments() {
|
|
30
|
+
return extractPrimarySegments(this.urlTree);
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
33
|
* Converts the visit into segments. Please not that these segments are not e
|
|
@@ -40,7 +48,10 @@ export class UrlSnapshot {
|
|
|
40
48
|
];
|
|
41
49
|
}
|
|
42
50
|
includesPathOf(placeDef) {
|
|
43
|
-
return this.getPrimarySegments(
|
|
51
|
+
return this.getPrimarySegments().find(s => s.path === placeDef.path);
|
|
52
|
+
}
|
|
53
|
+
createVisitFor(placeDef) {
|
|
54
|
+
return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));
|
|
44
55
|
}
|
|
45
56
|
getInteractionIds() {
|
|
46
57
|
const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
|
|
@@ -80,6 +91,18 @@ export class UrlSnapshot {
|
|
|
80
91
|
return `UrlSnapshot(${this.url})`;
|
|
81
92
|
}
|
|
82
93
|
}
|
|
94
|
+
__decorate([
|
|
95
|
+
Trace(),
|
|
96
|
+
__metadata("design:type", Function),
|
|
97
|
+
__metadata("design:paramtypes", [Visit]),
|
|
98
|
+
__metadata("design:returntype", UrlSnapshot)
|
|
99
|
+
], UrlSnapshot.prototype, "updateVisitSegments", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
Memoize(),
|
|
102
|
+
__metadata("design:type", Function),
|
|
103
|
+
__metadata("design:paramtypes", []),
|
|
104
|
+
__metadata("design:returntype", Array)
|
|
105
|
+
], UrlSnapshot.prototype, "getPrimarySegments", null);
|
|
83
106
|
(function (UrlSnapshot) {
|
|
84
107
|
UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
|
|
85
108
|
UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-snapshot.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/url-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,CAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"url-snapshot.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/url-snapshot.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,SAAS,sBAAsB,CAAC,OAAgB;IAC9C,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC;AAChD,CAAC;AAED,MAAM,OAAO,WAAW;IAItB,iIAAiI;IACjI,YAAqB,aAA4B,EAAW,GAAW;QAAlD,kBAAa,GAAb,aAAa,CAAe;Q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AW,CAAC,uBAAuB,CAAC,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC5F,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;SAChE;IACH,CAAC;IAED,WAAW;IACX,oBAAoB;QAClB,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE;YACnF,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC,CAAA,yCAAyC;SACnE;QACD,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,QAAQ;QACN,OAAO,eAAe,IAAI,CAAC,GAAG,GAAG,CAAC;IACpC,CAAC;CAWF;AA7FC;IADC,KAAK,EAAE;;qCAC0B,KAAK;oCAAG,WAAW;sDAUpD;AAGD;IADC,OAAO,EAAE;;;;qDAGT;AAgFH,WAAiB,WAAW;IAEb,mCAAuB,GAAG,kBAAkB,CAAC;IAC7C,oCAAwB,GAAG,IAAI,CAAC;IAE7C,SAAgB,mBAAmB,CAAC,IAAY;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,YAAA,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAFe,+BAAmB,sBAElC,CAAA;IAED,SAAgB,eAAe,CAAC,cAAwB;QACtD,OAAO,cAAc,CAAC,IAAI,CAAC,YAAA,wBAAwB,CAAC,CAAC;IACvD,CAAC;IAFe,2BAAe,kBAE9B,CAAA;AAKH,CAAC,EAhBgB,WAAW,KAAX,WAAW,QAgB3B","sourcesContent":["import { UrlSegment, UrlSerializer, UrlTree } from '@angular/router';\nimport { Trace } from '@coolon/pectin';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { ConsolidatedParameterMap } from './guards/consolidated-param-map';\nimport { PlaceDefinition } from './place-definition';\nimport { Visit } from './visit';\n\nfunction extractPrimarySegments(urlTree: UrlTree): UrlSegment[] {\n return urlTree.root.children.primary.segments;\n}\n\nexport class UrlSnapshot {\n\n readonly urlTree: UrlTree;\n\n // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.\n constructor(readonly urlSerializer: UrlSerializer, readonly url: string) {\n this.urlTree = urlSerializer.parse(url);\n }\n\n @Trace()\n public updateVisitSegments(visit: Visit): UrlSnapshot {\n const newUrlTree = this.urlSerializer.parse(this.url);\n // Ugly, but it works for now.\n const segments = [...extractPrimarySegments(newUrlTree)];\n const visitSegments = this.getSegmentsFor(visit);\n const replaceAt = segments.findIndex(segment => segment.path === visitSegments[0].path);\n // do not use the return value, it's the items that were removed!\n segments.splice(replaceAt, visitSegments.length, ...visitSegments);\n newUrlTree.root.children.primary.segments = segments;\n return new UrlSnapshot(this.urlSerializer, newUrlTree.toString());\n }\n\n @Memoize()\n private getPrimarySegments(): UrlSegment[] {\n return extractPrimarySegments(this.urlTree);\n }\n\n /**\n * Converts the visit into segments. Please not that these segments are not e\n * @param visit\n */\n protected getSegmentsFor(visit: Visit): UrlSegment[] {\n return visit.placeDefinition.hasRouteId() ?\n [\n // NOTE:\n // It's important to attach the params to the root path and not the id. If we attach them\n // to an empty id then the angular router won't match the pattern.\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit)),\n new UrlSegment(visit.placeDefinition.getFormattedRouteId(visit), {})]\n :\n [\n new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))\n ];\n }\n\n includesPathOf(placeDef: PlaceDefinition) {\n return this.getPrimarySegments().find(s => s.path === placeDef.path);\n }\n\n createVisitFor(placeDef: PlaceDefinition) {\n return new Visit(placeDef, new ConsolidatedParameterMap(this.getPrimarySegments()));\n }\n\n getInteractionIds() {\n const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];\n if (queryParam) {\n return UrlSnapshot.parseInteractionIds(queryParam);\n } else {\n return [];\n }\n }\n\n hasInteractions() {\n return this.getInteractionIds().length > 0;\n }\n\n hasInteractionIds(ids: string[]): boolean {\n return _.isEqual(this.getInteractionIds(), ids);\n }\n\n // @Trace()\n updateInteractionIds(ids: string[]): UrlSnapshot {\n if (ids.length === 0) {\n return this.removeInteractionIds();\n } else {\n const urlTree = this.urlSerializer.parse(this.url);\n urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n }\n\n // @Trace()\n removeInteractionIds(): UrlSnapshot {\n const urlTree = this.urlSerializer.parse(this.url);\n if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {\n urlTree.queryParams = {};//[UrlSnapshot.INTERACTION_ROUTER_OUTLET]\n }\n return new UrlSnapshot(this.urlSerializer, urlTree.toString());\n }\n\n toString(): string {\n return `UrlSnapshot(${this.url})`;\n }\n\n // withOptions(options: NavigationExtras) {\n // return new UrlSnapshot(this.urlSerializer, this.url, options);\n // }\n //\n // @Trace()\n // getNavigationExtras(): NavigationExtras {\n // return this.options;\n // }\n\n}\n\nexport namespace UrlSnapshot {\n\n export const INTERACTION_QUERY_PARAM = 'aup-interactions';\n export const INTERACTION_ID_SEPARATOR = '--';\n\n export function parseInteractionIds(path: string) {\n return path.split(INTERACTION_ID_SEPARATOR);\n }\n\n export function createPathIdFor(interactionIds: string[]) {\n return interactionIds.join(INTERACTION_ID_SEPARATOR);\n }\n\n export interface NavigationOptions {\n replaceUrl?: boolean;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"UrlSnapshot":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"UrlSnapshot":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSerializer","line":17,"character":38},{"__symbolic":"reference","name":"string"}]}],"updateVisitSegments":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"Trace","line":21,"character":3}}]}],"getPrimarySegments":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":34,"character":3}}]}],"getSegmentsFor":[{"__symbolic":"method"}],"includesPathOf":[{"__symbolic":"method"}],"createVisitFor":[{"__symbolic":"method"}],"getInteractionIds":[{"__symbolic":"method"}],"hasInteractions":[{"__symbolic":"method"}],"hasInteractionIds":[{"__symbolic":"method"}],"updateInteractionIds":[{"__symbolic":"method"}],"removeInteractionIds":[{"__symbolic":"method"}],"toString":[{"__symbolic":"method"}]}}}}]
|
|
@@ -16,14 +16,14 @@ export class Visit {
|
|
|
16
16
|
* Returns the value of the place parameter with the specified name. The parameter
|
|
17
17
|
* name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the
|
|
18
18
|
* same as the the ValueModel property name.
|
|
19
|
-
* @param
|
|
19
|
+
* @param parameterDef the visit parameter definition
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
return this.visitParameters[
|
|
21
|
+
getParameterValue(parameterDef) {
|
|
22
|
+
return this.visitParameters[parameterDef.name];
|
|
23
23
|
}
|
|
24
24
|
// @Trace()
|
|
25
|
-
hasParameter(
|
|
26
|
-
return Object.keys(this.visitParameters).includes(
|
|
25
|
+
hasParameter(parameterDef) {
|
|
26
|
+
return Object.keys(this.visitParameters).includes(parameterDef.name);
|
|
27
27
|
}
|
|
28
28
|
replace(parameter, value) {
|
|
29
29
|
return new Visit(this.placeDefinition, Object.assign(Object.assign({}, this.visitParameters), { [parameter.name]: value }));
|
|
@@ -41,8 +41,8 @@ export class Visit {
|
|
|
41
41
|
else {
|
|
42
42
|
// copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the
|
|
43
43
|
// defaults and remember sanitisation process.
|
|
44
|
-
const value = this.
|
|
45
|
-
if (this.hasParameter(def
|
|
44
|
+
const value = this.getParameterValue(def);
|
|
45
|
+
if (this.hasParameter(def)) {
|
|
46
46
|
params[def.name] = value;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/visit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B,MAAM,OAAO,KAAK;IAEhB,YAAqB,eAAgC,EAAmB,kBAA0B,EAAE;QAA/E,oBAAe,GAAf,eAAe,CAAiB;QAAmB,oBAAe,GAAf,eAAe,CAAa;IACpG,CAAC;IAED,WAAW;IACX,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,WAAW;IACX,UAAU;QACR,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACH,
|
|
1
|
+
{"version":3,"file":"visit.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/visit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B,MAAM,OAAO,KAAK;IAEhB,YAAqB,eAAgC,EAAmB,kBAA0B,EAAE;QAA/E,oBAAe,GAAf,eAAe,CAAiB;QAAmB,oBAAe,GAAf,eAAe,CAAa;IACpG,CAAC;IAED,WAAW;IACX,UAAU;QACR,OAAO,IAAI,CAAC,e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,CAAC,GAAG,CAAC,EAAE;oBAC1B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;iBAC1B;aACF;QACH,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB,CAAC,KAAY;QAChC,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,KAAK,IAAI,CAAC,eAAe,CAAC;QACjE,MAAM,mBAAmB,GAAG,CAAC,CAAC,OAAO,CACnC,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,EAC5D,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,CAC9D,CAAC;QACF,OAAO,CAAC,SAAS,IAAI,CAAC,mBAAmB,CAAC;IAC5C,CAAC;IAED,cAAc,CAAC,KAAY;QACzB,MAAM,sBAAsB,GAAG,CAAC,CAAC,OAAO,CACtC,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAChD,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAClD,CAAC;QACF,OAAO,CAAC,sBAAsB,IAAI,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,aAAa;QACX,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjG,CAAC;CAEF","sourcesContent":["import * as _ from 'lodash';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition';\n\ninterface Params {\n [p: string]: any\n}\n\n\nexport class Visit {\n\n constructor(readonly placeDefinition: PlaceDefinition, private readonly visitParameters: Params = {}) {\n }\n\n // @Trace()\n getRouteId(): any {\n return this.placeDefinition.getRouteIdFrom(this);\n }\n\n // @Trace()\n hasRouteId(): boolean {\n return !_.isNil(this.getRouteId());\n }\n\n /**\n * Returns the value of the place parameter with the specified name. The parameter\n * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the\n * same as the the ValueModel property name.\n * @param parameterDef the visit parameter definition\n */\n getParameterValue<T, S>(parameterDef: ParameterDefinition<T, S>): T {\n return this.visitParameters[parameterDef.name];\n }\n\n // @Trace()\n hasParameter(parameterDef: ParameterDefinition<any>): boolean {\n return Object.keys(this.visitParameters).includes(parameterDef.name);\n }\n\n replace<T>(parameter: ParameterDefinition<T, any>, value: T): Visit {\n return new Visit(this.placeDefinition, { ...this.visitParameters, [parameter.name]: value });\n }\n\n mergeRouteParameters<S>(routeParams: { [p: string]: any }): Visit {\n // todo: whitelist parameters.\n const routeParameterKeys = Object.keys(routeParams);\n const params = {};\n this.placeDefinition.getVisitParameterDefs().forEach(def => {\n if (def.isRouteId || def.isRouteParameter) {\n if (routeParameterKeys.includes(def.name)) {\n params[def.name] = routeParams[def.name];\n }\n } else {\n // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the\n // defaults and remember sanitisation process.\n const value = this.getParameterValue(def);\n if (this.hasParameter(def)) {\n params[def.name] = value;\n }\n }\n });\n return new Visit(this.placeDefinition, params);\n }\n\n hasRoutingChangedFrom(other: Visit): boolean {\n const samePlace = other.placeDefinition === this.placeDefinition;\n const sameRouteParameters = _.isEqual(\n this.placeDefinition.getFormattedRouteParameters(this, true),\n this.placeDefinition.getFormattedRouteParameters(other, true)\n );\n return !samePlace || !sameRouteParameters;\n }\n\n hasChangedFrom(other: Visit) {\n const sameNonRouteParameters = _.isEqual(\n this.placeDefinition.getNonRouteParameters(this),\n this.placeDefinition.getNonRouteParameters(other)\n );\n return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);\n }\n\n toDebugString() {\n return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(',');\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"Visit":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./place-definition","name":"PlaceDefinition","line":11,"character":40},{"__symbolic":"reference","name":"any"}]}],"getRouteId":[{"__symbolic":"method"}],"hasRouteId":[{"__symbolic":"method"}],"
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"Visit":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./place-definition","name":"PlaceDefinition","line":11,"character":40},{"__symbolic":"reference","name":"any"}]}],"getRouteId":[{"__symbolic":"method"}],"hasRouteId":[{"__symbolic":"method"}],"getParameterValue":[{"__symbolic":"method"}],"hasParameter":[{"__symbolic":"method"}],"replace":[{"__symbolic":"method"}],"mergeRouteParameters":[{"__symbolic":"method"}],"hasRoutingChangedFrom":[{"__symbolic":"method"}],"hasChangedFrom":[{"__symbolic":"method"}],"toDebugString":[{"__symbolic":"method"}]}}}}]
|