@coolon/angular-ui-powerups 3.10.0 → 3.10.2

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.
@@ -7,11 +7,29 @@ import { TreeExpansionModel } from './tree-expansion-model';
7
7
  import { TreeLabelColumnModel } from './tree-label-column-model';
8
8
  import { TreeToListModel } from './tree-to-list-model';
9
9
  import { SelfAndDescendantsVisitor } from './visitable.class';
10
+ // TODO:
11
+ // Selection Models:
12
+ // - as simple navigation tree
13
+ // - as editable grid (selecte all, even hidden etc?)
14
+ // - fixing selection on underlying model changes.
15
+ // - rendering selection: row highlighting, checkboxes (in the tree renderer or in separate column), both.
16
+ // Expansion Models:
17
+ // - Add ability to auto show to depth
18
+ // - Add a predicate to check default expansion (i.e. has children of a certain type)
19
+ //
10
20
  export class TreeTableModel extends AbstractTableModel {
11
21
  constructor(source, treeExpansionModel) {
12
22
  super(source);
13
23
  this.treeExpansionModel = treeExpansionModel;
14
24
  }
25
+ static fromRoot(sourceOfTruth, builder) {
26
+ const garbage = new GarbageCollector();
27
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);
28
+ const children = chain(sourceOfTruth).mapToList(root => [root]);
29
+ const model = this.fromList(children, builder);
30
+ model.registerDisposable(garbage);
31
+ return model;
32
+ }
15
33
  static fromChildrenOf(sourceOfTruth, builder) {
16
34
  const garbage = new GarbageCollector();
17
35
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);
@@ -1 +1 @@
1
- {"version":3,"file":"tree-table-model.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/components/tree-table/tree-table-model.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sGAAsG;AACtG,4EAA4E;AAC5E,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAA4C,MAAM,gBAAgB,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,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,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CAEF;AAED,yBAAyB;AACzB,EAAE;AACF,0CAA0C;AAC1C,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,kCAAkC;AAClC,EAAE;AACF,qDAAqD;AACrD,gCAAgC;AAChC,sEAAsE;AACtE,oDAAoD;AACpD,YAAY;AACZ,gCAAgC;AAChC,QAAQ;AACR,EAAE;AACF,gBAAgB;AAChB,4BAA4B;AAC5B,QAAQ;AACR,EAAE;AACF,EAAE;AACF,IAAI","sourcesContent":["// import {T } from '@client/api/light-architect/model/area/area.class';\n// import { SelfAndDescendantsVisitor } from '@client/api/light-architect/model/area/visitable.class';\n// import { Zone } from '@client/api/light-architect/model/area/zone.class';\nimport { Dsl, GarbageCollector, ListModel, MutableValueModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../table/abstract-table-model';\nimport { DecoratedTreeNode } from './decorated-tree-node';\nimport { TreeExpansionModel } from './tree-expansion-model';\nimport { TreeLabelColumnModel } from './tree-label-column-model';\nimport { TreeNode } from './tree-node';\nimport { TreeToListModel } from './tree-to-list-model';\nimport { SelfAndDescendantsVisitor, VisitableTree } from './visitable.class';\n\n\nexport class TreeTableModel<Row extends TreeNode<Row>> extends AbstractTableModel<DecoratedTreeNode<Row>> {\n constructor(source: ListModel<DecoratedTreeNode<Row>>, readonly treeExpansionModel: TreeExpansionModel<DecoratedTreeNode<Row>>) {\n super(source);\n }\n\n static fromChildrenOf<Row extends TreeNode<Row>>(sourceOfTruth: ValueModel<Row>, builder?: (tableModel: TreeTableModel<Row>) => void): TreeTableModel<Row> {\n const garbage = new GarbageCollector();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);\n const children = chain(sourceOfTruth).mapToList(root => root.children); // for some reason pluck list can't see 'children'\n const model = this.fromList(children, builder);\n model.registerDisposable(garbage);\n return model;\n }\n\n static fromList<Row extends TreeNode<Row>>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TreeTableModel<Row>) => void): TreeTableModel<Row> {\n const treeExpansionModel = new TreeExpansionModel<DecoratedTreeNode<Row>>(sourceOfTruth.identityOf);\n const nodes = new TreeToListModel(sourceOfTruth, treeExpansionModel);\n const model = new TreeTableModel<Row>(nodes, treeExpansionModel);\n model.registerDisposable(nodes);\n if (builder) builder(model);\n return model;\n }\n\n treeControlColumn(builder: (column: TreeLabelColumnModel<Row>) => void) {\n const columnId = 'tree-label';\n const column = new TreeLabelColumnModel<Row>(columnId, () => this.getColumnTextProperties(columnId), this.treeExpansionModel);\n builder(column);\n this.addColumn(column);\n }\n\n expand(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.expand(node);\n }\n\n collapse(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.expand(node);\n }\n\n isCollapsed(node: DecoratedTreeNode<Row>): boolean {\n return this.treeExpansionModel.isCollapsed(node);\n }\n\n ensureAncestorsAndSelfVisible(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.ensureAncestorsAndSelfVisible(node);\n }\n\n\n // saveSelection() {\n // let ids: number[] = [];\n // const selectedArea = this._decoratedSelectionModel.leadSelection.value;\n // if (selectedArea) {\n // ids.push(selectedArea.id);\n // ids = ids.concat(selectedArea.siblingsAfter().map(a => a.id));\n // ids = ids.concat(selectedArea.siblingsBefore().reverse().map(a => a.id));\n // ids = ids.concat(selectedArea.ancestorsToZone().reverse().map(a => a.id));\n // }\n // this._storedSelection = ids;\n // }\n //\n //\n // restoreSelection() {\n // const all = this.rootNodeModel.value.selfAndDescendants();\n // for (let i = 0; i < this._storedSelection.length; i++) {\n // const id = this._storedSelection[i];\n // const found = all.find(area => area.id === id);\n // if (found) {\n // this.selectedAreaId.value = found.id;\n // break;\n // }\n // }\n // }\n //\n // collapseAll(areas: T[]) {\n // this.collapsedAreaIds.value = [].concat(this.collapsedAreaIds.value, areas.map(a => a.id));\n // }\n\n // disableSelection(disable: boolean = true) {\n // this._disableSelection.value = disable;\n // }\n\n\n}\n\n\n// /**\n// * 1. Make this a TreeModel<T extends AbstractTree>\n// * 2. Move the decorated items to the view (along with viewToModel and modelToView)\n// */\n// export class TreeTableModel<T, K extends keyof T> {\n//\n// // public readonly decoratedVisibleAreas: ListModel<T>;\n// //\n// // private decoratorCache = undefined; //new DecoratorCache();\n// // private collapsedAreaIds: MutableListModel<number> = new MutableListModel<number>();\n// //\n// // private _rawSelectionModel: SingleSelectionModel<T, T[K]>;\n// // private _decoratedSelectionModel: SingleSelectionModel<T, T[K]>;\n// //\n// // private readonly _disableSelection = new MutableValueModel<boolean>(false);\n// // private _hoveredAreaModel: MutableValueModel<T> = new MutableValueModel<T>();\n// //\n// // private _decoratedHoverModel: ValueModel<T> = new MutableValueModel<T>();\n// // private _storedSelection: number[] = [];\n// //\n// // readonly visibleNodes: ListModelChain<T>;\n// //\n// // protected constructor(readonly rootNodeModel: ValueModel<T>, identifiedBy: K, readonly selectedAreaId: MutableValueModel<K>) {\n// // super();\n// // const {chain, valueOf, before, when, after, observe, switchOn} = Dsl.disposeWith(this);\n// //\n// // this.visibleNodes = chain(this.rootNodeModel).mapToList(root => {\n// // return root.visit(new FlattenStrategy(this.collapsedAreaIds.value)).flattenedAreas;\n// // }, {dependsOn: this.collapsedAreaIds});\n// //\n// // this.decoratedVisibleAreas = this.visibleNodes.map(area => {\n// // return this.decoratorCache.get(area);\n// // });\n// //\n// // this._rawSelectionModel = this.registerDisposable(SingleSelectionModel.fromList(this.visibleNodes, identifiedBy, {\n// // storeIdIn: this.selectedAreaId,\n// // // toggleSelection: false\n// // }));\n// // this._rawSelectionModel.selectBehaviour.disableWhen(this._disableSelection);\n// // this._decoratedSelectionModel = this.registerDisposable(SingleSelectionModel.fromList(this.decoratedVisibleAreas, identifiedBy, {\n// // storeIdIn: this.selectedAreaId,\n// // toggleSelection: false\n// // }));\n// // this._decoratedSelectionModel.selectBehaviour.disableWhen(this._disableSelection);\n// //\n// // // our areas will be different objects so we have to save, restore the\n// // // selection and rebuild our decorators\n// // before(rootNodeModel).changes(() => this.saveSelection());\n// // before(rootNodeModel).changes(() => this.decoratorCache.clear());\n// // when(rootNodeModel).changes(() => this.restoreSelection(), {asLongAs: () => !!rootNodeModel.value});\n// //\n// //\n// // this.registerDisposable(new Binding(this._decoratedHoverModel, this._hoveredAreaModel, {\n// // toLeft: (area) => area ? this.modelToView(area) : null,\n// // toRight: (decoratedArea) => decoratedArea ? this.viewToModel(decoratedArea) : null\n// // }));\n// //\n// // when(this.decoratedSelectionModel.leadSelection)\n// // .changes(selection => this.ensureAncestorsAndSelfVisible(selection), {\n// // asLongAs: selection => !!selection\n// // });\n// // }\n// //\n// // static fromRoot<T, K extends keyof T>(rootNodeModel: ValueModel<T>, identifiedBy: K, options?: TreeModel.Options<T, K>) {\n// //\n// // }\n// //\n// // public viewToModel(decoratedArea: T): T {\n// // assert.notNil(decoratedArea);\n// // return TreeModel.AreaDecorator.undecorate(decoratedArea);\n// // }\n// //\n// // public modelToView(area: T): T {\n// // assert.notNil(area);\n// // return this.decoratorCache.get(area);\n// // }\n// //\n// // get hoveredAreaModel(): ValueModel<T> {\n// // return this._hoveredAreaModel;\n// // }\n// //\n// // clearHover() {\n// // this._hoveredAreaModel.value = null;\n// // }\n// //\n// // get selectionModel(): SelectionModel<T> {\n// // return this._rawSelectionModel;\n// // }\n// //\n// // get decoratedSelectionModel(): SelectionModel<T> {\n// // return this._decoratedSelectionModel;\n// // }\n// //\n// // get decoratedHoverModel(): ValueModel<T> {\n// // return this._decoratedHoverModel;\n// // }\n// //\n// // decoratedArea(area: T): T {\n// // return this.decoratorCache.get(area);\n// // }\n// //\n// // select(area: T) {\n// // this.selectedAreaId.value = area ? area.id : null;\n// // }\n// }\n\n\nexport namespace TreeTableModel {\n\n export interface Options<T, K extends keyof T> {\n storeIdIn: MutableValueModel<K>\n }\n\n // export interface DecoratedArea extendsTDecorator,T {\n // }\n //\n // export classTDecorator extends Decorator<T> {\n //\n // static decorate(area:T): DecoratedArea {\n // return Decorator.create(area, newTDecorator(area)) as DecoratedArea;\n // }\n //\n // pathToRoot() {\n // return this.object.ancestorsToZone().slice(1);\n // }\n //\n // isLastChild() {\n // return this.object.isLastChild();\n // }\n //\n // isRoot() {\n // return this.object.isZone();\n // }\n // }\n\n}\n\n\nexport class FlattenStrategy<T extends VisitableTree<any>> extends SelfAndDescendantsVisitor<T> {\n\n private _areas: T[] = [];\n private _collapsed: Set<T>;\n\n constructor(private collapsedIds: T[]) {\n super();\n this._collapsed = new Set<T>(collapsedIds);\n }\n\n protected onVisit(it: T) {\n this._areas.push(it);\n }\n\n protected shouldVisitChildrenOf(it: T): boolean {\n return !this._collapsed.has(it);\n }\n\n get flattenedAreas(): T[] {\n return this._areas;\n }\n\n}\n\n// class DecoratorCache {\n//\n// private map = new Map<number, T>();\n//\n// get(area:T): T {\n//\n// if (!area) return null;\n//\n// let decoratedArea = this.map.get(area.id);\n// if (!decoratedArea) {\n// decoratedArea = TreeModel.AreaDecorator.decorate(area);\n// this.map.set(area.id, decoratedArea);\n// }\n// return decoratedArea;\n// }\n//\n// clear() {\n// this.map.clear();\n// }\n//\n//\n// }\n\n\n\n\n"]}
1
+ {"version":3,"file":"tree-table-model.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/components/tree-table/tree-table-model.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,sGAAsG;AACtG,4EAA4E;AAC5E,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAA4C,MAAM,gBAAgB,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,yBAA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C,CAAC;IACnD,CAAC;IAED,6BAA6B,CAAC,IAA4B;QACxD,IAAI,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;CAqCF;AA6ID,MAAM,OAAO,eAA8C,SAAQ,yBAA4B;IAK7F,YAAoB,YAAiB;QACnC,KAAK,EAAE,CAAC;QADU,iBAAY,GAAZ,YAAY,CAAK;QAH7B,WAAM,GAAQ,EAAE,CAAC;QAKvB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,CAAI,YAAY,CAAC,CAAC;IAC7C,CAAC;IAES,OAAO,CAAC,EAAK;QACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;IAES,qBAAqB,CAAC,EAAK;QACnC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CAEF;AAED,yBAAyB;AACzB,EAAE;AACF,0CAA0C;AAC1C,EAAE;AACF,uBAAuB;AACvB,EAAE;AACF,kCAAkC;AAClC,EAAE;AACF,qDAAqD;AACrD,gCAAgC;AAChC,sEAAsE;AACtE,oDAAoD;AACpD,YAAY;AACZ,gCAAgC;AAChC,QAAQ;AACR,EAAE;AACF,gBAAgB;AAChB,4BAA4B;AAC5B,QAAQ;AACR,EAAE;AACF,EAAE;AACF,IAAI","sourcesContent":["// import {T } from '@client/api/light-architect/model/area/area.class';\n// import { SelfAndDescendantsVisitor } from '@client/api/light-architect/model/area/visitable.class';\n// import { Zone } from '@client/api/light-architect/model/area/zone.class';\nimport { Dsl, GarbageCollector, ListModel, MutableValueModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../table/abstract-table-model';\nimport { DecoratedTreeNode } from './decorated-tree-node';\nimport { TreeExpansionModel } from './tree-expansion-model';\nimport { TreeLabelColumnModel } from './tree-label-column-model';\nimport { TreeNode } from './tree-node';\nimport { TreeToListModel } from './tree-to-list-model';\nimport { SelfAndDescendantsVisitor, VisitableTree } from './visitable.class';\n\n\n// TODO:\n// Selection Models:\n// - as simple navigation tree\n// - as editable grid (selecte all, even hidden etc?)\n// - fixing selection on underlying model changes.\n// - rendering selection: row highlighting, checkboxes (in the tree renderer or in separate column), both.\n// Expansion Models:\n// - Add ability to auto show to depth\n// - Add a predicate to check default expansion (i.e. has children of a certain type)\n//\nexport class TreeTableModel<Row extends TreeNode<Row>> extends AbstractTableModel<DecoratedTreeNode<Row>> {\n\n constructor(source: ListModel<DecoratedTreeNode<Row>>, readonly treeExpansionModel: TreeExpansionModel<DecoratedTreeNode<Row>>) {\n super(source);\n }\n\n static fromRoot<Row extends TreeNode<Row>>(sourceOfTruth: ValueModel<Row>, builder?: (tableModel: TreeTableModel<Row>) => void): TreeTableModel<Row> {\n const garbage = new GarbageCollector();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);\n const children = chain(sourceOfTruth).mapToList(root => [root]);\n const model = this.fromList(children, builder);\n model.registerDisposable(garbage);\n return model;\n }\n\n static fromChildrenOf<Row extends TreeNode<Row>>(sourceOfTruth: ValueModel<Row>, builder?: (tableModel: TreeTableModel<Row>) => void): TreeTableModel<Row> {\n const garbage = new GarbageCollector();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);\n const children = chain(sourceOfTruth).mapToList(root => root.children); // for some reason pluck list can't see 'children'\n const model = this.fromList(children, builder);\n model.registerDisposable(garbage);\n return model;\n }\n\n static fromList<Row extends TreeNode<Row>>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TreeTableModel<Row>) => void): TreeTableModel<Row> {\n const treeExpansionModel = new TreeExpansionModel<DecoratedTreeNode<Row>>(sourceOfTruth.identityOf);\n const nodes = new TreeToListModel(sourceOfTruth, treeExpansionModel);\n const model = new TreeTableModel<Row>(nodes, treeExpansionModel);\n model.registerDisposable(nodes);\n if (builder) builder(model);\n return model;\n }\n\n treeControlColumn(builder: (column: TreeLabelColumnModel<Row>) => void) {\n const columnId = 'tree-label';\n const column = new TreeLabelColumnModel<Row>(columnId, () => this.getColumnTextProperties(columnId), this.treeExpansionModel);\n builder(column);\n this.addColumn(column);\n }\n\n expand(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.expand(node);\n }\n\n collapse(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.expand(node);\n }\n\n isCollapsed(node: DecoratedTreeNode<Row>): boolean {\n return this.treeExpansionModel.isCollapsed(node);\n }\n\n ensureAncestorsAndSelfVisible(node: DecoratedTreeNode<Row>) {\n this.treeExpansionModel.ensureAncestorsAndSelfVisible(node);\n }\n\n\n // saveSelection() {\n // let ids: number[] = [];\n // const selectedArea = this._decoratedSelectionModel.leadSelection.value;\n // if (selectedArea) {\n // ids.push(selectedArea.id);\n // ids = ids.concat(selectedArea.siblingsAfter().map(a => a.id));\n // ids = ids.concat(selectedArea.siblingsBefore().reverse().map(a => a.id));\n // ids = ids.concat(selectedArea.ancestorsToZone().reverse().map(a => a.id));\n // }\n // this._storedSelection = ids;\n // }\n //\n //\n // restoreSelection() {\n // const all = this.rootNodeModel.value.selfAndDescendants();\n // for (let i = 0; i < this._storedSelection.length; i++) {\n // const id = this._storedSelection[i];\n // const found = all.find(area => area.id === id);\n // if (found) {\n // this.selectedAreaId.value = found.id;\n // break;\n // }\n // }\n // }\n //\n // collapseAll(areas: T[]) {\n // this.collapsedAreaIds.value = [].concat(this.collapsedAreaIds.value, areas.map(a => a.id));\n // }\n\n // disableSelection(disable: boolean = true) {\n // this._disableSelection.value = disable;\n // }\n\n\n}\n\n\n// /**\n// * 1. Make this a TreeModel<T extends AbstractTree>\n// * 2. Move the decorated items to the view (along with viewToModel and modelToView)\n// */\n// export class TreeTableModel<T, K extends keyof T> {\n//\n// // public readonly decoratedVisibleAreas: ListModel<T>;\n// //\n// // private decoratorCache = undefined; //new DecoratorCache();\n// // private collapsedAreaIds: MutableListModel<number> = new MutableListModel<number>();\n// //\n// // private _rawSelectionModel: SingleSelectionModel<T, T[K]>;\n// // private _decoratedSelectionModel: SingleSelectionModel<T, T[K]>;\n// //\n// // private readonly _disableSelection = new MutableValueModel<boolean>(false);\n// // private _hoveredAreaModel: MutableValueModel<T> = new MutableValueModel<T>();\n// //\n// // private _decoratedHoverModel: ValueModel<T> = new MutableValueModel<T>();\n// // private _storedSelection: number[] = [];\n// //\n// // readonly visibleNodes: ListModelChain<T>;\n// //\n// // protected constructor(readonly rootNodeModel: ValueModel<T>, identifiedBy: K, readonly selectedAreaId: MutableValueModel<K>) {\n// // super();\n// // const {chain, valueOf, before, when, after, observe, switchOn} = Dsl.disposeWith(this);\n// //\n// // this.visibleNodes = chain(this.rootNodeModel).mapToList(root => {\n// // return root.visit(new FlattenStrategy(this.collapsedAreaIds.value)).flattenedAreas;\n// // }, {dependsOn: this.collapsedAreaIds});\n// //\n// // this.decoratedVisibleAreas = this.visibleNodes.map(area => {\n// // return this.decoratorCache.get(area);\n// // });\n// //\n// // this._rawSelectionModel = this.registerDisposable(SingleSelectionModel.fromList(this.visibleNodes, identifiedBy, {\n// // storeIdIn: this.selectedAreaId,\n// // // toggleSelection: false\n// // }));\n// // this._rawSelectionModel.selectBehaviour.disableWhen(this._disableSelection);\n// // this._decoratedSelectionModel = this.registerDisposable(SingleSelectionModel.fromList(this.decoratedVisibleAreas, identifiedBy, {\n// // storeIdIn: this.selectedAreaId,\n// // toggleSelection: false\n// // }));\n// // this._decoratedSelectionModel.selectBehaviour.disableWhen(this._disableSelection);\n// //\n// // // our areas will be different objects so we have to save, restore the\n// // // selection and rebuild our decorators\n// // before(rootNodeModel).changes(() => this.saveSelection());\n// // before(rootNodeModel).changes(() => this.decoratorCache.clear());\n// // when(rootNodeModel).changes(() => this.restoreSelection(), {asLongAs: () => !!rootNodeModel.value});\n// //\n// //\n// // this.registerDisposable(new Binding(this._decoratedHoverModel, this._hoveredAreaModel, {\n// // toLeft: (area) => area ? this.modelToView(area) : null,\n// // toRight: (decoratedArea) => decoratedArea ? this.viewToModel(decoratedArea) : null\n// // }));\n// //\n// // when(this.decoratedSelectionModel.leadSelection)\n// // .changes(selection => this.ensureAncestorsAndSelfVisible(selection), {\n// // asLongAs: selection => !!selection\n// // });\n// // }\n// //\n// // static fromRoot<T, K extends keyof T>(rootNodeModel: ValueModel<T>, identifiedBy: K, options?: TreeModel.Options<T, K>) {\n// //\n// // }\n// //\n// // public viewToModel(decoratedArea: T): T {\n// // assert.notNil(decoratedArea);\n// // return TreeModel.AreaDecorator.undecorate(decoratedArea);\n// // }\n// //\n// // public modelToView(area: T): T {\n// // assert.notNil(area);\n// // return this.decoratorCache.get(area);\n// // }\n// //\n// // get hoveredAreaModel(): ValueModel<T> {\n// // return this._hoveredAreaModel;\n// // }\n// //\n// // clearHover() {\n// // this._hoveredAreaModel.value = null;\n// // }\n// //\n// // get selectionModel(): SelectionModel<T> {\n// // return this._rawSelectionModel;\n// // }\n// //\n// // get decoratedSelectionModel(): SelectionModel<T> {\n// // return this._decoratedSelectionModel;\n// // }\n// //\n// // get decoratedHoverModel(): ValueModel<T> {\n// // return this._decoratedHoverModel;\n// // }\n// //\n// // decoratedArea(area: T): T {\n// // return this.decoratorCache.get(area);\n// // }\n// //\n// // select(area: T) {\n// // this.selectedAreaId.value = area ? area.id : null;\n// // }\n// }\n\n\nexport namespace TreeTableModel {\n\n export interface Options<T, K extends keyof T> {\n storeIdIn: MutableValueModel<K>\n }\n\n // export interface DecoratedArea extendsTDecorator,T {\n // }\n //\n // export classTDecorator extends Decorator<T> {\n //\n // static decorate(area:T): DecoratedArea {\n // return Decorator.create(area, newTDecorator(area)) as DecoratedArea;\n // }\n //\n // pathToRoot() {\n // return this.object.ancestorsToZone().slice(1);\n // }\n //\n // isLastChild() {\n // return this.object.isLastChild();\n // }\n //\n // isRoot() {\n // return this.object.isZone();\n // }\n // }\n\n}\n\n\nexport class FlattenStrategy<T extends VisitableTree<any>> extends SelfAndDescendantsVisitor<T> {\n\n private _areas: T[] = [];\n private _collapsed: Set<T>;\n\n constructor(private collapsedIds: T[]) {\n super();\n this._collapsed = new Set<T>(collapsedIds);\n }\n\n protected onVisit(it: T) {\n this._areas.push(it);\n }\n\n protected shouldVisitChildrenOf(it: T): boolean {\n return !this._collapsed.has(it);\n }\n\n get flattenedAreas(): T[] {\n return this._areas;\n }\n\n}\n\n// class DecoratorCache {\n//\n// private map = new Map<number, T>();\n//\n// get(area:T): T {\n//\n// if (!area) return null;\n//\n// let decoratedArea = this.map.get(area.id);\n// if (!decoratedArea) {\n// decoratedArea = TreeModel.AreaDecorator.decorate(area);\n// this.map.set(area.id, decoratedArea);\n// }\n// return decoratedArea;\n// }\n//\n// clear() {\n// this.map.clear();\n// }\n//\n//\n// }\n\n\n\n\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"TreeTableModel":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../table/abstract-table-model","name":"AbstractTableModel","line":13,"character":63},"arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@coolon/pectin","name":"ListModel","line":14,"character":22,"arguments":[{"__symbolic":"reference","module":"./decorated-tree-node","name":"DecoratedTreeNode","line":14,"character":32,"arguments":[{"__symbolic":"error","message":"Could not resolve type","line":14,"character":123,"context":{"typeName":"Row"}}]}]},{"__symbolic":"reference","module":"./tree-expansion-model","name":"TreeExpansionModel","line":14,"character":86,"arguments":[{"__symbolic":"reference","module":"./decorated-tree-node","name":"DecoratedTreeNode","line":14,"character":32,"arguments":[{"__symbolic":"error","message":"Could not resolve type","line":14,"character":123,"context":{"typeName":"Row"}}]}]}]}],"treeControlColumn":[{"__symbolic":"method"}],"expand":[{"__symbolic":"method"}],"collapse":[{"__symbolic":"method"}],"isCollapsed":[{"__symbolic":"method"}],"ensureAncestorsAndSelfVisible":[{"__symbolic":"method"}]}},"FlattenStrategy":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./visitable.class","name":"SelfAndDescendantsVisitor","line":235,"character":67},"arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":240,"character":36,"context":{"typeName":"T"}}]}]}],"onVisit":[{"__symbolic":"method"}],"shouldVisitChildrenOf":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"TreeTableModel":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../table/abstract-table-model","name":"AbstractTableModel","line":23,"character":63},"arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@coolon/pectin","name":"ListModel","line":25,"character":22,"arguments":[{"__symbolic":"reference","module":"./decorated-tree-node","name":"DecoratedTreeNode","line":25,"character":32,"arguments":[{"__symbolic":"error","message":"Could not resolve type","line":25,"character":123,"context":{"typeName":"Row"}}]}]},{"__symbolic":"reference","module":"./tree-expansion-model","name":"TreeExpansionModel","line":25,"character":86,"arguments":[{"__symbolic":"reference","module":"./decorated-tree-node","name":"DecoratedTreeNode","line":25,"character":32,"arguments":[{"__symbolic":"error","message":"Could not resolve type","line":25,"character":123,"context":{"typeName":"Row"}}]}]}]}],"treeControlColumn":[{"__symbolic":"method"}],"expand":[{"__symbolic":"method"}],"collapse":[{"__symbolic":"method"}],"isCollapsed":[{"__symbolic":"method"}],"ensureAncestorsAndSelfVisible":[{"__symbolic":"method"}]}},"FlattenStrategy":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./visitable.class","name":"SelfAndDescendantsVisitor","line":255,"character":67},"arity":1,"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"error","message":"Could not resolve type","line":260,"character":36,"context":{"typeName":"T"}}]}]}],"onVisit":[{"__symbolic":"method"}],"shouldVisitChildrenOf":[{"__symbolic":"method"}]}}}}]
@@ -125,6 +125,15 @@ export class PlaceRouter extends GarbageCollector {
125
125
  isNavigating() {
126
126
  return this.navigationInProgress.value;
127
127
  }
128
+ waitUntilIdle() {
129
+ const { when } = Dsl.disposeWith(this);
130
+ return new Promise(resolve => {
131
+ when(this.navigationInProgress).becomesFalsey(() => resolve(), {
132
+ initialValue: 'evaluate',
133
+ once: true
134
+ });
135
+ });
136
+ }
128
137
  // @Trace()
129
138
  onPopState(event) {
130
139
  assert.isTruthy(event.navigationTrigger === 'popstate');
@@ -1 +1 @@
1
- {"version":3,"file":"place-router.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-router.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAGL,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEf,eAAe,EACf,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,GAAG,EACH,gBAAgB,EAChB,IAAI,EAIJ,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iEAAiE,CAAC;AAC9G,OAAO,EAAE,mCAAmC,EAAE,MAAM,2EAA2E,CAAC;AAChI,OAAO,EAAE,yCAAyC,EAAE,MAAM,kFAAkF,CAAC;AAC7I,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC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,OAAO,GAAG,IAAI,yCAAyC,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC,CAAC;SAEL;IACH,CAAC;IAGO,qBAAqB,CAAC,KAAY;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,eAAe,CAAC;QAClC,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;YACzB,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1E,CAAC,GAAG,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;;;;YAxUF,UAAU,SAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;YArCC,MAAM;YAVC,QAAQ;YA8BR,kBAAkB;YAWlB,UAAU;YADV,YAAY","sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n ActivatedRouteSnapshot,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router,\n RouterStateSnapshot\n} from '@angular/router';\nimport {\n assert,\n Binding,\n DebugContext,\n DelegatingValueModel,\n Dsl,\n GarbageCollector,\n lang,\n ListModel,\n Logger,\n MapModelChain,\n MutableListModel,\n MutableValueModel, Trace,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigatingDuringInteraction } from './navigation/session/interactions/navigating-during-interaction';\nimport { PopStateDuringInteractionNavigation } from './navigation/session/interactions/pop-state-during-interaction-navigation';\nimport { SynchroniseInteractionContextIdsWithRoute } from './navigation/session/interactions/synchronise-interaction-context-ids-with-route';\nimport { Navigating } from './navigation/session/navigating';\nimport { NavigationContext } from './navigation/session/navigation-context';\nimport { NavigationSession } from './navigation/session/navigation-session';\nimport { PopStateNavigation } from './navigation/session/pop-state-navigation';\nimport { PlaceAccessGuard } from './place-access-guard';\nimport { PlaceDefinition } from './place-definition';\nimport { PlaceHistory } from './place-history';\nimport { UrlService } from './url-service';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n readonly navigationSessionModel = new MutableValueModel<NavigationSession>();\n readonly navigationInProgress: ValueModelChain<boolean>;\n readonly navigationSessionName: ValueModelChain<string>; // used by tests\n\n private readonly navigationContext: NavigationContext.Impl;\n\n private readonly _activeVisits = new MutableListModel<Visit>();\n readonly activeVisitsByPlaceDefinition: MapModelChain<PlaceDefinition, Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\n\n /**\n * An observable model containing the authoriser function. This allows places to react to changes\n * in permissions when any underlying auth logic changes, e.g. a role being removed from a user.\n */\n private _accessGuard = new DelegatingValueModel<PlaceAccessGuard>().withDefault(new PlaceAccessGuard.NoAuth());\n private redirections: PlaceRouter.Redirections;\n\n constructor(private readonly angularRouter: Router,\n private readonly angularLocation: Location,\n private readonly interactionService: InteractionService,\n private readonly urlService: UrlService,\n private readonly placeHistory: PlaceHistory) {\n super();\n\n if (window['Cypress']) {\n window['aup.PlaceRouter'] = this;\n }\n\n this.routerInteractionAdapter = interactionService.registerPlaceRouter(this);\n\n // TODO: Make this an interface and use 'this' instead.\n this.navigationContext = new NavigationContext.Impl(\n this.urlService,\n this.routerInteractionAdapter,\n (urlSnapshot: UrlSnapshot, options: { replaceUrl: boolean }) => {\n return this.navigateByUrl(urlSnapshot, options);\n },\n state => {\n this.transitionTo(state);\n },\n visits => {\n this.routingSessionFinished(visits);\n });\n\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.navigationInProgress = chain(this.navigationSessionModel).isNotNil();\n\n const idleStateName = chain(this.interactionService.active).map(active => active ? 'IdleDuringInteraction' : 'Idle');\n this.navigationSessionName = chain(this.navigationSessionModel)\n .pluck('name')\n .otherwise(idleStateName);\n\n DebugContext.tag(this._activeVisits, 'PlaceRouter.activeVisits');\n this.activeVisitsByPlaceDefinition = chain(this._activeVisits).indexBy('placeDefinition');\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n angularRouter.events.subscribe(event => {\n // Routing event sequence\n // ======================\n // NavigationStart -> .... -> NavigationCancel --> redirect, go around again in the same session\n // NavigationStart -> .... -> NavigationEnd --> navigation complete, end session.\n // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.\n // =======================\n if (event instanceof NavigationStart) {\n // console.log(`---> NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n if (event.navigationTrigger === 'popstate') {\n this.onPopState(event);\n } else {\n this.onRouterStarted(event);\n }\n // console.log(`<--- NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n }\n if (event instanceof NavigationEnd) {\n // console.log(`---> NavigationEnd[${event.id}]: ${event.url}`);\n this.onRouterEnd(event);\n // console.log(`<--- NavigationEnd[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationError) {\n // console.log(`---> NavigationError[${event.id}]: ${event.url}`);\n this.onRouterError(event);\n // console.log(`<--- NavigationError[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationCancel) {\n // console.log(`---> NavigationCancel[${event.id}]: ${event.url}`);\n this.onRouterCancelled(event);\n // console.log(`<--- NavigationCancel[${event.id}]: ${event.url}`);\n }\n });\n\n // The router needs to know about url changes and in some cases they are the only way the router can know if\n // the back button was clicked.\n angularLocation.onUrlChange(url => this.onUrlChanged(url));\n\n }\n\n get accessGuard(): ValueModel<PlaceAccessGuard> {\n return this._accessGuard.readonly;\n }\n\n // @Trace()\n configureAuth(accessGrant: ValueModel<PlaceAccessGuard>, redirections: PlaceRouter.Redirections) {\n // We need a shitty mutable model until setDelegate is clever enough to work with readonly models.\n const hackyMutableModel = new MutableValueModel<PlaceAccessGuard>();\n const binding = new Binding(hackyMutableModel, accessGrant, {\n toRight(leftValue: PlaceAccessGuard) {\n return lang.illegalState('hackyMutableModel is read only');\n },\n toLeft: (rightValue: PlaceAccessGuard) => rightValue\n });\n binding.writeLeft();\n this._accessGuard.setDelegate(hackyMutableModel);\n this.redirections = redirections;\n }\n\n getAuthenticationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthenticationFailure(activatedRoute, state);\n }\n\n getAuthorisationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthorisationFailure(activatedRoute, state);\n }\n\n get navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.value;\n }\n\n isNavigating(): boolean {\n return this.navigationInProgress.value;\n }\n\n // @Trace()\n onPopState(event: NavigationStart) {\n assert.isTruthy(event.navigationTrigger === 'popstate');\n if (this.currentSession) {\n this.currentSession.onPopState(event);\n } else {\n const poppedHistoryUrl = event.url;\n const currentRouterUrl = this.urlService.getCurrentRouterUrl();\n const session = this.interactionService.isActive() ?\n new PopStateDuringInteractionNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl) :\n new PopStateNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl);\n this.transitionTo(session);\n }\n }\n\n // @Trace()\n onRouterStarted(event: NavigationStart) {\n assert.isFalsey(event.navigationTrigger === 'popstate');\n const inInteraction = this.interactionService.isActive();\n if (this.currentSession) {\n this.currentSession.onRouterStarted(event);\n } else {\n this.transitionTo(this.createNavigationSession(this.urlService.getCurrentRouterUrl()));\n }\n }\n\n // @Trace()\n onUrlChanged(newUrl: string) {\n // the back button can trigger a url change without a navigation session in progress so we\n // console.log(`---> Url Changed ${newUrl}`);\n if (this.currentSession) {\n this.currentSession.onUrlChange(newUrl);\n } else {\n console.log('FYI: url changed without a navigation session in progress');\n }\n // console.log(`<--- Url Changed`);\n }\n\n // @Trace()\n onRouterCancelled(event: NavigationCancel) {\n this.currentSession.onRouterCancelled(event);\n }\n\n // @Trace()\n onRouterError(event: NavigationError) {\n this.currentSession.onRouterError(event);\n }\n\n // @Trace()\n onRouterEnd(event: NavigationEnd) {\n this.currentSession.onRouterEnd(event);\n }\n\n navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n return this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.angularRouter.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n const navigation = this.createNavigationSession(this.urlService.getCurrentRouterUrl());\n navigation.storeVisit(visit);\n this.transitionTo(navigation);\n try {\n await runNavigationCommands(this.angularRouter);\n } finally {\n // Check if the router has finished (in the case where no router change required) and we're still in a\n // transient state and finish of the transition.\n if (!this.angularRouter.getCurrentNavigation() && this.currentSession) {\n this.currentSession.onRouterEnd(new NavigationEnd(-1, '', ''));\n }\n }\n }\n\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras) {\n // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);\n return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n // @Trace()\n async pushVisitChangesToRoute(previous: Visit, next: Visit): Promise<void> {\n this.placeHistory.updateVisit(next);\n\n // FIXME: no route id -> route id duplicates route parameters\n if (next.hasRoutingChangedFrom(previous)) {\n return this.doNavigation(next, router => {\n const urlSnapshot = this.urlService.parseUrl(this.angularRouter.routerState.snapshot.url).updateVisitSegments(next);\n // console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });\n return this.navigateByUrl(urlSnapshot);\n });\n }\n }\n\n\n private createNavigationSession(currentRouterUrl: string): NavigationSession {\n const inInteraction = this.interactionService.isActive();\n return inInteraction ?\n new NavigatingDuringInteraction(this.navigationContext, currentRouterUrl) :\n new Navigating(this.navigationContext, currentRouterUrl);\n }\n\n // @Trace()\n protected transitionTo(next: NavigationSession) {\n const previous = this.navigationSessionModel.value;\n if (!previous) {\n this.placeHistory.notifyNavigationStarted();\n }\n assert.isTruthy(next !== previous);\n // Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);\n this.navigationSessionModel.value = next;\n if (!!previous) {\n previous.dispose();\n }\n next.notifyActive();\n }\n\n // @Trace()\n private routingSessionFinished(visits: Visit[]) {\n if (visits && visits.length > 0) {\n assert.isTruthy(this.navigationInProgress.value);\n this.placeHistory.notifyNavigationFinished(visits);\n // We update the active visits before we finish the session so the\n // place outlets can ignore the incoming changes until things are\n // settled. TODO: can we removed the event'ness here and just do a push?\n this._activeVisits.value = visits;\n }\n const session = this.currentSession;\n session.dispose();\n this.navigationSessionModel.value = null;\n // console.log(`### Router Session Finished (was ${session.toString()})`);\n this.sessionFinishedJobs.forEach(job => job());\n this.sessionFinishedJobs = [];\n }\n\n private runAfterRoutingSessionFinishes(func: () => void) {\n assert.isTruthy(this.navigationInProgress);\n this.sessionFinishedJobs.push(func);\n }\n\n\n /**\n * Sync's the current interaction state with the URL. We need to push something in the URL in order\n * to be able to capture the back button on the first page. If we don't then the back click will exit\n * the app directly and we don't get to ask.\n */\n // @Trace()\n syncInteractionContextIdsWithRouter(): Promise<unknown> {\n if (this.navigationSession) {\n // console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);\n const session = this.navigationSession;\n return new Promise((resolve, reject) => {\n this.runAfterRoutingSessionFinishes(() => {\n this.runAfterRoutingSessionFinishes(resolve);\n const syncSession = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(syncSession);\n });\n });\n } else {\n return new Promise<unknown>(((resolve, reject) => {\n // console.log(`No navigation in progress, starting synchronisation job`);\n this.runAfterRoutingSessionFinishes(resolve);\n const session = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(session);\n }));\n\n }\n }\n\n\n private createRouteParameters(visit: Visit) {\n const def = visit.placeDefinition;\n return visit.hasRouteId() ?\n [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :\n [def.getFormattedRouteParameters(visit)];\n }\n\n}\n\nexport namespace PlaceRouter {\n\n export interface Redirections {\n onAuthenticationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n\n onAuthorisationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n }\n\n}\n"]}
1
+ {"version":3,"file":"place-router.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-router.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAGL,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEf,eAAe,EACf,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,GAAG,EACH,gBAAgB,EAChB,IAAI,EAGJ,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iEAAiE,CAAC;AAC9G,OAAO,EAAE,mCAAmC,EAAE,MAAM,2EAA2E,CAAC;AAChI,OAAO,EAAE,yCAAyC,EAAE,MAAM,kFAAkF,CAAC;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AkB;YAWlB,UAAU;YADV,YAAY","sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n ActivatedRouteSnapshot,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router,\n RouterStateSnapshot\n} from '@angular/router';\nimport {\n assert,\n Binding,\n DebugContext,\n DelegatingValueModel,\n Dsl,\n GarbageCollector,\n lang,\n ListModel,\n MapModelChain,\n MutableListModel,\n MutableValueModel,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigatingDuringInteraction } from './navigation/session/interactions/navigating-during-interaction';\nimport { PopStateDuringInteractionNavigation } from './navigation/session/interactions/pop-state-during-interaction-navigation';\nimport { SynchroniseInteractionContextIdsWithRoute } from './navigation/session/interactions/synchronise-interaction-context-ids-with-route';\nimport { Navigating } from './navigation/session/navigating';\nimport { NavigationContext } from './navigation/session/navigation-context';\nimport { NavigationSession } from './navigation/session/navigation-session';\nimport { PopStateNavigation } from './navigation/session/pop-state-navigation';\nimport { PlaceAccessGuard } from './place-access-guard';\nimport { PlaceDefinition } from './place-definition';\nimport { PlaceHistory } from './place-history';\nimport { UrlService } from './url-service';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n readonly navigationSessionModel = new MutableValueModel<NavigationSession>();\n readonly navigationInProgress: ValueModelChain<boolean>;\n readonly navigationSessionName: ValueModelChain<string>; // used by tests\n\n private readonly navigationContext: NavigationContext.Impl;\n\n private readonly _activeVisits = new MutableListModel<Visit>();\n readonly activeVisitsByPlaceDefinition: MapModelChain<PlaceDefinition, Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\n\n /**\n * An observable model containing the authoriser function. This allows places to react to changes\n * in permissions when any underlying auth logic changes, e.g. a role being removed from a user.\n */\n private _accessGuard = new DelegatingValueModel<PlaceAccessGuard>().withDefault(new PlaceAccessGuard.NoAuth());\n private redirections: PlaceRouter.Redirections;\n\n constructor(private readonly angularRouter: Router,\n private readonly angularLocation: Location,\n private readonly interactionService: InteractionService,\n private readonly urlService: UrlService,\n private readonly placeHistory: PlaceHistory) {\n super();\n\n if (window['Cypress']) {\n window['aup.PlaceRouter'] = this;\n }\n\n this.routerInteractionAdapter = interactionService.registerPlaceRouter(this);\n\n // TODO: Make this an interface and use 'this' instead.\n this.navigationContext = new NavigationContext.Impl(\n this.urlService,\n this.routerInteractionAdapter,\n (urlSnapshot: UrlSnapshot, options: { replaceUrl: boolean }) => {\n return this.navigateByUrl(urlSnapshot, options);\n },\n state => {\n this.transitionTo(state);\n },\n visits => {\n this.routingSessionFinished(visits);\n });\n\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.navigationInProgress = chain(this.navigationSessionModel).isNotNil();\n\n const idleStateName = chain(this.interactionService.active).map(active => active ? 'IdleDuringInteraction' : 'Idle');\n this.navigationSessionName = chain(this.navigationSessionModel)\n .pluck('name')\n .otherwise(idleStateName);\n\n DebugContext.tag(this._activeVisits, 'PlaceRouter.activeVisits');\n this.activeVisitsByPlaceDefinition = chain(this._activeVisits).indexBy('placeDefinition');\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n angularRouter.events.subscribe(event => {\n // Routing event sequence\n // ======================\n // NavigationStart -> .... -> NavigationCancel --> redirect, go around again in the same session\n // NavigationStart -> .... -> NavigationEnd --> navigation complete, end session.\n // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.\n // =======================\n if (event instanceof NavigationStart) {\n // console.log(`---> NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n if (event.navigationTrigger === 'popstate') {\n this.onPopState(event);\n } else {\n this.onRouterStarted(event);\n }\n // console.log(`<--- NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n }\n if (event instanceof NavigationEnd) {\n // console.log(`---> NavigationEnd[${event.id}]: ${event.url}`);\n this.onRouterEnd(event);\n // console.log(`<--- NavigationEnd[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationError) {\n // console.log(`---> NavigationError[${event.id}]: ${event.url}`);\n this.onRouterError(event);\n // console.log(`<--- NavigationError[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationCancel) {\n // console.log(`---> NavigationCancel[${event.id}]: ${event.url}`);\n this.onRouterCancelled(event);\n // console.log(`<--- NavigationCancel[${event.id}]: ${event.url}`);\n }\n });\n\n // The router needs to know about url changes and in some cases they are the only way the router can know if\n // the back button was clicked.\n angularLocation.onUrlChange(url => this.onUrlChanged(url));\n\n }\n\n get accessGuard(): ValueModel<PlaceAccessGuard> {\n return this._accessGuard.readonly;\n }\n\n // @Trace()\n configureAuth(accessGrant: ValueModel<PlaceAccessGuard>, redirections: PlaceRouter.Redirections) {\n // We need a shitty mutable model until setDelegate is clever enough to work with readonly models.\n const hackyMutableModel = new MutableValueModel<PlaceAccessGuard>();\n const binding = new Binding(hackyMutableModel, accessGrant, {\n toRight(leftValue: PlaceAccessGuard) {\n return lang.illegalState('hackyMutableModel is read only');\n },\n toLeft: (rightValue: PlaceAccessGuard) => rightValue\n });\n binding.writeLeft();\n this._accessGuard.setDelegate(hackyMutableModel);\n this.redirections = redirections;\n }\n\n getAuthenticationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthenticationFailure(activatedRoute, state);\n }\n\n getAuthorisationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthorisationFailure(activatedRoute, state);\n }\n\n get navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.value;\n }\n\n isNavigating(): boolean {\n return this.navigationInProgress.value;\n }\n\n waitUntilIdle(): Promise<void> {\n const { when } = Dsl.disposeWith(this);\n return new Promise<void>(resolve => {\n when(this.navigationInProgress).becomesFalsey(() => resolve(), {\n initialValue: 'evaluate',\n once: true\n })\n })\n }\n\n // @Trace()\n onPopState(event: NavigationStart) {\n assert.isTruthy(event.navigationTrigger === 'popstate');\n if (this.currentSession) {\n this.currentSession.onPopState(event);\n } else {\n const poppedHistoryUrl = event.url;\n const currentRouterUrl = this.urlService.getCurrentRouterUrl();\n const session = this.interactionService.isActive() ?\n new PopStateDuringInteractionNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl) :\n new PopStateNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl);\n this.transitionTo(session);\n }\n }\n\n // @Trace()\n onRouterStarted(event: NavigationStart) {\n assert.isFalsey(event.navigationTrigger === 'popstate');\n const inInteraction = this.interactionService.isActive();\n if (this.currentSession) {\n this.currentSession.onRouterStarted(event);\n } else {\n this.transitionTo(this.createNavigationSession(this.urlService.getCurrentRouterUrl()));\n }\n }\n\n // @Trace()\n onUrlChanged(newUrl: string) {\n // the back button can trigger a url change without a navigation session in progress so we\n // console.log(`---> Url Changed ${newUrl}`);\n if (this.currentSession) {\n this.currentSession.onUrlChange(newUrl);\n } else {\n console.log('FYI: url changed without a navigation session in progress');\n }\n // console.log(`<--- Url Changed`);\n }\n\n // @Trace()\n onRouterCancelled(event: NavigationCancel) {\n this.currentSession.onRouterCancelled(event);\n }\n\n // @Trace()\n onRouterError(event: NavigationError) {\n this.currentSession.onRouterError(event);\n }\n\n // @Trace()\n onRouterEnd(event: NavigationEnd) {\n this.currentSession.onRouterEnd(event);\n }\n\n navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n return this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.angularRouter.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n const navigation = this.createNavigationSession(this.urlService.getCurrentRouterUrl());\n navigation.storeVisit(visit);\n this.transitionTo(navigation);\n try {\n await runNavigationCommands(this.angularRouter);\n } finally {\n // Check if the router has finished (in the case where no router change required) and we're still in a\n // transient state and finish of the transition.\n if (!this.angularRouter.getCurrentNavigation() && this.currentSession) {\n this.currentSession.onRouterEnd(new NavigationEnd(-1, '', ''));\n }\n }\n }\n\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras) {\n // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);\n return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n // @Trace()\n async pushVisitChangesToRoute(previous: Visit, next: Visit): Promise<void> {\n this.placeHistory.updateVisit(next);\n\n // FIXME: no route id -> route id duplicates route parameters\n if (next.hasRoutingChangedFrom(previous)) {\n return this.doNavigation(next, router => {\n const urlSnapshot = this.urlService.parseUrl(this.angularRouter.routerState.snapshot.url).updateVisitSegments(next);\n // console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });\n return this.navigateByUrl(urlSnapshot);\n });\n }\n }\n\n\n private createNavigationSession(currentRouterUrl: string): NavigationSession {\n const inInteraction = this.interactionService.isActive();\n return inInteraction ?\n new NavigatingDuringInteraction(this.navigationContext, currentRouterUrl) :\n new Navigating(this.navigationContext, currentRouterUrl);\n }\n\n // @Trace()\n protected transitionTo(next: NavigationSession) {\n const previous = this.navigationSessionModel.value;\n if (!previous) {\n this.placeHistory.notifyNavigationStarted();\n }\n assert.isTruthy(next !== previous);\n // Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);\n this.navigationSessionModel.value = next;\n if (!!previous) {\n previous.dispose();\n }\n next.notifyActive();\n }\n\n // @Trace()\n private routingSessionFinished(visits: Visit[]) {\n if (visits && visits.length > 0) {\n assert.isTruthy(this.navigationInProgress.value);\n this.placeHistory.notifyNavigationFinished(visits);\n // We update the active visits before we finish the session so the\n // place outlets can ignore the incoming changes until things are\n // settled. TODO: can we removed the event'ness here and just do a push?\n this._activeVisits.value = visits;\n }\n const session = this.currentSession;\n session.dispose();\n this.navigationSessionModel.value = null;\n // console.log(`### Router Session Finished (was ${session.toString()})`);\n this.sessionFinishedJobs.forEach(job => job());\n this.sessionFinishedJobs = [];\n }\n\n private runAfterRoutingSessionFinishes(func: () => void) {\n assert.isTruthy(this.navigationInProgress);\n this.sessionFinishedJobs.push(func);\n }\n\n\n /**\n * Sync's the current interaction state with the URL. We need to push something in the URL in order\n * to be able to capture the back button on the first page. If we don't then the back click will exit\n * the app directly and we don't get to ask.\n */\n // @Trace()\n syncInteractionContextIdsWithRouter(): Promise<unknown> {\n if (this.navigationSession) {\n // console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);\n const session = this.navigationSession;\n return new Promise((resolve, reject) => {\n this.runAfterRoutingSessionFinishes(() => {\n this.runAfterRoutingSessionFinishes(resolve);\n const syncSession = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(syncSession);\n });\n });\n } else {\n return new Promise<unknown>(((resolve, reject) => {\n // console.log(`No navigation in progress, starting synchronisation job`);\n this.runAfterRoutingSessionFinishes(resolve);\n const session = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(session);\n }));\n\n }\n }\n\n\n private createRouteParameters(visit: Visit) {\n const def = visit.placeDefinition;\n return visit.hasRouteId() ?\n [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :\n [def.getFormattedRouteParameters(visit)];\n }\n\n}\n\nexport namespace PlaceRouter {\n\n export interface Redirections {\n onAuthenticationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n\n onAuthorisationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n }\n\n}\n"]}
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"PlaceRouter":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@coolon/pectin","name":"GarbageCollector","line":48,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":45,"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"}],"getAuthorisationFailureRedirect":[{"__symbolic":"method"}],"isNavigating":[{"__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":67,"character":46},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":68,"character":48},{"__symbolic":"reference","module":"../interaction/services/interaction.service","name":"InteractionService","line":69,"character":51},{"__symbolic":"reference","module":"./url-service","name":"UrlService","line":70,"character":43},{"__symbolic":"reference","module":"./place-history","name":"PlaceHistory","line":71,"character":45}]}],"configureAuth":[{"__symbolic":"method"}],"getAuthenticationFailureRedirect":[{"__symbolic":"method"}],"getAuthorisationFailureRedirect":[{"__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":{}}}}}]
@@ -15,7 +15,7 @@ export class VisitSanitiser {
15
15
  const routeIdDef = placeDef.getRouteIdParameterDef();
16
16
  const routeId = visit.getRouteId();
17
17
  const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector, this.navigationSession.isPopState);
18
- console.log({ routeId, sanitisedValue });
18
+ // console.log({routeId, sanitisedValue});
19
19
  // ###------- EARLY EXIT --------###
20
20
  if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
21
21
  // if the route id has changed we redirect immediately as other
@@ -1 +1 @@
1
- {"version":3,"file":"visit-sanitiser.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/visit-sanitiser.ts"],"names":[],"mappings":";AAOA,MAAM,OAAO,cAAc;IACzB,YAAoB,iBAAoC,EAAU,cAAsC,EAAU,MAAc,EAAU,YAA0B,EAAU,QAAkB;QAA5K,sBAAiB,GAAjB,iBAAiB,CAAmB;QAAU,mBAAc,GAAd,cAAc,CAAwB;QAAU,WAAM,GAAN,MAAM,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAc;QAAU,aAAQ,GAAR,QAAQ,CAAU;IAEhM,CAAC;IAED,WAAW;IACL,QAAQ,CAAC,KAAY;;YACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC;YACvC,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE;gBACzB,MAAM,UAAU,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;gBACrD,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;gBACnC,MAAM,cAAc,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBACtI,OAAO,CAAC,GAAG,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;gBACvC,oCAAoC;gBACpC,IAAI,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE;oBAClD,+DAA+D;oBAC/D,qCAAqC;oBACrC,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;iBAClD;aACF;YAED,2EAA2E;YAC3E,MAAM,aAAa,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,YAAY,CAAC,GAAG,CAAC,IAAI,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.getParameter(def.name);\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
+ {"version":3,"file":"visit-sanitiser.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/route/visit-sanitiser.ts"],"names":[],"mappings":";AAOA,MAAM,OAAO,cAAc;IACzB,YAAoB,iBAAoC,EAAU,cAAsC,EAAU,MAAc,EAAU,YAA0B,EAAU,QAAkB;QAA5K,sBAAiB,GAAjB,iBAAiB,CAAmB;QAAU,mBAAc,GAAd,cAAc,CAAwB;QAAU,WAAM,GAAN,MAAM,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAc;QAAU,aAAQ,GAAR,QAAQ,CAAU;IAEhM,CAAC;IAED,WAAW;IACL,QAAQ,CAAC,KAAY;;YACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,eAAe,CAAC;YACvC,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE;gBACzB,MAAM,UAAU,GAAG,QAAQ,CAAC,sBAAsB,EAAE,CAAC;gB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AAC,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.getParameter(def.name);\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"]}
@@ -3246,11 +3246,29 @@ class TreeToListModel extends ComputedListModel {
3246
3246
  }
3247
3247
 
3248
3248
  // import {T } from '@client/api/light-architect/model/area/area.class';
3249
+ // TODO:
3250
+ // Selection Models:
3251
+ // - as simple navigation tree
3252
+ // - as editable grid (selecte all, even hidden etc?)
3253
+ // - fixing selection on underlying model changes.
3254
+ // - rendering selection: row highlighting, checkboxes (in the tree renderer or in separate column), both.
3255
+ // Expansion Models:
3256
+ // - Add ability to auto show to depth
3257
+ // - Add a predicate to check default expansion (i.e. has children of a certain type)
3258
+ //
3249
3259
  class TreeTableModel extends AbstractTableModel {
3250
3260
  constructor(source, treeExpansionModel) {
3251
3261
  super(source);
3252
3262
  this.treeExpansionModel = treeExpansionModel;
3253
3263
  }
3264
+ static fromRoot(sourceOfTruth, builder) {
3265
+ const garbage = new GarbageCollector();
3266
+ const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);
3267
+ const children = chain(sourceOfTruth).mapToList(root => [root]);
3268
+ const model = this.fromList(children, builder);
3269
+ model.registerDisposable(garbage);
3270
+ return model;
3271
+ }
3254
3272
  static fromChildrenOf(sourceOfTruth, builder) {
3255
3273
  const garbage = new GarbageCollector();
3256
3274
  const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(garbage);
@@ -6326,6 +6344,15 @@ class PlaceRouter extends GarbageCollector {
6326
6344
  isNavigating() {
6327
6345
  return this.navigationInProgress.value;
6328
6346
  }
6347
+ waitUntilIdle() {
6348
+ const { when } = Dsl.disposeWith(this);
6349
+ return new Promise(resolve => {
6350
+ when(this.navigationInProgress).becomesFalsey(() => resolve(), {
6351
+ initialValue: 'evaluate',
6352
+ once: true
6353
+ });
6354
+ });
6355
+ }
6329
6356
  // @Trace()
6330
6357
  onPopState(event) {
6331
6358
  assert.isTruthy(event.navigationTrigger === 'popstate');
@@ -7338,7 +7365,7 @@ class VisitSanitiser {
7338
7365
  const routeIdDef = placeDef.getRouteIdParameterDef();
7339
7366
  const routeId = visit.getRouteId();
7340
7367
  const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector, this.navigationSession.isPopState);
7341
- console.log({ routeId, sanitisedValue });
7368
+ // console.log({routeId, sanitisedValue});
7342
7369
  // ###------- EARLY EXIT --------###
7343
7370
  if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7344
7371
  // if the route id has changed we redirect immediately as other