@coolon/angular-ui-powerups 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +36 -8
- 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/components.module.ngfactory.js.map +1 -1
- package/esm2015/lib/components/table/column-model.js +11 -2
- 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/select-header-cell-renderer/select-header-cell-renderer.component.js +1 -1
- package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js.map +1 -1
- package/esm2015/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.metadata.json +1 -1
- package/esm2015/lib/components/table/table-model.js +12 -3
- 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 +8 -2
- package/esm2015/lib/components/table/table.component.js.map +1 -1
- package/esm2015/lib/components/table/table.component.metadata.json +1 -1
- package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.js +6 -2
- package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.js.map +1 -1
- package/esm2015/lib/interaction/directives/interaction-context-trigger-for.directive.metadata.json +1 -1
- package/esm5/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm5/lib/components/table/column-model.js +11 -2
- package/esm5/lib/components/table/column-model.js.map +1 -1
- package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js +1 -1
- package/esm5/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.js.map +1 -1
- package/esm5/lib/components/table/table-model.js +12 -3
- package/esm5/lib/components/table/table-model.js.map +1 -1
- package/esm5/lib/components/table/table.component.js +8 -2
- package/esm5/lib/components/table/table.component.js.map +1 -1
- package/esm5/lib/interaction/directives/interaction-context-trigger-for.directive.js +6 -2
- package/esm5/lib/interaction/directives/interaction-context-trigger-for.directive.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +37 -9
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +37 -9
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/table/column-model.d.ts +10 -1
- package/lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.d.ts +1 -0
- package/lib/components/table/table-model.d.ts +4 -1
- package/lib/components/table/table.component.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __extends, __metadata } from "tslib";
|
|
2
|
-
import { MultipleSelectionModel } from '@coolon/pectin';
|
|
2
|
+
import { MultipleSelectionModel, OptionsHelper } from '@coolon/pectin';
|
|
3
3
|
import { assert } from '@coolon/typescript-utilities';
|
|
4
4
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
5
5
|
import _ from 'lodash';
|
|
@@ -222,11 +222,15 @@ var CustomTemplateColumnModel = /** @class */ (function (_super) {
|
|
|
222
222
|
export { CustomTemplateColumnModel };
|
|
223
223
|
var SelectionColumnModel = /** @class */ (function (_super) {
|
|
224
224
|
__extends(SelectionColumnModel, _super);
|
|
225
|
-
function SelectionColumnModel(columnId, defaults, selectionModel) {
|
|
225
|
+
function SelectionColumnModel(columnId, defaults, selectionModel, options) {
|
|
226
226
|
var _this = _super.call(this, columnId, defaults) || this;
|
|
227
|
+
_this.selectionModel = selectionModel;
|
|
228
|
+
var opts = OptionsHelper.for(options);
|
|
229
|
+
_this.selectOnRowClick = opts.get("selectOnRowClick", false);
|
|
227
230
|
if (selectionModel instanceof MultipleSelectionModel) {
|
|
228
231
|
_this.cellHeaderRenderer(SelectHeaderCellRendererComponent, function (component) {
|
|
229
232
|
component.selectionModel = selectionModel;
|
|
233
|
+
component.enableHeaderControls = opts.get("headerControl", true);
|
|
230
234
|
});
|
|
231
235
|
}
|
|
232
236
|
_this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, function (component, rowData) {
|
|
@@ -238,6 +242,11 @@ var SelectionColumnModel = /** @class */ (function (_super) {
|
|
|
238
242
|
SelectionColumnModel.prototype.getDefaultHeaderText = function () {
|
|
239
243
|
return '';
|
|
240
244
|
};
|
|
245
|
+
SelectionColumnModel.prototype.onRowClick = function (row) {
|
|
246
|
+
if (this.selectOnRowClick) {
|
|
247
|
+
this.selectionModel.selectCommand.execute(row);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
241
250
|
return SelectionColumnModel;
|
|
242
251
|
}(ColumnModel));
|
|
243
252
|
export { SelectionColumnModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-model.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/column-model.ts"],"names":[],"mappings":";AAEA,OAAO,EAAiB,sBAAsB,EAAkD,MAAM,gBAAgB,CAAC;AACvH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,EAAE,kCAAkC,EAAE,MAAM,uEAAuE,CAAC;AAC3H,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,EAAE,iCAAiC,EAAE,MA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c,YAAY,sBAAsB,EAAE;YACpD,KAAI,CAAC,kBAAkB,CAAC,iCAAiC,EAAE,UAAC,SAAS;gBACnE,SAAS,CAAC,cAAc,GAAG,cAAc,CAAC;YAC5C,CAAC,CAAC,CAAC;SACJ;QACD,KAAI,CAAC,qBAAqB,CAAC,IAAI,8BAA8B,CAAC,2BAA2B,EAAE,UAAC,SAAS,EAAE,OAAqB;YAC1H,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAC5B,SAAS,CAAC,cAAc,GAAG,cAAc,CAAC;QAC5C,CAAC,CAAC,CAAC,CAAC;;IACN,CAAC;IAES,mDAAoB,GAA9B;QACE,OAAO,EAAE,CAAC;IACZ,CAAC;IACH,2BAAC;AAAD,CAAC,AAjBD,CAA+C,WAAW,GAiBzD","sourcesContent":["import { ComponentType } from '@angular/cdk/overlay';\nimport { TemplateRef, ViewContainerRef } from '@angular/core';\nimport { Command, Form, MultipleSelectionModel, SelectionModel, Types, UnaryCommand, Validator } from '@coolon/pectin';\nimport { assert } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { CellEditorComponent, CellListEditorComponent } from './cell-editors';\nimport {\n CellEditorPortalRef,\n CellHeaderPortalRef,\n CellRendererPortalRef,\n ComponentCellRendererPortalRef,\n TemplateCellRendererPortalRef\n} from './cell-protal-ref';\nimport { ColumnTextProperties } from './column-text-properties';\nimport { DefaultCellRendererComponent } from './default-cell-renderer/default-cell-renderer.component';\nimport { DefaultHeaderCellRendererComponent } from './default-header-cell-renderer/default-header-cell-renderer.component';\nimport { EditRowControls } from './edit-row-controls/edit-row-controls.component';\nimport { EditSession } from './edit-session';\nimport { SelectCellRendererComponent } from './select-cell-renderer/select-cell-renderer.component';\nimport { SelectHeaderCellRendererComponent } from './select-header-cell-renderer/select-header-cell-renderer.component';\nimport { TableCellRendererComponent } from './table-cell-renderer/table-cell-renderer.component';\nimport { TableHeaderCellRendererComponent } from './table-header-cell-renderer/table-header-cell-renderer.component';\n\n\nconst noop = () => {\n};\n\nexport interface RowData<Row> {\n row: Row;\n editSession?: EditSession<Row>;\n editRowCommand: Command<void>;\n}\n\n\nexport class ColumnModel<Row> {\n\n private _columnTextProperties: ColumnTextProperties;\n\n private _columnHeaderPortalRef: CellHeaderPortalRef<Row, any>;\n private _cellRendererPortalRef: CellRendererPortalRef<Row, any>;\n private _cellEditorPortalRef: CellEditorPortalRef<Row, any>;\n\n constructor(readonly columnId: string, private defaults: ColumnModel.Defaults) {\n this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {\n component.headerText = column.getHeaderText();\n });\n }\n\n @Memoize()\n getHeaderText(): string {\n return this.getColumnTextProperties()?.headerText() || this.getDefaultHeaderText();\n }\n\n protected getDefaultHeaderText() {\n return this.columnId;\n }\n\n @Memoize()\n getColumnTextProperties(): ColumnTextProperties {\n return this._columnTextProperties || this.defaults.getColumnTextProperties(this);\n }\n\n textProperties(columnTextProperties: ColumnTextProperties): this {\n this._columnTextProperties = columnTextProperties;\n return this;\n }\n\n protected configureHeaderRenderer<C>(config: CellHeaderPortalRef<Row, any>): void {\n this._columnHeaderPortalRef = config;\n }\n\n protected configureCellRenderer<C>(config: CellRendererPortalRef<Row, any>): void {\n this._cellRendererPortalRef = config;\n }\n\n protected configureCellEditor<E>(cellEditor: CellEditorPortalRef<Row, E>): void {\n this._cellEditorPortalRef = cellEditor;\n }\n\n cellHeaderRenderer<C>(componentType: ComponentType<C>, initialiser: (component: C, column: ColumnModel<Row>) => void): this {\n this.configureHeaderRenderer(new CellHeaderPortalRef<Row, C>(componentType, initialiser));\n return this;\n }\n\n hasEditorPortal() {\n return !!this._cellEditorPortalRef;\n }\n\n attachHeaderCell(host: any) {\n this._columnHeaderPortalRef.initialiseHost(host, this);\n }\n\n attachCell(host: any) {\n this._cellRendererPortalRef.initialiseHost(host, this);\n if (this.hasEditorPortal()) {\n this._cellEditorPortalRef.initialiseHost(host, this);\n }\n }\n\n onHeaderAttached(host: TableHeaderCellRendererComponent, component: any) {\n this._columnHeaderPortalRef.onPortalAttached(host, component);\n }\n\n onRendererAttached(host: TableCellRendererComponent<Row>, component: any) {\n this._cellRendererPortalRef.onPortalAttached(host, component);\n }\n\n // @Trace()\n onEditorAttached(host: TableCellRendererComponent<Row>, component: any) {\n this._cellEditorPortalRef.onPortalAttached(host, component);\n }\n\n updatePortalContent(host: TableCellRendererComponent<Row>) {\n this._cellRendererPortalRef.pushState(host);\n }\n}\n\nexport namespace ColumnModel {\n export interface Defaults {\n getColumnTextProperties(columnModel: ColumnModel<any>): ColumnTextProperties;\n }\n}\n\nexport interface CellEditorOptions<V, C> { //extends CellRendererOptions<E> {\n validators?: Validator<V>[];\n\n initialiseComponent?(component: C);\n}\n\nexport class PropertyColumnModel<Row, P extends Types.ValuePropertiesOf<Row>> extends ColumnModel<Row> {\n\n\n private _format: (value: Row[P]) => any = (value) => value;\n\n constructor(readonly property: P, defaults: ColumnModel.Defaults) {\n super(property.toString(), defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: Row[P] }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this._format(rowData.row[this.property]);\n }));\n return this;\n }\n\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, validators?: Validator<Row[P]>[], initialiseComponent?: (component: E) => void): this\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, initialiseComponent?: (component: E) => void): this\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, validatorsOrInitialiser?: Validator<Row[P]>[] | ((component: E) => void), initialiseComponent?: (component: E) => void): this {\n const validators = Array.isArray(validatorsOrInitialiser) ? validatorsOrInitialiser : undefined;\n const initialiser = _.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;\n this.configureCellEditor(new CellEditorPortalRef(editor, (component: E, editSession: EditSession<Row>) => {\n const formValueModel = editSession.form.pluck(this.property);\n if (validators) {\n formValueModel.validateUsing(validators);\n }\n component.valueModel = formValueModel;\n if (initialiser) {\n initialiser(component);\n }\n }));\n return this;\n }\n\n format(formatter: (value: Row[P]) => any): this {\n assert.isFunction(formatter);\n this._format = formatter;\n return this;\n }\n}\n\nexport class ListPropertyColumnModel<Row, P extends Types.ArrayPropertiesOf<Row>> extends ColumnModel<Row> {\n\n private _format: (value: Types.ArrayElementType<Row, P>[]) => any = (value) => value.map(v => v?.toString()).join(', ');\n\n constructor(readonly property: P, defaults: ColumnModel.Defaults) {\n super(property.toString(), defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: Types.ArrayElementType<Row, P>[] }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this._format(rowData.row[this.property]);\n }));\n return this;\n }\n\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, validators?: Validator<Types.ArrayElementType<Row, P>[]>[], initialiseComponent?: (component: C) => void): this\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, initialiseComponent?: (component: C) => void): this\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, validatorsOrInitialiser?: Validator<Types.ArrayElementType<Row, P>[]>[] | ((component: C) => void), initialiseComponent?: (component: C) => void): this {\n const validators = Array.isArray(validatorsOrInitialiser) ? validatorsOrInitialiser : undefined;\n const initialiser = _.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;\n\n this.configureCellEditor(new CellEditorPortalRef(editor, (component: C, editSession: EditSession<Row>) => {\n const formListModel = editSession.form.pluckList(this.property);\n if (validators) {\n formListModel.validateUsing(validators);\n }\n component.listModel = formListModel;\n if (initialiser) {\n initialiser(component);\n }\n }));\n return this;\n }\n\n format(formatter: (value: Types.ArrayElementType<Row, P>[]) => any): this {\n assert.isFunction(formatter);\n this._format = formatter;\n return this;\n }\n}\n\nexport class CustomValueColumnModel<Row, V> extends ColumnModel<Row> {\n constructor(columnId: string, defaults: ColumnModel.Defaults, private getValue: (row: Row) => V) {\n super(columnId, defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: V }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this.getValue(rowData.row);\n }));\n return this;\n }\n}\n\nexport class EditorControlColumnModel<Row> extends ColumnModel<Row> {\n\n constructor(columnId: string, saveCommand: UnaryCommand<Form<Row>, boolean>, defaults: ColumnModel.Defaults) {\n super(columnId, defaults);\n this.cellRenderer(EditRowControls);\n }\n\n cellRenderer(componentType: ComponentType<{ row: Row, editSession: EditSession<Row>, editRowCommand: Command<void> }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData: RowData<Row>) => {\n component.row = rowData.row;\n component.editSession = rowData.editSession;\n component.editRowCommand = rowData.editRowCommand;\n }));\n return this;\n }\n\n protected getDefaultHeaderText(): string {\n return '';\n }\n}\n\nexport class CustomTemplateColumnModel<Row> extends ColumnModel<Row> {\n private readonly config = new TemplateCellRendererPortalRef<Row>();\n\n constructor(columnId: string, defaults: ColumnModel.Defaults) {\n super(columnId, defaults);\n this.configureCellRenderer(this.config);\n }\n\n setTemplate(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, fillCell: boolean, padChild: boolean) {\n this.config.registerPortal(templateRef, viewContainer, fillCell, padChild);\n }\n}\n\nexport class SelectionColumnModel<Row> extends ColumnModel<Row> {\n constructor(columnId: string, defaults: ColumnModel.Defaults, selectionModel: SelectionModel<Row>) {\n super(columnId, defaults);\n if (selectionModel instanceof MultipleSelectionModel) {\n this.cellHeaderRenderer(SelectHeaderCellRendererComponent, (component) => {\n component.selectionModel = selectionModel;\n });\n }\n this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, (component, rowData: RowData<Row>) => {\n component.row = rowData.row;\n component.selectionModel = selectionModel;\n }));\n }\n\n protected getDefaultHeaderText(): string {\n return '';\n }\n}\n\n\n"]}
|
|
1
|
+
{"version":3,"file":"column-model.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/column-model.ts"],"names":[],"mappings":";AAEA,OAAO,EAGL,sBAAsB,EACtB,aAAa,EAKd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EAEnB,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,4BAA4B,EAAE,MAAM,yDAAyD,CAAC;AACvG,OAAO,EAAE,kCAAkC,EAAE,MAAM,uEAAuE,CAAC;AAC3H,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,EAAE,iCAAiC,EAAE,MAAM,qEAAqE,CAAC;AAKxH,IAAM,IAAI,GAAG;AACb,CAAC,CAAC;;AASF;IAQE,qBAAqB,QAAgB,EAAU,QAA8B;QAAxD,aAAQ,GAAR,QAAQ,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAsB;QAC3E,IAAI,CAAC,kBAAkB,CAAC,kCAAkC,EAAE,UAAC,SAAS,EAAE,MAAM;YAC5E,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC;IAGD,mCAAa,GAAb;;QACE,OAAO,OAAA,IAAI,CAAC,uBAAuB,EAAE,0CAAE,UAAU,OAAM,IAAI,CAAC,oBAAoB,EAAE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ACJ;QACD,KAAI,CAAC,qBAAqB,CAAC,IAAI,8BAA8B,CAAC,2BAA2B,EAAE,UAAC,SAAS,EAAE,OAAqB;YAC1H,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAC5B,SAAS,CAAC,cAAc,GAAG,cAAc,CAAC;QAC5C,CAAC,CAAC,CAAC,CAAC;;IACN,CAAC;IAES,mDAAoB,GAA9B;QACE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,yCAAU,GAAV,UAAW,GAAQ;QACjB,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAChD;IACH,CAAC;IACH,2BAAC;AAAD,CAAC,AA7BD,CAA+C,WAAW,GA6BzD","sourcesContent":["import { ComponentType } from '@angular/cdk/overlay';\nimport { TemplateRef, ViewContainerRef } from '@angular/core';\nimport {\n Command,\n Form,\n MultipleSelectionModel,\n OptionsHelper,\n SelectionModel,\n Types,\n UnaryCommand,\n Validator\n} from '@coolon/pectin';\nimport { assert } from '@coolon/typescript-utilities';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport _ from 'lodash';\nimport { CellEditorComponent, CellListEditorComponent } from './cell-editors';\nimport {\n CellEditorPortalRef,\n CellHeaderPortalRef,\n CellRendererPortalRef,\n ComponentCellRendererPortalRef,\n TemplateCellRendererPortalRef\n} from './cell-protal-ref';\nimport { ColumnTextProperties } from './column-text-properties';\nimport { DefaultCellRendererComponent } from './default-cell-renderer/default-cell-renderer.component';\nimport { DefaultHeaderCellRendererComponent } from './default-header-cell-renderer/default-header-cell-renderer.component';\nimport { EditRowControls } from './edit-row-controls/edit-row-controls.component';\nimport { EditSession } from './edit-session';\nimport { SelectCellRendererComponent } from './select-cell-renderer/select-cell-renderer.component';\nimport { SelectHeaderCellRendererComponent } from './select-header-cell-renderer/select-header-cell-renderer.component';\nimport { TableCellRendererComponent } from './table-cell-renderer/table-cell-renderer.component';\nimport { TableHeaderCellRendererComponent } from './table-header-cell-renderer/table-header-cell-renderer.component';\n\n\nconst noop = () => {\n};\n\nexport interface RowData<Row> {\n row: Row;\n editSession?: EditSession<Row>;\n editRowCommand: Command<void>;\n}\n\n\nexport class ColumnModel<Row> {\n\n private _columnTextProperties: ColumnTextProperties;\n\n private _columnHeaderPortalRef: CellHeaderPortalRef<Row, any>;\n private _cellRendererPortalRef: CellRendererPortalRef<Row, any>;\n private _cellEditorPortalRef: CellEditorPortalRef<Row, any>;\n\n constructor(readonly columnId: string, private defaults: ColumnModel.Defaults) {\n this.cellHeaderRenderer(DefaultHeaderCellRendererComponent, (component, column) => {\n component.headerText = column.getHeaderText();\n });\n }\n\n @Memoize()\n getHeaderText(): string {\n return this.getColumnTextProperties()?.headerText() || this.getDefaultHeaderText();\n }\n\n protected getDefaultHeaderText() {\n return this.columnId;\n }\n\n @Memoize()\n getColumnTextProperties(): ColumnTextProperties {\n return this._columnTextProperties || this.defaults.getColumnTextProperties(this);\n }\n\n textProperties(columnTextProperties: ColumnTextProperties): this {\n this._columnTextProperties = columnTextProperties;\n return this;\n }\n\n protected configureHeaderRenderer<C>(config: CellHeaderPortalRef<Row, any>): void {\n this._columnHeaderPortalRef = config;\n }\n\n protected configureCellRenderer<C>(config: CellRendererPortalRef<Row, any>): void {\n this._cellRendererPortalRef = config;\n }\n\n protected configureCellEditor<E>(cellEditor: CellEditorPortalRef<Row, E>): void {\n this._cellEditorPortalRef = cellEditor;\n }\n\n cellHeaderRenderer<C>(componentType: ComponentType<C>, initialiser: (component: C, column: ColumnModel<Row>) => void): this {\n this.configureHeaderRenderer(new CellHeaderPortalRef<Row, C>(componentType, initialiser));\n return this;\n }\n\n hasEditorPortal() {\n return !!this._cellEditorPortalRef;\n }\n\n attachHeaderCell(host: any) {\n this._columnHeaderPortalRef.initialiseHost(host, this);\n }\n\n attachCell(host: any) {\n this._cellRendererPortalRef.initialiseHost(host, this);\n if (this.hasEditorPortal()) {\n this._cellEditorPortalRef.initialiseHost(host, this);\n }\n }\n\n onHeaderAttached(host: TableHeaderCellRendererComponent, component: any) {\n this._columnHeaderPortalRef.onPortalAttached(host, component);\n }\n\n onRendererAttached(host: TableCellRendererComponent<Row>, component: any) {\n this._cellRendererPortalRef.onPortalAttached(host, component);\n }\n\n // @Trace()\n onEditorAttached(host: TableCellRendererComponent<Row>, component: any) {\n this._cellEditorPortalRef.onPortalAttached(host, component);\n }\n\n updatePortalContent(host: TableCellRendererComponent<Row>) {\n this._cellRendererPortalRef.pushState(host);\n }\n}\n\nexport namespace ColumnModel {\n export interface Defaults {\n getColumnTextProperties(columnModel: ColumnModel<any>): ColumnTextProperties;\n }\n}\n\nexport interface CellEditorOptions<V, C> { //extends CellRendererOptions<E> {\n validators?: Validator<V>[];\n\n initialiseComponent?(component: C);\n}\n\nexport class PropertyColumnModel<Row, P extends Types.ValuePropertiesOf<Row>> extends ColumnModel<Row> {\n\n\n private _format: (value: Row[P]) => any = (value) => value;\n\n constructor(readonly property: P, defaults: ColumnModel.Defaults) {\n super(property.toString(), defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: Row[P] }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this._format(rowData.row[this.property]);\n }));\n return this;\n }\n\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, validators?: Validator<Row[P]>[], initialiseComponent?: (component: E) => void): this\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, initialiseComponent?: (component: E) => void): this\n cellEditor<E extends CellEditorComponent<Row[P]>>(editor: ComponentType<E>, validatorsOrInitialiser?: Validator<Row[P]>[] | ((component: E) => void), initialiseComponent?: (component: E) => void): this {\n const validators = Array.isArray(validatorsOrInitialiser) ? validatorsOrInitialiser : undefined;\n const initialiser = _.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;\n this.configureCellEditor(new CellEditorPortalRef(editor, (component: E, editSession: EditSession<Row>) => {\n const formValueModel = editSession.form.pluck(this.property);\n if (validators) {\n formValueModel.validateUsing(validators);\n }\n component.valueModel = formValueModel;\n if (initialiser) {\n initialiser(component);\n }\n }));\n return this;\n }\n\n format(formatter: (value: Row[P]) => any): this {\n assert.isFunction(formatter);\n this._format = formatter;\n return this;\n }\n}\n\nexport class ListPropertyColumnModel<Row, P extends Types.ArrayPropertiesOf<Row>> extends ColumnModel<Row> {\n\n private _format: (value: Types.ArrayElementType<Row, P>[]) => any = (value) => value.map(v => v?.toString()).join(', ');\n\n constructor(readonly property: P, defaults: ColumnModel.Defaults) {\n super(property.toString(), defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: Types.ArrayElementType<Row, P>[] }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this._format(rowData.row[this.property]);\n }));\n return this;\n }\n\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, validators?: Validator<Types.ArrayElementType<Row, P>[]>[], initialiseComponent?: (component: C) => void): this\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, initialiseComponent?: (component: C) => void): this\n cellEditor<C extends CellListEditorComponent<Types.ArrayElementType<Row, P>>>(editor: ComponentType<C>, validatorsOrInitialiser?: Validator<Types.ArrayElementType<Row, P>[]>[] | ((component: C) => void), initialiseComponent?: (component: C) => void): this {\n const validators = Array.isArray(validatorsOrInitialiser) ? validatorsOrInitialiser : undefined;\n const initialiser = _.isFunction(validatorsOrInitialiser) ? validatorsOrInitialiser : initialiseComponent;\n\n this.configureCellEditor(new CellEditorPortalRef(editor, (component: C, editSession: EditSession<Row>) => {\n const formListModel = editSession.form.pluckList(this.property);\n if (validators) {\n formListModel.validateUsing(validators);\n }\n component.listModel = formListModel;\n if (initialiser) {\n initialiser(component);\n }\n }));\n return this;\n }\n\n format(formatter: (value: Types.ArrayElementType<Row, P>[]) => any): this {\n assert.isFunction(formatter);\n this._format = formatter;\n return this;\n }\n}\n\nexport class CustomValueColumnModel<Row, V> extends ColumnModel<Row> {\n constructor(columnId: string, defaults: ColumnModel.Defaults, private getValue: (row: Row) => V) {\n super(columnId, defaults);\n this.cellRenderer(DefaultCellRendererComponent);\n }\n\n cellRenderer(componentType: ComponentType<{ value: V }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData) => {\n component.value = this.getValue(rowData.row);\n }));\n return this;\n }\n}\n\nexport class EditorControlColumnModel<Row> extends ColumnModel<Row> {\n\n constructor(columnId: string, saveCommand: UnaryCommand<Form<Row>, boolean>, defaults: ColumnModel.Defaults) {\n super(columnId, defaults);\n this.cellRenderer(EditRowControls);\n }\n\n cellRenderer(componentType: ComponentType<{ row: Row, editSession: EditSession<Row>, editRowCommand: Command<void> }>): this {\n this.configureCellRenderer(new ComponentCellRendererPortalRef(componentType, (component, rowData: RowData<Row>) => {\n component.row = rowData.row;\n component.editSession = rowData.editSession;\n component.editRowCommand = rowData.editRowCommand;\n }));\n return this;\n }\n\n protected getDefaultHeaderText(): string {\n return '';\n }\n}\n\nexport class CustomTemplateColumnModel<Row> extends ColumnModel<Row> {\n private readonly config = new TemplateCellRendererPortalRef<Row>();\n\n constructor(columnId: string, defaults: ColumnModel.Defaults) {\n super(columnId, defaults);\n this.configureCellRenderer(this.config);\n }\n\n setTemplate(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, fillCell: boolean, padChild: boolean) {\n this.config.registerPortal(templateRef, viewContainer, fillCell, padChild);\n }\n}\n\nexport class SelectionColumnModel<Row> extends ColumnModel<Row> {\n\n readonly selectOnRowClick: boolean;\n\n constructor(columnId: string, defaults: ColumnModel.Defaults, private readonly selectionModel: SelectionModel<Row>, options?: SelectionColumnModel.SelectionOptions) {\n super(columnId, defaults);\n const opts = OptionsHelper.for(options);\n this.selectOnRowClick = opts.get(\"selectOnRowClick\", false);\n if (selectionModel instanceof MultipleSelectionModel) {\n this.cellHeaderRenderer(SelectHeaderCellRendererComponent, (component) => {\n component.selectionModel = selectionModel;\n component.enableHeaderControls = opts.get(\"headerControl\", true);\n });\n }\n this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, (component, rowData: RowData<Row>) => {\n component.row = rowData.row;\n component.selectionModel = selectionModel;\n }));\n }\n\n protected getDefaultHeaderText(): string {\n return '';\n }\n\n onRowClick(row: Row) {\n if (this.selectOnRowClick) {\n this.selectionModel.selectCommand.execute(row);\n }\n }\n}\n\nexport namespace SelectionColumnModel {\n export interface SelectionOptions {\n headerControl?: boolean;\n selectOnRowClick?: boolean;\n }\n}\n\n\n"]}
|
|
@@ -22,7 +22,7 @@ var SelectHeaderCellRendererComponent = /** @class */ (function (_super) {
|
|
|
22
22
|
SelectHeaderCellRendererComponent = __decorate([
|
|
23
23
|
Component({
|
|
24
24
|
selector: 'aup-select-header-cell-renderer',
|
|
25
|
-
template: "<mat-checkbox [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\" [indeterminate]=\"this.isIntermediate()\"></mat-checkbox>\n",
|
|
25
|
+
template: "<mat-checkbox *ngIf=\"enableHeaderControls\" [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\" [indeterminate]=\"this.isIntermediate()\"></mat-checkbox>\n",
|
|
26
26
|
styles: [""]
|
|
27
27
|
}),
|
|
28
28
|
__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-header-cell-renderer.component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAA0B,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAOjE;IAA4D,qDAAmB;
|
|
1
|
+
{"version":3,"file":"select-header-cell-renderer.component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/select-header-cell-renderer/select-header-cell-renderer.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,OAAO,EAA0B,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAOjE;IAA4D,qDAAmB;IAO7E;QAAA,YACE,iBAAO,SAIR;QAHC,KAAI,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;YAClC,KAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;;IACL,CAAC;IAED,sDAAU,GAAV;;QACE,OAAO,OAAA,IAAI,CAAC,cAAc,0CAAE,WAAW,CAAC,KAAK,KAAI,KAAK,CAAC;IACzD,CAAC;IAED,0DAAc,GAAd;;QACE,OAAO,OAAA,IAAI,CAAC,cAAc,0CAAE,YAAY,CAAC,KAAK,KAAI,KAAK,CAAC;IAC1D,CAAC;IApBU,iCAAiC;QAL7C,SAAS,CAAC;YACT,QAAQ,EAAE,iCAAiC;YAC3C,iLAA2D;;SAE5D,CAAC;;OACW,iCAAiC,CAqB7C;IAAD,wCAAC;CAAA,AArBD,CAA4D,mBAAmB,GAqB9E;SArBY,iCAAiC","sourcesContent":["import { Component } from '@angular/core';\n\nimport { Command, MultipleSelectionModel } from '@coolon/pectin';\nimport { DisposableComponent } from '../../disposable-component';\n\n@Component({\n selector: 'aup-select-header-cell-renderer',\n templateUrl: './select-header-cell-renderer.component.html',\n styleUrls: ['./select-header-cell-renderer.component.scss']\n})\nexport class SelectHeaderCellRendererComponent<Row> extends DisposableComponent {\n\n readonly selectCommand: Command<void>;\n\n selectionModel: MultipleSelectionModel<Row, any>;\n enableHeaderControls: boolean;\n\n constructor() {\n super();\n this.selectCommand = Command.create(() => {\n this.selectionModel.toggleAllCommand.execute();\n });\n }\n\n isSelected(): boolean {\n return this.selectionModel?.allSelected.value || false;\n }\n\n isIntermediate() {\n return this.selectionModel?.someSelected.value || false;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { BooleanValueModelChain, CanIdentify, Dsl, Form, GarbageCollector, lang, ListModel, ListModelChain, MapModelChain, MutableListModel, SelectionModel, TrackExternal, Types, UnaryCommand, ValueModelChain } from '@coolon/pectin';
|
|
2
|
+
import { assert, BooleanValueModelChain, CanIdentify, Dsl, Form, GarbageCollector, lang, ListModel, ListModelChain, MapModelChain, MutableListModel, SelectionModel, TrackExternal, Types, UnaryCommand, ValueModelChain } from '@coolon/pectin';
|
|
3
3
|
import { CustomTemplateColumnModel, CustomValueColumnModel, EditorControlColumnModel, ListPropertyColumnModel, PropertyColumnModel, SelectionColumnModel } from './column-model';
|
|
4
4
|
import { EditSession } from './edit-session';
|
|
5
5
|
// export type StringPropertiesOf<T> = { [K in keyof T]: T[K] extends string ? K : never }[keyof T];
|
|
@@ -124,8 +124,10 @@ var TableModel = /** @class */ (function () {
|
|
|
124
124
|
TableModel.prototype.pluckList = function (property) {
|
|
125
125
|
return this.addColumn(new ListPropertyColumnModel(property, this));
|
|
126
126
|
};
|
|
127
|
-
TableModel.prototype.addSelectionColumn = function (selectionModel) {
|
|
128
|
-
|
|
127
|
+
TableModel.prototype.addSelectionColumn = function (selectionModel, options) {
|
|
128
|
+
assert.isNil(this.selectionColumnModel);
|
|
129
|
+
this.selectionColumnModel = new SelectionColumnModel('selection', this, selectionModel, options);
|
|
130
|
+
return this.addColumn(this.selectionColumnModel);
|
|
129
131
|
};
|
|
130
132
|
TableModel.prototype.addEditControls = function (saveCommand) {
|
|
131
133
|
this.saveCommand = saveCommand;
|
|
@@ -188,6 +190,13 @@ var TableModel = /** @class */ (function () {
|
|
|
188
190
|
});
|
|
189
191
|
});
|
|
190
192
|
};
|
|
193
|
+
TableModel.prototype.onRowClicked = function (row) {
|
|
194
|
+
var _a;
|
|
195
|
+
(_a = this.selectionColumnModel) === null || _a === void 0 ? void 0 : _a.onRowClick(row);
|
|
196
|
+
};
|
|
197
|
+
TableModel.prototype.isRowSelectionEnabled = function () {
|
|
198
|
+
return this.selectionColumnModel ? this.selectionColumnModel.selectOnRowClick : false;
|
|
199
|
+
};
|
|
191
200
|
var TableModel_1;
|
|
192
201
|
TableModel.ctorParameters = function () { return [
|
|
193
202
|
{ type: ListModel }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-model.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table-model.ts"],"names":[],"mappings":";AACA,OAAO,EACL,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,EAAE,eAAe,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACQ,yBAAyB,EACtC,sBAAsB,EACtB,wBAAwB,EAAE,uBAAuB,EACjD,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,oGAAoG;AACpG,oGAAoG;AAGpG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH;IA2BE,oBAA8B,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;QAzB1C,aAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAElC,aAAQ,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAE7D,oBAAe,GAAG,IAAI,gBAAgB,EAAoB,CAAC;QAmB3D,gBAAW,GAA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C;SArIY,UAAU","sourcesContent":["import { TemplateRef } from '@angular/core';\nimport {\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, ValueModelChain\n} from '@coolon/pectin';\nimport {\n ColumnModel, CustomTemplateColumnModel,\n CustomValueColumnModel,\n EditorControlColumnModel, 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\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>): SelectionColumnModel<Row> {\n return this.addColumn(new SelectionColumnModel<Row>('selection', this, selectionModel));\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"]}
|
|
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,E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CAAC,KAAK,CAAC,CAAC;gBAC7D,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,aAAW,CAAC,CAAC;YAC3C,CAAC,CAAC,CAAC;YACH,OAAO,aAAW,CAAC;SACpB;IACH,CAAC;IAED,sCAAiB,GAAjB,UAAkB,GAAQ;QACxB,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,4CAAuB,GAAvB;QAAA,iBAMC;QALC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,UAAC,KAAK;YAC1C,KAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC;gBACrC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,OAAO,EAAE,EAAjB,CAAiB,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,iCAAY,GAAZ,UAAa,GAAQ;;QACnB,MAAA,IAAI,CAAC,oBAAoB,0CAAE,UAAU,CAAC,GAAG,EAAE;IAC7C,CAAC;IAED,0CAAqB,GAArB;QACE,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC;IACxF,CAAC;;;gBAnH4C,SAAS;;IA5B3C,UAAU;QADtB,aAAa,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,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"]}
|
|
@@ -51,6 +51,12 @@ var TableComponent = /** @class */ (function (_super) {
|
|
|
51
51
|
column.setTemplate(templateRef, viewContainer, fillCell, padChild);
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
TableComponent.prototype.onRowClicked = function (row) {
|
|
55
|
+
this.tableModel.onRowClicked(row);
|
|
56
|
+
};
|
|
57
|
+
TableComponent.prototype.isRowSelectionEnabled = function () {
|
|
58
|
+
return this.tableModel.isRowSelectionEnabled();
|
|
59
|
+
};
|
|
54
60
|
__decorate([
|
|
55
61
|
Input(),
|
|
56
62
|
TrackExternal(),
|
|
@@ -59,8 +65,8 @@ var TableComponent = /** @class */ (function (_super) {
|
|
|
59
65
|
TableComponent = __decorate([
|
|
60
66
|
Component({
|
|
61
67
|
selector: 'aup-table',
|
|
62
|
-
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;\"></tr>\n\n</table>\n",
|
|
63
|
-
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}"]
|
|
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;\" (click)=\"onRowClicked(row)\" [class.select-row-on-click]=\"isRowSelectionEnabled()\"></tr>\n\n</table>\n",
|
|
69
|
+
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}:host table tr.select-row-on-click td{cursor:pointer}"]
|
|
64
70
|
}),
|
|
65
71
|
__metadata("design:paramtypes", [])
|
|
66
72
|
], 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":";AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAyC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,GAAG,EAAwC,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1F,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;IAAuC,kCAAmB;IAUxD;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,GAAM;QACd,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;
|
|
1
|
+
{"version":3,"file":"table.component.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/components/table/table.component.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAyC,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,GAAG,EAAwC,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1F,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;IAAuC,kCAAmB;IAUxD;eACE,iBAAO;IACT,CAAC;IAED,iCAAQ,GAAR;QACQ,IAAA,0BAAkF,EAAhF,gBAAK,EAAE,oBAA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Ac","sourcesContent":["import { TemplatePortal } from '@angular/cdk/portal';\nimport { Component, Input, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';\nimport { Dsl, ListModelChain, MapModelChain, Trace, 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<T> extends DisposableComponent implements OnInit {\n\n @Input()\n @TrackExternal()\n tableModel: TableModel<T>;\n\n columns: ListModelChain<ColumnModel<T>>;\n columnIds: ListModelChain<string>;\n private columnsById: MapModelChain<string, ColumnModel<T>>;\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: T): 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 onRowClicked(row: any) {\n this.tableModel.onRowClicked(row);\n }\n\n isRowSelectionEnabled() {\n return this.tableModel.isRowSelectionEnabled();\n }\n}\n"]}
|
|
@@ -11,6 +11,8 @@ var InteractionContextTriggerFor = /** @class */ (function (_super) {
|
|
|
11
11
|
return _this;
|
|
12
12
|
}
|
|
13
13
|
InteractionContextTriggerFor.prototype.onEnter = function (event) {
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
event.stopPropagation();
|
|
14
16
|
if (!this.aupInteractionContextTriggerFor.isActive()) {
|
|
15
17
|
this.startActivity();
|
|
16
18
|
}
|
|
@@ -19,6 +21,8 @@ var InteractionContextTriggerFor = /** @class */ (function (_super) {
|
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
InteractionContextTriggerFor.prototype.onClick = function (event) {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
event.stopPropagation();
|
|
22
26
|
if (!this.aupInteractionContextTriggerFor.isActive()) {
|
|
23
27
|
this.startActivity();
|
|
24
28
|
}
|
|
@@ -67,13 +71,13 @@ var InteractionContextTriggerFor = /** @class */ (function (_super) {
|
|
|
67
71
|
__metadata("design:type", Object)
|
|
68
72
|
], InteractionContextTriggerFor.prototype, "activityCancelled", void 0);
|
|
69
73
|
__decorate([
|
|
70
|
-
HostListener('keyup.enter'),
|
|
74
|
+
HostListener('keyup.enter', ['$event']),
|
|
71
75
|
__metadata("design:type", Function),
|
|
72
76
|
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
73
77
|
__metadata("design:returntype", void 0)
|
|
74
78
|
], InteractionContextTriggerFor.prototype, "onEnter", null);
|
|
75
79
|
__decorate([
|
|
76
|
-
HostListener('click'),
|
|
80
|
+
HostListener('click', ['$event']),
|
|
77
81
|
__metadata("design:type", Function),
|
|
78
82
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
79
83
|
__metadata("design:returntype", void 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction-context-trigger-for.directive.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/interaction/directives/interaction-context-trigger-for.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,MAAM,EAAiB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,CAAC,MAAM,QAAQ,CAAC;AAOvB;IAA2D,gDAAgB;IAoBzE;QAAA,YACE,iBAAO,SACR;QAPD,kBAAY,GAAG,IAAI,YAAY,EAAK,CAAC;QAGrC,uBAAiB,GAAG,IAAI,YAAY,EAAK,CAAC;;IAI1C,CAAC;IAGD,8CAAO,GAAP,UAAQ,KAAoB;QAC1B,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,QAAQ,EAAE,EAAE;YACpD,IAAI,CAAC,aAAa,EAAE,CAAC;SACtB;aAAM;YACL,IAAI,CAAC,+BAA+B,CAAC,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"interaction-context-trigger-for.directive.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/interaction/directives/interaction-context-trigger-for.directive.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,MAAM,EAAiB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,CAAC,MAAM,QAAQ,CAAC;AAOvB;IAA2D,gDAAgB;IAoBzE;QAAA,YACE,iBAAO,SACR;QAPD,kBAAY,GAAG,IAAI,YAAY,EAAK,CAAC;QAGrC,uBAAiB,GAAG,IAAI,YAAY,EAAK,CAAC;;IAI1C,CAAC;IAGD,8CAAO,GAAP,UAAQ,KAAoB;QAC1B,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,+BAA+B,C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EAAE;;uEACwC;IAGhD;QADC,KAAK,EAAE;;sEACS;IAGjB;QADC,KAAK,EAAE;;6EACsB;IAG9B;QADC,MAAM,EAAE;;sEAC4B;IAGrC;QADC,MAAM,EAAE;;2EACiC;IAO1C;QADC,YAAY,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC;;yCACzB,aAAa;;+DAQ3B;IAGD;QADC,YAAY,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;;yCACnB,UAAU;;+DAQxB;IA5CU,4BAA4B;QAHxC,SAAS,CAAC;YACT,QAAQ,EAAE,mCAAmC;SAC9C,CAAC;;OACW,4BAA4B,CA+DxC;IAAD,mCAAC;CAAA,AA/DD,CAA2D,gBAAgB,GA+D1E;SA/DY,4BAA4B","sourcesContent":["import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';\nimport { assert, Constructable, GarbageCollector } from '@coolon/pectin';\nimport _ from 'lodash';\nimport { Activity } from '../activity';\nimport { InteractionContext } from '../interaction-context';\n\n@Directive({\n selector: '[aupInteractionContextTriggerFor]'\n})\nexport class InteractionContextTriggerFor<D, R, E> extends GarbageCollector {\n\n @Input()\n aupInteractionContextTriggerFor: Pick<InteractionContext, 'startActivity' | 'isActive' | 'cancelActiveActivity'>;\n\n @Input()\n activityClass: Constructable<Activity<D, R, E>>;\n\n @Input()\n activityData?: D;\n\n @Input()\n activityDataFactory?: () => D;\n\n @Output()\n activityDone = new EventEmitter<R>();\n\n @Output()\n activityCancelled = new EventEmitter<E>();\n\n constructor() {\n super();\n }\n\n @HostListener('keyup.enter', ['$event'])\n onEnter(event: KeyboardEvent): void {\n event.preventDefault();\n event.stopPropagation();\n if (!this.aupInteractionContextTriggerFor.isActive()) {\n this.startActivity();\n } else {\n this.aupInteractionContextTriggerFor.cancelActiveActivity();\n }\n }\n\n @HostListener('click', ['$event'])\n onClick(event: MouseEvent): void {\n event.preventDefault();\n event.stopPropagation();\n if (!this.aupInteractionContextTriggerFor.isActive()) {\n this.startActivity();\n } else {\n this.aupInteractionContextTriggerFor.cancelActiveActivity();\n }\n }\n\n protected startActivity() {\n assert.isTruthy(this.aupInteractionContextTriggerFor);\n assert.isFalsey(this.aupInteractionContextTriggerFor.isActive());\n assert.isTruthy(this.activityClass);\n this.aupInteractionContextTriggerFor.startActivity(this.activityClass, this.activityData)\n .then(result => {\n this.activityDone.emit(result);\n })\n .catch(error => {\n this.activityCancelled.emit(error);\n });\n }\n\n prepareActivityData(): D {\n return _.isFunction(this.activityDataFactory()) ? this.activityDataFactory() : this.activityData;\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, MultipleSelectionModel, MutableListModel, Form, Deferred, Trace, Guard, DebugContext, Binding, Functions } from '@coolon/pectin';
|
|
16
|
+
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, TrackExternal, Command, FocusManager, DelegatingFormListModel, DelegatingFormValueModel, ListModel, StoreInListModel, ValueModel, StoreInValueModel, MutableValueModel, OptionsHelper, 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';
|
|
@@ -1222,7 +1222,7 @@ let SelectHeaderCellRendererComponent = class SelectHeaderCellRendererComponent
|
|
|
1222
1222
|
SelectHeaderCellRendererComponent = __decorate([
|
|
1223
1223
|
Component({
|
|
1224
1224
|
selector: 'aup-select-header-cell-renderer',
|
|
1225
|
-
template: "<mat-checkbox [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\" [indeterminate]=\"this.isIntermediate()\"></mat-checkbox>\n",
|
|
1225
|
+
template: "<mat-checkbox *ngIf=\"enableHeaderControls\" [pectinCommand]=\"selectCommand\" [checked]=\"isSelected()\" [indeterminate]=\"this.isIntermediate()\"></mat-checkbox>\n",
|
|
1226
1226
|
styles: [""]
|
|
1227
1227
|
}),
|
|
1228
1228
|
__metadata("design:paramtypes", [])
|
|
@@ -1413,11 +1413,15 @@ class CustomTemplateColumnModel extends ColumnModel {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
}
|
|
1415
1415
|
class SelectionColumnModel extends ColumnModel {
|
|
1416
|
-
constructor(columnId, defaults, selectionModel) {
|
|
1416
|
+
constructor(columnId, defaults, selectionModel, options) {
|
|
1417
1417
|
super(columnId, defaults);
|
|
1418
|
+
this.selectionModel = selectionModel;
|
|
1419
|
+
const opts = OptionsHelper.for(options);
|
|
1420
|
+
this.selectOnRowClick = opts.get("selectOnRowClick", false);
|
|
1418
1421
|
if (selectionModel instanceof MultipleSelectionModel) {
|
|
1419
1422
|
this.cellHeaderRenderer(SelectHeaderCellRendererComponent, (component) => {
|
|
1420
1423
|
component.selectionModel = selectionModel;
|
|
1424
|
+
component.enableHeaderControls = opts.get("headerControl", true);
|
|
1421
1425
|
});
|
|
1422
1426
|
}
|
|
1423
1427
|
this.configureCellRenderer(new ComponentCellRendererPortalRef(SelectCellRendererComponent, (component, rowData) => {
|
|
@@ -1428,6 +1432,11 @@ class SelectionColumnModel extends ColumnModel {
|
|
|
1428
1432
|
getDefaultHeaderText() {
|
|
1429
1433
|
return '';
|
|
1430
1434
|
}
|
|
1435
|
+
onRowClick(row) {
|
|
1436
|
+
if (this.selectOnRowClick) {
|
|
1437
|
+
this.selectionModel.selectCommand.execute(row);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1431
1440
|
}
|
|
1432
1441
|
|
|
1433
1442
|
var TableModel_1;
|
|
@@ -1543,8 +1552,10 @@ let TableModel = TableModel_1 = class TableModel {
|
|
|
1543
1552
|
pluckList(property) {
|
|
1544
1553
|
return this.addColumn(new ListPropertyColumnModel(property, this));
|
|
1545
1554
|
}
|
|
1546
|
-
addSelectionColumn(selectionModel) {
|
|
1547
|
-
|
|
1555
|
+
addSelectionColumn(selectionModel, options) {
|
|
1556
|
+
assert.isNil(this.selectionColumnModel);
|
|
1557
|
+
this.selectionColumnModel = new SelectionColumnModel('selection', this, selectionModel, options);
|
|
1558
|
+
return this.addColumn(this.selectionColumnModel);
|
|
1548
1559
|
}
|
|
1549
1560
|
addEditControls(saveCommand) {
|
|
1550
1561
|
this.saveCommand = saveCommand;
|
|
@@ -1605,6 +1616,13 @@ let TableModel = TableModel_1 = class TableModel {
|
|
|
1605
1616
|
});
|
|
1606
1617
|
});
|
|
1607
1618
|
}
|
|
1619
|
+
onRowClicked(row) {
|
|
1620
|
+
var _a;
|
|
1621
|
+
(_a = this.selectionColumnModel) === null || _a === void 0 ? void 0 : _a.onRowClick(row);
|
|
1622
|
+
}
|
|
1623
|
+
isRowSelectionEnabled() {
|
|
1624
|
+
return this.selectionColumnModel ? this.selectionColumnModel.selectOnRowClick : false;
|
|
1625
|
+
}
|
|
1608
1626
|
};
|
|
1609
1627
|
TableModel.ctorParameters = () => [
|
|
1610
1628
|
{ type: ListModel }
|
|
@@ -1660,6 +1678,12 @@ let TableComponent = class TableComponent extends DisposableComponent {
|
|
|
1660
1678
|
column.setTemplate(templateRef, viewContainer, fillCell, padChild);
|
|
1661
1679
|
}
|
|
1662
1680
|
}
|
|
1681
|
+
onRowClicked(row) {
|
|
1682
|
+
this.tableModel.onRowClicked(row);
|
|
1683
|
+
}
|
|
1684
|
+
isRowSelectionEnabled() {
|
|
1685
|
+
return this.tableModel.isRowSelectionEnabled();
|
|
1686
|
+
}
|
|
1663
1687
|
};
|
|
1664
1688
|
__decorate([
|
|
1665
1689
|
Input(),
|
|
@@ -1669,8 +1693,8 @@ __decorate([
|
|
|
1669
1693
|
TableComponent = __decorate([
|
|
1670
1694
|
Component({
|
|
1671
1695
|
selector: 'aup-table',
|
|
1672
|
-
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;\"></tr>\n\n</table>\n",
|
|
1673
|
-
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}"]
|
|
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;\" (click)=\"onRowClicked(row)\" [class.select-row-on-click]=\"isRowSelectionEnabled()\"></tr>\n\n</table>\n",
|
|
1697
|
+
styles: [":host{display:flex;flex-direction:column;align-items:stretch}:host table{flex:1}:host table tr.select-row-on-click td{cursor:pointer}"]
|
|
1674
1698
|
}),
|
|
1675
1699
|
__metadata("design:paramtypes", [])
|
|
1676
1700
|
], TableComponent);
|
|
@@ -3017,6 +3041,8 @@ let InteractionContextTriggerFor = class InteractionContextTriggerFor extends Ga
|
|
|
3017
3041
|
this.activityCancelled = new EventEmitter();
|
|
3018
3042
|
}
|
|
3019
3043
|
onEnter(event) {
|
|
3044
|
+
event.preventDefault();
|
|
3045
|
+
event.stopPropagation();
|
|
3020
3046
|
if (!this.aupInteractionContextTriggerFor.isActive()) {
|
|
3021
3047
|
this.startActivity();
|
|
3022
3048
|
}
|
|
@@ -3025,6 +3051,8 @@ let InteractionContextTriggerFor = class InteractionContextTriggerFor extends Ga
|
|
|
3025
3051
|
}
|
|
3026
3052
|
}
|
|
3027
3053
|
onClick(event) {
|
|
3054
|
+
event.preventDefault();
|
|
3055
|
+
event.stopPropagation();
|
|
3028
3056
|
if (!this.aupInteractionContextTriggerFor.isActive()) {
|
|
3029
3057
|
this.startActivity();
|
|
3030
3058
|
}
|
|
@@ -3073,13 +3101,13 @@ __decorate([
|
|
|
3073
3101
|
__metadata("design:type", Object)
|
|
3074
3102
|
], InteractionContextTriggerFor.prototype, "activityCancelled", void 0);
|
|
3075
3103
|
__decorate([
|
|
3076
|
-
HostListener('keyup.enter'),
|
|
3104
|
+
HostListener('keyup.enter', ['$event']),
|
|
3077
3105
|
__metadata("design:type", Function),
|
|
3078
3106
|
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
3079
3107
|
__metadata("design:returntype", void 0)
|
|
3080
3108
|
], InteractionContextTriggerFor.prototype, "onEnter", null);
|
|
3081
3109
|
__decorate([
|
|
3082
|
-
HostListener('click'),
|
|
3110
|
+
HostListener('click', ['$event']),
|
|
3083
3111
|
__metadata("design:type", Function),
|
|
3084
3112
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
3085
3113
|
__metadata("design:returntype", void 0)
|