@rxap/ngx-material-table-select 16.0.1-dev.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 +8 -0
- package/README.md +21 -0
- package/esm2022/index.mjs +14 -0
- package/esm2022/lib/decorators.mjs +25 -0
- package/esm2022/lib/open-table-select-window.directive.mjs +117 -0
- package/esm2022/lib/open-table-select-window.method.mjs +104 -0
- package/esm2022/lib/table-select-control.directive.mjs +205 -0
- package/esm2022/lib/table-select-control.module.mjs +31 -0
- package/esm2022/lib/table-select-input/table-select-input.component.mjs +144 -0
- package/esm2022/lib/table-select-window/table-select-window.component.mjs +102 -0
- package/esm2022/rxap-ngx-material-table-select.mjs +5 -0
- package/fesm2022/rxap-ngx-material-table-select.mjs +695 -0
- package/fesm2022/rxap-ngx-material-table-select.mjs.map +1 -0
- package/index.d.ts +7 -0
- package/lib/decorators.d.ts +14 -0
- package/lib/open-table-select-window.directive.d.ts +33 -0
- package/lib/open-table-select-window.method.d.ts +55 -0
- package/lib/table-select-control.directive.d.ts +49 -0
- package/lib/table-select-control.module.d.ts +8 -0
- package/lib/table-select-input/table-select-input.component.d.ts +45 -0
- package/lib/table-select-window/table-select-window.component.d.ts +21 -0
- package/package.json +129 -0
|
@@ -0,0 +1,695 @@
|
|
|
1
|
+
import { NgIf, NgFor, NgSwitch, NgSwitchCase, NgSwitchDefault, AsyncPipe, KeyValuePipe, NgClass } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Component, ChangeDetectionStrategy, Inject, forwardRef, Optional, Self, HostBinding, Input, Injector, INJECTOR, Injectable, EventEmitter, isDevMode, Directive, Output, HostListener, ContentChildren, ContentChild, NgModule } from '@angular/core';
|
|
4
|
+
import * as i11 from '@angular/flex-layout/flex';
|
|
5
|
+
import { FlexModule } from '@angular/flex-layout/flex';
|
|
6
|
+
import * as i7 from '@angular/forms';
|
|
7
|
+
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
+
import * as i8 from '@angular/material/button';
|
|
9
|
+
import { MatButtonModule, MatButton } from '@angular/material/button';
|
|
10
|
+
import * as i5 from '@angular/material/form-field';
|
|
11
|
+
import { MatFormFieldModule, MatFormFieldControl, MatFormField } from '@angular/material/form-field';
|
|
12
|
+
import * as i9 from '@angular/material/icon';
|
|
13
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
14
|
+
import * as i6 from '@angular/material/input';
|
|
15
|
+
import { MatInputModule } from '@angular/material/input';
|
|
16
|
+
import * as i10 from '@angular/material/paginator';
|
|
17
|
+
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
18
|
+
import * as i2 from '@angular/material/progress-bar';
|
|
19
|
+
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
20
|
+
import * as i4 from '@angular/material/sort';
|
|
21
|
+
import { MatSortModule } from '@angular/material/sort';
|
|
22
|
+
import * as i3 from '@angular/material/table';
|
|
23
|
+
import { MatTableModule } from '@angular/material/table';
|
|
24
|
+
import { ParentControlContainerDirective, ControlValueAccessor, RxapFormControl, RxapFormGroup } from '@rxap/forms';
|
|
25
|
+
import { InputClearButtonDirective } from '@rxap/material-form-system';
|
|
26
|
+
import * as i1 from '@rxap/material-table-system';
|
|
27
|
+
import { SelectRowService, TableFilterService, TableDataSourceDirective, FilterHeaderRowDirective, CheckboxHeaderCellComponent, CheckboxCellComponent, DateCellComponent, BooleanCellComponent, RowAnimation, RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS, TABLE_DATA_SOURCE, RXAP_TABLE_METHOD, TABLE_REMOTE_METHOD_ADAPTER_FACTORY, RXAP_TABLE_FILTER, RXAP_TABLE_FILTER_FORM_DEFINITION } from '@rxap/material-table-system';
|
|
28
|
+
import { GetFromObjectPipe } from '@rxap/pipes';
|
|
29
|
+
import * as i1$1 from '@rxap/window-system';
|
|
30
|
+
import { RXAP_WINDOW_DATA, RXAP_WINDOW_REF, WindowFooterDirective, RXAP_WINDOW_SETTINGS } from '@rxap/window-system';
|
|
31
|
+
import { map, tap, take } from 'rxjs/operators';
|
|
32
|
+
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
33
|
+
import { Subject, Subscription, startWith, delay } from 'rxjs';
|
|
34
|
+
import { UseDataSource, RxapFormSystemError } from '@rxap/form-system';
|
|
35
|
+
import { setMetadataMap, getMetadata } from '@rxap/reflect-metadata';
|
|
36
|
+
import * as i1$2 from '@rxap/data-source';
|
|
37
|
+
import { staticDataSource, BaseDataSource, DataSourceLoader } from '@rxap/data-source';
|
|
38
|
+
import { GenerateRandomString, coerceArray } from '@rxap/utilities';
|
|
39
|
+
import { TableDataSource, AbstractTableDataSource } from '@rxap/data-source/table';
|
|
40
|
+
import '@rxap/rxjs';
|
|
41
|
+
import { __decorate, __metadata } from 'tslib';
|
|
42
|
+
import { ExtractDatasourceMixin } from '@rxap/material-table-window-system';
|
|
43
|
+
import { Mixin } from '@rxap/mixin';
|
|
44
|
+
|
|
45
|
+
class TableSelectWindowComponent {
|
|
46
|
+
constructor(data, selectRows, windowRef) {
|
|
47
|
+
this.data = data;
|
|
48
|
+
this.selectRows = selectRows;
|
|
49
|
+
this.windowRef = windowRef;
|
|
50
|
+
this.id = this.data.id;
|
|
51
|
+
this.displayColumns = [...this.data.columns.keys()];
|
|
52
|
+
if (this.data.multiple) {
|
|
53
|
+
this.displayColumns.unshift('select');
|
|
54
|
+
}
|
|
55
|
+
this.filterDisplayColumns = this.displayColumns.map(column => ['filter', column].join('__'));
|
|
56
|
+
this.hasSomeFilterColumn = Array.from(this.data.columns.values()).some(column => column.filter);
|
|
57
|
+
this.hasNotSelected$ = this.selectRows.selectedRows$.pipe(map((selected) => selected.length === 0));
|
|
58
|
+
}
|
|
59
|
+
selectRow(element) {
|
|
60
|
+
this.selectRows.selectionModel.select(element);
|
|
61
|
+
// if not multi select send the selection and close
|
|
62
|
+
if (!this.data.multiple) {
|
|
63
|
+
this.select();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
close() {
|
|
67
|
+
this.windowRef.complete();
|
|
68
|
+
}
|
|
69
|
+
select() {
|
|
70
|
+
this.windowRef.next(this.selectRows.selectedRows);
|
|
71
|
+
this.close();
|
|
72
|
+
}
|
|
73
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectWindowComponent, deps: [{ token: RXAP_WINDOW_DATA }, { token: i1.SelectRowService }, { token: RXAP_WINDOW_REF }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
74
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: TableSelectWindowComponent, isStandalone: true, selector: "rxap-table-select-window", providers: [SelectRowService, TableFilterService], ngImport: i0, template: "<mat-progress-bar *ngIf=\"tableDataSourceDirective.loading$ | async\" mode=\"indeterminate\"></mat-progress-bar>\n<table #tableDataSourceDirective=\"rxapTableDataSource\"\n [id]=\"id ?? 'table-select'\"\n [paginator]=\"paginator\"\n [parameters]=\"data.parameters\"\n mat-table\n matSort\n rxap-filter-header-row\n rxapTableDataSource>\n\n <ng-container *ngIf=\"data.multiple\" matColumnDef=\"select\" sticky>\n <th *matHeaderCellDef mat-header-cell rxap-checkbox-header-cell></th>\n <td\n *matCellDef=\"let element\"\n [element]=\"element\"\n mat-cell\n rxap-checkbox-cell\n ></td>\n </ng-container>\n\n <ng-container *ngIf=\"hasSomeFilterColumn\">\n\n <ng-container *ngIf=\"data.multiple\" [matColumnDef]=\"'filter__select'\">\n <th *matHeaderCellDef mat-header-cell></th>\n </ng-container>\n\n <ng-container *ngFor=\"let item of data.columns | keyvalue\">\n\n <ng-container *ngIf=\"item.value.filter\">\n\n <ng-container [ngSwitch]=\"item.value.type\">\n\n <ng-container *ngSwitchCase=\"'date'\">\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n\n </th>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'boolean'\">\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n\n </th>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n <mat-form-field rxapNoPadding>\n <mat-label i18n>{{item.value.label}}</mat-label>\n <input\n [formControlName]=\"item.key\"\n [placeholder]=\"'Enter the ' + item.value.label + ' filter'\"\n i18n-placeholder\n matInput\n parentControlContainer\n />\n <button mat-icon-button matSuffix rxapInputClearButton>\n <mat-icon>clear</mat-icon>\n </button>\n </mat-form-field>\n </th>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngIf=\"!item.value.filter\">\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>{{data.showHeader ? '' : item.value.label}}</th>\n </ng-container>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngFor=\"let item of data.columns | keyvalue\">\n\n <ng-container [ngSwitch]=\"item.value.type\">\n\n <ng-container *ngSwitchCase=\"'date'\">\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>{{item.value.label}}</th>\n <td\n *matCellDef=\"let element\"\n [format]=\"item.value.format\"\n [rxap-date-cell]=\"element | getFromObject:item.key\"\n mat-cell\n ></td>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'boolean'\">\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>{{item.value.label}}</th>\n <td\n *matCellDef=\"let element\"\n [rxap-boolean-cell]=\"element | getFromObject:item.key\"\n mat-cell\n ></td>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>\n {{item.value.label}}\n </th>\n <td *matCellDef=\"let element\" mat-cell>\n {{ element | getFromObject:item.key }}\n </td>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngIf=\"hasSomeFilterColumn\">\n <tr\n *matHeaderRowDef=\"filterDisplayColumns\"\n class=\"filter-header\"\n mat-header-row\n ></tr>\n </ng-container>\n\n <ng-template [ngIf]=\"data.showHeader\">\n <tr\n *matHeaderRowDef=\"displayColumns\"\n mat-header-row\n ></tr>\n </ng-template>\n\n <tr\n (click)=\"selectRow(element)\"\n *matRowDef=\"let element; columns: displayColumns\"\n [@rowsAnimation]\n mat-row\n ></tr>\n\n</table>\n\n<mat-paginator\n #paginator=\"matPaginator\"\n [pageSizeOptions]=\"[5, 10, 25, 50, 75, 100, 150, 200]\"\n [pageSize]=\"10\"\n></mat-paginator>\n\n<ng-template rxapWindowFooter>\n <div fxLayout=\"row\" fxLayoutAlign=\"start center\" fxLayoutGap=\"16px\">\n <button (click)=\"close()\" fxFlex=\"nogrow\" mat-stroked-button type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"select()\" *ngIf=\"data.multiple\" [disabled]=\"hasNotSelected$ | async\" fxFlex=\"nogrow\" mat-raised-button\n type=\"button\">\n <ng-container i18n>Select</ng-container>\n </button>\n <span *ngIf=\"!data.multiple\" class=\"hint\" i18n>Click on a row to select an entry.</span>\n </div>\n</ng-template>\n", styles: [".filter-header ::ng-deep .mat-form-field .mat-form-field-wrapper{padding-bottom:initial}.filter-header ::ng-deep .mat-form-field .mat-form-field-wrapper .mat-form-field-underline{bottom:0}.hint{font-size:14px;opacity:.5}tr.mat-row{cursor:pointer}tr.mat-row:hover{opacity:.7}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i2.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatTableModule }, { kind: "component", type: i3.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i3.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i3.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i3.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i3.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i3.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i3.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i3.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i3.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i3.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "directive", type: TableDataSourceDirective, selector: "table[mat-table][rxapTableDataSource],mat-table[rxapTableDataSource]", inputs: ["rxapTableDataSource", "paginator", "id", "parameters", "dataSource"], exportAs: ["rxapTableDataSource"] }, { kind: "directive", type: FilterHeaderRowDirective, selector: "table[rxap-filter-header-row]", inputs: ["rxap-filter-header-row"] }, { kind: "ngmodule", type: MatSortModule }, { kind: "directive", type: i4.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "component", type: i4.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { kind: "component", type: CheckboxHeaderCellComponent, selector: "th[rxap-checkbox-header-cell]" }, { kind: "component", type: CheckboxCellComponent, selector: "td[rxap-checkbox-cell]", inputs: ["element"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i5.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i5.MatLabel, selector: "mat-label" }, { kind: "directive", type: i5.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i6.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i7.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i7.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i7.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: ParentControlContainerDirective, selector: "[formControlName][parentControlContainer],[formControlGroup][parentControlContainer]" }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i8.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i8.MatIconButton, selector: "button[mat-icon-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "directive", type: InputClearButtonDirective, selector: "[rxapInputClearButton]" }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i9.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: DateCellComponent, selector: "td[rxap-date-cell]", inputs: ["rxap-date-cell", "format"] }, { kind: "component", type: BooleanCellComponent, selector: "td[rxap-boolean-cell]", inputs: ["rxap-boolean-cell"] }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i10.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "directive", type: WindowFooterDirective, selector: "[rxapWindowFooter]" }, { kind: "ngmodule", type: FlexModule }, { kind: "directive", type: i11.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { kind: "directive", type: i11.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { kind: "directive", type: i11.DefaultLayoutAlignDirective, selector: " [fxLayoutAlign], [fxLayoutAlign.xs], [fxLayoutAlign.sm], [fxLayoutAlign.md], [fxLayoutAlign.lg], [fxLayoutAlign.xl], [fxLayoutAlign.lt-sm], [fxLayoutAlign.lt-md], [fxLayoutAlign.lt-lg], [fxLayoutAlign.lt-xl], [fxLayoutAlign.gt-xs], [fxLayoutAlign.gt-sm], [fxLayoutAlign.gt-md], [fxLayoutAlign.gt-lg]", inputs: ["fxLayoutAlign", "fxLayoutAlign.xs", "fxLayoutAlign.sm", "fxLayoutAlign.md", "fxLayoutAlign.lg", "fxLayoutAlign.xl", "fxLayoutAlign.lt-sm", "fxLayoutAlign.lt-md", "fxLayoutAlign.lt-lg", "fxLayoutAlign.lt-xl", "fxLayoutAlign.gt-xs", "fxLayoutAlign.gt-sm", "fxLayoutAlign.gt-md", "fxLayoutAlign.gt-lg"] }, { kind: "directive", type: i11.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }, { kind: "pipe", type: GetFromObjectPipe, name: "getFromObject" }], animations: [RowAnimation], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
75
|
+
}
|
|
76
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectWindowComponent, decorators: [{
|
|
77
|
+
type: Component,
|
|
78
|
+
args: [{ selector: 'rxap-table-select-window', changeDetection: ChangeDetectionStrategy.OnPush, animations: [RowAnimation], providers: [SelectRowService, TableFilterService], standalone: true, imports: [
|
|
79
|
+
NgIf,
|
|
80
|
+
MatProgressBarModule,
|
|
81
|
+
MatTableModule,
|
|
82
|
+
TableDataSourceDirective,
|
|
83
|
+
FilterHeaderRowDirective,
|
|
84
|
+
MatSortModule,
|
|
85
|
+
CheckboxHeaderCellComponent,
|
|
86
|
+
CheckboxCellComponent,
|
|
87
|
+
NgFor,
|
|
88
|
+
NgSwitch,
|
|
89
|
+
NgSwitchCase,
|
|
90
|
+
NgSwitchDefault,
|
|
91
|
+
MatFormFieldModule,
|
|
92
|
+
MatInputModule,
|
|
93
|
+
FormsModule,
|
|
94
|
+
ReactiveFormsModule,
|
|
95
|
+
ParentControlContainerDirective,
|
|
96
|
+
MatButtonModule,
|
|
97
|
+
InputClearButtonDirective,
|
|
98
|
+
MatIconModule,
|
|
99
|
+
DateCellComponent,
|
|
100
|
+
BooleanCellComponent,
|
|
101
|
+
MatPaginatorModule,
|
|
102
|
+
WindowFooterDirective,
|
|
103
|
+
FlexModule,
|
|
104
|
+
AsyncPipe,
|
|
105
|
+
KeyValuePipe,
|
|
106
|
+
GetFromObjectPipe,
|
|
107
|
+
], template: "<mat-progress-bar *ngIf=\"tableDataSourceDirective.loading$ | async\" mode=\"indeterminate\"></mat-progress-bar>\n<table #tableDataSourceDirective=\"rxapTableDataSource\"\n [id]=\"id ?? 'table-select'\"\n [paginator]=\"paginator\"\n [parameters]=\"data.parameters\"\n mat-table\n matSort\n rxap-filter-header-row\n rxapTableDataSource>\n\n <ng-container *ngIf=\"data.multiple\" matColumnDef=\"select\" sticky>\n <th *matHeaderCellDef mat-header-cell rxap-checkbox-header-cell></th>\n <td\n *matCellDef=\"let element\"\n [element]=\"element\"\n mat-cell\n rxap-checkbox-cell\n ></td>\n </ng-container>\n\n <ng-container *ngIf=\"hasSomeFilterColumn\">\n\n <ng-container *ngIf=\"data.multiple\" [matColumnDef]=\"'filter__select'\">\n <th *matHeaderCellDef mat-header-cell></th>\n </ng-container>\n\n <ng-container *ngFor=\"let item of data.columns | keyvalue\">\n\n <ng-container *ngIf=\"item.value.filter\">\n\n <ng-container [ngSwitch]=\"item.value.type\">\n\n <ng-container *ngSwitchCase=\"'date'\">\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n\n </th>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'boolean'\">\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n\n </th>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>\n <mat-form-field rxapNoPadding>\n <mat-label i18n>{{item.value.label}}</mat-label>\n <input\n [formControlName]=\"item.key\"\n [placeholder]=\"'Enter the ' + item.value.label + ' filter'\"\n i18n-placeholder\n matInput\n parentControlContainer\n />\n <button mat-icon-button matSuffix rxapInputClearButton>\n <mat-icon>clear</mat-icon>\n </button>\n </mat-form-field>\n </th>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngIf=\"!item.value.filter\">\n <ng-container [matColumnDef]=\"'filter__' + item.key\">\n <th *matHeaderCellDef mat-header-cell>{{data.showHeader ? '' : item.value.label}}</th>\n </ng-container>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngFor=\"let item of data.columns | keyvalue\">\n\n <ng-container [ngSwitch]=\"item.value.type\">\n\n <ng-container *ngSwitchCase=\"'date'\">\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>{{item.value.label}}</th>\n <td\n *matCellDef=\"let element\"\n [format]=\"item.value.format\"\n [rxap-date-cell]=\"element | getFromObject:item.key\"\n mat-cell\n ></td>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'boolean'\">\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>{{item.value.label}}</th>\n <td\n *matCellDef=\"let element\"\n [rxap-boolean-cell]=\"element | getFromObject:item.key\"\n mat-cell\n ></td>\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n\n <ng-container [matColumnDef]=\"item.key\">\n <th *matHeaderCellDef mat-header-cell mat-sort-header>\n {{item.value.label}}\n </th>\n <td *matCellDef=\"let element\" mat-cell>\n {{ element | getFromObject:item.key }}\n </td>\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n </ng-container>\n\n <ng-container *ngIf=\"hasSomeFilterColumn\">\n <tr\n *matHeaderRowDef=\"filterDisplayColumns\"\n class=\"filter-header\"\n mat-header-row\n ></tr>\n </ng-container>\n\n <ng-template [ngIf]=\"data.showHeader\">\n <tr\n *matHeaderRowDef=\"displayColumns\"\n mat-header-row\n ></tr>\n </ng-template>\n\n <tr\n (click)=\"selectRow(element)\"\n *matRowDef=\"let element; columns: displayColumns\"\n [@rowsAnimation]\n mat-row\n ></tr>\n\n</table>\n\n<mat-paginator\n #paginator=\"matPaginator\"\n [pageSizeOptions]=\"[5, 10, 25, 50, 75, 100, 150, 200]\"\n [pageSize]=\"10\"\n></mat-paginator>\n\n<ng-template rxapWindowFooter>\n <div fxLayout=\"row\" fxLayoutAlign=\"start center\" fxLayoutGap=\"16px\">\n <button (click)=\"close()\" fxFlex=\"nogrow\" mat-stroked-button type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button (click)=\"select()\" *ngIf=\"data.multiple\" [disabled]=\"hasNotSelected$ | async\" fxFlex=\"nogrow\" mat-raised-button\n type=\"button\">\n <ng-container i18n>Select</ng-container>\n </button>\n <span *ngIf=\"!data.multiple\" class=\"hint\" i18n>Click on a row to select an entry.</span>\n </div>\n</ng-template>\n", styles: [".filter-header ::ng-deep .mat-form-field .mat-form-field-wrapper{padding-bottom:initial}.filter-header ::ng-deep .mat-form-field .mat-form-field-wrapper .mat-form-field-underline{bottom:0}.hint{font-size:14px;opacity:.5}tr.mat-row{cursor:pointer}tr.mat-row:hover{opacity:.7}\n"] }]
|
|
108
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
109
|
+
type: Inject,
|
|
110
|
+
args: [RXAP_WINDOW_DATA]
|
|
111
|
+
}] }, { type: i1.SelectRowService }, { type: i1$1.WindowRef, decorators: [{
|
|
112
|
+
type: Inject,
|
|
113
|
+
args: [RXAP_WINDOW_REF]
|
|
114
|
+
}] }]; } });
|
|
115
|
+
|
|
116
|
+
class TableSelectInputComponent extends ControlValueAccessor {
|
|
117
|
+
static { this.nextId = 0; }
|
|
118
|
+
constructor(ngControl, cdr) {
|
|
119
|
+
super();
|
|
120
|
+
this.ngControl = ngControl;
|
|
121
|
+
this.cdr = cdr;
|
|
122
|
+
this.id = `eurogard-table-select-input-${TableSelectInputComponent.nextId++}`;
|
|
123
|
+
this.stateChanges = new Subject();
|
|
124
|
+
this.control = null;
|
|
125
|
+
this.rxapControl = null;
|
|
126
|
+
this.focused = false;
|
|
127
|
+
this._subscription = new Subscription();
|
|
128
|
+
this._disabled = false;
|
|
129
|
+
this._required = false;
|
|
130
|
+
this._value = null;
|
|
131
|
+
this._placeholder = '';
|
|
132
|
+
// Replace the provider from above with this.
|
|
133
|
+
if (this.ngControl != null) {
|
|
134
|
+
// Setting the value accessor directly (instead of using
|
|
135
|
+
// the providers) to avoid running into a circular import.
|
|
136
|
+
this.ngControl.valueAccessor = this;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
get empty() {
|
|
140
|
+
return this._value === null;
|
|
141
|
+
}
|
|
142
|
+
get shouldLabelFloat() {
|
|
143
|
+
return this.focused || !this.empty;
|
|
144
|
+
}
|
|
145
|
+
get errorState() {
|
|
146
|
+
return this.ngControl?.invalid || false;
|
|
147
|
+
}
|
|
148
|
+
get disabled() { return this._disabled; }
|
|
149
|
+
set disabled(value) {
|
|
150
|
+
this._disabled = coerceBooleanProperty(value);
|
|
151
|
+
this.stateChanges.next();
|
|
152
|
+
}
|
|
153
|
+
get required() {
|
|
154
|
+
return this._required;
|
|
155
|
+
}
|
|
156
|
+
set required(req) {
|
|
157
|
+
this._required = coerceBooleanProperty(req);
|
|
158
|
+
this.stateChanges.next();
|
|
159
|
+
}
|
|
160
|
+
get value() {
|
|
161
|
+
return this._value;
|
|
162
|
+
}
|
|
163
|
+
set value(value) {
|
|
164
|
+
this._value = value;
|
|
165
|
+
this.stateChanges.next();
|
|
166
|
+
}
|
|
167
|
+
get placeholder() {
|
|
168
|
+
return this._placeholder;
|
|
169
|
+
}
|
|
170
|
+
set placeholder(placeholder) {
|
|
171
|
+
this._placeholder = placeholder;
|
|
172
|
+
this.stateChanges.next();
|
|
173
|
+
}
|
|
174
|
+
get display() {
|
|
175
|
+
return this._display;
|
|
176
|
+
}
|
|
177
|
+
set display(value) {
|
|
178
|
+
this._display = value;
|
|
179
|
+
this.cdr.detectChanges();
|
|
180
|
+
}
|
|
181
|
+
writeValue(value) {
|
|
182
|
+
this.value = value;
|
|
183
|
+
}
|
|
184
|
+
setValue(value) {
|
|
185
|
+
this.value = value;
|
|
186
|
+
if (this.onChange) {
|
|
187
|
+
this.onChange(this.value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
ngAfterViewInit() {
|
|
191
|
+
if (this.ngControl) {
|
|
192
|
+
this.control = this.ngControl.control;
|
|
193
|
+
if (this.control instanceof RxapFormControl) {
|
|
194
|
+
this.rxapControl = this.control;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
this._subscription.add(this.control?.valueChanges.pipe(startWith(this.control?.value ?? null), delay(100), // TODO : remove timing workaround
|
|
198
|
+
// the method updateTableSelectInput of TableSelectControlDirective is called in the ngAfterViewInit
|
|
199
|
+
// and will be executed AFTER the first value is used to create the display
|
|
200
|
+
// solution: it must be ensured the the this.toDisplay function is called after the updateTableSelectInput
|
|
201
|
+
// execution else for the first this.toDisplay function the default implementation is used
|
|
202
|
+
tap(async (value) => this.display = value === null ? '' : await this.toDisplay(value))).subscribe());
|
|
203
|
+
this._subscription.add(this.rxapControl?.disabled$.pipe(tap(disabled => this.disabled = disabled)).subscribe());
|
|
204
|
+
}
|
|
205
|
+
toDisplay(value) {
|
|
206
|
+
return value;
|
|
207
|
+
}
|
|
208
|
+
ngOnDestroy() {
|
|
209
|
+
this.stateChanges.complete();
|
|
210
|
+
this._subscription?.unsubscribe();
|
|
211
|
+
}
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
213
|
+
setDescribedByIds(ids) {
|
|
214
|
+
}
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
216
|
+
onContainerClick(event) {
|
|
217
|
+
}
|
|
218
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectInputComponent, deps: [{ token: i7.NgControl, optional: true, self: true }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
219
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: TableSelectInputComponent, isStandalone: true, selector: "rxap-table-select-input", inputs: { disabled: "disabled", required: "required", placeholder: "placeholder" }, host: { properties: { "id": "this.id", "class.floating": "this.shouldLabelFloat" } }, providers: [
|
|
220
|
+
{
|
|
221
|
+
provide: MatFormFieldControl,
|
|
222
|
+
useExisting: forwardRef(() => TableSelectInputComponent),
|
|
223
|
+
},
|
|
224
|
+
], usesInheritance: true, ngImport: i0, template: "<div [ngClass]=\"{ disabled: disabled }\" class=\"mat-select-trigger\">\n <span *ngIf=\"display || placeholder\">{{display ?? placeholder}}</span>\n</div>\n", styles: [":host{display:inline-block;width:100%;outline:none}.container{display:inline-flex;align-items:center;cursor:pointer;position:relative;box-sizing:border-box;width:100%;height:24px}.disabled{color:#ffffff80;cursor:initial}.mat-select-trigger{overflow:hidden}.mat-select-trigger span{white-space:nowrap}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
225
|
+
}
|
|
226
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectInputComponent, decorators: [{
|
|
227
|
+
type: Component,
|
|
228
|
+
args: [{ selector: 'rxap-table-select-input', changeDetection: ChangeDetectionStrategy.OnPush, providers: [
|
|
229
|
+
{
|
|
230
|
+
provide: MatFormFieldControl,
|
|
231
|
+
useExisting: forwardRef(() => TableSelectInputComponent),
|
|
232
|
+
},
|
|
233
|
+
], standalone: true, imports: [NgClass, NgIf], template: "<div [ngClass]=\"{ disabled: disabled }\" class=\"mat-select-trigger\">\n <span *ngIf=\"display || placeholder\">{{display ?? placeholder}}</span>\n</div>\n", styles: [":host{display:inline-block;width:100%;outline:none}.container{display:inline-flex;align-items:center;cursor:pointer;position:relative;box-sizing:border-box;width:100%;height:24px}.disabled{color:#ffffff80;cursor:initial}.mat-select-trigger{overflow:hidden}.mat-select-trigger span{white-space:nowrap}\n"] }]
|
|
234
|
+
}], ctorParameters: function () { return [{ type: i7.NgControl, decorators: [{
|
|
235
|
+
type: Optional
|
|
236
|
+
}, {
|
|
237
|
+
type: Self
|
|
238
|
+
}] }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { id: [{
|
|
239
|
+
type: HostBinding
|
|
240
|
+
}], shouldLabelFloat: [{
|
|
241
|
+
type: HostBinding,
|
|
242
|
+
args: ['class.floating']
|
|
243
|
+
}], disabled: [{
|
|
244
|
+
type: Input
|
|
245
|
+
}], required: [{
|
|
246
|
+
type: Input
|
|
247
|
+
}], placeholder: [{
|
|
248
|
+
type: Input
|
|
249
|
+
}] } });
|
|
250
|
+
|
|
251
|
+
const TABLE_SELECT_COLUMN_MAP = 'TABLE_SELECT_COLUMN_MAP';
|
|
252
|
+
const TABLE_SELECT_TO_DISPLAY = 'TABLE_SELECT_TO_DISPLAY';
|
|
253
|
+
const TABLE_SELECT_TO_VALUE = 'TABLE_SELECT_TO_VALUE';
|
|
254
|
+
const TABLE_SELECT_DATA_SOURCE = 'TABLE_SELECT_DATA_SOURCE';
|
|
255
|
+
function UseTableSelectColumns(columnMap) {
|
|
256
|
+
return function (target, propertyKey) {
|
|
257
|
+
setMetadataMap(propertyKey, columnMap, TABLE_SELECT_COLUMN_MAP, target);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function UseTableSelectDataSource(dataSource, settings) {
|
|
261
|
+
return UseDataSource(dataSource, TABLE_SELECT_DATA_SOURCE, settings);
|
|
262
|
+
}
|
|
263
|
+
function UseTableSelectToDisplay(toDisplay) {
|
|
264
|
+
return function (target, propertyKey) {
|
|
265
|
+
setMetadataMap(propertyKey, toDisplay, TABLE_SELECT_TO_DISPLAY, target);
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function UseTableSelectToValue(toValue) {
|
|
269
|
+
return function (target, propertyKey) {
|
|
270
|
+
setMetadataMap(propertyKey, toValue, TABLE_SELECT_TO_VALUE, target);
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
class OpenTableSelectWindowMethod {
|
|
275
|
+
constructor(windowService, injector) {
|
|
276
|
+
this.windowService = windowService;
|
|
277
|
+
this.injector = injector;
|
|
278
|
+
}
|
|
279
|
+
call(parameters) {
|
|
280
|
+
const providers = [
|
|
281
|
+
{
|
|
282
|
+
provide: RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS,
|
|
283
|
+
useValue: {
|
|
284
|
+
multiple: parameters.multiple ?? false,
|
|
285
|
+
selected: parameters.selected ?? [],
|
|
286
|
+
compareWith: parameters.compareWith,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
];
|
|
290
|
+
if (Array.isArray(parameters.data)) {
|
|
291
|
+
providers.push({
|
|
292
|
+
provide: TABLE_DATA_SOURCE,
|
|
293
|
+
useValue: new TableDataSource(staticDataSource(parameters.data)),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
else if (parameters.data instanceof AbstractTableDataSource) {
|
|
297
|
+
providers.push({
|
|
298
|
+
provide: TABLE_DATA_SOURCE,
|
|
299
|
+
useValue: parameters.data,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
providers.push({
|
|
304
|
+
provide: TABLE_DATA_SOURCE,
|
|
305
|
+
useValue: new TableDataSource(parameters.data),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
providers.push({
|
|
309
|
+
provide: RXAP_TABLE_METHOD,
|
|
310
|
+
useValue: null,
|
|
311
|
+
});
|
|
312
|
+
providers.push({
|
|
313
|
+
provide: TABLE_REMOTE_METHOD_ADAPTER_FACTORY,
|
|
314
|
+
useValue: null,
|
|
315
|
+
});
|
|
316
|
+
providers.push({
|
|
317
|
+
provide: RXAP_TABLE_FILTER,
|
|
318
|
+
useValue: null,
|
|
319
|
+
});
|
|
320
|
+
providers.push({
|
|
321
|
+
provide: RXAP_WINDOW_SETTINGS,
|
|
322
|
+
useValue: null,
|
|
323
|
+
});
|
|
324
|
+
providers.push(this.createFilterForm(parameters.columns));
|
|
325
|
+
const windowRef = this.windowService.open({
|
|
326
|
+
...parameters.windowConfig,
|
|
327
|
+
viewContainerRef: parameters.viewContainerRef,
|
|
328
|
+
injector: Injector.create({
|
|
329
|
+
parent: parameters.injector ?? this.injector,
|
|
330
|
+
providers,
|
|
331
|
+
}),
|
|
332
|
+
title: parameters.title ?? $localize `Select`,
|
|
333
|
+
data: parameters,
|
|
334
|
+
component: TableSelectWindowComponent,
|
|
335
|
+
});
|
|
336
|
+
return windowRef.pipe(take(1), map(selected => selected ?? [])).toPromise();
|
|
337
|
+
}
|
|
338
|
+
createFilterForm(columns) {
|
|
339
|
+
const columnNameList = Array.from(columns.entries())
|
|
340
|
+
.filter(([key, column]) => column.filter)
|
|
341
|
+
.map(([key, column]) => key);
|
|
342
|
+
const controls = {};
|
|
343
|
+
for (const column of columnNameList) {
|
|
344
|
+
controls[column] = new RxapFormControl(null, { controlId: column });
|
|
345
|
+
}
|
|
346
|
+
const form = {
|
|
347
|
+
...controls,
|
|
348
|
+
rxapFormGroup: new RxapFormGroup(controls, { controlId: 'filter' }),
|
|
349
|
+
rxapMetadata: { controlId: 'filter' },
|
|
350
|
+
};
|
|
351
|
+
Reflect.set(form.rxapFormGroup, '_rxapFormDefinition', form);
|
|
352
|
+
return {
|
|
353
|
+
provide: RXAP_TABLE_FILTER_FORM_DEFINITION,
|
|
354
|
+
useValue: form,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: OpenTableSelectWindowMethod, deps: [{ token: i1$1.WindowService }, { token: INJECTOR }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
358
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: OpenTableSelectWindowMethod }); }
|
|
359
|
+
}
|
|
360
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: OpenTableSelectWindowMethod, decorators: [{
|
|
361
|
+
type: Injectable
|
|
362
|
+
}], ctorParameters: function () { return [{ type: i1$1.WindowService }, { type: i0.Injector, decorators: [{
|
|
363
|
+
type: Inject,
|
|
364
|
+
args: [INJECTOR]
|
|
365
|
+
}] }]; } });
|
|
366
|
+
|
|
367
|
+
class OpenTableSelectWindowDirective {
|
|
368
|
+
constructor(openMethod, injector, matButton) {
|
|
369
|
+
this.openMethod = openMethod;
|
|
370
|
+
this.injector = injector;
|
|
371
|
+
this.matButton = matButton;
|
|
372
|
+
this.selected = [];
|
|
373
|
+
this.selectedChange = new EventEmitter();
|
|
374
|
+
this.type = 'button';
|
|
375
|
+
this._hasOpenWindow = false;
|
|
376
|
+
this.invalidInputs = false;
|
|
377
|
+
this._disabled = false;
|
|
378
|
+
}
|
|
379
|
+
get disabled() {
|
|
380
|
+
return this._disabled || this.invalidInputs;
|
|
381
|
+
}
|
|
382
|
+
set disabled(value) {
|
|
383
|
+
this._disabled = value;
|
|
384
|
+
}
|
|
385
|
+
ngOnChanges() {
|
|
386
|
+
this.checkInputs();
|
|
387
|
+
}
|
|
388
|
+
ngOnInit() {
|
|
389
|
+
this.checkInputs();
|
|
390
|
+
}
|
|
391
|
+
async onClick($event) {
|
|
392
|
+
if (this.disabled || this._hasOpenWindow) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
$event.stopPropagation();
|
|
396
|
+
if (!this.data || !this.columns) {
|
|
397
|
+
throw new Error('FATAL: The data or columns input is not set');
|
|
398
|
+
}
|
|
399
|
+
const selected = await this.openMethod.call({
|
|
400
|
+
injector: this.injector,
|
|
401
|
+
data: this.data,
|
|
402
|
+
columns: this.columns instanceof Map ? this.columns : new Map(Object.entries(this.columns)),
|
|
403
|
+
selected: this.selected?.slice() ?? [],
|
|
404
|
+
title: this.label ?? 'Select value',
|
|
405
|
+
compareWith: this.compareWith,
|
|
406
|
+
id: this.id ?? GenerateRandomString(10),
|
|
407
|
+
parameters: this.parameters,
|
|
408
|
+
});
|
|
409
|
+
if (isDevMode()) {
|
|
410
|
+
console.debug('selected', selected);
|
|
411
|
+
}
|
|
412
|
+
this.selected = selected ?? [];
|
|
413
|
+
this._hasOpenWindow = false;
|
|
414
|
+
this.selectedChange.emit(selected);
|
|
415
|
+
}
|
|
416
|
+
checkInputs() {
|
|
417
|
+
if (!this.columns || !this.data) {
|
|
418
|
+
console.warn('columns or data is not defined');
|
|
419
|
+
this.invalidInputs = true;
|
|
420
|
+
if (this.matButton) {
|
|
421
|
+
this.matButton.disabled = this.disabled;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
if (typeof this.columns !== 'object') {
|
|
426
|
+
throw new Error('Ensure that the input columns has a valid value');
|
|
427
|
+
}
|
|
428
|
+
if (!Array.isArray(this.data) && !(this.data instanceof BaseDataSource)) {
|
|
429
|
+
throw new Error('Ensure that the input data has a valid value');
|
|
430
|
+
}
|
|
431
|
+
this.invalidInputs = false;
|
|
432
|
+
if (this.matButton) {
|
|
433
|
+
this.matButton.disabled = this.disabled;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: OpenTableSelectWindowDirective, deps: [{ token: OpenTableSelectWindowMethod }, { token: i0.Injector }, { token: MatButton, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
438
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: OpenTableSelectWindowDirective, isStandalone: true, selector: "[rxapOpenTableSelectWindow]", inputs: { data: "data", columns: "columns", selected: "selected", parameters: "parameters", label: "label", id: "id", compareWith: "compareWith" }, outputs: { selectedChange: "selectedChange" }, host: { listeners: { "click": "onClick($event)" }, properties: { "type": "this.type" } }, usesOnChanges: true, ngImport: i0 }); }
|
|
439
|
+
}
|
|
440
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: OpenTableSelectWindowDirective, decorators: [{
|
|
441
|
+
type: Directive,
|
|
442
|
+
args: [{
|
|
443
|
+
selector: '[rxapOpenTableSelectWindow]',
|
|
444
|
+
standalone: true,
|
|
445
|
+
}]
|
|
446
|
+
}], ctorParameters: function () { return [{ type: OpenTableSelectWindowMethod }, { type: i0.Injector }, { type: i8.MatButton, decorators: [{
|
|
447
|
+
type: Optional
|
|
448
|
+
}, {
|
|
449
|
+
type: Inject,
|
|
450
|
+
args: [MatButton]
|
|
451
|
+
}] }]; }, propDecorators: { data: [{
|
|
452
|
+
type: Input
|
|
453
|
+
}], columns: [{
|
|
454
|
+
type: Input
|
|
455
|
+
}], selected: [{
|
|
456
|
+
type: Input
|
|
457
|
+
}], parameters: [{
|
|
458
|
+
type: Input
|
|
459
|
+
}], selectedChange: [{
|
|
460
|
+
type: Output
|
|
461
|
+
}], label: [{
|
|
462
|
+
type: Input
|
|
463
|
+
}], id: [{
|
|
464
|
+
type: Input
|
|
465
|
+
}], compareWith: [{
|
|
466
|
+
type: Input
|
|
467
|
+
}], type: [{
|
|
468
|
+
type: HostBinding,
|
|
469
|
+
args: ['type']
|
|
470
|
+
}], onClick: [{
|
|
471
|
+
type: HostListener,
|
|
472
|
+
args: ['click', ['$event']]
|
|
473
|
+
}] } });
|
|
474
|
+
|
|
475
|
+
let TableSelectControlDirective = class TableSelectControlDirective {
|
|
476
|
+
constructor(injector,
|
|
477
|
+
// required for the use mixin ExtractDatasourceMixin
|
|
478
|
+
dataSourceLoader, matFormField) {
|
|
479
|
+
this.injector = injector;
|
|
480
|
+
this.dataSourceLoader = dataSourceLoader;
|
|
481
|
+
this.matFormField = matFormField;
|
|
482
|
+
this.ngControl = null;
|
|
483
|
+
this.value = null;
|
|
484
|
+
this.disabled = false;
|
|
485
|
+
this._subscription = new Subscription();
|
|
486
|
+
this.toDisplay = value => value;
|
|
487
|
+
}
|
|
488
|
+
get selected() {
|
|
489
|
+
return this.value !== null ? [this.value] : [];
|
|
490
|
+
}
|
|
491
|
+
ngOnChanges(changes) {
|
|
492
|
+
const columnsChange = changes['columns'];
|
|
493
|
+
const dataChange = changes['data'];
|
|
494
|
+
if (this.openTableSelectWindow) {
|
|
495
|
+
if (columnsChange || dataChange) {
|
|
496
|
+
this.updateOpenTableSelectWindow();
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
ngAfterViewInit() {
|
|
501
|
+
this.ngControl = this.matFormField._control?.ngControl;
|
|
502
|
+
if (this.ngControl) {
|
|
503
|
+
const control = this.ngControl.control;
|
|
504
|
+
if (!control) {
|
|
505
|
+
throw new Error('The control container does not have a control object');
|
|
506
|
+
}
|
|
507
|
+
if (control instanceof RxapFormControl) {
|
|
508
|
+
// TODO : replace with custom data source extractor
|
|
509
|
+
this.data =
|
|
510
|
+
this.extractDatasource(TABLE_SELECT_DATA_SOURCE, this.control = control);
|
|
511
|
+
this.toDisplay = this.extractTableSelectToDisplay(this.control = control) ?? this.toDisplay;
|
|
512
|
+
this.toValue = this.extractTableSelectToValue(this.control = control);
|
|
513
|
+
this.columns = this.extractTableSelectColumnMap(this.control = control);
|
|
514
|
+
this.updateOpenTableSelectWindow();
|
|
515
|
+
this._subscription?.add(control.disabled$.pipe(tap(disabled => this.disabled = disabled), tap(() => this.updateOpenTableSelectWindowDisabledState())).subscribe());
|
|
516
|
+
}
|
|
517
|
+
else {
|
|
518
|
+
console.warn('The control in the ControlContainer is not a RxapFormControl. Can not extract the data source');
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
if (isDevMode()) {
|
|
523
|
+
console.log('standalone mode');
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
this.updateTableSelectInput();
|
|
527
|
+
}
|
|
528
|
+
ngAfterContentInit() {
|
|
529
|
+
this.updateOpenTableSelectWindow();
|
|
530
|
+
for (const openTableSelectWindow of this.openTableSelectWindow) {
|
|
531
|
+
this._subscription.add(openTableSelectWindow.selectedChange.pipe(tap($event => this.onSelected($event))).subscribe());
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
ngOnDestroy() {
|
|
535
|
+
this._subscription?.unsubscribe();
|
|
536
|
+
}
|
|
537
|
+
updateTableSelectInput() {
|
|
538
|
+
if (this.toDisplay) {
|
|
539
|
+
this.tableSelectInput.toDisplay = this.toDisplay.bind(this);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
updateOpenTableSelectWindowDisabledState() {
|
|
543
|
+
for (const openTableSelectWindow of this.openTableSelectWindow) {
|
|
544
|
+
openTableSelectWindow.disabled = this.disabled;
|
|
545
|
+
openTableSelectWindow.checkInputs();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
updateOpenTableSelectWindow() {
|
|
549
|
+
for (const openTableSelectWindow of this.openTableSelectWindow) {
|
|
550
|
+
openTableSelectWindow.disabled = this.disabled;
|
|
551
|
+
if (this.columns) {
|
|
552
|
+
openTableSelectWindow.columns = this.columns;
|
|
553
|
+
}
|
|
554
|
+
if (this.data) {
|
|
555
|
+
openTableSelectWindow.data = this.data;
|
|
556
|
+
}
|
|
557
|
+
if (this.toValue) {
|
|
558
|
+
openTableSelectWindow.compareWith = ((o1, o2) => {
|
|
559
|
+
if (this.toValue) {
|
|
560
|
+
return this.toValue(o1) === this.toValue(o2);
|
|
561
|
+
}
|
|
562
|
+
return o1 === o2;
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (this.matLabel) {
|
|
566
|
+
openTableSelectWindow.label = this.matLabel?.nativeElement.innerText;
|
|
567
|
+
}
|
|
568
|
+
if (this.ngControl) {
|
|
569
|
+
const control = this.ngControl.control;
|
|
570
|
+
if (control?.value) {
|
|
571
|
+
openTableSelectWindow.selected = coerceArray(control.value);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
openTableSelectWindow.checkInputs();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
async onSelected($event) {
|
|
578
|
+
if ($event?.length) {
|
|
579
|
+
this.tableSelectInput.display = await this.toDisplay($event[0]);
|
|
580
|
+
this.value = $event[0];
|
|
581
|
+
this.tableSelectInput.setValue(this.value);
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
this.value = null;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
extractTableSelectColumnMap(control = this.control) {
|
|
588
|
+
// TODO : create utility function to extract metadata for a specific control
|
|
589
|
+
const formDefinition = this.extractFormDefinition(control);
|
|
590
|
+
const map = getMetadata(TABLE_SELECT_COLUMN_MAP, Object.getPrototypeOf(formDefinition));
|
|
591
|
+
if (!map) {
|
|
592
|
+
throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
|
|
593
|
+
}
|
|
594
|
+
if (!map.has(control.controlId)) {
|
|
595
|
+
throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
|
|
596
|
+
}
|
|
597
|
+
return map.get(control.controlId);
|
|
598
|
+
}
|
|
599
|
+
extractTableSelectToDisplay(control = this.control) {
|
|
600
|
+
// TODO : create utility function to extract metadata for a specific control
|
|
601
|
+
const formDefinition = this.extractFormDefinition(control);
|
|
602
|
+
const map = getMetadata(TABLE_SELECT_TO_DISPLAY, Object.getPrototypeOf(formDefinition));
|
|
603
|
+
if (!map) {
|
|
604
|
+
throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
|
|
605
|
+
}
|
|
606
|
+
if (!map.has(control.controlId)) {
|
|
607
|
+
throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
|
|
608
|
+
}
|
|
609
|
+
return map.get(control.controlId);
|
|
610
|
+
}
|
|
611
|
+
extractTableSelectToValue(control = this.control) {
|
|
612
|
+
// TODO : create utility function to extract metadata for a specific control
|
|
613
|
+
const formDefinition = this.extractFormDefinition(control);
|
|
614
|
+
const map = getMetadata(TABLE_SELECT_TO_VALUE, Object.getPrototypeOf(formDefinition));
|
|
615
|
+
if (!map) {
|
|
616
|
+
throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
|
|
617
|
+
}
|
|
618
|
+
if (!map.has(control.controlId)) {
|
|
619
|
+
throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
|
|
620
|
+
}
|
|
621
|
+
return map.get(control.controlId);
|
|
622
|
+
}
|
|
623
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlDirective, deps: [{ token: i0.Injector }, { token: i1$2.DataSourceLoader }, { token: i5.MatFormField }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
624
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.4", type: TableSelectControlDirective, isStandalone: true, selector: "mat-form-field[rxapTableSelectControl]", inputs: { multiple: "multiple", openMethod: "openMethod", data: "data", columns: "columns", toValue: "toValue", toDisplay: "toDisplay" }, queries: [{ propertyName: "tableSelectInput", first: true, predicate: TableSelectInputComponent, descendants: true }, { propertyName: "matLabel", first: true, predicate: ["mat-label"], descendants: true }, { propertyName: "openTableSelectWindow", predicate: OpenTableSelectWindowDirective }], usesOnChanges: true, ngImport: i0 }); }
|
|
625
|
+
};
|
|
626
|
+
TableSelectControlDirective = __decorate([
|
|
627
|
+
Mixin(ExtractDatasourceMixin),
|
|
628
|
+
__metadata("design:paramtypes", [Injector,
|
|
629
|
+
DataSourceLoader,
|
|
630
|
+
MatFormField])
|
|
631
|
+
], TableSelectControlDirective);
|
|
632
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlDirective, decorators: [{
|
|
633
|
+
type: Directive,
|
|
634
|
+
args: [{
|
|
635
|
+
selector: 'mat-form-field[rxapTableSelectControl]',
|
|
636
|
+
standalone: true,
|
|
637
|
+
}]
|
|
638
|
+
}], ctorParameters: function () { return [{ type: i0.Injector }, { type: i1$2.DataSourceLoader }, { type: i5.MatFormField }]; }, propDecorators: { multiple: [{
|
|
639
|
+
type: Input
|
|
640
|
+
}], openMethod: [{
|
|
641
|
+
type: Input
|
|
642
|
+
}], data: [{
|
|
643
|
+
type: Input
|
|
644
|
+
}], columns: [{
|
|
645
|
+
type: Input
|
|
646
|
+
}], openTableSelectWindow: [{
|
|
647
|
+
type: ContentChildren,
|
|
648
|
+
args: [OpenTableSelectWindowDirective]
|
|
649
|
+
}], tableSelectInput: [{
|
|
650
|
+
type: ContentChild,
|
|
651
|
+
args: [TableSelectInputComponent]
|
|
652
|
+
}], matLabel: [{
|
|
653
|
+
type: ContentChild,
|
|
654
|
+
args: ['mat-label']
|
|
655
|
+
}], toValue: [{
|
|
656
|
+
type: Input
|
|
657
|
+
}], toDisplay: [{
|
|
658
|
+
type: Input
|
|
659
|
+
}] } });
|
|
660
|
+
|
|
661
|
+
class TableSelectControlModule {
|
|
662
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
663
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlModule, imports: [OpenTableSelectWindowDirective,
|
|
664
|
+
TableSelectControlDirective], exports: [OpenTableSelectWindowDirective,
|
|
665
|
+
TableSelectControlDirective] }); }
|
|
666
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlModule, providers: [
|
|
667
|
+
OpenTableSelectWindowMethod,
|
|
668
|
+
] }); }
|
|
669
|
+
}
|
|
670
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: TableSelectControlModule, decorators: [{
|
|
671
|
+
type: NgModule,
|
|
672
|
+
args: [{
|
|
673
|
+
imports: [
|
|
674
|
+
OpenTableSelectWindowDirective,
|
|
675
|
+
TableSelectControlDirective,
|
|
676
|
+
],
|
|
677
|
+
exports: [
|
|
678
|
+
OpenTableSelectWindowDirective,
|
|
679
|
+
TableSelectControlDirective,
|
|
680
|
+
],
|
|
681
|
+
providers: [
|
|
682
|
+
OpenTableSelectWindowMethod,
|
|
683
|
+
],
|
|
684
|
+
}]
|
|
685
|
+
}] });
|
|
686
|
+
|
|
687
|
+
// region table-select-window
|
|
688
|
+
// endregion
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Generated bundle index. Do not edit.
|
|
692
|
+
*/
|
|
693
|
+
|
|
694
|
+
export { OpenTableSelectWindowDirective, OpenTableSelectWindowMethod, TABLE_SELECT_COLUMN_MAP, TABLE_SELECT_DATA_SOURCE, TABLE_SELECT_TO_DISPLAY, TABLE_SELECT_TO_VALUE, TableSelectControlDirective, TableSelectControlModule, TableSelectInputComponent, TableSelectWindowComponent, UseTableSelectColumns, UseTableSelectDataSource, UseTableSelectToDisplay, UseTableSelectToValue };
|
|
695
|
+
//# sourceMappingURL=rxap-ngx-material-table-select.mjs.map
|