@coolon/angular-ui-powerups 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/assets/table.scss +12 -1
- package/bundles/coolon-angular-ui-powerups.umd.js +64 -21
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -2
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/components/card-container/card-container.component.js +1 -1
- package/esm2015/lib/components/card-container/card-container.component.metadata.json +1 -1
- package/esm2015/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm2015/lib/components/table/column-model.js +45 -9
- package/esm2015/lib/components/table/column-model.js.map +1 -1
- package/esm2015/lib/components/table/column-model.metadata.json +1 -1
- package/esm2015/lib/components/table/table-model.js +13 -5
- package/esm2015/lib/components/table/table-model.js.map +1 -1
- package/esm2015/lib/components/table/table-model.metadata.json +1 -1
- package/esm2015/lib/components/table/table.component.js +6 -7
- package/esm2015/lib/components/table/table.component.js.map +1 -1
- package/esm2015/lib/components/table/table.component.metadata.json +1 -1
- package/esm5/lib/components/card-container/card-container.component.js +1 -1
- package/esm5/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm5/lib/components/table/column-model.js +45 -9
- package/esm5/lib/components/table/column-model.js.map +1 -1
- package/esm5/lib/components/table/table-model.js +13 -5
- package/esm5/lib/components/table/table-model.js.map +1 -1
- package/esm5/lib/components/table/table.component.js +6 -7
- package/esm5/lib/components/table/table.component.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +65 -22
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +65 -22
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/table/column-model.d.ts +15 -9
- package/lib/components/table/table-model.d.ts +5 -2
- package/lib/components/table/table.component.d.ts +5 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-model.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table-model.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,WAAW,EACX,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,SAAS,EACT,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,EACL,YAAY,EACZ,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,oGAAoG;AACpG,oGAAoG;AAGpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH;IA4BE,oBAA8B,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QA1B1C,aAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAElC,aAAQ,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAE7D,oBAAe,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAoB3D,gBAAW,GAA4B,UAAC,GAAG,IAAK,OAAA,IAAI,IAAI,EAAO,EAAf,CAAe,CAAC;QAGtE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;QACrC,IAAA,mCAA2F,EAAzF,gBAAK,EAAE,oBAAO,EAAE,kBAAM,EAAE,cAAI,EAAE,gBAAK,EAAE,oBAAO,EAAE,sBAA2C,CAAC;QAClG,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,O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AC,cAAc,EAAE,CAAC;yCA6BZ,SAAS;OA5B3C,UAAU,CAgJtB;IAAD,iBAAC;CAAA,AAhJD,IAgJC;SAhJY,UAAU","sourcesContent":["import {\n assert,\n BooleanValueModelChain,\n CanIdentify,\n Dsl,\n Form,\n GarbageCollector,\n lang,\n ListModel,\n ListModelChain,\n MapModelChain,\n MutableListModel,\n SelectionModel,\n TrackExternal,\n Types,\n UnaryCommand,\n ValueModelChain\n} from '@coolon/pectin';\nimport {\n ColumnModel,\n CustomTemplateColumnModel,\n CustomValueColumnModel,\n EditorControlColumnModel,\n ListPropertyColumnModel,\n PropertyColumnModel,\n SelectionColumnModel\n} from './column-model';\nimport { ColumnTextProperties } from './column-text-properties';\nimport { EditSession } from './edit-session';\n\n// export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];\n// export type NumberPropertiesOf<T> = { [K in keyof T]: T[K] extends number ? K : never }[keyof T];\n\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: FormValueModel<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: FormValueModel<string> | ValueModel<string>; }\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\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 */\n@TrackExternal.Strategy(new TrackExternal.OneTimeBinding())\nexport class TableModel<Row> {\n\n private readonly _garbage = new GarbageCollector();\n\n private readonly _columns = new MutableListModel<ColumnModel<Row>>();\n private _columnsById: MapModelChain<string, ColumnModel<Row>>;\n private _editorSessions = new MutableListModel<EditSession<Row>>();\n private readonly _rowsBeingEdited: MutableListModel<Row>;\n\n private _columnTextPropertiesLookup: { [columnName: string]: () => ColumnTextProperties };\n\n readonly identityOf: CanIdentify<Row>['identityOf'];\n private saveCommand: UnaryCommand<Form<Row>, boolean>;\n private _editorSessionByRowId: MapModelChain<any, EditSession<Row>>;\n\n readonly editing: BooleanValueModelChain;\n readonly dataSource: ListModelChain<Row>;\n readonly firstEditableColumn: ValueModelChain<ColumnModel<Row>>;\n private selectionColumnModel: SelectionColumnModel<Row>;\n\n static fromList<Row>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TableModel<Row>) => void): TableModel<Row> {\n const model = new TableModel<Row>(sourceOfTruth);\n builder(model);\n return model;\n }\n\n private _createForm: (row: Row) => Form<Row> = (row) => new Form<Row>();\n\n protected constructor(private sourceOfTruth: ListModel<Row>) {\n this.identityOf = sourceOfTruth.identityOf;\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);\n this._columnsById = chain(this._columns).indexBy('columnId');\n this._rowsBeingEdited = new MutableListModel<Row>([], {\n identifiedWith: this.identityOf\n });\n this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');\n this.editing = chain(this._editorSessions).count().isGreaterThan(0);\n this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);\n this.firstEditableColumn = chain(this.columns).select(c => c.hasEditorPortal()).first();\n }\n\n get rowsBeingEdited(): ListModel<Row> {\n return this._rowsBeingEdited.readonly;\n }\n\n getTrackByFunction() {\n return (index: number, item: Row) => {\n return this.identityOf ? this.identityOf(item) : index;\n };\n }\n\n get columns(): ListModel<ColumnModel<Row>> {\n return this._columns.readonly;\n }\n\n pluck<P extends Types.ValuePropertiesOf<Row>>(property: P): PropertyColumnModel<Row, P> {\n return this.addColumn(new PropertyColumnModel<Row, P>(property, this));\n }\n\n pluckList<P extends Types.ArrayPropertiesOf<Row>>(property: P): ListPropertyColumnModel<Row, P> {\n return this.addColumn(new ListPropertyColumnModel<Row, P>(property, this));\n }\n\n addSelectionColumn(selectionModel: SelectionModel<Row>, options?: SelectionColumnModel.SelectionOptions): SelectionColumnModel<Row> {\n assert.isNil(this.selectionColumnModel);\n this.selectionColumnModel = new SelectionColumnModel<Row>('selection', this, selectionModel, options);\n return this.addColumn(this.selectionColumnModel);\n }\n\n addEditControls(saveCommand: UnaryCommand<Form<Row>, boolean>): EditorControlColumnModel<Row> {\n this.saveCommand = saveCommand;\n return this.addColumn(new EditorControlColumnModel<Row>('editControls', saveCommand, this));\n }\n\n addCustomColumn<V>(columnId: string, dataAccessor: (row: Row) => V): CustomValueColumnModel<Row, V> {\n return this.addColumn(new CustomValueColumnModel<Row, V>(columnId, this, dataAccessor));\n }\n\n addTemplateColumn<V>(columnId: string): CustomTemplateColumnModel<Row> {\n return this.addColumn(new CustomTemplateColumnModel<Row>(columnId, this));\n }\n\n useFormFactory(factory: (row: Row) => Form<Row>): this {\n this._createForm = factory;\n return this;\n }\n\n protected addColumn<C extends ColumnModel<Row>>(column: C): C {\n if (this._columnsById.get(column.columnId)) {\n lang.illegalState(`Column with id=${column.columnId} already exists`);\n } else {\n this._columns.push(column);\n }\n return column;\n }\n\n columnTextProperties(columnTextProperties: { [columnName: string]: () => ColumnTextProperties }) {\n this._columnTextPropertiesLookup = columnTextProperties;\n }\n\n getColumnTextProperties(column: ColumnModel<Row>): ColumnTextProperties {\n const factory = this._columnTextPropertiesLookup ? this._columnTextPropertiesLookup[column.columnId] : undefined;\n return factory ? factory() : undefined;\n }\n\n startEditSession(row: Row): EditSession<Row> {\n const rowId = this.identityOf(row);\n if (this._rowsBeingEdited.query().indexOf(row) > -1) {\n return lang.illegalState(`Row with id=${rowId} already being edited`);\n } else {\n const editSession = new EditSession<Row>(rowId, row, this._createForm(row), this.saveCommand);\n const { when } = Dsl.disposeWith(editSession);\n when.valueOf(editSession.liveRowValue).changes((editedValue) => {\n this._rowsBeingEdited.replaceOrPush(editedValue);\n }, { initialValue: 'triggerChangeUnlessNil' });\n\n this._editorSessions.push(editSession);\n editSession.onDispose(() => {\n this._rowsBeingEdited.remove(editSession.liveRowValue.value);\n this._editorSessions.remove(editSession);\n });\n return editSession;\n }\n }\n\n getEditSessionFor(row: Row): EditSession<Row> {\n return this._editorSessionByRowId.get(this.identityOf(row));\n }\n\n cancelAllEditorSessions() {\n this._editorSessions.runInTransaction((draft) => {\n this._rowsBeingEdited.runInTransaction(() => {\n draft.value.forEach(session => session.dispose());\n });\n });\n }\n\n onRowClicked(row: Row) {\n this.selectionColumnModel?.onRowClick(row);\n }\n\n isRowSelectionEnabled() {\n return this.selectionColumnModel ? this.selectionColumnModel.selectOnRowClick : false;\n }\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"table-model.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table-model.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,sBAAsB,EACtB,WAAW,EACX,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,SAAS,EACT,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,EACL,YAAY,EACZ,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,oGAAoG;AACpG,oGAAoG;AAGpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH;IA6BE,oBAA8B,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QA3B1C,aAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAElC,aAAQ,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAE7D,oBAAe,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAqB3D,gBAAW,GAA4B,UAAC,GAAG,IAAK,OAAA,IAAI,IAAI,EAAO,EAAf,CAAe,CAAC;QAGtE,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;QACrC,IAAA,mCAA2F,EAAzF,gBAAK,EAAE,oBAAO,EAAE,kBAAM,EAAE,cAAI,EAAE,gBAAK,EAAE,oBAAO,EAAE,sBAA2C,CAAC;QAClG,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,IA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B,EAAE,CAAC,CAAA;IAC/G,CAAC;IAED,mDAA8B,GAA9B;QACE,OAAO,IAAI,CAAC,oBAAoB,CAAC,8BAA8B,EAAE,CAAC;IACpE,CAAC;IAED,0CAAqB,GAArB;QACE,OAAO,IAAI,CAAC,2CAA2C,CAAC,KAAK,IAAI,IAAI,CAAC,8BAA8B,EAAE,CAAC;IACzG,CAAC;IAED,8BAAS,GAAT,UAAU,GAAQ;;QAChB,MAAA,IAAI,CAAC,oBAAoB,0CAAE,SAAS,CAAC,GAAG,EAAE;IAC5C,CAAC;;;gBA5H4C,SAAS;;IA7B3C,UAAU;QADtB,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,cAAc,EAAE,CAAC;yCA8BZ,SAAS;OA7B3C,UAAU,CA0JtB;IAAD,iBAAC;CAAA,AA1JD,IA0JC;SA1JY,UAAU","sourcesContent":["import {\n assert,\n BooleanValueModelChain,\n CanIdentify,\n Dsl,\n Form,\n GarbageCollector,\n lang,\n ListModel,\n ListModelChain,\n MapModelChain,\n MutableListModel,\n SelectionModel,\n TrackExternal,\n Types,\n UnaryCommand,\n ValueModelChain\n} from '@coolon/pectin';\nimport {\n ColumnModel,\n CustomTemplateColumnModel,\n CustomValueColumnModel,\n EditorControlColumnModel,\n ListPropertyColumnModel,\n PropertyColumnModel,\n SelectionColumnModel\n} from './column-model';\nimport { ColumnTextProperties } from './column-text-properties';\nimport { EditSession } from './edit-session';\n\n// export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];\n// export type NumberPropertiesOf<T> = { [K in keyof T]: T[K] extends number ? K : never }[keyof T];\n\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: FormValueModel<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: FormValueModel<string> | ValueModel<string>; }\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\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 */\n@TrackExternal.Strategy(new TrackExternal.OneTimeBinding())\nexport class TableModel<Row> {\n\n private readonly _garbage = new GarbageCollector();\n\n private readonly _columns = new MutableListModel<ColumnModel<Row>>();\n private _columnsById: MapModelChain<string, ColumnModel<Row>>;\n private _editorSessions = new MutableListModel<EditSession<Row>>();\n private readonly _rowsBeingEdited: MutableListModel<Row>;\n\n private _columnTextPropertiesLookup: { [columnName: string]: () => ColumnTextProperties };\n\n readonly identityOf: CanIdentify<Row>['identityOf'];\n private saveCommand: UnaryCommand<Form<Row>, boolean>;\n private _editorSessionByRowId: MapModelChain<any, EditSession<Row>>;\n\n readonly editing: BooleanValueModelChain;\n readonly dataSource: ListModelChain<Row>;\n readonly firstEditableColumn: ValueModelChain<ColumnModel<Row>>;\n private selectionColumnModel: SelectionColumnModel<Row>;\n private hasColumnsWithRowSelectionExplicitlyEnabled: BooleanValueModelChain;\n\n static fromList<Row>(sourceOfTruth: ListModel<Row>, builder?: (tableModel: TableModel<Row>) => void): TableModel<Row> {\n const model = new TableModel<Row>(sourceOfTruth);\n builder(model);\n return model;\n }\n\n private _createForm: (row: Row) => Form<Row> = (row) => new Form<Row>();\n\n protected constructor(private sourceOfTruth: ListModel<Row>) {\n this.identityOf = sourceOfTruth.identityOf;\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this._garbage);\n this._columnsById = chain(this._columns).indexBy('columnId');\n this._rowsBeingEdited = new MutableListModel<Row>([], {\n identifiedWith: this.identityOf\n });\n this._editorSessionByRowId = chain(this._editorSessions).indexBy('rowId');\n this.editing = chain(this._editorSessions).count().isGreaterThan(0);\n this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);\n this.firstEditableColumn = chain(this.columns).select(c => c.hasEditorPortal()).first();\n this.hasColumnsWithRowSelectionExplicitlyEnabled = chain(this._columns).findIndex(column => column.isRowSelectionExplicitlyEnabled()).isGreaterThanOrEqualTo(0);\n }\n\n get rowsBeingEdited(): ListModel<Row> {\n return this._rowsBeingEdited.readonly;\n }\n\n getTrackByFunction() {\n return (index: number, item: Row) => {\n return this.identityOf ? this.identityOf(item) : index;\n };\n }\n\n get columns(): ListModel<ColumnModel<Row>> {\n return this._columns.readonly;\n }\n\n pluck<P extends Types.ValuePropertiesOf<Row>>(property: P): PropertyColumnModel<Row, P> {\n return this.addColumn(new PropertyColumnModel<Row, P>(property, this));\n }\n\n pluckList<P extends Types.ArrayPropertiesOf<Row>>(property: P): ListPropertyColumnModel<Row, P> {\n return this.addColumn(new ListPropertyColumnModel<Row, P>(property, this));\n }\n\n addSelectionColumn(selectionModel: SelectionModel<Row>): SelectionColumnModel<Row> {\n assert.isNil(this.selectionColumnModel);\n this.selectionColumnModel = new SelectionColumnModel<Row>('selection', this, selectionModel);\n return this.addColumn(this.selectionColumnModel);\n }\n\n addEditControls(saveCommand: UnaryCommand<Form<Row>, boolean>): EditorControlColumnModel<Row> {\n this.saveCommand = saveCommand;\n return this.addColumn(new EditorControlColumnModel<Row>('editControls', saveCommand, this));\n }\n\n addCustomColumn<V>(columnId: string, dataAccessor: (row: Row) => V): CustomValueColumnModel<Row, V> {\n return this.addColumn(new CustomValueColumnModel<Row, V>(columnId, this, dataAccessor));\n }\n\n addTemplateColumn<V>(columnId: string): CustomTemplateColumnModel<Row> {\n return this.addColumn(new CustomTemplateColumnModel<Row>(columnId, this));\n }\n\n useFormFactory(factory: (row: Row) => Form<Row>): this {\n this._createForm = factory;\n return this;\n }\n\n protected addColumn<C extends ColumnModel<Row>>(column: C): C {\n if (this._columnsById.get(column.columnId)) {\n lang.illegalState(`Column with id=${column.columnId} already exists`);\n } else {\n this._columns.push(column);\n }\n return column;\n }\n\n columnTextProperties(columnTextProperties: { [columnName: string]: () => ColumnTextProperties }) {\n this._columnTextPropertiesLookup = columnTextProperties;\n }\n\n getColumnTextProperties(column: ColumnModel<Row>): ColumnTextProperties {\n const factory = this._columnTextPropertiesLookup ? this._columnTextPropertiesLookup[column.columnId] : undefined;\n return factory ? factory() : undefined;\n }\n\n startEditSession(row: Row): EditSession<Row> {\n const rowId = this.identityOf(row);\n if (this._rowsBeingEdited.query().indexOf(row) > -1) {\n return lang.illegalState(`Row with id=${rowId} already being edited`);\n } else {\n const editSession = new EditSession<Row>(rowId, row, this._createForm(row), this.saveCommand);\n const { when } = Dsl.disposeWith(editSession);\n when.valueOf(editSession.liveRowValue).changes((editedValue) => {\n this._rowsBeingEdited.replaceOrPush(editedValue);\n }, { initialValue: 'triggerChangeUnlessNil' });\n\n this._editorSessions.push(editSession);\n editSession.onDispose(() => {\n this._rowsBeingEdited.remove(editSession.liveRowValue.value);\n this._editorSessions.remove(editSession);\n });\n return editSession;\n }\n }\n\n getEditSessionFor(row: Row): EditSession<Row> {\n return this._editorSessionByRowId.get(this.identityOf(row));\n }\n\n cancelAllEditorSessions() {\n this._editorSessions.runInTransaction((draft) => {\n this._rowsBeingEdited.runInTransaction(() => {\n draft.value.forEach(session => session.dispose());\n });\n });\n }\n\n isRowSelectionEnabledFor(column: ColumnModel<Row>): boolean | undefined {\n return this.selectionColumnModel && (column.isRowSelectionEnabled() ?? this.isRowSelectionEnabledByDefault())\n }\n\n isRowSelectionEnabledByDefault(): boolean {\n return this.selectionColumnModel.isRowSelectionEnabledByDefault();\n }\n\n isRowSelectionEnabled() {\n return this.hasColumnsWithRowSelectionExplicitlyEnabled.value || this.isRowSelectionEnabledByDefault();\n }\n\n selectRow(row: Row) {\n this.selectionColumnModel?.selectRow(row);\n }\n}\n\n"]}
|
|
@@ -51,11 +51,10 @@ var TableComponent = /** @class */ (function (_super) {
|
|
|
51
51
|
column.setTemplate(templateRef, viewContainer, fillCell, padChild);
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
TableComponent.prototype.
|
|
55
|
-
this.tableModel.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return this.tableModel.isRowSelectionEnabled();
|
|
54
|
+
TableComponent.prototype.onCellClicked = function (columnModel, row) {
|
|
55
|
+
if (this.tableModel.isRowSelectionEnabledFor(columnModel)) {
|
|
56
|
+
this.tableModel.selectRow(row);
|
|
57
|
+
}
|
|
59
58
|
};
|
|
60
59
|
__decorate([
|
|
61
60
|
Input(),
|
|
@@ -65,8 +64,8 @@ var TableComponent = /** @class */ (function (_super) {
|
|
|
65
64
|
TableComponent = __decorate([
|
|
66
65
|
Component({
|
|
67
66
|
selector: 'aup-table',
|
|
68
|
-
template: "<table mat-table [dataSource]=\"tableModel.dataSource.value\" [trackBy]=\"tableModel.getTrackByFunction()\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\" matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef>\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\">\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"tableModel\"\n [editSession]=\"tableModel.getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value;\"
|
|
69
|
-
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}
|
|
67
|
+
template: "<table mat-table [dataSource]=\"tableModel.dataSource.value\" [trackBy]=\"tableModel.getTrackByFunction()\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\" matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef>\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"onCellClicked(column, row)\" [class.enable-cursor]=\"tableModel.isRowSelectionEnabledFor(column)\">\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"tableModel\"\n [editSession]=\"tableModel.getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value;\" [class.enable-hover]=\"tableModel.isRowSelectionEnabled()\"></tr>\n\n</table>\n",
|
|
68
|
+
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}"]
|
|
70
69
|
}),
|
|
71
70
|
__metadata("design:paramtypes", [])
|
|
72
71
|
], TableComponent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table.component.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"table.component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAyC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,GAAG,EAAiC,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAe,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH;IAAyC,kCAAmB;IAU1D;eACE,iBAAO;IACT,CAAC;IAED,iCAAQ,GAAR;QACQ,IAAA,0BAAkF,EAAhF,gBAAK,EAAE,oBAAO,EAAE,kBAAM,EAAE,cAAI,EAAE,gBAAK,EAAE,oBAAO,EAAE,sBAAkC,CAAC;QACzF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;IAED,kCAAS,GAAT,UAAU,GAAQ;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,+CAAsB,GAAtB,UAAuB,QAAgB,EAAE,WAA6B,EAAE,aAA+B,EAAE,QAAiB,EAAE,QAAiB;QAC3I,IAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,MAAM,YAAY,yBAAyB,EAAE;YAC/C,MAAM,CAAC,WAAW,CAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;SACpE;IACH,CAAC;IAED,sCAAa,GAAb,UAAc,WAA6B,EAAE,GAAQ;QACnD,IAAI,IAAI,CAAC,UAAU,CAAC,wBAAwB,CAAC,WAAW,CAAC,EAAE;YACzD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;SAChC;IACH,CAAC;IAhCD;QAFC,KAAK,EAAE;QACP,aAAa,EAAE;kCACJ,UAAU;sDAAM;IAJjB,cAAc;QAL1B,SAAS,CAAC;YACT,QAAQ,EAAE,WAAW;YACrB,08CAAqC;;SAEtC,CAAC;;OACW,cAAc,CAsC1B;IAAD,qBAAC;CAAA,AAtCD,CAAyC,mBAAmB,GAsC3D;SAtCY,cAAc","sourcesContent":["import { Component, Input, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { Dsl, ListModelChain, MapModelChain, TrackExternal } from '@coolon/pectin';\nimport { DisposableComponent } from '../disposable-component';\nimport { ColumnModel, CustomTemplateColumnModel } from './column-model';\nimport { TableModel } from './table-model';\n\n/**\n * Create your model:\n * @example\n * this.heroTableModel = TableModel.fromList(heroList, table => {\n * table.pluck(\"firstName\");\n * table.pluck(\"lastName\");\n * table.addCustomColumn(\"fullName\", hero => `${hero.firstName} ${hero.lastName}`);\n * });\n *\n * Create your table\n * @example\n * <aup-table [tableModel]=\"heroTableModel\"></aup-table>\n *\n * Styling\n * @example\n * aup-table {\n * --column-gap: 10px; // defaults to 24px\n * aup-table-cell-renderer {\n * &:first-column {\n * // do stuff\n * }\n * &:last-column {\n * // do stuff\n * }\n * }\n * }\n */\n@Component({\n selector: 'aup-table',\n templateUrl: './table.component.html',\n styleUrls: ['./table.component.scss']\n})\nexport class TableComponent<Row> extends DisposableComponent implements OnInit {\n\n @Input()\n @TrackExternal()\n tableModel: TableModel<Row>;\n\n columns: ListModelChain<ColumnModel<Row>>;\n columnIds: ListModelChain<string>;\n private columnsById: MapModelChain<string, ColumnModel<Row>>;\n\n constructor() {\n super();\n }\n\n ngOnInit(): void {\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.columns = chain(this.tableModel.columns);\n this.columnIds = chain(this.columns).pluck('columnId');\n this.columnsById = chain(this.columns).indexBy('columnId');\n }\n\n isEditing(row: Row): boolean {\n return !!this.tableModel.getEditSessionFor(row);\n }\n\n registerColumnTemplate(columnId: string, templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, fillCell: boolean, padChild: boolean) {\n const column = this.columnsById.get(columnId);\n if (column instanceof CustomTemplateColumnModel) {\n column.setTemplate(templateRef, viewContainer, fillCell, padChild);\n }\n }\n\n onCellClicked(columnModel: ColumnModel<Row>, row: Row) {\n if (this.tableModel.isRowSelectionEnabledFor(columnModel)) {\n this.tableModel.selectRow(row);\n }\n }\n\n}\n"]}
|
|
@@ -13,7 +13,7 @@ import { MatButtonModule } from '@angular/material/button';
|
|
|
13
13
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
14
14
|
import { MatIconModule } from '@angular/material/icon';
|
|
15
15
|
import { MatTableModule } from '@angular/material/table';
|
|
16
|
-
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, Command, FocusManager, DelegatingFormListModel, DelegatingFormValueModel, ListModel, StoreInListModel, ValueModel, StoreInValueModel, MutableValueModel,
|
|
16
|
+
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, Command, FocusManager, DelegatingFormListModel, DelegatingFormValueModel, ListModel, StoreInListModel, ValueModel, StoreInValueModel, MutableValueModel, MultipleSelectionModel, MutableListModel, Form, Deferred, Trace, Guard, DebugContext, Binding, Functions } from '@coolon/pectin';
|
|
17
17
|
import { assert as assert$1, Opts, lang as lang$1, Klass } from '@coolon/typescript-utilities';
|
|
18
18
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
19
19
|
import ___default, { isEqual, isNil } from 'lodash';
|
|
@@ -369,7 +369,7 @@ CardContainerComponent = __decorate([
|
|
|
369
369
|
Component({
|
|
370
370
|
selector: 'aup-card-container',
|
|
371
371
|
template: "<div class=\"card-container\">\n <ng-content></ng-content>\n\n <div class=\"add-card-container\" *ngIf=\"addCardCommand.enabled.value\" [pectinCommand]=\"addCardCommand\">\n <aup-icon icon=\"mat:add\"></aup-icon>\n </div>\n\n <div class=\"add-card-template\" *ngIf=\"addCardTemplate\">\n <ng-container [ngTemplateOutlet]=\"addCardTemplate\"></ng-container>\n </div>\n\n</div>\n",
|
|
372
|
-
styles: [":root{--aup-default-padding:var(--default-padding, 18px);--aup-default-background:white}.router-outlet-container>*{position:absolute;top:0;left:0;bottom:0;right:0}[no-tab-header]>mat-tab-header{display:none}[full-height-tabs] .mat-tab-body-wrapper,mat-tab-group.full-height-tabs .mat-tab-body-wrapper{flex:1}[full-height-tabs] .mat-tab-body-wrapper .mat-tab-body-content,[full-height-tabs] .mat-tab-body-wrapper mat-tab-body,mat-tab-group.full-height-tabs .mat-tab-body-wrapper .mat-tab-body-content,mat-tab-group.full-height-tabs .mat-tab-body-wrapper mat-tab-body{display:flex;flex-direction:column;justify-content:stretch}.dialog-interaction-context{max-width:95vw!important;max-height:95vh!important}.dialog-interaction-context mat-dialog-container{max-width:95vw!important;max-height:95vh!important;padding:0}.aup-popup-interaction-panel{background:var(--aup-default-background,#fff);box-shadow:0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(.4,0,.2,1)}.aup-input-activity{padding:calc(var(--aup-default-padding)/2)}.aup-input-component{display:block}.aup-input-component input,.aup-input-component mat-form-field{width:100%}.aup-input-component input mat-hint.faux-error,.aup-input-component mat-form-field mat-hint.faux-error{color:#f44336}aup-table-cell-renderer>.aup-input-component .mat-form-field-flex{padding-top:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-infix{width:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-label-wrapper{display:none}aup-table{--default-column-gap:var(--column-gap, 24px)}aup-table .mat-table td.mat-cell:first-of-type,aup-table .mat-table td.mat-footer-cell:first-of-type,aup-table .mat-table th.mat-header-cell:first-of-type{padding-left:0}aup-table aup-table-cell-renderer,aup-table aup-table-header-cell-renderer{display:flex;flex-direction:column;align-items:stretch;justify-content:center;height:100%;min-height:47px}aup-table aup-table-cell-renderer.first-column,aup-table aup-table-cell-renderer:not(.first-column),aup-table aup-table-header-cell-renderer.first-column,aup-table aup-table-header-cell-renderer:not(.first-column){padding-left:var(--default-column-gap)}aup-table aup-table-cell-renderer.fillCell{justify-content:stretch;padding-left:0!important}aup-table aup-table-cell-renderer.padChild>:first-child{padding-left:var(--default-column-gap);flex:1}:host{--resolved-card-gap:var(--card-gap, 16px);--resolved-card-width:var(--card-width, 300px);--resolved-card-height:var(--card-height, auto);--resolved-card-min-height:var(--card-min-height, auto);--resolved-card-background:var(--card-background, #fcfcfb);flex:1;display:block;background:var(--resolved-card-background)}.card-container{display:-ms-grid;display:grid;grid-template-columns:repeat(auto-fill,var(--resolved-card-width));grid-template-rows:repeat(auto-fit,minmax(0,var(--resolved-card-height)));grid-gap:var(--resolved-card-gap);box-sizing:border-box;padding:var(--resolved-card-gap);min-height:calc(var(--resolved-card-height) + 2 * var(--resolved-card-gap));min-width:calc(var(--resolved-card-width) + 2 * var(--resolved-card-gap));width:calc((var(--resolved-card-width) + var(--resolved-card-gap)) * 2 + var(--grid-gap));max-width:100%}.add-card-container{width:var(--resolved-card-width);height:var(--resolved-card-height);min-height:var(--resolved-card-min-height);display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;border:2px dashed rgba(0,0,0,.1);border-radius:6px;font-weight:300;cursor:pointer;color:rgba(0,0,0,.54);background-color:rgba(255,255,255,.8);transition:280ms cubic-bezier(.4,0,.2,1)}.add-card-container mat-icon{font-size:200%}.add-card-container:hover{transition:280ms cubic-bezier(.4,0,.2,1);border-color:transparent;background-color:#fff;color:rgba(0,0,0,.54)}.add-card-container:hover:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}.add-card-template-container{width:var(--resolved-card-width);height:var(--resolved-card-height);display:flex;flex-direction:column;align-items:stretch;justify-content:stretch}"]
|
|
372
|
+
styles: [":root{--aup-default-padding:var(--default-padding, 18px);--aup-default-background:white}.router-outlet-container>*{position:absolute;top:0;left:0;bottom:0;right:0}[no-tab-header]>mat-tab-header{display:none}[full-height-tabs] .mat-tab-body-wrapper,mat-tab-group.full-height-tabs .mat-tab-body-wrapper{flex:1}[full-height-tabs] .mat-tab-body-wrapper .mat-tab-body-content,[full-height-tabs] .mat-tab-body-wrapper mat-tab-body,mat-tab-group.full-height-tabs .mat-tab-body-wrapper .mat-tab-body-content,mat-tab-group.full-height-tabs .mat-tab-body-wrapper mat-tab-body{display:flex;flex-direction:column;justify-content:stretch}.dialog-interaction-context{max-width:95vw!important;max-height:95vh!important}.dialog-interaction-context mat-dialog-container{max-width:95vw!important;max-height:95vh!important;padding:0}.aup-popup-interaction-panel{background:var(--aup-default-background,#fff);box-shadow:0 2px 1px -1px rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 1px 3px 0 rgba(0,0,0,.12);transition:box-shadow 280ms cubic-bezier(.4,0,.2,1)}.aup-input-activity{padding:calc(var(--aup-default-padding)/2)}.aup-input-component{display:block}.aup-input-component input,.aup-input-component mat-form-field{width:100%}.aup-input-component input mat-hint.faux-error,.aup-input-component mat-form-field mat-hint.faux-error{color:#f44336}aup-table-cell-renderer>.aup-input-component .mat-form-field-flex{padding-top:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-infix{width:0}aup-table-cell-renderer>.aup-input-component .mat-form-field-label-wrapper{display:none}aup-table{--default-column-gap:var(--column-gap, 24px);--resolved-row-hover-background-color:var(--row-hover-background-color, rgba(0, 0, 0, 0.05))}aup-table .mat-table td.mat-cell:first-of-type,aup-table .mat-table td.mat-footer-cell:first-of-type,aup-table .mat-table th.mat-header-cell:first-of-type{padding-left:0}aup-table .mat-table tr.enable-hover:hover{background-color:var(--resolved-row-hover-background-color)}aup-table .mat-table td.enable-cursor{cursor:pointer}aup-table aup-table-cell-renderer,aup-table aup-table-header-cell-renderer{display:flex;flex-direction:column;align-items:stretch;justify-content:center;height:100%;min-height:47px}aup-table aup-table-cell-renderer.first-column,aup-table aup-table-cell-renderer:not(.first-column),aup-table aup-table-header-cell-renderer.first-column,aup-table aup-table-header-cell-renderer:not(.first-column){padding-left:var(--default-column-gap)}aup-table aup-table-cell-renderer.fillCell{justify-content:stretch;padding-left:0!important}aup-table aup-table-cell-renderer.padChild>:first-child{padding-left:var(--default-column-gap);flex:1}:host{--resolved-card-gap:var(--card-gap, 16px);--resolved-card-width:var(--card-width, 300px);--resolved-card-height:var(--card-height, auto);--resolved-card-min-height:var(--card-min-height, auto);--resolved-card-background:var(--card-background, #fcfcfb);flex:1;display:block;background:var(--resolved-card-background)}.card-container{display:-ms-grid;display:grid;grid-template-columns:repeat(auto-fill,var(--resolved-card-width));grid-template-rows:repeat(auto-fit,minmax(0,var(--resolved-card-height)));grid-gap:var(--resolved-card-gap);box-sizing:border-box;padding:var(--resolved-card-gap);min-height:calc(var(--resolved-card-height) + 2 * var(--resolved-card-gap));min-width:calc(var(--resolved-card-width) + 2 * var(--resolved-card-gap));width:calc((var(--resolved-card-width) + var(--resolved-card-gap)) * 2 + var(--grid-gap));max-width:100%}.add-card-container{width:var(--resolved-card-width);height:var(--resolved-card-height);min-height:var(--resolved-card-min-height);display:flex;flex-direction:column;align-items:center;justify-content:center;box-sizing:border-box;border:2px dashed rgba(0,0,0,.1);border-radius:6px;font-weight:300;cursor:pointer;color:rgba(0,0,0,.54);background-color:rgba(255,255,255,.8);transition:280ms cubic-bezier(.4,0,.2,1)}.add-card-container mat-icon{font-size:200%}.add-card-container:hover{transition:280ms cubic-bezier(.4,0,.2,1);border-color:transparent;background-color:#fff;color:rgba(0,0,0,.54)}.add-card-container:hover:hover{box-shadow:0 2px 4px -1px rgba(0,0,0,.2),0 4px 5px 0 rgba(0,0,0,.14),0 1px 10px 0 rgba(0,0,0,.12)}.add-card-template-container{width:var(--resolved-card-width);height:var(--resolved-card-height);display:flex;flex-direction:column;align-items:stretch;justify-content:stretch}"]
|
|
373
373
|
}),
|
|
374
374
|
__metadata("design:paramtypes", [])
|
|
375
375
|
], CardContainerComponent);
|
|
@@ -1235,6 +1235,7 @@ class ColumnModel {
|
|
|
1235
1235
|
constructor(columnId, defaults) {
|
|
1236
1236
|
this.columnId = columnId;
|
|
1237
1237
|
this.defaults = defaults;
|
|
1238
|
+
this._selectRowOnClick = undefined;
|
|
1238
1239
|
this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {
|
|
1239
1240
|
component.headerText = column.getHeaderText();
|
|
1240
1241
|
});
|
|
@@ -1291,6 +1292,19 @@ class ColumnModel {
|
|
|
1291
1292
|
updatePortalContent(host) {
|
|
1292
1293
|
this._cellRendererPortalRef.pushState(host);
|
|
1293
1294
|
}
|
|
1295
|
+
selectRowOnClick(selectOnRowClick) {
|
|
1296
|
+
this._selectRowOnClick = selectOnRowClick;
|
|
1297
|
+
return this;
|
|
1298
|
+
}
|
|
1299
|
+
isRowSelectionEnabled() {
|
|
1300
|
+
return this._selectRowOnClick;
|
|
1301
|
+
}
|
|
1302
|
+
isRowSelectionExplicitlyEnabled() {
|
|
1303
|
+
return this._selectRowOnClick === true;
|
|
1304
|
+
}
|
|
1305
|
+
isRowSelectionExplicitlyDisabled() {
|
|
1306
|
+
return this._selectRowOnClick === false;
|
|
1307
|
+
}
|
|
1294
1308
|
}
|
|
1295
1309
|
__decorate([
|
|
1296
1310
|
Memoize(),
|
|
@@ -1337,6 +1351,9 @@ class PropertyColumnModel extends ColumnModel {
|
|
|
1337
1351
|
this._format = formatter;
|
|
1338
1352
|
return this;
|
|
1339
1353
|
}
|
|
1354
|
+
selectRowOnClick(selectOnRowClick) {
|
|
1355
|
+
return super.selectRowOnClick(selectOnRowClick);
|
|
1356
|
+
}
|
|
1340
1357
|
}
|
|
1341
1358
|
class ListPropertyColumnModel extends ColumnModel {
|
|
1342
1359
|
constructor(property, defaults) {
|
|
@@ -1371,6 +1388,9 @@ class ListPropertyColumnModel extends ColumnModel {
|
|
|
1371
1388
|
this._format = formatter;
|
|
1372
1389
|
return this;
|
|
1373
1390
|
}
|
|
1391
|
+
selectRowOnClick(selectOnRowClick) {
|
|
1392
|
+
return super.selectRowOnClick(selectOnRowClick);
|
|
1393
|
+
}
|
|
1374
1394
|
}
|
|
1375
1395
|
class CustomValueColumnModel extends ColumnModel {
|
|
1376
1396
|
constructor(columnId, defaults, getValue) {
|
|
@@ -1384,6 +1404,9 @@ class CustomValueColumnModel extends ColumnModel {
|
|
|
1384
1404
|
}));
|
|
1385
1405
|
return this;
|
|
1386
1406
|
}
|
|
1407
|
+
selectRowOnClick(selectOnRowClick) {
|
|
1408
|
+
return super.selectRowOnClick(selectOnRowClick);
|
|
1409
|
+
}
|
|
1387
1410
|
}
|
|
1388
1411
|
class EditorControlColumnModel extends ColumnModel {
|
|
1389
1412
|
constructor(columnId, saveCommand, defaults) {
|
|
@@ -1411,17 +1434,20 @@ class CustomTemplateColumnModel extends ColumnModel {
|
|
|
1411
1434
|
setTemplate(templateRef, viewContainer, fillCell, padChild) {
|
|
1412
1435
|
this.config.registerPortal(templateRef, viewContainer, fillCell, padChild);
|
|
1413
1436
|
}
|
|
1437
|
+
selectRowOnClick(selectOnRowClick) {
|
|
1438
|
+
return super.selectRowOnClick(selectOnRowClick);
|
|
1439
|
+
}
|
|
1414
1440
|
}
|
|
1415
1441
|
class SelectionColumnModel extends ColumnModel {
|
|
1416
|
-
constructor(columnId, defaults, selectionModel
|
|
1442
|
+
constructor(columnId, defaults, selectionModel) {
|
|
1417
1443
|
super(columnId, defaults);
|
|
1418
1444
|
this.selectionModel = selectionModel;
|
|
1419
|
-
|
|
1420
|
-
this.selectOnRowClick
|
|
1445
|
+
this._enableHeaderControls = true;
|
|
1446
|
+
this.selectOnRowClick(false);
|
|
1421
1447
|
if (selectionModel instanceof MultipleSelectionModel) {
|
|
1422
1448
|
this.cellHeaderRenderer(SelectHeaderCellRendererComponent, (component) => {
|
|
1423
1449
|
component.selectionModel = selectionModel;
|
|
1424
|
-
component.enableHeaderControls =
|
|
1450
|
+
component.enableHeaderControls = this._enableHeaderControls;
|
|
1425
1451
|
});
|
|
1426
1452
|
}
|
|
1427
1453
|
this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, (component, rowData) => {
|
|
@@ -1432,10 +1458,20 @@ class SelectionColumnModel extends ColumnModel {
|
|
|
1432
1458
|
getDefaultHeaderText() {
|
|
1433
1459
|
return '';
|
|
1434
1460
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1461
|
+
isRowSelectionEnabledByDefault() {
|
|
1462
|
+
return this.isRowSelectionExplicitlyEnabled();
|
|
1463
|
+
}
|
|
1464
|
+
selectOnRowClick(selectOnRowClick) {
|
|
1465
|
+
// note we're using different method name as the selection column treats this
|
|
1466
|
+
// state as the default for all columns.
|
|
1467
|
+
return super.selectRowOnClick(selectOnRowClick);
|
|
1468
|
+
}
|
|
1469
|
+
enableHeaderControls(enable) {
|
|
1470
|
+
this._enableHeaderControls = enable;
|
|
1471
|
+
return this;
|
|
1472
|
+
}
|
|
1473
|
+
selectRow(row) {
|
|
1474
|
+
this.selectionModel.selectCommand.execute(row);
|
|
1439
1475
|
}
|
|
1440
1476
|
}
|
|
1441
1477
|
|
|
@@ -1529,6 +1565,7 @@ let TableModel = TableModel_1 = class TableModel {
|
|
|
1529
1565
|
this.editing = chain(this._editorSessions).count().isGreaterThan(0);
|
|
1530
1566
|
this.dataSource = chain(this.sourceOfTruth).replaceAll(this.rowsBeingEdited);
|
|
1531
1567
|
this.firstEditableColumn = chain(this.columns).select(c => c.hasEditorPortal()).first();
|
|
1568
|
+
this.hasColumnsWithRowSelectionExplicitlyEnabled = chain(this._columns).findIndex(column => column.isRowSelectionExplicitlyEnabled()).isGreaterThanOrEqualTo(0);
|
|
1532
1569
|
}
|
|
1533
1570
|
static fromList(sourceOfTruth, builder) {
|
|
1534
1571
|
const model = new TableModel_1(sourceOfTruth);
|
|
@@ -1552,9 +1589,9 @@ let TableModel = TableModel_1 = class TableModel {
|
|
|
1552
1589
|
pluckList(property) {
|
|
1553
1590
|
return this.addColumn(new ListPropertyColumnModel(property, this));
|
|
1554
1591
|
}
|
|
1555
|
-
addSelectionColumn(selectionModel
|
|
1592
|
+
addSelectionColumn(selectionModel) {
|
|
1556
1593
|
assert.isNil(this.selectionColumnModel);
|
|
1557
|
-
this.selectionColumnModel = new SelectionColumnModel('selection', this, selectionModel
|
|
1594
|
+
this.selectionColumnModel = new SelectionColumnModel('selection', this, selectionModel);
|
|
1558
1595
|
return this.addColumn(this.selectionColumnModel);
|
|
1559
1596
|
}
|
|
1560
1597
|
addEditControls(saveCommand) {
|
|
@@ -1616,12 +1653,19 @@ let TableModel = TableModel_1 = class TableModel {
|
|
|
1616
1653
|
});
|
|
1617
1654
|
});
|
|
1618
1655
|
}
|
|
1619
|
-
|
|
1656
|
+
isRowSelectionEnabledFor(column) {
|
|
1620
1657
|
var _a;
|
|
1621
|
-
(_a =
|
|
1658
|
+
return this.selectionColumnModel && ((_a = column.isRowSelectionEnabled()) !== null && _a !== void 0 ? _a : this.isRowSelectionEnabledByDefault());
|
|
1659
|
+
}
|
|
1660
|
+
isRowSelectionEnabledByDefault() {
|
|
1661
|
+
return this.selectionColumnModel.isRowSelectionEnabledByDefault();
|
|
1622
1662
|
}
|
|
1623
1663
|
isRowSelectionEnabled() {
|
|
1624
|
-
return this.
|
|
1664
|
+
return this.hasColumnsWithRowSelectionExplicitlyEnabled.value || this.isRowSelectionEnabledByDefault();
|
|
1665
|
+
}
|
|
1666
|
+
selectRow(row) {
|
|
1667
|
+
var _a;
|
|
1668
|
+
(_a = this.selectionColumnModel) === null || _a === void 0 ? void 0 : _a.selectRow(row);
|
|
1625
1669
|
}
|
|
1626
1670
|
};
|
|
1627
1671
|
TableModel.ctorParameters = () => [
|
|
@@ -1678,11 +1722,10 @@ let TableComponent = class TableComponent extends DisposableComponent {
|
|
|
1678
1722
|
column.setTemplate(templateRef, viewContainer, fillCell, padChild);
|
|
1679
1723
|
}
|
|
1680
1724
|
}
|
|
1681
|
-
|
|
1682
|
-
this.tableModel.
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
return this.tableModel.isRowSelectionEnabled();
|
|
1725
|
+
onCellClicked(columnModel, row) {
|
|
1726
|
+
if (this.tableModel.isRowSelectionEnabledFor(columnModel)) {
|
|
1727
|
+
this.tableModel.selectRow(row);
|
|
1728
|
+
}
|
|
1686
1729
|
}
|
|
1687
1730
|
};
|
|
1688
1731
|
__decorate([
|
|
@@ -1693,8 +1736,8 @@ __decorate([
|
|
|
1693
1736
|
TableComponent = __decorate([
|
|
1694
1737
|
Component({
|
|
1695
1738
|
selector: 'aup-table',
|
|
1696
|
-
template: "<table mat-table [dataSource]=\"tableModel.dataSource.value\" [trackBy]=\"tableModel.getTrackByFunction()\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\" matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef>\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\">\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"tableModel\"\n [editSession]=\"tableModel.getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value;\"
|
|
1697
|
-
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}
|
|
1739
|
+
template: "<table mat-table [dataSource]=\"tableModel.dataSource.value\" [trackBy]=\"tableModel.getTrackByFunction()\">\n\n <ng-container *ngFor=\"let column of columns.value; index as index; first as first; last as last\" matColumnDef=\"{{column.columnId}}\">\n <th mat-header-cell *matHeaderCellDef>\n <aup-table-header-cell-renderer [column]=\"column\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-header-cell-renderer>\n </th>\n <td mat-cell *matCellDef=\"let row\" (click)=\"onCellClicked(column, row)\" [class.enable-cursor]=\"tableModel.isRowSelectionEnabledFor(column)\">\n <aup-table-cell-renderer [column]=\"column\"\n [row]=\"row\"\n [tableModel]=\"tableModel\"\n [editSession]=\"tableModel.getEditSessionFor(row)\"\n [attr.column-index]=\"index\"\n [class.first-column]=\"first\"\n [class.last-column]=\"last\"\n ></aup-table-cell-renderer>\n </td>\n </ng-container>\n\n <tr mat-header-row *matHeaderRowDef=\"columnIds.value\"></tr>\n <tr mat-row *matRowDef=\"let row; columns: columnIds.value;\" [class.enable-hover]=\"tableModel.isRowSelectionEnabled()\"></tr>\n\n</table>\n",
|
|
1740
|
+
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}"]
|
|
1698
1741
|
}),
|
|
1699
1742
|
__metadata("design:paramtypes", [])
|
|
1700
1743
|
], TableComponent);
|