@coolon/angular-ui-powerups 12.0.3 → 12.0.4

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.
@@ -80,7 +80,7 @@ import { AbstractTableModel } from '../abstract-table-model';
80
80
  */
81
81
  export class TableModel extends AbstractTableModel {
82
82
  static fromList(sourceOfTruth, builder) {
83
- const model = new TableModel(sourceOfTruth);
83
+ const model = new this(sourceOfTruth);
84
84
  if (builder)
85
85
  builder(model);
86
86
  return model;
@@ -1 +1 @@
1
- {"version":3,"file":"table-model.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/components/tables/table/table-model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,MAAM,OAAO,UAAgB,SAAQ,kBAAuB;IAE1D,MAAM,CAAC,QAAQ,CAAM,aAA6B,EAAE,OAA+C;QACjG,MAAM,KAAK,GAAG,IAAI,UAAU,CAAM,aAAa,CAAC,CAAC;QACjD,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kBAAkB,CAAC,cAAoC,EAAE,mBAAmD;QAC1G,OAAO,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["import { ListModel, SelectionModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../abstract-table-model';\nimport { SelectionColumnModel } from './column-model';\n\n/**\n * Example:\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"firstName\");\n * table.pluck(\"lastName\");\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\n *\n * Editable tables\n * @example\n * const saveCommand = UnaryCommand.create((form: Form<Hero>) => {\n * if (form.validate()) {\n * // normal form save stuff\n * return true; // finish editing\n * }\n * return false; // continue editiing\n * }\n * const colorsNames: ListModel<string> = ...;\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"firstName\").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: DirtyTrackingForm.ValueModel<string> | ValueModel<string>; }\n * table.pluck(\"lastName\").cellEditor(StringInputComponent, {\n * validators: [Validator.present(\"We need a last name\")]\n * });\n * table.pluck(\"age\").cellEditor(NumberInputComponent);\n * table.pluck(\"favoriteColor\").cellEditor(SelectInputComponent, {\n * initialiseComponent(component: SelectInputComponent) {\n * selectInput.optionsModel = colorsNames; // <- initialise our component\n * }\n * });\n * table.addEditControls(saveCommand); // <- required to enable editing\n * });\n *\n * Selection models\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model\n * table.pluck(\"firstName\");\n * table.pluck(\"lastName\");\n * });\n *\n * Custom cell renderers and editors\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"favoriteColor\")\n * .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {\n * // configure your component with what ever you need.\n * });\n * .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }\n * .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: DirtyTrackingForm.ValueModel<string> | ValueModel<string>; }\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\n *\n * Template columns\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model\n * table.addTemplateColumn(\"myTemplate\");\n * });\n *\n * <div *aupColumnTemplate=\"let hero; columnId: 'myTemplate'\">{{hero.age}}</div>\n *\n * I18n\n * @example\n * [table.yml]\n * table:\n * columns(ColumnTextProperties[]):\n * firstName:\n * headerText: \"First Name\"\n * fullName:\n * headerText: \"Full Name\"\n *\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"favoriteColor\").cellRenderer(...).cellEditor(...);\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n *\n * table.columnTextProperties(I18n.table.columns); // <- configures all columns\n * });\n */\nexport class TableModel<Row> extends AbstractTableModel<Row> {\n\n static fromList<Row>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TableModel<Row>) => void): TableModel<Row> {\n const model = new TableModel<Row>(sourceOfTruth);\n if (builder) builder(model);\n return model;\n }\n\n addSelectionColumn(selectionModel?: SelectionModel<Row>, showSelectionColumn?: ValueModel<boolean> | boolean): SelectionColumnModel<Row> {\n return this._addSelectionColumn(selectionModel, showSelectionColumn);\n }\n}\n"]}
1
+ {"version":3,"file":"table-model.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/components/tables/table/table-model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,MAAM,OAAO,UAAgB,SAAQ,kBAAuB;IAE1D,MAAM,CAAC,QAAQ,CAAM,aAA6B,EAAE,OAA+C;QACjG,MAAM,KAAK,GAAG,IAAI,IAAI,CAAM,aAAa,CAAC,CAAC;QAC3C,IAAI,OAAO;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,kBAAkB,CAAC,cAAoC,EAAE,mBAAmD;QAC1G,OAAO,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["import { ListModel, SelectionModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../abstract-table-model';\nimport { SelectionColumnModel } from './column-model';\n\n/**\n * Example:\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"firstName\");\n * table.pluck(\"lastName\");\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\n *\n * Editable tables\n * @example\n * const saveCommand = UnaryCommand.create((form: Form<Hero>) => {\n * if (form.validate()) {\n * // normal form save stuff\n * return true; // finish editing\n * }\n * return false; // continue editiing\n * }\n * const colorsNames: ListModel<string> = ...;\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"firstName\").cellEditor(StringInputComponent); <-- interface CellEditor { valueModel: DirtyTrackingForm.ValueModel<string> | ValueModel<string>; }\n * table.pluck(\"lastName\").cellEditor(StringInputComponent, {\n * validators: [Validator.present(\"We need a last name\")]\n * });\n * table.pluck(\"age\").cellEditor(NumberInputComponent);\n * table.pluck(\"favoriteColor\").cellEditor(SelectInputComponent, {\n * initialiseComponent(component: SelectInputComponent) {\n * selectInput.optionsModel = colorsNames; // <- initialise our component\n * }\n * });\n * table.addEditControls(saveCommand); // <- required to enable editing\n * });\n *\n * Selection models\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model\n * table.pluck(\"firstName\");\n * table.pluck(\"lastName\");\n * });\n *\n * Custom cell renderers and editors\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"favoriteColor\")\n * .cellHeaderRenderer(CellHeaderRendererComponent, (component, column) => {\n * // configure your component with what ever you need.\n * });\n * .cellRenderer(CellRendererComponent) // <-- interface CellEditor { value: string; }\n * .cellEditor(CellEditorComponent.); // <-- interface CellEditor { valueModel: DirtyTrackingForm.ValueModel<string> | ValueModel<string>; }\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\n *\n * Template columns\n * @example\n * const model = TableModel.fromList(heroList, table => {\n * table.addSelectionColumn(selectionModel); // <- can be single or multiple selection model\n * table.addTemplateColumn(\"myTemplate\");\n * });\n *\n * <div *aupColumnTemplate=\"let hero; columnId: 'myTemplate'\">{{hero.age}}</div>\n *\n * I18n\n * @example\n * [table.yml]\n * table:\n * columns(ColumnTextProperties[]):\n * firstName:\n * headerText: \"First Name\"\n * fullName:\n * headerText: \"Full Name\"\n *\n * const model = TableModel.fromList(heroList, table => {\n * table.pluck(\"favoriteColor\").cellRenderer(...).cellEditor(...);\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n *\n * table.columnTextProperties(I18n.table.columns); // <- configures all columns\n * });\n */\nexport class TableModel<Row> extends AbstractTableModel<Row> {\n\n static fromList<Row>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TableModel<Row>) => void): TableModel<Row> {\n const model = new this<Row>(sourceOfTruth);\n if (builder) builder(model);\n return model;\n }\n\n addSelectionColumn(selectionModel?: SelectionModel<Row>, showSelectionColumn?: ValueModel<boolean> | boolean): SelectionColumnModel<Row> {\n return this._addSelectionColumn(selectionModel, showSelectionColumn);\n }\n}\n"]}
@@ -39,7 +39,7 @@ export class TreeTableModel extends AbstractTableModel {
39
39
  static fromList(sourceOfTruth, builder) {
40
40
  const treeExpansionModel = new TreeExpansionModel(sourceOfTruth.identityOf);
41
41
  const nodes = new TreeToListModel(sourceOfTruth, treeExpansionModel);
42
- const model = new TreeTableModel(nodes, treeExpansionModel);
42
+ const model = new this(nodes, treeExpansionModel);
43
43
  model.registerDisposable(nodes);
44
44
  if (builder)
45
45
  builder(model);
@@ -1 +1 @@
1
- {"version":3,"file":"tree-table-model.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/components/tables/tree-table/tree-table-model.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,4EAA4E;AAC5E,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAA4D,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,o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OAAO,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,6BAA6B,CAAC,IAA4B;QACxD,IAAI,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,kBAAkB,CAAC,cAAuD,EAAE,mBAAmD;QAC7H,OAAO,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACvE,CAAC;CAoCF;AAaD,oGAAoG;AACpG,EAAE;AACF,8BAA8B;AAC9B,gCAAgC;AAChC,EAAE;AACF,6CAA6C;AAC7C,eAAe;AACf,kDAAkD;AAClD,MAAM;AACN,EAAE;AACF,+BAA+B;AAC/B,4BAA4B;AAC5B,MAAM;AACN,EAAE;AACF,sDAAsD;AACtD,uCAAuC;AACvC,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,0BAA0B;AAC1B,MAAM;AACN,EAAE;AACF,IAAI;AAEJ,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';\nimport { TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';\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, SelectionModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../abstract-table-model';\nimport { CustomTemplateColumnModel, SelectionColumnModel } from '../table/column-model';\nimport { TableComponent } from '../table/table.component';\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 addSelectionColumn(selectionModel?: SelectionModel<DecoratedTreeNode<Row>>, showSelectionColumn?: ValueModel<boolean> | boolean): SelectionColumnModel<DecoratedTreeNode<Row>> {\n return this._addSelectionColumn(selectionModel, showSelectionColumn);\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\nexport namespace TreeTableModel {\n\n export interface Options<T, K extends keyof T> {\n storeIdIn: MutableValueModel<K>\n }\n\n}\n\n\n// export 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/tables/tree-table/tree-table-model.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,4EAA4E;AAC5E,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAA4D,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAI7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,QAAQ;AACR,uBAAuB;AACvB,mCAAmC;AACnC,0DAA0D;AAC1D,uDAAuD;AACvD,+GAA+G;AAC/G,uBAAuB;AACvB,2C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C,cAAuD,EAAE,mBAAmD;QAC7H,OAAO,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IACvE,CAAC;CAoCF;AAaD,oGAAoG;AACpG,EAAE;AACF,8BAA8B;AAC9B,gCAAgC;AAChC,EAAE;AACF,6CAA6C;AAC7C,eAAe;AACf,kDAAkD;AAClD,MAAM;AACN,EAAE;AACF,+BAA+B;AAC/B,4BAA4B;AAC5B,MAAM;AACN,EAAE;AACF,sDAAsD;AACtD,uCAAuC;AACvC,MAAM;AACN,EAAE;AACF,gCAAgC;AAChC,0BAA0B;AAC1B,MAAM;AACN,EAAE;AACF,IAAI;AAEJ,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';\nimport { TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';\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, SelectionModel, ValueModel } from '@coolon/pectin';\nimport { AbstractTableModel } from '../abstract-table-model';\nimport { CustomTemplateColumnModel, SelectionColumnModel } from '../table/column-model';\nimport { TableComponent } from '../table/table.component';\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 this<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 addSelectionColumn(selectionModel?: SelectionModel<DecoratedTreeNode<Row>>, showSelectionColumn?: ValueModel<boolean> | boolean): SelectionColumnModel<DecoratedTreeNode<Row>> {\n return this._addSelectionColumn(selectionModel, showSelectionColumn);\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\nexport namespace TreeTableModel {\n\n export interface Options<T, K extends keyof T> {\n storeIdIn: MutableValueModel<K>\n }\n\n}\n\n\n// export 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"]}
@@ -3670,7 +3670,7 @@ class TreeTableModel extends AbstractTableModel {
3670
3670
  static fromList(sourceOfTruth, builder) {
3671
3671
  const treeExpansionModel = new TreeExpansionModel(sourceOfTruth.identityOf);
3672
3672
  const nodes = new TreeToListModel(sourceOfTruth, treeExpansionModel);
3673
- const model = new TreeTableModel(nodes, treeExpansionModel);
3673
+ const model = new this(nodes, treeExpansionModel);
3674
3674
  model.registerDisposable(nodes);
3675
3675
  if (builder)
3676
3676
  builder(model);
@@ -5447,7 +5447,7 @@ SelectInputActivity.decorators = [
5447
5447
  */
5448
5448
  class TableModel extends AbstractTableModel {
5449
5449
  static fromList(sourceOfTruth, builder) {
5450
- const model = new TableModel(sourceOfTruth);
5450
+ const model = new this(sourceOfTruth);
5451
5451
  if (builder)
5452
5452
  builder(model);
5453
5453
  return model;