@kris701/ez-ui 0.0.9 → 1.0.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/fesm2022/kris701-ez-ui.mjs +2536 -0
- package/fesm2022/kris701-ez-ui.mjs.map +1 -0
- package/package.json +22 -8
- package/types/kris701-ez-ui.d.ts +348 -0
- package/index.ts +0 -2
- package/ng-package.json +0 -15
- package/public-api.ts +0 -15
- package/src/components/dateinput.ts +0 -58
- package/src/components/floatfileupload.ts +0 -52
- package/src/components/floattable/filters/tuiThDateFilter.ts +0 -159
- package/src/components/floattable/filters/tuiThSelectFilter.ts +0 -178
- package/src/components/floattable/filters/tuiThTextFilter.ts +0 -161
- package/src/components/floattable/floattable.presets.ts +0 -197
- package/src/components/floattable/floattable.ts +0 -309
- package/src/components/floattable/helpers/floattable.filterhelpers.ts +0 -23
- package/src/components/floattable/models/FloatTableFilter.ts +0 -5
- package/src/components/floattable/models/FloatTableFilterMethod.ts +0 -5
- package/src/components/floattable/models/FloatTableSort.ts +0 -4
- package/src/components/floattable/models/FloatTableSortFilterPreset.ts +0 -10
- package/src/components/floattable/models/FloatTableSortFilterPresetSave.ts +0 -6
- package/src/components/floattable/models/FloatTableSortMethod.ts +0 -4
- package/src/components/floattable/services/floattable.filterservice.ts +0 -110
- package/src/components/floattable/sorts/tuiThSortable.ts +0 -75
- package/src/components/markdowneditor.ts +0 -340
- package/src/components/menubar.ts +0 -144
- package/src/components/multiselect.ts +0 -77
- package/src/components/numberinput.ts +0 -45
- package/src/components/passwordinput.ts +0 -44
- package/src/components/textinput.ts +0 -40
- package/src/helpers/compressImage.ts +0 -20
- package/src/interfaces/baseCRUDInterface.ts +0 -181
- package/src/interfaces/baseListService.ts +0 -62
- package/tsconfig.lib.json +0 -12
- package/tsconfig.lib.prod.json +0 -11
|
@@ -0,0 +1,2536 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Output, Input, Component, signal, ViewChild, ContentChild, Directive } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
import { TuiDay, TuiTime } from '@taiga-ui/cdk/date-time';
|
|
6
|
+
import * as i3$1 from '@taiga-ui/core';
|
|
7
|
+
import { TuiInput, TuiOption, TuiDropdown, TuiGroup, TuiButton, TuiScrollbar, TuiSelectLike, TuiDataList, TuiTextfield, TuiIcon, TuiHint, TuiLoader } from '@taiga-ui/core';
|
|
8
|
+
import * as i4$1 from '@taiga-ui/kit';
|
|
9
|
+
import { TuiInputDate, TuiFiles, TuiChevron, TuiTextarea, TuiMultiSelect, TuiInputNumber, TuiInputChip, TuiPassword, TuiBadge, TuiStatus, TuiDataListWrapper, TuiButtonSelect, TuiBadgeNotification, TuiStringifyContentPipe, TuiBadgedContent, TuiInputDateTime, TUI_CONFIRM } from '@taiga-ui/kit';
|
|
10
|
+
import * as i2 from '@taiga-ui/core/components/label';
|
|
11
|
+
import * as i3 from '@taiga-ui/core/components/textfield';
|
|
12
|
+
import * as i4 from '@taiga-ui/core/portals/dropdown';
|
|
13
|
+
import * as i6 from '@taiga-ui/core/components/calendar';
|
|
14
|
+
import * as i2$1 from '@angular/common';
|
|
15
|
+
import { CommonModule } from '@angular/common';
|
|
16
|
+
import { marked } from 'marked';
|
|
17
|
+
import Compressor from 'compressorjs';
|
|
18
|
+
import * as i7 from '@taiga-ui/cdk/directives/item';
|
|
19
|
+
import * as i3$2 from '@taiga-ui/addon-table';
|
|
20
|
+
import { TuiTablePagination, TuiTable } from '@taiga-ui/addon-table';
|
|
21
|
+
import * as i4$2 from '@taiga-ui/layout';
|
|
22
|
+
import { TuiBlockStatus } from '@taiga-ui/layout';
|
|
23
|
+
import { v4 } from 'uuid';
|
|
24
|
+
import { firstValueFrom, switchMap } from 'rxjs';
|
|
25
|
+
import * as i1$1 from '@angular/common/http';
|
|
26
|
+
import * as i3$3 from '@taiga-ui/addon-mobile';
|
|
27
|
+
|
|
28
|
+
class EzUIDateInput {
|
|
29
|
+
icon = '';
|
|
30
|
+
label = '';
|
|
31
|
+
size = 'm';
|
|
32
|
+
disabled = false;
|
|
33
|
+
min = null;
|
|
34
|
+
max = null;
|
|
35
|
+
TuiDay = TuiDay;
|
|
36
|
+
value = new Date;
|
|
37
|
+
valueChange = new EventEmitter();
|
|
38
|
+
internalValue = null;
|
|
39
|
+
ngOnChanges(changes) {
|
|
40
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
41
|
+
this.value = changes['value'].currentValue;
|
|
42
|
+
this.value = new Date(this.value);
|
|
43
|
+
this.internalValue = TuiDay.fromUtcNativeDate(this.value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
updateValue() {
|
|
47
|
+
if (this.internalValue) {
|
|
48
|
+
this.value = this.internalValue?.toUtcNativeDate();
|
|
49
|
+
this.valueChange.emit(this.value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIDateInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
53
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIDateInput, isStandalone: true, selector: "ezui-dateinput", inputs: { icon: "icon", label: "label", size: "size", disabled: "disabled", min: "min", max: "max", value: "value" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
54
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
55
|
+
@if(label){
|
|
56
|
+
<label tuiLabel>{{label}}</label>
|
|
57
|
+
}
|
|
58
|
+
<input tuiInputDate [(ngModel)]="internalValue" (ngModelChange)="updateValue()" [disabled]="disabled" [min]="min ? TuiDay.fromLocalNativeDate(min) : null" [max]="max ? TuiDay.fromLocalNativeDate(max) : null"/>
|
|
59
|
+
<tui-calendar *tuiDropdown />
|
|
60
|
+
</tui-textfield>
|
|
61
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i4.TuiDropdownContent, selector: "ng-template[tuiDropdown]" }, { kind: "directive", type: i4$1.TuiInputDateDirective, selector: "input[tuiInputDate]", inputs: ["max", "min"] }, { kind: "component", type: i6.TuiCalendar, selector: "tui-calendar:not([new])", inputs: ["minViewedMonth", "maxViewedMonth", "showAdjacent", "markerHandler", "initialView", "hoveredItem"], outputs: ["hoveredItemChange", "dayClick"] }] });
|
|
62
|
+
}
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIDateInput, decorators: [{
|
|
64
|
+
type: Component,
|
|
65
|
+
args: [{ selector: 'ezui-dateinput', imports: [
|
|
66
|
+
FormsModule,
|
|
67
|
+
TuiInput,
|
|
68
|
+
TuiInputDate
|
|
69
|
+
], template: `
|
|
70
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
71
|
+
@if(label){
|
|
72
|
+
<label tuiLabel>{{label}}</label>
|
|
73
|
+
}
|
|
74
|
+
<input tuiInputDate [(ngModel)]="internalValue" (ngModelChange)="updateValue()" [disabled]="disabled" [min]="min ? TuiDay.fromLocalNativeDate(min) : null" [max]="max ? TuiDay.fromLocalNativeDate(max) : null"/>
|
|
75
|
+
<tui-calendar *tuiDropdown />
|
|
76
|
+
</tui-textfield>
|
|
77
|
+
` }]
|
|
78
|
+
}], propDecorators: { icon: [{
|
|
79
|
+
type: Input
|
|
80
|
+
}], label: [{
|
|
81
|
+
type: Input
|
|
82
|
+
}], size: [{
|
|
83
|
+
type: Input
|
|
84
|
+
}], disabled: [{
|
|
85
|
+
type: Input
|
|
86
|
+
}], min: [{
|
|
87
|
+
type: Input
|
|
88
|
+
}], max: [{
|
|
89
|
+
type: Input
|
|
90
|
+
}], value: [{
|
|
91
|
+
type: Input
|
|
92
|
+
}], valueChange: [{
|
|
93
|
+
type: Output
|
|
94
|
+
}] } });
|
|
95
|
+
|
|
96
|
+
class EzUIFileInput {
|
|
97
|
+
files = signal([], /* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []));
|
|
99
|
+
clear() {
|
|
100
|
+
this.files.set([]);
|
|
101
|
+
}
|
|
102
|
+
onChange(files) {
|
|
103
|
+
if (files instanceof File)
|
|
104
|
+
this.files.set([files]);
|
|
105
|
+
else
|
|
106
|
+
this.files.set(files);
|
|
107
|
+
}
|
|
108
|
+
removeFile(file) {
|
|
109
|
+
var files = this.files();
|
|
110
|
+
var index = files.indexOf(file);
|
|
111
|
+
if (index != -1) {
|
|
112
|
+
files.splice(index, 1);
|
|
113
|
+
this.files.set(files);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIFileInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
117
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIFileInput, isStandalone: true, selector: "ezui-fileinput", ngImport: i0, template: `
|
|
118
|
+
<label tuiInputFiles>
|
|
119
|
+
<input
|
|
120
|
+
#validator="tuiInputFilesValidator"
|
|
121
|
+
accept="*/*"
|
|
122
|
+
tuiInputFiles
|
|
123
|
+
[ngModel]="files()"
|
|
124
|
+
(ngModelChange)="onChange($event)"
|
|
125
|
+
/>
|
|
126
|
+
</label>
|
|
127
|
+
|
|
128
|
+
<tui-files>
|
|
129
|
+
@for(file of files(); track file){
|
|
130
|
+
<tui-file
|
|
131
|
+
state="normal"
|
|
132
|
+
[file]="file"
|
|
133
|
+
(remove)="removeFile(file)"
|
|
134
|
+
/>
|
|
135
|
+
}
|
|
136
|
+
</tui-files>
|
|
137
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i4$1.TuiFile, selector: "tui-file,a[tuiFile],button[tuiFile]", inputs: ["file", "state", "size", "showDelete", "showSize", "leftContent"], outputs: ["remove"] }, { kind: "component", type: i4$1.TuiInputFiles, selector: "label[tuiInputFiles]", inputs: ["tuiInputFiles"] }, { kind: "component", type: i4$1.TuiFilesComponent, selector: "tui-files", inputs: ["max", "expanded"], outputs: ["expandedChange"] }, { kind: "directive", type: i4$1.TuiInputFilesDirective, selector: "input[tuiInputFiles]", outputs: ["reject"] }] });
|
|
138
|
+
}
|
|
139
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIFileInput, decorators: [{
|
|
140
|
+
type: Component,
|
|
141
|
+
args: [{
|
|
142
|
+
selector: 'ezui-fileinput',
|
|
143
|
+
imports: [FormsModule, TuiFiles],
|
|
144
|
+
template: `
|
|
145
|
+
<label tuiInputFiles>
|
|
146
|
+
<input
|
|
147
|
+
#validator="tuiInputFilesValidator"
|
|
148
|
+
accept="*/*"
|
|
149
|
+
tuiInputFiles
|
|
150
|
+
[ngModel]="files()"
|
|
151
|
+
(ngModelChange)="onChange($event)"
|
|
152
|
+
/>
|
|
153
|
+
</label>
|
|
154
|
+
|
|
155
|
+
<tui-files>
|
|
156
|
+
@for(file of files(); track file){
|
|
157
|
+
<tui-file
|
|
158
|
+
state="normal"
|
|
159
|
+
[file]="file"
|
|
160
|
+
(remove)="removeFile(file)"
|
|
161
|
+
/>
|
|
162
|
+
}
|
|
163
|
+
</tui-files>
|
|
164
|
+
`
|
|
165
|
+
}]
|
|
166
|
+
}] });
|
|
167
|
+
|
|
168
|
+
const compressImage = async (file, quality, maxHeight, maxWidth, convertSize) => {
|
|
169
|
+
return await new Promise((resolve, reject) => {
|
|
170
|
+
new Compressor(file, {
|
|
171
|
+
quality,
|
|
172
|
+
maxHeight,
|
|
173
|
+
maxWidth,
|
|
174
|
+
convertSize,
|
|
175
|
+
success: resolve,
|
|
176
|
+
error: reject,
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
class EzUIMenuBarSubDataList {
|
|
182
|
+
subdatalist = [];
|
|
183
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBarSubDataList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
184
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIMenuBarSubDataList, isStandalone: true, selector: "tui-data-list[subdatalist]", inputs: { subdatalist: "subdatalist" }, ngImport: i0, template: `
|
|
185
|
+
@for(item of subdatalist; track $index){
|
|
186
|
+
@if(item.items){
|
|
187
|
+
<button
|
|
188
|
+
tuiOption
|
|
189
|
+
tuiChevron
|
|
190
|
+
[iconStart]="item.icon"
|
|
191
|
+
[disabled]="item.disabled"
|
|
192
|
+
[tuiDropdown]="dropdownContent"
|
|
193
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
194
|
+
tuiDropdownLimitWidth="fixed"
|
|
195
|
+
tuiDropdownSided="true"
|
|
196
|
+
>
|
|
197
|
+
{{item.label}}
|
|
198
|
+
</button>
|
|
199
|
+
|
|
200
|
+
<ng-template #dropdownContent>
|
|
201
|
+
<tui-data-list
|
|
202
|
+
class="subdatalist"
|
|
203
|
+
[subdatalist]="item.items">
|
|
204
|
+
</tui-data-list>
|
|
205
|
+
</ng-template>
|
|
206
|
+
}
|
|
207
|
+
@else {
|
|
208
|
+
<button
|
|
209
|
+
tuiOption
|
|
210
|
+
[iconStart]="item.icon"
|
|
211
|
+
[disabled]="item.disabled"
|
|
212
|
+
(click)="item.command()"
|
|
213
|
+
>
|
|
214
|
+
{{item.label}}
|
|
215
|
+
</button>
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
`, isInline: true, styles: [".subdatalist{display:flex;flex-direction:column}\n"], dependencies: [{ kind: "component", type: EzUIMenuBarSubDataList, selector: "tui-data-list[subdatalist]", inputs: ["subdatalist"] }, { kind: "directive", type: i3$1.TuiDropdownOptionsDirective, selector: "[tuiDropdownAlign], [tuiDropdownAppearance], [tuiDropdownDirection], [tuiDropdownLimitWidth], [tuiDropdownMinHeight], [tuiDropdownMaxHeight], [tuiDropdownOffset]", inputs: ["tuiDropdownAlign", "tuiDropdownAppearance", "tuiDropdownDirection", "tuiDropdownLimitWidth", "tuiDropdownMinHeight", "tuiDropdownMaxHeight", "tuiDropdownOffset"] }, { kind: "directive", type: i3$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i3$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: i3$1.TuiDropdownPositionSided, selector: "[tuiDropdownSided]", inputs: ["tuiDropdownSided", "tuiDropdownSidedOffset"] }, { kind: "directive", type: TuiOption, selector: "button[tuiOption], a[tuiOption], label[tuiOption]", inputs: ["disabled"] }, { kind: "directive", type: TuiChevron, selector: "[tuiChevron]", inputs: ["tuiChevron"] }] });
|
|
219
|
+
}
|
|
220
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBarSubDataList, decorators: [{
|
|
221
|
+
type: Component,
|
|
222
|
+
args: [{ selector: 'tui-data-list[subdatalist]', standalone: true, imports: [
|
|
223
|
+
TuiDropdown,
|
|
224
|
+
TuiOption,
|
|
225
|
+
TuiChevron
|
|
226
|
+
], template: `
|
|
227
|
+
@for(item of subdatalist; track $index){
|
|
228
|
+
@if(item.items){
|
|
229
|
+
<button
|
|
230
|
+
tuiOption
|
|
231
|
+
tuiChevron
|
|
232
|
+
[iconStart]="item.icon"
|
|
233
|
+
[disabled]="item.disabled"
|
|
234
|
+
[tuiDropdown]="dropdownContent"
|
|
235
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
236
|
+
tuiDropdownLimitWidth="fixed"
|
|
237
|
+
tuiDropdownSided="true"
|
|
238
|
+
>
|
|
239
|
+
{{item.label}}
|
|
240
|
+
</button>
|
|
241
|
+
|
|
242
|
+
<ng-template #dropdownContent>
|
|
243
|
+
<tui-data-list
|
|
244
|
+
class="subdatalist"
|
|
245
|
+
[subdatalist]="item.items">
|
|
246
|
+
</tui-data-list>
|
|
247
|
+
</ng-template>
|
|
248
|
+
}
|
|
249
|
+
@else {
|
|
250
|
+
<button
|
|
251
|
+
tuiOption
|
|
252
|
+
[iconStart]="item.icon"
|
|
253
|
+
[disabled]="item.disabled"
|
|
254
|
+
(click)="item.command()"
|
|
255
|
+
>
|
|
256
|
+
{{item.label}}
|
|
257
|
+
</button>
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
`, styles: [".subdatalist{display:flex;flex-direction:column}\n"] }]
|
|
261
|
+
}], propDecorators: { subdatalist: [{
|
|
262
|
+
type: Input
|
|
263
|
+
}] } });
|
|
264
|
+
class EzUIMenuBar {
|
|
265
|
+
items = [];
|
|
266
|
+
ngOnChanges(changes) {
|
|
267
|
+
if (changes['items'] && changes['items'].currentValue != changes['items'].previousValue) {
|
|
268
|
+
this.items = changes['items'].currentValue;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
272
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIMenuBar, isStandalone: true, selector: "ezui-menubar", inputs: { items: "items" }, usesOnChanges: true, ngImport: i0, template: `
|
|
273
|
+
<div tuiGroup class="group" [collapsed]="true">
|
|
274
|
+
@for(item of items; track $index){
|
|
275
|
+
@if(item.items){
|
|
276
|
+
<button
|
|
277
|
+
tuiButton
|
|
278
|
+
tuiChevron
|
|
279
|
+
size="s"
|
|
280
|
+
appearance="outline"
|
|
281
|
+
type="button"
|
|
282
|
+
[iconStart]="item.icon"
|
|
283
|
+
[disabled]="item.disabled"
|
|
284
|
+
[tuiDropdown]="dropdownContent"
|
|
285
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
286
|
+
tuiDropdownLimitWidth="fixed"
|
|
287
|
+
>
|
|
288
|
+
{{item.label}}
|
|
289
|
+
</button>
|
|
290
|
+
|
|
291
|
+
<ng-template #dropdownContent>
|
|
292
|
+
<tui-data-list
|
|
293
|
+
class="subdatalist"
|
|
294
|
+
[subdatalist]="item.items">
|
|
295
|
+
</tui-data-list>
|
|
296
|
+
</ng-template>
|
|
297
|
+
}
|
|
298
|
+
@else {
|
|
299
|
+
<button
|
|
300
|
+
appearance="outline"
|
|
301
|
+
size="s"
|
|
302
|
+
tuiButton
|
|
303
|
+
type="button"
|
|
304
|
+
[iconStart]="item.icon"
|
|
305
|
+
[disabled]="item.disabled"
|
|
306
|
+
(click)="item.command()"
|
|
307
|
+
>
|
|
308
|
+
{{item.label}}
|
|
309
|
+
</button>
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
</div>
|
|
313
|
+
`, isInline: true, styles: [".group{width:100%;white-space:nowrap}.subdatalist{display:flex;flex-direction:column}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TuiGroup, selector: "[tuiGroup]:not(ng-container)", inputs: ["orientation", "collapsed", "rounded", "size"] }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: i3$1.TuiDropdownOptionsDirective, selector: "[tuiDropdownAlign], [tuiDropdownAppearance], [tuiDropdownDirection], [tuiDropdownLimitWidth], [tuiDropdownMinHeight], [tuiDropdownMaxHeight], [tuiDropdownOffset]", inputs: ["tuiDropdownAlign", "tuiDropdownAppearance", "tuiDropdownDirection", "tuiDropdownLimitWidth", "tuiDropdownMinHeight", "tuiDropdownMaxHeight", "tuiDropdownOffset"] }, { kind: "directive", type: i3$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i3$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: TuiChevron, selector: "[tuiChevron]", inputs: ["tuiChevron"] }, { kind: "component", type: EzUIMenuBarSubDataList, selector: "tui-data-list[subdatalist]", inputs: ["subdatalist"] }] });
|
|
314
|
+
}
|
|
315
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBar, decorators: [{
|
|
316
|
+
type: Component,
|
|
317
|
+
args: [{ selector: 'ezui-menubar', standalone: true, imports: [
|
|
318
|
+
FormsModule,
|
|
319
|
+
CommonModule,
|
|
320
|
+
TuiGroup,
|
|
321
|
+
TuiButton,
|
|
322
|
+
TuiDropdown,
|
|
323
|
+
TuiChevron,
|
|
324
|
+
EzUIMenuBarSubDataList
|
|
325
|
+
], template: `
|
|
326
|
+
<div tuiGroup class="group" [collapsed]="true">
|
|
327
|
+
@for(item of items; track $index){
|
|
328
|
+
@if(item.items){
|
|
329
|
+
<button
|
|
330
|
+
tuiButton
|
|
331
|
+
tuiChevron
|
|
332
|
+
size="s"
|
|
333
|
+
appearance="outline"
|
|
334
|
+
type="button"
|
|
335
|
+
[iconStart]="item.icon"
|
|
336
|
+
[disabled]="item.disabled"
|
|
337
|
+
[tuiDropdown]="dropdownContent"
|
|
338
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
339
|
+
tuiDropdownLimitWidth="fixed"
|
|
340
|
+
>
|
|
341
|
+
{{item.label}}
|
|
342
|
+
</button>
|
|
343
|
+
|
|
344
|
+
<ng-template #dropdownContent>
|
|
345
|
+
<tui-data-list
|
|
346
|
+
class="subdatalist"
|
|
347
|
+
[subdatalist]="item.items">
|
|
348
|
+
</tui-data-list>
|
|
349
|
+
</ng-template>
|
|
350
|
+
}
|
|
351
|
+
@else {
|
|
352
|
+
<button
|
|
353
|
+
appearance="outline"
|
|
354
|
+
size="s"
|
|
355
|
+
tuiButton
|
|
356
|
+
type="button"
|
|
357
|
+
[iconStart]="item.icon"
|
|
358
|
+
[disabled]="item.disabled"
|
|
359
|
+
(click)="item.command()"
|
|
360
|
+
>
|
|
361
|
+
{{item.label}}
|
|
362
|
+
</button>
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
</div>
|
|
366
|
+
`, styles: [".group{width:100%;white-space:nowrap}.subdatalist{display:flex;flex-direction:column}\n"] }]
|
|
367
|
+
}], propDecorators: { items: [{
|
|
368
|
+
type: Input
|
|
369
|
+
}] } });
|
|
370
|
+
|
|
371
|
+
class EzUIMarkdownEditor {
|
|
372
|
+
preview;
|
|
373
|
+
editor;
|
|
374
|
+
fileUpload;
|
|
375
|
+
disabled = false;
|
|
376
|
+
value = null;
|
|
377
|
+
valueChange = new EventEmitter();
|
|
378
|
+
unsavedValue = signal("", /* @ts-ignore */
|
|
379
|
+
...(ngDevMode ? [{ debugName: "unsavedValue" }] : /* istanbul ignore next */ []));
|
|
380
|
+
isFirst = true;
|
|
381
|
+
isEditing = signal(false, /* @ts-ignore */
|
|
382
|
+
...(ngDevMode ? [{ debugName: "isEditing" }] : /* istanbul ignore next */ []));
|
|
383
|
+
items = signal([
|
|
384
|
+
{
|
|
385
|
+
icon: 'save',
|
|
386
|
+
command: async () => await this.toggleEdit(true)
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
icon: 'x',
|
|
390
|
+
command: async () => await this.toggleEdit(false)
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
label: 'B',
|
|
394
|
+
command: async () => {
|
|
395
|
+
if (this.editor) {
|
|
396
|
+
var editor = this.editor.nativeElement;
|
|
397
|
+
var start = editor.selectionStart;
|
|
398
|
+
var finish = editor.selectionEnd;
|
|
399
|
+
var sel = editor.value.substring(start, finish);
|
|
400
|
+
var newStr = "**" + sel + "**";
|
|
401
|
+
await this.replaceSection(newStr, start + 2, finish + 2);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
label: 'I',
|
|
407
|
+
command: async () => {
|
|
408
|
+
if (this.editor) {
|
|
409
|
+
var editor = this.editor.nativeElement;
|
|
410
|
+
var start = editor.selectionStart;
|
|
411
|
+
var finish = editor.selectionEnd;
|
|
412
|
+
var sel = editor.value.substring(start, finish);
|
|
413
|
+
var newStr = "*" + sel + "*";
|
|
414
|
+
await this.replaceSection(newStr, start + 1, finish + 1);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
label: 'H',
|
|
420
|
+
items: [
|
|
421
|
+
{
|
|
422
|
+
label: 'H1',
|
|
423
|
+
command: async () => {
|
|
424
|
+
if (this.editor) {
|
|
425
|
+
var editor = this.editor.nativeElement;
|
|
426
|
+
var start = editor.selectionStart;
|
|
427
|
+
var finish = editor.selectionEnd;
|
|
428
|
+
var sel = editor.value.substring(start, finish);
|
|
429
|
+
var newStr = "# " + sel;
|
|
430
|
+
await this.replaceSection(newStr, start + 2, finish + 2);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
label: 'H2',
|
|
436
|
+
command: async () => {
|
|
437
|
+
if (this.editor) {
|
|
438
|
+
var editor = this.editor.nativeElement;
|
|
439
|
+
var start = editor.selectionStart;
|
|
440
|
+
var finish = editor.selectionEnd;
|
|
441
|
+
var sel = editor.value.substring(start, finish);
|
|
442
|
+
var newStr = "## " + sel;
|
|
443
|
+
await this.replaceSection(newStr, start + 3, finish + 3);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
label: 'H3',
|
|
449
|
+
command: async () => {
|
|
450
|
+
if (this.editor) {
|
|
451
|
+
var editor = this.editor.nativeElement;
|
|
452
|
+
var start = editor.selectionStart;
|
|
453
|
+
var finish = editor.selectionEnd;
|
|
454
|
+
var sel = editor.value.substring(start, finish);
|
|
455
|
+
var newStr = "### " + sel;
|
|
456
|
+
await this.replaceSection(newStr, start + 4, finish + 4);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
]
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
icon: 'link',
|
|
464
|
+
command: async () => {
|
|
465
|
+
if (this.editor) {
|
|
466
|
+
var editor = this.editor.nativeElement;
|
|
467
|
+
var start = editor.selectionStart;
|
|
468
|
+
var finish = editor.selectionEnd;
|
|
469
|
+
var sel = editor.value.substring(start, finish);
|
|
470
|
+
var newStr = "[" + sel + "](link)";
|
|
471
|
+
await this.replaceSection(newStr, start + 1, finish + 1);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
icon: 'image',
|
|
477
|
+
command: async () => {
|
|
478
|
+
if (this.editor) {
|
|
479
|
+
this.fileUpload?.nativeElement.click();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
},
|
|
483
|
+
], /* @ts-ignore */
|
|
484
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
485
|
+
async onFileSelected(event) {
|
|
486
|
+
var files = Array.from(event.target.files);
|
|
487
|
+
if (files && files.length > 0) {
|
|
488
|
+
var file = files[0];
|
|
489
|
+
await this.insertImageInEditor(file);
|
|
490
|
+
this.fileUpload.nativeElement.value = '';
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
toBase65(file) {
|
|
494
|
+
return new Promise((resolve, reject) => {
|
|
495
|
+
var reader = new FileReader();
|
|
496
|
+
reader.readAsDataURL(file);
|
|
497
|
+
reader.onload = () => resolve(reader.result);
|
|
498
|
+
reader.onerror = reject;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
async onPaste(event) {
|
|
502
|
+
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
|
503
|
+
let blob = null;
|
|
504
|
+
for (const item of items) {
|
|
505
|
+
if (item.type.indexOf('image') === 0) {
|
|
506
|
+
blob = item.getAsFile();
|
|
507
|
+
await this.insertImageInEditor(blob);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
async insertImageInEditor(file) {
|
|
512
|
+
var compressed = await compressImage(file, 0.5, 300, 300);
|
|
513
|
+
var asBase64 = await this.toBase65(compressed);
|
|
514
|
+
if (asBase64 && this.editor) {
|
|
515
|
+
var editor = this.editor.nativeElement;
|
|
516
|
+
var start = editor.selectionStart;
|
|
517
|
+
var finish = editor.selectionEnd;
|
|
518
|
+
var sel = editor.value.substring(start, finish);
|
|
519
|
+
var newStr = "";
|
|
520
|
+
await this.replaceSection(newStr, start + newStr.length, finish + newStr.length);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async replaceSection(newStr, finalStart, finalFinish) {
|
|
524
|
+
var editor = this.editor.nativeElement;
|
|
525
|
+
editor.focus();
|
|
526
|
+
document.execCommand("insertText", false, newStr);
|
|
527
|
+
await this.formatPreview();
|
|
528
|
+
editor.focus();
|
|
529
|
+
editor.setSelectionRange(finalStart, finalFinish);
|
|
530
|
+
}
|
|
531
|
+
async ngOnChanges(changes) {
|
|
532
|
+
if (changes['value']) {
|
|
533
|
+
if (changes['value'].currentValue != changes['value'].previousValue) {
|
|
534
|
+
this.value = changes['value'].currentValue;
|
|
535
|
+
await this.formatPreview();
|
|
536
|
+
if (this.isFirst) {
|
|
537
|
+
setTimeout(async () => await this.formatPreview(), 500);
|
|
538
|
+
this.isFirst = false;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
async formatPreview() {
|
|
544
|
+
if (this.preview) {
|
|
545
|
+
if (this.isEditing())
|
|
546
|
+
this.preview.nativeElement.innerHTML = await marked(this.unsavedValue());
|
|
547
|
+
else if (this.value)
|
|
548
|
+
this.preview.nativeElement.innerHTML = await marked(this.value);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
async toggleEdit(save) {
|
|
552
|
+
if (!this.isEditing() && this.value) {
|
|
553
|
+
this.unsavedValue.set(this.value);
|
|
554
|
+
}
|
|
555
|
+
if (save && this.isEditing()) {
|
|
556
|
+
this.value = this.unsavedValue();
|
|
557
|
+
this.valueChange.emit(this.value);
|
|
558
|
+
}
|
|
559
|
+
this.isEditing.set(!this.isEditing());
|
|
560
|
+
setTimeout(async () => await this.formatPreview(), 500);
|
|
561
|
+
}
|
|
562
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMarkdownEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
563
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIMarkdownEditor, isStandalone: true, selector: "ezui-markdowneditor", inputs: { disabled: "disabled", value: "value" }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "flex h-full w-full" }, viewQueries: [{ propertyName: "preview", first: true, predicate: ["preview"], descendants: true }, { propertyName: "editor", first: true, predicate: ["editor"], descendants: true }, { propertyName: "fileUpload", first: true, predicate: ["fileUpload"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
564
|
+
@if(isEditing() && !disabled){
|
|
565
|
+
<div class="editor-container">
|
|
566
|
+
<div class="editor">
|
|
567
|
+
<ezui-menubar [items]="items()"/>
|
|
568
|
+
|
|
569
|
+
<tui-textfield class="editor-field">
|
|
570
|
+
<textarea
|
|
571
|
+
#editor
|
|
572
|
+
placeholder="Markdown Content"
|
|
573
|
+
tuiTextarea
|
|
574
|
+
[(ngModel)]="unsavedValue"
|
|
575
|
+
(input)="formatPreview()"
|
|
576
|
+
></textarea>
|
|
577
|
+
</tui-textfield>
|
|
578
|
+
</div>
|
|
579
|
+
|
|
580
|
+
<div class="preview-container">
|
|
581
|
+
<tui-scrollbar>
|
|
582
|
+
<div class="preview" #preview>Rendering...</div>
|
|
583
|
+
</tui-scrollbar>
|
|
584
|
+
</div>
|
|
585
|
+
|
|
586
|
+
<input type="file" (change)="onFileSelected($event)" #fileUpload [style]="{ display: 'none' }" accept="image/png, image/jpeg" />
|
|
587
|
+
</div>
|
|
588
|
+
}
|
|
589
|
+
@else {
|
|
590
|
+
<div class="preview-readonly-container">
|
|
591
|
+
@if(!disabled){
|
|
592
|
+
<button tuiButton class="edit-button" iconStart="edit" appearance="flat" size="s"(click)="toggleEdit(false)"></button>
|
|
593
|
+
}
|
|
594
|
+
<tui-scrollbar>
|
|
595
|
+
<div class="preview" #preview>Rendering...</div>
|
|
596
|
+
</tui-scrollbar>
|
|
597
|
+
</div>
|
|
598
|
+
}
|
|
599
|
+
`, isInline: true, styles: [".editor-container{display:flex;flex-direction:row;width:100%;outline:.125rem solid var(--tui-background-accent-1);border-radius:var(--tui-radius-l)}.editor-container .editor{display:flex;flex-direction:column;width:100%}.editor-container .editor .editor-field{block-size:100%;border-radius:0px 0px 0px var(--tui-radius-l)}.preview-container{width:100%;border-radius:0px var(--tui-radius-l) var(--tui-radius-l) 0px;transition-property:box-shadow,background-color,outline-color,border-color,color;transition-duration:calc(var(--tui-duration) / 2);transition-timing-function:var(--tui-curve-productive-standard);--t-shadow: 0 .125rem .1875rem rgba(0, 0, 0, .1);background-color:var(--tui-background-base);color:var(--tui-text-tertiary);box-shadow:var(--t-shadow);outline:1px solid var(--tui-border-normal);outline-offset:-1px;border-width:0;block-size:100%}.preview-container ::ng-deep tui-scrollbar{height:100%}.preview-container ::ng-deep .t-content{display:flex;block-size:auto!important}.preview-container .preview{padding:10px}.preview-readonly-container{width:100%;border-radius:var(--tui-radius-l);transition-property:box-shadow,background-color,outline-color,border-color,color;transition-duration:calc(var(--tui-duration) / 2);transition-timing-function:var(--tui-curve-productive-standard);--t-shadow: 0 .125rem .1875rem rgba(0, 0, 0, .1);background-color:var(--tui-background-base);color:var(--tui-text-tertiary);box-shadow:var(--t-shadow);outline:1px solid var(--tui-border-normal);outline-offset:-1px;border-width:0;block-size:100%}.preview-readonly-container .edit-button{position:absolute;z-index:999}.preview-readonly-container ::ng-deep tui-scrollbar{height:100%}.preview-readonly-container ::ng-deep .t-content{display:flex;block-size:auto!important}.preview-readonly-container .preview{padding:10px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4$1.TuiTextareaComponent, selector: "textarea[tuiTextarea]", inputs: ["min", "max", "content"] }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "component", type: TuiScrollbar, selector: "tui-scrollbar" }, { kind: "component", type: EzUIMenuBar, selector: "ezui-menubar", inputs: ["items"] }] });
|
|
600
|
+
}
|
|
601
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMarkdownEditor, decorators: [{
|
|
602
|
+
type: Component,
|
|
603
|
+
args: [{ selector: 'ezui-markdowneditor', imports: [FormsModule, CommonModule, TuiTextarea, TuiButton, TuiScrollbar, EzUIMenuBar], template: `
|
|
604
|
+
@if(isEditing() && !disabled){
|
|
605
|
+
<div class="editor-container">
|
|
606
|
+
<div class="editor">
|
|
607
|
+
<ezui-menubar [items]="items()"/>
|
|
608
|
+
|
|
609
|
+
<tui-textfield class="editor-field">
|
|
610
|
+
<textarea
|
|
611
|
+
#editor
|
|
612
|
+
placeholder="Markdown Content"
|
|
613
|
+
tuiTextarea
|
|
614
|
+
[(ngModel)]="unsavedValue"
|
|
615
|
+
(input)="formatPreview()"
|
|
616
|
+
></textarea>
|
|
617
|
+
</tui-textfield>
|
|
618
|
+
</div>
|
|
619
|
+
|
|
620
|
+
<div class="preview-container">
|
|
621
|
+
<tui-scrollbar>
|
|
622
|
+
<div class="preview" #preview>Rendering...</div>
|
|
623
|
+
</tui-scrollbar>
|
|
624
|
+
</div>
|
|
625
|
+
|
|
626
|
+
<input type="file" (change)="onFileSelected($event)" #fileUpload [style]="{ display: 'none' }" accept="image/png, image/jpeg" />
|
|
627
|
+
</div>
|
|
628
|
+
}
|
|
629
|
+
@else {
|
|
630
|
+
<div class="preview-readonly-container">
|
|
631
|
+
@if(!disabled){
|
|
632
|
+
<button tuiButton class="edit-button" iconStart="edit" appearance="flat" size="s"(click)="toggleEdit(false)"></button>
|
|
633
|
+
}
|
|
634
|
+
<tui-scrollbar>
|
|
635
|
+
<div class="preview" #preview>Rendering...</div>
|
|
636
|
+
</tui-scrollbar>
|
|
637
|
+
</div>
|
|
638
|
+
}
|
|
639
|
+
`, host: {
|
|
640
|
+
class: 'flex h-full w-full'
|
|
641
|
+
}, styles: [".editor-container{display:flex;flex-direction:row;width:100%;outline:.125rem solid var(--tui-background-accent-1);border-radius:var(--tui-radius-l)}.editor-container .editor{display:flex;flex-direction:column;width:100%}.editor-container .editor .editor-field{block-size:100%;border-radius:0px 0px 0px var(--tui-radius-l)}.preview-container{width:100%;border-radius:0px var(--tui-radius-l) var(--tui-radius-l) 0px;transition-property:box-shadow,background-color,outline-color,border-color,color;transition-duration:calc(var(--tui-duration) / 2);transition-timing-function:var(--tui-curve-productive-standard);--t-shadow: 0 .125rem .1875rem rgba(0, 0, 0, .1);background-color:var(--tui-background-base);color:var(--tui-text-tertiary);box-shadow:var(--t-shadow);outline:1px solid var(--tui-border-normal);outline-offset:-1px;border-width:0;block-size:100%}.preview-container ::ng-deep tui-scrollbar{height:100%}.preview-container ::ng-deep .t-content{display:flex;block-size:auto!important}.preview-container .preview{padding:10px}.preview-readonly-container{width:100%;border-radius:var(--tui-radius-l);transition-property:box-shadow,background-color,outline-color,border-color,color;transition-duration:calc(var(--tui-duration) / 2);transition-timing-function:var(--tui-curve-productive-standard);--t-shadow: 0 .125rem .1875rem rgba(0, 0, 0, .1);background-color:var(--tui-background-base);color:var(--tui-text-tertiary);box-shadow:var(--t-shadow);outline:1px solid var(--tui-border-normal);outline-offset:-1px;border-width:0;block-size:100%}.preview-readonly-container .edit-button{position:absolute;z-index:999}.preview-readonly-container ::ng-deep tui-scrollbar{height:100%}.preview-readonly-container ::ng-deep .t-content{display:flex;block-size:auto!important}.preview-readonly-container .preview{padding:10px}\n"] }]
|
|
642
|
+
}], propDecorators: { preview: [{
|
|
643
|
+
type: ViewChild,
|
|
644
|
+
args: ['preview']
|
|
645
|
+
}], editor: [{
|
|
646
|
+
type: ViewChild,
|
|
647
|
+
args: ['editor']
|
|
648
|
+
}], fileUpload: [{
|
|
649
|
+
type: ViewChild,
|
|
650
|
+
args: ['fileUpload']
|
|
651
|
+
}], disabled: [{
|
|
652
|
+
type: Input
|
|
653
|
+
}], value: [{
|
|
654
|
+
type: Input
|
|
655
|
+
}], valueChange: [{
|
|
656
|
+
type: Output
|
|
657
|
+
}] } });
|
|
658
|
+
|
|
659
|
+
class EzUIMultiSelect {
|
|
660
|
+
icon = '';
|
|
661
|
+
label = '';
|
|
662
|
+
size = 'm';
|
|
663
|
+
optionLabel = undefined;
|
|
664
|
+
optionValue = undefined;
|
|
665
|
+
options = [];
|
|
666
|
+
disabled = false;
|
|
667
|
+
selected = undefined;
|
|
668
|
+
selectedChange = new EventEmitter();
|
|
669
|
+
ngOnChanges(changes) {
|
|
670
|
+
if (changes['selected'] && changes['selected'].currentValue != changes['selected'].previousValue) {
|
|
671
|
+
this.selected = changes['selected'].currentValue;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
stringify = (value) => this.getOptionLabel(this.options.find((item) => this.getOptionValue(item) === value));
|
|
675
|
+
getOptionLabel(item) {
|
|
676
|
+
if (!item)
|
|
677
|
+
return "";
|
|
678
|
+
if (this.optionLabel == undefined || this.optionLabel == '')
|
|
679
|
+
return item;
|
|
680
|
+
return item[this.optionLabel];
|
|
681
|
+
}
|
|
682
|
+
getOptionValue(item) {
|
|
683
|
+
if (!item)
|
|
684
|
+
return "";
|
|
685
|
+
if (this.optionValue == undefined || this.optionValue == '')
|
|
686
|
+
return item;
|
|
687
|
+
return item[this.optionValue];
|
|
688
|
+
}
|
|
689
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMultiSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
690
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIMultiSelect, isStandalone: true, selector: "ezui-multiselect", inputs: { icon: "icon", label: "label", size: "size", optionLabel: "optionLabel", optionValue: "optionValue", options: "options", disabled: "disabled", selected: "selected" }, outputs: { selectedChange: "selectedChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
691
|
+
<tui-textfield multi tuiChevron [stringify]="stringify" [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
692
|
+
@if(label != ''){
|
|
693
|
+
<label tuiLabel>{{label}}</label>
|
|
694
|
+
}
|
|
695
|
+
<input tuiInputChip tuiSelectLike [(ngModel)]="selected" (ngModelChange)="selectedChange.emit(this.selected)" [disabled]="disabled"/>
|
|
696
|
+
<tui-input-chip *tuiItem />
|
|
697
|
+
<tui-data-list *tuiDropdown tuiMultiSelectGroup >
|
|
698
|
+
@for (item of options; track getOptionValue(item)) {
|
|
699
|
+
<button tuiOption [value]="getOptionValue(item)">
|
|
700
|
+
{{ getOptionLabel(item) }}
|
|
701
|
+
</button>
|
|
702
|
+
}
|
|
703
|
+
</tui-data-list>
|
|
704
|
+
</tui-textfield>
|
|
705
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i4$1.TuiMultiSelectGroupDirective, selector: "[tuiMultiSelectGroup]" }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i4.TuiDropdownContent, selector: "ng-template[tuiDropdown]" }, { kind: "component", type: i3$1.TuiDataListComponent, selector: "tui-data-list", inputs: ["emptyContent", "size"] }, { kind: "directive", type: i3$1.TuiOption, selector: "button[tuiOption], a[tuiOption], label[tuiOption]", inputs: ["disabled"] }, { kind: "directive", type: i3$1.TuiOptionWithValue, selector: "button[tuiOption][value], a[tuiOption][value], label[tuiOption][value]", inputs: ["disabled", "value"] }, { kind: "directive", type: i7.TuiItem, selector: "[tuiItem]" }, { kind: "component", type: i3$1.TuiTextfieldMultiComponent, selector: "tui-textfield[multi]", inputs: ["rows"] }, { kind: "directive", type: i4$1.TuiInputChipDirective, selector: "input[tuiInputChip]", inputs: ["separator", "unique"] }, { kind: "component", type: i4$1.TuiInputChipComponent, selector: "tui-input-chip", inputs: ["editable"] }, { kind: "directive", type: TuiSelectLike, selector: "[tuiSelectLike]" }, { kind: "directive", type: TuiChevron, selector: "[tuiChevron]", inputs: ["tuiChevron"] }] });
|
|
706
|
+
}
|
|
707
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMultiSelect, decorators: [{
|
|
708
|
+
type: Component,
|
|
709
|
+
args: [{ selector: 'ezui-multiselect', imports: [
|
|
710
|
+
FormsModule,
|
|
711
|
+
CommonModule,
|
|
712
|
+
TuiMultiSelect,
|
|
713
|
+
TuiInputNumber,
|
|
714
|
+
TuiDataList,
|
|
715
|
+
TuiTextfield,
|
|
716
|
+
TuiInputChip,
|
|
717
|
+
TuiSelectLike,
|
|
718
|
+
TuiMultiSelect,
|
|
719
|
+
TuiDropdown,
|
|
720
|
+
TuiChevron
|
|
721
|
+
], template: `
|
|
722
|
+
<tui-textfield multi tuiChevron [stringify]="stringify" [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
723
|
+
@if(label != ''){
|
|
724
|
+
<label tuiLabel>{{label}}</label>
|
|
725
|
+
}
|
|
726
|
+
<input tuiInputChip tuiSelectLike [(ngModel)]="selected" (ngModelChange)="selectedChange.emit(this.selected)" [disabled]="disabled"/>
|
|
727
|
+
<tui-input-chip *tuiItem />
|
|
728
|
+
<tui-data-list *tuiDropdown tuiMultiSelectGroup >
|
|
729
|
+
@for (item of options; track getOptionValue(item)) {
|
|
730
|
+
<button tuiOption [value]="getOptionValue(item)">
|
|
731
|
+
{{ getOptionLabel(item) }}
|
|
732
|
+
</button>
|
|
733
|
+
}
|
|
734
|
+
</tui-data-list>
|
|
735
|
+
</tui-textfield>
|
|
736
|
+
` }]
|
|
737
|
+
}], propDecorators: { icon: [{
|
|
738
|
+
type: Input
|
|
739
|
+
}], label: [{
|
|
740
|
+
type: Input
|
|
741
|
+
}], size: [{
|
|
742
|
+
type: Input
|
|
743
|
+
}], optionLabel: [{
|
|
744
|
+
type: Input
|
|
745
|
+
}], optionValue: [{
|
|
746
|
+
type: Input
|
|
747
|
+
}], options: [{
|
|
748
|
+
type: Input
|
|
749
|
+
}], disabled: [{
|
|
750
|
+
type: Input
|
|
751
|
+
}], selected: [{
|
|
752
|
+
type: Input
|
|
753
|
+
}], selectedChange: [{
|
|
754
|
+
type: Output
|
|
755
|
+
}] } });
|
|
756
|
+
|
|
757
|
+
class EzUINumberInput {
|
|
758
|
+
icon = '';
|
|
759
|
+
label = '';
|
|
760
|
+
size = 'm';
|
|
761
|
+
disabled = false;
|
|
762
|
+
min = null;
|
|
763
|
+
max = null;
|
|
764
|
+
value = "";
|
|
765
|
+
valueChange = new EventEmitter();
|
|
766
|
+
ngOnChanges(changes) {
|
|
767
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
768
|
+
this.value = changes['value'].currentValue;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUINumberInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
772
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUINumberInput, isStandalone: true, selector: "ezui-numberinput", inputs: { icon: "icon", label: "label", size: "size", disabled: "disabled", min: "min", max: "max", value: "value" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
773
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
774
|
+
@if(label){
|
|
775
|
+
<label tuiLabel>{{label}}</label>
|
|
776
|
+
}
|
|
777
|
+
<input tuiInputNumber [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled" [min]="min" [max]="max"/>
|
|
778
|
+
</tui-textfield>
|
|
779
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i4$1.TuiInputNumberDirective, selector: "input[tuiInputNumber]" }] });
|
|
780
|
+
}
|
|
781
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUINumberInput, decorators: [{
|
|
782
|
+
type: Component,
|
|
783
|
+
args: [{ selector: 'ezui-numberinput', imports: [
|
|
784
|
+
FormsModule,
|
|
785
|
+
CommonModule,
|
|
786
|
+
TuiInput,
|
|
787
|
+
TuiInputNumber
|
|
788
|
+
], template: `
|
|
789
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
790
|
+
@if(label){
|
|
791
|
+
<label tuiLabel>{{label}}</label>
|
|
792
|
+
}
|
|
793
|
+
<input tuiInputNumber [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled" [min]="min" [max]="max"/>
|
|
794
|
+
</tui-textfield>
|
|
795
|
+
` }]
|
|
796
|
+
}], propDecorators: { icon: [{
|
|
797
|
+
type: Input
|
|
798
|
+
}], label: [{
|
|
799
|
+
type: Input
|
|
800
|
+
}], size: [{
|
|
801
|
+
type: Input
|
|
802
|
+
}], disabled: [{
|
|
803
|
+
type: Input
|
|
804
|
+
}], min: [{
|
|
805
|
+
type: Input
|
|
806
|
+
}], max: [{
|
|
807
|
+
type: Input
|
|
808
|
+
}], value: [{
|
|
809
|
+
type: Input
|
|
810
|
+
}], valueChange: [{
|
|
811
|
+
type: Output
|
|
812
|
+
}] } });
|
|
813
|
+
|
|
814
|
+
class EzUIPasswordInput {
|
|
815
|
+
icon = '';
|
|
816
|
+
label = '';
|
|
817
|
+
size = 'm';
|
|
818
|
+
disabled = false;
|
|
819
|
+
value = "";
|
|
820
|
+
valueChange = new EventEmitter();
|
|
821
|
+
ngOnChanges(changes) {
|
|
822
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
823
|
+
this.value = changes['value'].currentValue;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIPasswordInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
827
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUIPasswordInput, isStandalone: true, selector: "ezui-passwordinput", inputs: { icon: "icon", label: "label", size: "size", disabled: "disabled", value: "value" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
828
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
829
|
+
@if(label){
|
|
830
|
+
<label tuiLabel>{{label}}</label>
|
|
831
|
+
}
|
|
832
|
+
<input tuiInput type="password" [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
833
|
+
<tui-icon tuiPassword />
|
|
834
|
+
</tui-textfield>
|
|
835
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i3$1.TuiInputDirective, selector: "input[tuiInput]", inputs: ["readOnly", "invalid", "focused", "state"] }, { kind: "component", type: TuiIcon, selector: "tui-icon:not([tuiBadge])", inputs: ["background"] }, { kind: "directive", type: TuiPassword, selector: "tui-icon[tuiPassword]" }] });
|
|
836
|
+
}
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIPasswordInput, decorators: [{
|
|
838
|
+
type: Component,
|
|
839
|
+
args: [{ selector: 'ezui-passwordinput', imports: [
|
|
840
|
+
FormsModule,
|
|
841
|
+
CommonModule,
|
|
842
|
+
TuiInput,
|
|
843
|
+
TuiIcon,
|
|
844
|
+
TuiPassword
|
|
845
|
+
], template: `
|
|
846
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
847
|
+
@if(label){
|
|
848
|
+
<label tuiLabel>{{label}}</label>
|
|
849
|
+
}
|
|
850
|
+
<input tuiInput type="password" [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
851
|
+
<tui-icon tuiPassword />
|
|
852
|
+
</tui-textfield>
|
|
853
|
+
` }]
|
|
854
|
+
}], propDecorators: { icon: [{
|
|
855
|
+
type: Input
|
|
856
|
+
}], label: [{
|
|
857
|
+
type: Input
|
|
858
|
+
}], size: [{
|
|
859
|
+
type: Input
|
|
860
|
+
}], disabled: [{
|
|
861
|
+
type: Input
|
|
862
|
+
}], value: [{
|
|
863
|
+
type: Input
|
|
864
|
+
}], valueChange: [{
|
|
865
|
+
type: Output
|
|
866
|
+
}] } });
|
|
867
|
+
|
|
868
|
+
class EzUITablePresets {
|
|
869
|
+
table;
|
|
870
|
+
storageKey = null;
|
|
871
|
+
currentPreset = signal(null, /* @ts-ignore */
|
|
872
|
+
...(ngDevMode ? [{ debugName: "currentPreset" }] : /* istanbul ignore next */ []));
|
|
873
|
+
presets = signal([], /* @ts-ignore */
|
|
874
|
+
...(ngDevMode ? [{ debugName: "presets" }] : /* istanbul ignore next */ []));
|
|
875
|
+
constructor(table) {
|
|
876
|
+
this.table = table;
|
|
877
|
+
}
|
|
878
|
+
async ngOnChanges(changes) {
|
|
879
|
+
if (changes['storageKey'] && changes['storageKey'].previousValue != changes['storageKey'].currentValue) {
|
|
880
|
+
this.storageKey = changes['storageKey'].currentValue;
|
|
881
|
+
if (this.storageKey) {
|
|
882
|
+
var item = localStorage.getItem(this.storageKey);
|
|
883
|
+
if (item) {
|
|
884
|
+
var parsed = JSON.parse(item);
|
|
885
|
+
if (parsed) {
|
|
886
|
+
this.presets.set(parsed.presets);
|
|
887
|
+
if (parsed.current) {
|
|
888
|
+
var target = (parsed.presets).find(x => x.id == parsed.current);
|
|
889
|
+
if (target)
|
|
890
|
+
this.selectPreset(target.id);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
ngOnInit() {
|
|
898
|
+
setTimeout(() => {
|
|
899
|
+
var current = this.currentPreset();
|
|
900
|
+
if (current)
|
|
901
|
+
this.onPresetChange.emit(current);
|
|
902
|
+
}, 500);
|
|
903
|
+
}
|
|
904
|
+
onPresetChange = new EventEmitter();
|
|
905
|
+
saveCurrentPreset() {
|
|
906
|
+
var currentPreset = this.currentPreset();
|
|
907
|
+
if (currentPreset) {
|
|
908
|
+
currentPreset.sorts = [...this.table.sorts()];
|
|
909
|
+
currentPreset.filters = [...this.table.filters()];
|
|
910
|
+
this.currentPreset.set(currentPreset);
|
|
911
|
+
var presets = this.presets();
|
|
912
|
+
var target = this.presets().findIndex(x => x.id == currentPreset?.id);
|
|
913
|
+
if (target != -1)
|
|
914
|
+
presets[target] = currentPreset;
|
|
915
|
+
this.presets.set(presets);
|
|
916
|
+
this.savePresets();
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
selectPreset(id) {
|
|
920
|
+
var presets = this.presets();
|
|
921
|
+
var target = presets.findIndex(x => x.id == id);
|
|
922
|
+
if (target != -1) {
|
|
923
|
+
var preset = presets[target];
|
|
924
|
+
this.currentPreset.set(preset);
|
|
925
|
+
this.table.sorts.set(preset.sorts);
|
|
926
|
+
this.table.filters.set(preset.filters);
|
|
927
|
+
this.onPresetChange.emit(preset);
|
|
928
|
+
this.table.applyFilter();
|
|
929
|
+
}
|
|
930
|
+
this.savePresets();
|
|
931
|
+
}
|
|
932
|
+
createPreset() {
|
|
933
|
+
this.saveCurrentPreset();
|
|
934
|
+
var preset = {
|
|
935
|
+
id: v4(),
|
|
936
|
+
name: 'New Preset',
|
|
937
|
+
sorts: [...this.table.sorts()],
|
|
938
|
+
filters: [...this.table.filters()]
|
|
939
|
+
};
|
|
940
|
+
this.currentPreset.set(preset);
|
|
941
|
+
var presets = this.presets();
|
|
942
|
+
presets.push(preset);
|
|
943
|
+
this.presets.set(presets);
|
|
944
|
+
this.savePresets();
|
|
945
|
+
}
|
|
946
|
+
removePreset(id) {
|
|
947
|
+
var presets = this.presets();
|
|
948
|
+
var target = presets.findIndex(x => x.id == id);
|
|
949
|
+
if (target != -1)
|
|
950
|
+
presets.splice(target, 1);
|
|
951
|
+
this.presets.set(presets);
|
|
952
|
+
var current = this.currentPreset();
|
|
953
|
+
if (current?.id == id) {
|
|
954
|
+
if (presets.length > 0) {
|
|
955
|
+
this.currentPreset.set(presets[0]);
|
|
956
|
+
this.onPresetChange.emit(presets[0]);
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
this.currentPreset.set(null);
|
|
960
|
+
this.onPresetChange.emit(null);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
this.savePresets();
|
|
964
|
+
}
|
|
965
|
+
savePresets() {
|
|
966
|
+
if (this.storageKey) {
|
|
967
|
+
var saveBody = {
|
|
968
|
+
current: this.currentPreset()?.id,
|
|
969
|
+
presets: [...this.presets()]
|
|
970
|
+
};
|
|
971
|
+
localStorage.setItem(this.storageKey, JSON.stringify(saveBody));
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
clearFilters() {
|
|
975
|
+
this.currentPreset.set(null);
|
|
976
|
+
this.onPresetChange.emit(null);
|
|
977
|
+
this.table.sorts.set([]);
|
|
978
|
+
this.table.filters.set([]);
|
|
979
|
+
this.savePresets();
|
|
980
|
+
this.table.applyFilter();
|
|
981
|
+
}
|
|
982
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITablePresets, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
983
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITablePresets, isStandalone: true, selector: "ezui-table-presets", inputs: { storageKey: "storageKey" }, outputs: { onPresetChange: "onPresetChange" }, host: { styleAttribute: "display:flex;flex-direction: row;gap:10px;padding:5px;padding-top:0px;" }, usesOnChanges: true, ngImport: i0, template: `
|
|
984
|
+
<button tuiButton iconStart="plus" size="s" appearance="secondary" (click)="createPreset()" tuiHint="Create new preset from current filters"></button>
|
|
985
|
+
|
|
986
|
+
<tui-scrollbar>
|
|
987
|
+
@let current = currentPreset();
|
|
988
|
+
@for(preset of presets(); track preset.id){
|
|
989
|
+
<div tuiGroup [collapsed]="true" [rounded]="true">
|
|
990
|
+
@let isActive = current?.id == preset.id;
|
|
991
|
+
@if(isActive){
|
|
992
|
+
@if(preset.edit){
|
|
993
|
+
<tui-textfield style="width:10rem" tuiTextfieldSize="s" (keydown.enter)="preset.edit = false;saveCurrentPreset()">
|
|
994
|
+
<input tuiInput [(ngModel)]="preset.name"/>
|
|
995
|
+
</tui-textfield>
|
|
996
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="save" size="s" appearance="info" (click)="preset.edit = false;saveCurrentPreset()" tuiHint="Save"></button>
|
|
997
|
+
}
|
|
998
|
+
@else {
|
|
999
|
+
<div style="height:100%" appearance="positive" tuiBadge tuiStatus>
|
|
1000
|
+
{{preset.name}}
|
|
1001
|
+
</div>
|
|
1002
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="square-pen" size="s" appearance="info" (click)="preset.edit = true" tuiHint="Edit"></button>
|
|
1003
|
+
}
|
|
1004
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="x" size="s" appearance="negative" (click)="removePreset(preset.id)" tuiHint="Delete"></button>
|
|
1005
|
+
}
|
|
1006
|
+
@else {
|
|
1007
|
+
<button style="flex: 0 0 auto;" tuiButton appearance="secondary" size="s" (click)="selectPreset(preset.id)">{{preset.name}}</button>
|
|
1008
|
+
}
|
|
1009
|
+
</div>
|
|
1010
|
+
}
|
|
1011
|
+
</tui-scrollbar>
|
|
1012
|
+
`, isInline: true, styles: ["tui-scrollbar{width:100%!important}tui-scrollbar ::ng-deep>.t-content{display:flex;gap:10px;width:0px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "component", type: TuiScrollbar, selector: "tui-scrollbar" }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: TuiGroup, selector: "[tuiGroup]:not(ng-container)", inputs: ["orientation", "collapsed", "rounded", "size"] }, { kind: "directive", type: TuiBadge, selector: "[tuiBadge],tui-icon[tuiBadge]", inputs: ["size"] }, { kind: "directive", type: TuiStatus, selector: "[tuiStatus]", inputs: ["tuiStatus"] }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i3$1.TuiInputDirective, selector: "input[tuiInput]", inputs: ["readOnly", "invalid", "focused", "state"] }, { kind: "directive", type: i3$1.TuiHintDirective, selector: "[tuiHint]:not(ng-container):not(ng-template)", inputs: ["tuiHint", "tuiHintContext", "tuiHintAppearance"], outputs: ["tuiHintVisible"] }] });
|
|
1013
|
+
}
|
|
1014
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITablePresets, decorators: [{
|
|
1015
|
+
type: Component,
|
|
1016
|
+
args: [{ selector: 'ezui-table-presets', imports: [FormsModule, CommonModule, TuiScrollbar, TuiButton, TuiGroup, TuiBadge, TuiStatus, TuiInput, TuiHint], template: `
|
|
1017
|
+
<button tuiButton iconStart="plus" size="s" appearance="secondary" (click)="createPreset()" tuiHint="Create new preset from current filters"></button>
|
|
1018
|
+
|
|
1019
|
+
<tui-scrollbar>
|
|
1020
|
+
@let current = currentPreset();
|
|
1021
|
+
@for(preset of presets(); track preset.id){
|
|
1022
|
+
<div tuiGroup [collapsed]="true" [rounded]="true">
|
|
1023
|
+
@let isActive = current?.id == preset.id;
|
|
1024
|
+
@if(isActive){
|
|
1025
|
+
@if(preset.edit){
|
|
1026
|
+
<tui-textfield style="width:10rem" tuiTextfieldSize="s" (keydown.enter)="preset.edit = false;saveCurrentPreset()">
|
|
1027
|
+
<input tuiInput [(ngModel)]="preset.name"/>
|
|
1028
|
+
</tui-textfield>
|
|
1029
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="save" size="s" appearance="info" (click)="preset.edit = false;saveCurrentPreset()" tuiHint="Save"></button>
|
|
1030
|
+
}
|
|
1031
|
+
@else {
|
|
1032
|
+
<div style="height:100%" appearance="positive" tuiBadge tuiStatus>
|
|
1033
|
+
{{preset.name}}
|
|
1034
|
+
</div>
|
|
1035
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="square-pen" size="s" appearance="info" (click)="preset.edit = true" tuiHint="Edit"></button>
|
|
1036
|
+
}
|
|
1037
|
+
<button style="flex: 0 0 auto;" tuiButton iconStart="x" size="s" appearance="negative" (click)="removePreset(preset.id)" tuiHint="Delete"></button>
|
|
1038
|
+
}
|
|
1039
|
+
@else {
|
|
1040
|
+
<button style="flex: 0 0 auto;" tuiButton appearance="secondary" size="s" (click)="selectPreset(preset.id)">{{preset.name}}</button>
|
|
1041
|
+
}
|
|
1042
|
+
</div>
|
|
1043
|
+
}
|
|
1044
|
+
</tui-scrollbar>
|
|
1045
|
+
`, host: {
|
|
1046
|
+
style: 'display:flex;flex-direction: row;gap:10px;padding:5px;padding-top:0px;'
|
|
1047
|
+
}, styles: ["tui-scrollbar{width:100%!important}tui-scrollbar ::ng-deep>.t-content{display:flex;gap:10px;width:0px}\n"] }]
|
|
1048
|
+
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { storageKey: [{
|
|
1049
|
+
type: Input
|
|
1050
|
+
}], onPresetChange: [{
|
|
1051
|
+
type: Output
|
|
1052
|
+
}] } });
|
|
1053
|
+
|
|
1054
|
+
class EzUIFilterHelpers {
|
|
1055
|
+
static textFilter(values, fn, column) {
|
|
1056
|
+
var filtered = [];
|
|
1057
|
+
for (let value of values) {
|
|
1058
|
+
var asStr = value[column];
|
|
1059
|
+
if (fn(asStr))
|
|
1060
|
+
filtered.push(value);
|
|
1061
|
+
}
|
|
1062
|
+
return filtered;
|
|
1063
|
+
}
|
|
1064
|
+
static dateFilter(values, fn, column) {
|
|
1065
|
+
var filtered = [];
|
|
1066
|
+
for (let value of values) {
|
|
1067
|
+
var asDate = new Date(value[column]);
|
|
1068
|
+
if (fn(asDate))
|
|
1069
|
+
filtered.push(value);
|
|
1070
|
+
}
|
|
1071
|
+
return filtered;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
class EzUITableFilterService {
|
|
1076
|
+
sortMethods = [
|
|
1077
|
+
{
|
|
1078
|
+
state: 'asc',
|
|
1079
|
+
sort: (a, b, column) => {
|
|
1080
|
+
if (a[column] < b[column])
|
|
1081
|
+
return 1;
|
|
1082
|
+
if (a[column] > b[column])
|
|
1083
|
+
return -1;
|
|
1084
|
+
return 0;
|
|
1085
|
+
}
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
state: 'desc',
|
|
1089
|
+
sort: (a, b, column) => {
|
|
1090
|
+
if (a[column] < b[column])
|
|
1091
|
+
return -1;
|
|
1092
|
+
if (a[column] > b[column])
|
|
1093
|
+
return 1;
|
|
1094
|
+
return 0;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
];
|
|
1098
|
+
filterMethods = [
|
|
1099
|
+
// Text filters
|
|
1100
|
+
{
|
|
1101
|
+
key: 'str',
|
|
1102
|
+
action: 'con',
|
|
1103
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => i.includes(value), column)
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
key: 'str',
|
|
1107
|
+
action: 'ncon',
|
|
1108
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => !i.includes(value), column)
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
key: 'str',
|
|
1112
|
+
action: 'sta',
|
|
1113
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => i.startsWith(value), column)
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
key: 'str',
|
|
1117
|
+
action: 'end',
|
|
1118
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => i.endsWith(value), column)
|
|
1119
|
+
},
|
|
1120
|
+
// Select filters
|
|
1121
|
+
{
|
|
1122
|
+
key: 'sel',
|
|
1123
|
+
action: 'con',
|
|
1124
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => value.includes(i), column)
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
key: 'sel',
|
|
1128
|
+
action: 'ncon',
|
|
1129
|
+
filter: (values, column, value) => EzUIFilterHelpers.textFilter(values, (i) => !value.includes(i), column)
|
|
1130
|
+
},
|
|
1131
|
+
// Date filters
|
|
1132
|
+
{
|
|
1133
|
+
key: 'dat',
|
|
1134
|
+
action: 'bef',
|
|
1135
|
+
filter: (values, column, value) => EzUIFilterHelpers.dateFilter(values, (i) => {
|
|
1136
|
+
var normal = value[0].toLocalNativeDate();
|
|
1137
|
+
normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
|
|
1138
|
+
return i.getTime() < normal.getTime();
|
|
1139
|
+
}, column)
|
|
1140
|
+
},
|
|
1141
|
+
{
|
|
1142
|
+
key: 'dat',
|
|
1143
|
+
action: 'aft',
|
|
1144
|
+
filter: (values, column, value) => EzUIFilterHelpers.dateFilter(values, (i) => {
|
|
1145
|
+
var normal = value[0].toLocalNativeDate();
|
|
1146
|
+
normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
|
|
1147
|
+
return i.getTime() > normal.getTime();
|
|
1148
|
+
}, column)
|
|
1149
|
+
},
|
|
1150
|
+
];
|
|
1151
|
+
sort(values, sort) {
|
|
1152
|
+
var target = this.sortMethods.find(x => x.state == sort.state);
|
|
1153
|
+
if (target)
|
|
1154
|
+
return values.sort((a, b) => target.sort(a, b, sort.column));
|
|
1155
|
+
return values;
|
|
1156
|
+
}
|
|
1157
|
+
filter(values, filter) {
|
|
1158
|
+
var split = filter.expression.split(';');
|
|
1159
|
+
var target = this.filterMethods.find(x => split[0] == x.key && split[1] == x.action);
|
|
1160
|
+
if (target)
|
|
1161
|
+
return target.filter(values, filter.column, filter.value);
|
|
1162
|
+
return values;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
class EzUITable {
|
|
1167
|
+
filterService;
|
|
1168
|
+
tableHeader;
|
|
1169
|
+
tableRows;
|
|
1170
|
+
tableExpandedrow;
|
|
1171
|
+
presetHeader;
|
|
1172
|
+
disabled = false;
|
|
1173
|
+
isLoading = signal(false, /* @ts-ignore */
|
|
1174
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
1175
|
+
showAdd = false;
|
|
1176
|
+
showRefresh = false;
|
|
1177
|
+
showClearFilters = false;
|
|
1178
|
+
expandable = false;
|
|
1179
|
+
values = [];
|
|
1180
|
+
internalValues = [];
|
|
1181
|
+
displayValues = signal([], /* @ts-ignore */
|
|
1182
|
+
...(ngDevMode ? [{ debugName: "displayValues" }] : /* istanbul ignore next */ []));
|
|
1183
|
+
sorts = signal([], /* @ts-ignore */
|
|
1184
|
+
...(ngDevMode ? [{ debugName: "sorts" }] : /* istanbul ignore next */ []));
|
|
1185
|
+
filters = signal([], /* @ts-ignore */
|
|
1186
|
+
...(ngDevMode ? [{ debugName: "filters" }] : /* istanbul ignore next */ []));
|
|
1187
|
+
storageKey = null;
|
|
1188
|
+
allowPresets = false;
|
|
1189
|
+
constructor(filterService) {
|
|
1190
|
+
this.filterService = filterService;
|
|
1191
|
+
}
|
|
1192
|
+
async ngOnChanges(changes) {
|
|
1193
|
+
if (changes['values'] && changes['values'].previousValue != changes['values'].currentValue) {
|
|
1194
|
+
this.values = changes['values'].currentValue;
|
|
1195
|
+
this.applyFilter();
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
onAddItem = new EventEmitter();
|
|
1199
|
+
onLoadItems = new EventEmitter();
|
|
1200
|
+
onRowExpanded = new EventEmitter();
|
|
1201
|
+
onPresetChange = new EventEmitter();
|
|
1202
|
+
pageSize = signal(25, /* @ts-ignore */
|
|
1203
|
+
...(ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []));
|
|
1204
|
+
page = signal(0, /* @ts-ignore */
|
|
1205
|
+
...(ngDevMode ? [{ debugName: "page" }] : /* istanbul ignore next */ []));
|
|
1206
|
+
pages = signal(0, /* @ts-ignore */
|
|
1207
|
+
...(ngDevMode ? [{ debugName: "pages" }] : /* istanbul ignore next */ []));
|
|
1208
|
+
pageSizes = [10, 25, 50, 100, 1000];
|
|
1209
|
+
processPage() {
|
|
1210
|
+
var fromIndex = this.pageSize() * this.page();
|
|
1211
|
+
var toIndex = fromIndex + this.pageSize();
|
|
1212
|
+
this.displayValues.set(this.internalValues.slice(fromIndex, toIndex));
|
|
1213
|
+
}
|
|
1214
|
+
applySorts() {
|
|
1215
|
+
var sorted = [...this.internalValues];
|
|
1216
|
+
for (var sort of this.sorts())
|
|
1217
|
+
sorted = this.filterService.sort(sorted, sort);
|
|
1218
|
+
this.internalValues = sorted;
|
|
1219
|
+
}
|
|
1220
|
+
applyFilter() {
|
|
1221
|
+
var filtered = [...this.values];
|
|
1222
|
+
for (var filter of this.filters())
|
|
1223
|
+
filtered = this.filterService.filter(filtered, filter);
|
|
1224
|
+
this.internalValues = filtered;
|
|
1225
|
+
this.applySorts();
|
|
1226
|
+
this.state = [];
|
|
1227
|
+
this.page.set(0);
|
|
1228
|
+
this.pages.set(Math.floor(this.internalValues.length / this.pageSize()) + 1);
|
|
1229
|
+
this.processPage();
|
|
1230
|
+
this.presetHeader?.saveCurrentPreset();
|
|
1231
|
+
}
|
|
1232
|
+
state = {};
|
|
1233
|
+
setSort(sort) {
|
|
1234
|
+
var sorts = this.sorts();
|
|
1235
|
+
var target = sorts.findIndex(x => x.column == sort.column);
|
|
1236
|
+
if (target != -1)
|
|
1237
|
+
sorts[target] = sort;
|
|
1238
|
+
else
|
|
1239
|
+
sorts.push(sort);
|
|
1240
|
+
this.sorts.set(sorts);
|
|
1241
|
+
this.applyFilter();
|
|
1242
|
+
}
|
|
1243
|
+
clearSort(column) {
|
|
1244
|
+
var sorts = this.sorts();
|
|
1245
|
+
var target = sorts.findIndex(x => x.column == column);
|
|
1246
|
+
if (target != -1)
|
|
1247
|
+
sorts.splice(target, 1);
|
|
1248
|
+
this.sorts.set(sorts);
|
|
1249
|
+
this.applyFilter();
|
|
1250
|
+
}
|
|
1251
|
+
setFilter(filter) {
|
|
1252
|
+
var filters = this.filters();
|
|
1253
|
+
var target = filters.findIndex(x => x.column == filter.column);
|
|
1254
|
+
if (target != -1) {
|
|
1255
|
+
filters[target] = filter;
|
|
1256
|
+
}
|
|
1257
|
+
else
|
|
1258
|
+
filters.push(filter);
|
|
1259
|
+
this.filters.set(filters);
|
|
1260
|
+
this.applyFilter();
|
|
1261
|
+
}
|
|
1262
|
+
clearFilter(column) {
|
|
1263
|
+
var filters = this.filters();
|
|
1264
|
+
var target = filters.findIndex(x => x.column == column);
|
|
1265
|
+
if (target != -1)
|
|
1266
|
+
filters.splice(target, 1);
|
|
1267
|
+
this.filters.set(filters);
|
|
1268
|
+
this.applyFilter();
|
|
1269
|
+
}
|
|
1270
|
+
clearFilters() {
|
|
1271
|
+
this.presetHeader?.currentPreset.set(null);
|
|
1272
|
+
this.onPresetChange.emit(null);
|
|
1273
|
+
this.sorts.set([]);
|
|
1274
|
+
this.filters.set([]);
|
|
1275
|
+
this.presetHeader?.savePresets();
|
|
1276
|
+
this.applyFilter();
|
|
1277
|
+
}
|
|
1278
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITable, deps: [{ token: EzUITableFilterService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1279
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITable, isStandalone: true, selector: "ezui-table", inputs: { disabled: "disabled", isLoading: "isLoading", showAdd: "showAdd", showRefresh: "showRefresh", showClearFilters: "showClearFilters", expandable: "expandable", values: "values", storageKey: "storageKey", allowPresets: "allowPresets", pageSize: "pageSize" }, outputs: { onAddItem: "onAddItem", onLoadItems: "onLoadItems", onRowExpanded: "onRowExpanded", onPresetChange: "onPresetChange" }, host: { classAttribute: "w-full h-full" }, queries: [{ propertyName: "tableHeader", first: true, predicate: ["tableHeader"], descendants: true }, { propertyName: "tableRows", first: true, predicate: ["tableRows"], descendants: true }, { propertyName: "tableExpandedrow", first: true, predicate: ["tableExpandedrow"], descendants: true }], viewQueries: [{ propertyName: "presetHeader", first: true, predicate: ["presetHeader"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
1280
|
+
<div class="ezui-table">
|
|
1281
|
+
<tui-loader [inheritColor]="true" [overlay]="true" size="xxl" [loading]="isLoading()">
|
|
1282
|
+
@if(values.length == 0){
|
|
1283
|
+
<tui-block-status>
|
|
1284
|
+
<tui-icon tuiSlot="top" icon="grid-2x2-x" />
|
|
1285
|
+
|
|
1286
|
+
<h3>No Data</h3>
|
|
1287
|
+
|
|
1288
|
+
No data to display.
|
|
1289
|
+
</tui-block-status>
|
|
1290
|
+
}
|
|
1291
|
+
@else {
|
|
1292
|
+
@if(showAdd || showRefresh || showClearFilters){
|
|
1293
|
+
<div class="ezui-table-header">
|
|
1294
|
+
@if(showRefresh){
|
|
1295
|
+
<button tuiButton iconStart="rotate-cw" size="s" appearance="info" (click)="onLoadItems.emit()" tuiHint="Refresh the table"></button>
|
|
1296
|
+
}
|
|
1297
|
+
@if(showAdd){
|
|
1298
|
+
<button tuiButton iconStart="plus" size="s" appearance="info" (click)="onAddItem.emit()" tuiHint="Add new item"></button>
|
|
1299
|
+
}
|
|
1300
|
+
@if(showClearFilters){
|
|
1301
|
+
<button tuiButton iconStart="funnel-x" size="s" appearance="info" (click)="clearFilters()" tuiHint="Clear filters"></button>
|
|
1302
|
+
}
|
|
1303
|
+
</div>
|
|
1304
|
+
}
|
|
1305
|
+
@if(allowPresets){
|
|
1306
|
+
<ezui-table-presets #presetHeader [storageKey]="storageKey" (onPresetChange)="onPresetChange.emit($event)">
|
|
1307
|
+
</ezui-table-presets>
|
|
1308
|
+
}
|
|
1309
|
+
<tui-scrollbar class="forcefullsize">
|
|
1310
|
+
<table tuiTable class="forcefullsize">
|
|
1311
|
+
<thead>
|
|
1312
|
+
<tr>
|
|
1313
|
+
@if(expandable){
|
|
1314
|
+
<th tuiTh></th>
|
|
1315
|
+
}
|
|
1316
|
+
<ng-container [ngTemplateOutlet]="tableHeader"></ng-container>
|
|
1317
|
+
</tr>
|
|
1318
|
+
</thead>
|
|
1319
|
+
@for (item of displayValues(); track page() * pageSize() + i; let i = $index){
|
|
1320
|
+
@let fullIndex = page() * pageSize() + i;
|
|
1321
|
+
<tbody tuiTbody>
|
|
1322
|
+
<tr>
|
|
1323
|
+
@if(expandable){
|
|
1324
|
+
<td tuiTd class="ezui-table-expander">
|
|
1325
|
+
<button
|
|
1326
|
+
appearance="flat-grayscale"
|
|
1327
|
+
size="xs"
|
|
1328
|
+
tuiIconButton
|
|
1329
|
+
type="button"
|
|
1330
|
+
[tuiChevron]="state[fullIndex] ?? false"
|
|
1331
|
+
(click)="state[fullIndex] = !state[fullIndex];onRowExpanded.emit(item)"
|
|
1332
|
+
>
|
|
1333
|
+
Toggle
|
|
1334
|
+
</button>
|
|
1335
|
+
</td>
|
|
1336
|
+
}
|
|
1337
|
+
<ng-container [ngTemplateOutlet]="tableRows" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
|
1338
|
+
</tr>
|
|
1339
|
+
</tbody>
|
|
1340
|
+
|
|
1341
|
+
<tbody tuiTableExpand [expanded]="state[fullIndex] ?? false">
|
|
1342
|
+
@if(state[fullIndex] ?? false){
|
|
1343
|
+
<tr>
|
|
1344
|
+
<ng-container [ngTemplateOutlet]="tableExpandedrow" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
|
1345
|
+
</tr>
|
|
1346
|
+
}
|
|
1347
|
+
</tbody>
|
|
1348
|
+
}
|
|
1349
|
+
</table>
|
|
1350
|
+
</tui-scrollbar>
|
|
1351
|
+
@if(internalValues.length > pageSize() || pageSize() != 25){
|
|
1352
|
+
<div class="ezui-table-footer">
|
|
1353
|
+
<tui-table-pagination
|
|
1354
|
+
[(size)]="pageSize"
|
|
1355
|
+
[(page)]="page"
|
|
1356
|
+
[total]="internalValues.length"
|
|
1357
|
+
[items]="pageSizes"
|
|
1358
|
+
(pageChange)="processPage()"
|
|
1359
|
+
(sizeChange)="processPage()"
|
|
1360
|
+
/>
|
|
1361
|
+
</div>
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
</tui-loader>
|
|
1365
|
+
</div>
|
|
1366
|
+
`, isInline: true, styles: [".ezui-table{border:2px solid var(--tui-border-normal);border-radius:var(--tui-radius-l);display:flex;height:100%;width:100%;overflow:hidden}.ezui-table ::ng-deep tui-loader{display:flex;height:100%;width:100%;flex-direction:column}.ezui-table .ezui-table-header{display:flex;flex-direction:row;gap:10px;padding:5px 5px 0}.ezui-table .ezui-table-footer{display:flex;margin-bottom:.5rem;padding-left:2rem;padding-right:2rem}.ezui-table .ezui-table-footer tui-table-pagination{flex:1}.ezui-table ::ng-deep table{border-radius:var(--tui-radius-l)}.ezui-table ::ng-deep th{background-color:var(--tui-background-base-alt)!important}.ezui-table ::ng-deep .ezui-table-expander{padding:0}.ezui-table th[tuiTh]{align-items:center}.ezui-table .forcefullsize{width:100%!important}.ezui-table tui-block-status{padding-top:20px;padding-bottom:20px}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i3$2.TuiTableDirective, selector: "table[tuiTable]", inputs: ["columns", "size", "direction", "sorter"], outputs: ["directionChange", "sorterChange", "sortChange"] }, { kind: "component", type: i3$2.TuiTableTbody, selector: "tbody[tuiTbody]", inputs: ["heading", "open"], outputs: ["openChange"] }, { kind: "component", type: i3$2.TuiTableTh, selector: "th[tuiTh]", inputs: ["minWidth", "maxWidth", "sorter", "resizable", "sticky", "requiredSort"], outputs: ["sorterChange"] }, { kind: "component", type: i3$2.TuiTableTd, selector: "th[tuiTd], td[tuiTd]" }, { kind: "component", type: i3$2.TuiTableExpand, selector: "tui-table-expand, tbody[tuiTableExpand]", inputs: ["expanded"], outputs: ["expandedChange"] }, { kind: "component", type: TuiScrollbar, selector: "tui-scrollbar" }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: TuiChevron, selector: "[tuiChevron]", inputs: ["tuiChevron"] }, { kind: "component", type: TuiTablePagination, selector: "tui-table-pagination", inputs: ["items", "total", "page", "size"], outputs: ["pageChange", "sizeChange", "paginationChange"] }, { kind: "component", type: TuiLoader, selector: "tui-loader", inputs: ["size", "inheritColor", "overlay", "textContent", "loading"] }, { kind: "component", type: i4$2.TuiBlockStatusComponent, selector: "tui-block-status", inputs: ["card", "size"] }, { kind: "directive", type: i4$2.TuiBlockStatusDirective, selector: "[tuiSlot]", inputs: ["tuiSlot"] }, { kind: "component", type: TuiIcon, selector: "tui-icon:not([tuiBadge])", inputs: ["background"] }, { kind: "component", type: EzUITablePresets, selector: "ezui-table-presets", inputs: ["storageKey"], outputs: ["onPresetChange"] }, { kind: "directive", type: i3$1.TuiHintDirective, selector: "[tuiHint]:not(ng-container):not(ng-template)", inputs: ["tuiHint", "tuiHintContext", "tuiHintAppearance"], outputs: ["tuiHintVisible"] }] });
|
|
1367
|
+
}
|
|
1368
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITable, decorators: [{
|
|
1369
|
+
type: Component,
|
|
1370
|
+
args: [{ selector: 'ezui-table', imports: [FormsModule, CommonModule, TuiTable, TuiScrollbar, TuiButton, TuiChevron, TuiDropdown, TuiDataListWrapper, TuiTablePagination, TuiLoader, TuiBlockStatus, TuiIcon, TuiInput, EzUITablePresets, TuiHint], template: `
|
|
1371
|
+
<div class="ezui-table">
|
|
1372
|
+
<tui-loader [inheritColor]="true" [overlay]="true" size="xxl" [loading]="isLoading()">
|
|
1373
|
+
@if(values.length == 0){
|
|
1374
|
+
<tui-block-status>
|
|
1375
|
+
<tui-icon tuiSlot="top" icon="grid-2x2-x" />
|
|
1376
|
+
|
|
1377
|
+
<h3>No Data</h3>
|
|
1378
|
+
|
|
1379
|
+
No data to display.
|
|
1380
|
+
</tui-block-status>
|
|
1381
|
+
}
|
|
1382
|
+
@else {
|
|
1383
|
+
@if(showAdd || showRefresh || showClearFilters){
|
|
1384
|
+
<div class="ezui-table-header">
|
|
1385
|
+
@if(showRefresh){
|
|
1386
|
+
<button tuiButton iconStart="rotate-cw" size="s" appearance="info" (click)="onLoadItems.emit()" tuiHint="Refresh the table"></button>
|
|
1387
|
+
}
|
|
1388
|
+
@if(showAdd){
|
|
1389
|
+
<button tuiButton iconStart="plus" size="s" appearance="info" (click)="onAddItem.emit()" tuiHint="Add new item"></button>
|
|
1390
|
+
}
|
|
1391
|
+
@if(showClearFilters){
|
|
1392
|
+
<button tuiButton iconStart="funnel-x" size="s" appearance="info" (click)="clearFilters()" tuiHint="Clear filters"></button>
|
|
1393
|
+
}
|
|
1394
|
+
</div>
|
|
1395
|
+
}
|
|
1396
|
+
@if(allowPresets){
|
|
1397
|
+
<ezui-table-presets #presetHeader [storageKey]="storageKey" (onPresetChange)="onPresetChange.emit($event)">
|
|
1398
|
+
</ezui-table-presets>
|
|
1399
|
+
}
|
|
1400
|
+
<tui-scrollbar class="forcefullsize">
|
|
1401
|
+
<table tuiTable class="forcefullsize">
|
|
1402
|
+
<thead>
|
|
1403
|
+
<tr>
|
|
1404
|
+
@if(expandable){
|
|
1405
|
+
<th tuiTh></th>
|
|
1406
|
+
}
|
|
1407
|
+
<ng-container [ngTemplateOutlet]="tableHeader"></ng-container>
|
|
1408
|
+
</tr>
|
|
1409
|
+
</thead>
|
|
1410
|
+
@for (item of displayValues(); track page() * pageSize() + i; let i = $index){
|
|
1411
|
+
@let fullIndex = page() * pageSize() + i;
|
|
1412
|
+
<tbody tuiTbody>
|
|
1413
|
+
<tr>
|
|
1414
|
+
@if(expandable){
|
|
1415
|
+
<td tuiTd class="ezui-table-expander">
|
|
1416
|
+
<button
|
|
1417
|
+
appearance="flat-grayscale"
|
|
1418
|
+
size="xs"
|
|
1419
|
+
tuiIconButton
|
|
1420
|
+
type="button"
|
|
1421
|
+
[tuiChevron]="state[fullIndex] ?? false"
|
|
1422
|
+
(click)="state[fullIndex] = !state[fullIndex];onRowExpanded.emit(item)"
|
|
1423
|
+
>
|
|
1424
|
+
Toggle
|
|
1425
|
+
</button>
|
|
1426
|
+
</td>
|
|
1427
|
+
}
|
|
1428
|
+
<ng-container [ngTemplateOutlet]="tableRows" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
|
1429
|
+
</tr>
|
|
1430
|
+
</tbody>
|
|
1431
|
+
|
|
1432
|
+
<tbody tuiTableExpand [expanded]="state[fullIndex] ?? false">
|
|
1433
|
+
@if(state[fullIndex] ?? false){
|
|
1434
|
+
<tr>
|
|
1435
|
+
<ng-container [ngTemplateOutlet]="tableExpandedrow" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
|
1436
|
+
</tr>
|
|
1437
|
+
}
|
|
1438
|
+
</tbody>
|
|
1439
|
+
}
|
|
1440
|
+
</table>
|
|
1441
|
+
</tui-scrollbar>
|
|
1442
|
+
@if(internalValues.length > pageSize() || pageSize() != 25){
|
|
1443
|
+
<div class="ezui-table-footer">
|
|
1444
|
+
<tui-table-pagination
|
|
1445
|
+
[(size)]="pageSize"
|
|
1446
|
+
[(page)]="page"
|
|
1447
|
+
[total]="internalValues.length"
|
|
1448
|
+
[items]="pageSizes"
|
|
1449
|
+
(pageChange)="processPage()"
|
|
1450
|
+
(sizeChange)="processPage()"
|
|
1451
|
+
/>
|
|
1452
|
+
</div>
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
</tui-loader>
|
|
1456
|
+
</div>
|
|
1457
|
+
`, host: {
|
|
1458
|
+
class: 'w-full h-full'
|
|
1459
|
+
}, styles: [".ezui-table{border:2px solid var(--tui-border-normal);border-radius:var(--tui-radius-l);display:flex;height:100%;width:100%;overflow:hidden}.ezui-table ::ng-deep tui-loader{display:flex;height:100%;width:100%;flex-direction:column}.ezui-table .ezui-table-header{display:flex;flex-direction:row;gap:10px;padding:5px 5px 0}.ezui-table .ezui-table-footer{display:flex;margin-bottom:.5rem;padding-left:2rem;padding-right:2rem}.ezui-table .ezui-table-footer tui-table-pagination{flex:1}.ezui-table ::ng-deep table{border-radius:var(--tui-radius-l)}.ezui-table ::ng-deep th{background-color:var(--tui-background-base-alt)!important}.ezui-table ::ng-deep .ezui-table-expander{padding:0}.ezui-table th[tuiTh]{align-items:center}.ezui-table .forcefullsize{width:100%!important}.ezui-table tui-block-status{padding-top:20px;padding-bottom:20px}\n"] }]
|
|
1460
|
+
}], ctorParameters: () => [{ type: EzUITableFilterService }], propDecorators: { tableHeader: [{
|
|
1461
|
+
type: ContentChild,
|
|
1462
|
+
args: ['tableHeader', { static: false }]
|
|
1463
|
+
}], tableRows: [{
|
|
1464
|
+
type: ContentChild,
|
|
1465
|
+
args: ['tableRows', { static: false }]
|
|
1466
|
+
}], tableExpandedrow: [{
|
|
1467
|
+
type: ContentChild,
|
|
1468
|
+
args: ['tableExpandedrow', { static: false }]
|
|
1469
|
+
}], presetHeader: [{
|
|
1470
|
+
type: ViewChild,
|
|
1471
|
+
args: ['presetHeader', { static: false }]
|
|
1472
|
+
}], disabled: [{
|
|
1473
|
+
type: Input
|
|
1474
|
+
}], isLoading: [{
|
|
1475
|
+
type: Input
|
|
1476
|
+
}], showAdd: [{
|
|
1477
|
+
type: Input
|
|
1478
|
+
}], showRefresh: [{
|
|
1479
|
+
type: Input
|
|
1480
|
+
}], showClearFilters: [{
|
|
1481
|
+
type: Input
|
|
1482
|
+
}], expandable: [{
|
|
1483
|
+
type: Input
|
|
1484
|
+
}], values: [{
|
|
1485
|
+
type: Input
|
|
1486
|
+
}], storageKey: [{
|
|
1487
|
+
type: Input
|
|
1488
|
+
}], allowPresets: [{
|
|
1489
|
+
type: Input
|
|
1490
|
+
}], onAddItem: [{
|
|
1491
|
+
type: Output
|
|
1492
|
+
}], onLoadItems: [{
|
|
1493
|
+
type: Output
|
|
1494
|
+
}], onRowExpanded: [{
|
|
1495
|
+
type: Output
|
|
1496
|
+
}], onPresetChange: [{
|
|
1497
|
+
type: Output
|
|
1498
|
+
}], pageSize: [{
|
|
1499
|
+
type: Input
|
|
1500
|
+
}] } });
|
|
1501
|
+
|
|
1502
|
+
class EzUITableDateFilter {
|
|
1503
|
+
column;
|
|
1504
|
+
filterApplied = signal(false, /* @ts-ignore */
|
|
1505
|
+
...(ngDevMode ? [{ debugName: "filterApplied" }] : /* istanbul ignore next */ []));
|
|
1506
|
+
filterVisible = signal(false, /* @ts-ignore */
|
|
1507
|
+
...(ngDevMode ? [{ debugName: "filterVisible" }] : /* istanbul ignore next */ []));
|
|
1508
|
+
table;
|
|
1509
|
+
value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
1510
|
+
filterType;
|
|
1511
|
+
filterTypes;
|
|
1512
|
+
stringify = (item) => `${item.label}`;
|
|
1513
|
+
constructor(table) {
|
|
1514
|
+
this.table = table;
|
|
1515
|
+
this.filterTypes = [
|
|
1516
|
+
{
|
|
1517
|
+
label: 'After',
|
|
1518
|
+
expression: 'dat;aft'
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
label: 'Before',
|
|
1522
|
+
expression: 'dat;bef'
|
|
1523
|
+
}
|
|
1524
|
+
];
|
|
1525
|
+
this.filterType = this.filterTypes[0];
|
|
1526
|
+
this.table.onPresetChange.subscribe(x => {
|
|
1527
|
+
if (!x) {
|
|
1528
|
+
this.filterType = this.filterTypes[0];
|
|
1529
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
1530
|
+
this.filterApplied.set(false);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
var filter = x.filters.find(x => x.column == this.column);
|
|
1534
|
+
if (!filter) {
|
|
1535
|
+
this.filterType = this.filterTypes[0];
|
|
1536
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
1537
|
+
this.filterApplied.set(false);
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
var type = this.filterTypes.find(x => x.expression == filter.expression);
|
|
1541
|
+
if (!type) {
|
|
1542
|
+
this.filterType = this.filterTypes[0];
|
|
1543
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
1544
|
+
this.filterApplied.set(false);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
this.filterType = type;
|
|
1548
|
+
this.value = filter.value;
|
|
1549
|
+
this.filterApplied.set(true);
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
applyFilter(expression) {
|
|
1553
|
+
this.table.setFilter({
|
|
1554
|
+
column: this.column,
|
|
1555
|
+
value: this.value,
|
|
1556
|
+
expression: expression,
|
|
1557
|
+
});
|
|
1558
|
+
this.filterVisible.set(false);
|
|
1559
|
+
this.filterApplied.set(true);
|
|
1560
|
+
}
|
|
1561
|
+
clearFilter() {
|
|
1562
|
+
this.table.clearFilter(this.column);
|
|
1563
|
+
this.filterVisible.set(false);
|
|
1564
|
+
this.filterApplied.set(false);
|
|
1565
|
+
}
|
|
1566
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableDateFilter, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
1567
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITableDateFilter, isStandalone: true, selector: "ezui-table-datefilter", inputs: { column: "column" }, ngImport: i0, template: `
|
|
1568
|
+
@if(column){
|
|
1569
|
+
<tui-badged-content>
|
|
1570
|
+
@if(filterApplied()){
|
|
1571
|
+
<tui-badge-notification
|
|
1572
|
+
size="s"
|
|
1573
|
+
tuiSlot="top"
|
|
1574
|
+
>
|
|
1575
|
+
1
|
|
1576
|
+
</tui-badge-notification>
|
|
1577
|
+
}
|
|
1578
|
+
<button
|
|
1579
|
+
tuiButton size="s"
|
|
1580
|
+
iconStart="funnel"
|
|
1581
|
+
appearance="flat-grayscale"
|
|
1582
|
+
style="opacity:0.72"
|
|
1583
|
+
[tuiDropdown]="filterPop"
|
|
1584
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
1585
|
+
(click)="filterVisible.set(true)"
|
|
1586
|
+
></button>
|
|
1587
|
+
</tui-badged-content>
|
|
1588
|
+
|
|
1589
|
+
<ng-template #filterPop>
|
|
1590
|
+
<div class="filterPopContainer">
|
|
1591
|
+
<button
|
|
1592
|
+
appearance="outline-grayscale"
|
|
1593
|
+
size="s"
|
|
1594
|
+
tuiButton
|
|
1595
|
+
tuiButtonSelect
|
|
1596
|
+
[(ngModel)]="filterType"
|
|
1597
|
+
>
|
|
1598
|
+
{{ filterType.label }}
|
|
1599
|
+
<tui-data-list-wrapper
|
|
1600
|
+
*tuiDropdown
|
|
1601
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
1602
|
+
[items]="filterTypes"
|
|
1603
|
+
/>
|
|
1604
|
+
</button>
|
|
1605
|
+
|
|
1606
|
+
<tui-textfield (keydown.enter)="applyFilter(filterType.expression)">
|
|
1607
|
+
<label tuiLabel>Choose a date</label>
|
|
1608
|
+
<input
|
|
1609
|
+
tuiInputDateTime
|
|
1610
|
+
[(ngModel)]="value"
|
|
1611
|
+
/>
|
|
1612
|
+
<tui-calendar *tuiDropdown />
|
|
1613
|
+
</tui-textfield>
|
|
1614
|
+
<button
|
|
1615
|
+
tuiButton size="s"
|
|
1616
|
+
iconStart="funnel"
|
|
1617
|
+
tuiButton
|
|
1618
|
+
(click)="applyFilter(filterType.expression)"
|
|
1619
|
+
>
|
|
1620
|
+
Apply
|
|
1621
|
+
</button>
|
|
1622
|
+
|
|
1623
|
+
@if(filterApplied()){
|
|
1624
|
+
<button
|
|
1625
|
+
tuiButton size="s"
|
|
1626
|
+
iconStart="circle-x"
|
|
1627
|
+
tuiButton
|
|
1628
|
+
(click)="clearFilter()"
|
|
1629
|
+
>
|
|
1630
|
+
Clear
|
|
1631
|
+
</button>
|
|
1632
|
+
}
|
|
1633
|
+
</div>
|
|
1634
|
+
</ng-template>
|
|
1635
|
+
}
|
|
1636
|
+
`, isInline: true, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i3$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: i3$1.TuiDropdownContent, selector: "ng-template[tuiDropdown]" }, { kind: "component", type: i4$1.TuiDataListWrapperComponent, selector: "tui-data-list-wrapper:not([labels])", inputs: ["items", "emptyContent", "size", "itemContent"], outputs: ["itemClick"] }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: TuiButtonSelect, selector: "button[tuiButtonSelect]" }, { kind: "component", type: TuiBadgeNotification, selector: "tui-badge-notification", inputs: ["size"] }, { kind: "directive", type: i4$1.TuiBadgedContentDirective, selector: "[tuiSlot]", inputs: ["tuiSlot"] }, { kind: "component", type: i4$1.TuiBadgedContentComponent, selector: "tui-badged-content" }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i4$1.TuiInputDateTimeDirective, selector: "input[tuiInputDateTime]", inputs: ["timeMode", "min", "max"] }, { kind: "component", type: i6.TuiCalendar, selector: "tui-calendar:not([new])", inputs: ["minViewedMonth", "maxViewedMonth", "showAdjacent", "markerHandler", "initialView", "hoveredItem"], outputs: ["hoveredItemChange", "dayClick"] }, { kind: "pipe", type: TuiStringifyContentPipe, name: "tuiStringifyContent" }] });
|
|
1637
|
+
}
|
|
1638
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableDateFilter, decorators: [{
|
|
1639
|
+
type: Component,
|
|
1640
|
+
args: [{ selector: 'ezui-table-datefilter', imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiInputDateTime], template: `
|
|
1641
|
+
@if(column){
|
|
1642
|
+
<tui-badged-content>
|
|
1643
|
+
@if(filterApplied()){
|
|
1644
|
+
<tui-badge-notification
|
|
1645
|
+
size="s"
|
|
1646
|
+
tuiSlot="top"
|
|
1647
|
+
>
|
|
1648
|
+
1
|
|
1649
|
+
</tui-badge-notification>
|
|
1650
|
+
}
|
|
1651
|
+
<button
|
|
1652
|
+
tuiButton size="s"
|
|
1653
|
+
iconStart="funnel"
|
|
1654
|
+
appearance="flat-grayscale"
|
|
1655
|
+
style="opacity:0.72"
|
|
1656
|
+
[tuiDropdown]="filterPop"
|
|
1657
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
1658
|
+
(click)="filterVisible.set(true)"
|
|
1659
|
+
></button>
|
|
1660
|
+
</tui-badged-content>
|
|
1661
|
+
|
|
1662
|
+
<ng-template #filterPop>
|
|
1663
|
+
<div class="filterPopContainer">
|
|
1664
|
+
<button
|
|
1665
|
+
appearance="outline-grayscale"
|
|
1666
|
+
size="s"
|
|
1667
|
+
tuiButton
|
|
1668
|
+
tuiButtonSelect
|
|
1669
|
+
[(ngModel)]="filterType"
|
|
1670
|
+
>
|
|
1671
|
+
{{ filterType.label }}
|
|
1672
|
+
<tui-data-list-wrapper
|
|
1673
|
+
*tuiDropdown
|
|
1674
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
1675
|
+
[items]="filterTypes"
|
|
1676
|
+
/>
|
|
1677
|
+
</button>
|
|
1678
|
+
|
|
1679
|
+
<tui-textfield (keydown.enter)="applyFilter(filterType.expression)">
|
|
1680
|
+
<label tuiLabel>Choose a date</label>
|
|
1681
|
+
<input
|
|
1682
|
+
tuiInputDateTime
|
|
1683
|
+
[(ngModel)]="value"
|
|
1684
|
+
/>
|
|
1685
|
+
<tui-calendar *tuiDropdown />
|
|
1686
|
+
</tui-textfield>
|
|
1687
|
+
<button
|
|
1688
|
+
tuiButton size="s"
|
|
1689
|
+
iconStart="funnel"
|
|
1690
|
+
tuiButton
|
|
1691
|
+
(click)="applyFilter(filterType.expression)"
|
|
1692
|
+
>
|
|
1693
|
+
Apply
|
|
1694
|
+
</button>
|
|
1695
|
+
|
|
1696
|
+
@if(filterApplied()){
|
|
1697
|
+
<button
|
|
1698
|
+
tuiButton size="s"
|
|
1699
|
+
iconStart="circle-x"
|
|
1700
|
+
tuiButton
|
|
1701
|
+
(click)="clearFilter()"
|
|
1702
|
+
>
|
|
1703
|
+
Clear
|
|
1704
|
+
</button>
|
|
1705
|
+
}
|
|
1706
|
+
</div>
|
|
1707
|
+
</ng-template>
|
|
1708
|
+
}
|
|
1709
|
+
`, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"] }]
|
|
1710
|
+
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
1711
|
+
type: Input
|
|
1712
|
+
}] } });
|
|
1713
|
+
|
|
1714
|
+
class EzUITableSelectFilter {
|
|
1715
|
+
column;
|
|
1716
|
+
filterApplied = signal(false, /* @ts-ignore */
|
|
1717
|
+
...(ngDevMode ? [{ debugName: "filterApplied" }] : /* istanbul ignore next */ []));
|
|
1718
|
+
filterVisible = signal(false, /* @ts-ignore */
|
|
1719
|
+
...(ngDevMode ? [{ debugName: "filterVisible" }] : /* istanbul ignore next */ []));
|
|
1720
|
+
table;
|
|
1721
|
+
options = [];
|
|
1722
|
+
selected = [];
|
|
1723
|
+
filterType;
|
|
1724
|
+
filterTypes;
|
|
1725
|
+
stringify = (item) => `${item.label}`;
|
|
1726
|
+
constructor(table) {
|
|
1727
|
+
this.table = table;
|
|
1728
|
+
this.filterTypes = [
|
|
1729
|
+
{
|
|
1730
|
+
label: 'Contains',
|
|
1731
|
+
expression: 'sel;con'
|
|
1732
|
+
},
|
|
1733
|
+
{
|
|
1734
|
+
label: 'Not Contains',
|
|
1735
|
+
expression: 'sel;ncon'
|
|
1736
|
+
}
|
|
1737
|
+
];
|
|
1738
|
+
this.filterType = this.filterTypes[0];
|
|
1739
|
+
this.table.onPresetChange.subscribe(x => {
|
|
1740
|
+
if (!x) {
|
|
1741
|
+
this.filterType = this.filterTypes[0];
|
|
1742
|
+
this.selected = [];
|
|
1743
|
+
this.filterApplied.set(false);
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
var filter = x.filters.find(x => x.column == this.column);
|
|
1747
|
+
if (!filter) {
|
|
1748
|
+
this.filterType = this.filterTypes[0];
|
|
1749
|
+
this.selected = [];
|
|
1750
|
+
this.filterApplied.set(false);
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
var type = this.filterTypes.find(x => x.expression == filter.expression);
|
|
1754
|
+
if (!type) {
|
|
1755
|
+
this.filterType = this.filterTypes[0];
|
|
1756
|
+
this.selected = [];
|
|
1757
|
+
this.filterApplied.set(false);
|
|
1758
|
+
return;
|
|
1759
|
+
}
|
|
1760
|
+
this.filterType = type;
|
|
1761
|
+
this.selected = filter.value;
|
|
1762
|
+
this.filterApplied.set(true);
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
applyFilter(expression) {
|
|
1766
|
+
this.table.setFilter({
|
|
1767
|
+
column: this.column,
|
|
1768
|
+
value: this.selected,
|
|
1769
|
+
expression: expression,
|
|
1770
|
+
});
|
|
1771
|
+
this.filterVisible.set(false);
|
|
1772
|
+
this.filterApplied.set(true);
|
|
1773
|
+
}
|
|
1774
|
+
clearFilter() {
|
|
1775
|
+
this.table.clearFilter(this.column);
|
|
1776
|
+
this.filterVisible.set(false);
|
|
1777
|
+
this.filterApplied.set(false);
|
|
1778
|
+
}
|
|
1779
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableSelectFilter, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
1780
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITableSelectFilter, isStandalone: true, selector: "ezui-table-selectfilter", inputs: { column: "column", options: "options" }, ngImport: i0, template: `
|
|
1781
|
+
@if(column){
|
|
1782
|
+
<tui-badged-content>
|
|
1783
|
+
@if(filterApplied()){
|
|
1784
|
+
<tui-badge-notification
|
|
1785
|
+
size="s"
|
|
1786
|
+
tuiSlot="top"
|
|
1787
|
+
>
|
|
1788
|
+
1
|
|
1789
|
+
</tui-badge-notification>
|
|
1790
|
+
}
|
|
1791
|
+
<button
|
|
1792
|
+
tuiButton size="s"
|
|
1793
|
+
iconStart="funnel"
|
|
1794
|
+
appearance="flat-grayscale"
|
|
1795
|
+
style="opacity:0.72"
|
|
1796
|
+
[tuiDropdown]="filterPop"
|
|
1797
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
1798
|
+
(click)="filterVisible.set(true)"
|
|
1799
|
+
></button>
|
|
1800
|
+
</tui-badged-content>
|
|
1801
|
+
|
|
1802
|
+
<ng-template #filterPop>
|
|
1803
|
+
<div class="filterPopContainer">
|
|
1804
|
+
<button
|
|
1805
|
+
appearance="outline-grayscale"
|
|
1806
|
+
size="s"
|
|
1807
|
+
tuiButton
|
|
1808
|
+
tuiButtonSelect
|
|
1809
|
+
[(ngModel)]="filterType"
|
|
1810
|
+
>
|
|
1811
|
+
{{ filterType.label }}
|
|
1812
|
+
<tui-data-list-wrapper
|
|
1813
|
+
*tuiDropdown
|
|
1814
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
1815
|
+
[items]="filterTypes"
|
|
1816
|
+
/>
|
|
1817
|
+
</button>
|
|
1818
|
+
|
|
1819
|
+
<button
|
|
1820
|
+
appearance="secondary-grayscale"
|
|
1821
|
+
size="s"
|
|
1822
|
+
tuiButton
|
|
1823
|
+
tuiButtonSelect
|
|
1824
|
+
[(ngModel)]="selected"
|
|
1825
|
+
>
|
|
1826
|
+
{{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
|
|
1827
|
+
|
|
1828
|
+
<tui-data-list *tuiDropdown>
|
|
1829
|
+
<tui-opt-group
|
|
1830
|
+
label="Options"
|
|
1831
|
+
tuiMultiSelectGroup
|
|
1832
|
+
>
|
|
1833
|
+
@for (option of options; track option) {
|
|
1834
|
+
<button
|
|
1835
|
+
tuiOption
|
|
1836
|
+
type="button"
|
|
1837
|
+
[value]="option"
|
|
1838
|
+
>
|
|
1839
|
+
{{ option }}
|
|
1840
|
+
</button>
|
|
1841
|
+
}
|
|
1842
|
+
</tui-opt-group>
|
|
1843
|
+
</tui-data-list>
|
|
1844
|
+
</button>
|
|
1845
|
+
|
|
1846
|
+
<button
|
|
1847
|
+
tuiButton size="s"
|
|
1848
|
+
iconStart="funnel"
|
|
1849
|
+
tuiButton
|
|
1850
|
+
(click)="applyFilter(filterType.expression)"
|
|
1851
|
+
>
|
|
1852
|
+
Apply
|
|
1853
|
+
</button>
|
|
1854
|
+
|
|
1855
|
+
@if(filterApplied()){
|
|
1856
|
+
<button
|
|
1857
|
+
tuiButton size="s"
|
|
1858
|
+
iconStart="circle-x"
|
|
1859
|
+
tuiButton
|
|
1860
|
+
(click)="clearFilter()"
|
|
1861
|
+
>
|
|
1862
|
+
Clear
|
|
1863
|
+
</button>
|
|
1864
|
+
}
|
|
1865
|
+
</div>
|
|
1866
|
+
</ng-template>
|
|
1867
|
+
}
|
|
1868
|
+
`, isInline: true, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i3$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: i3$1.TuiDropdownContent, selector: "ng-template[tuiDropdown]" }, { kind: "component", type: i4$1.TuiDataListWrapperComponent, selector: "tui-data-list-wrapper:not([labels])", inputs: ["items", "emptyContent", "size", "itemContent"], outputs: ["itemClick"] }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: TuiButtonSelect, selector: "button[tuiButtonSelect]" }, { kind: "component", type: TuiBadgeNotification, selector: "tui-badge-notification", inputs: ["size"] }, { kind: "directive", type: i4$1.TuiBadgedContentDirective, selector: "[tuiSlot]", inputs: ["tuiSlot"] }, { kind: "component", type: i4$1.TuiBadgedContentComponent, selector: "tui-badged-content" }, { kind: "component", type: i4$1.TuiMultiSelectGroupComponent, selector: "tui-opt-group[tuiMultiSelectGroup]", inputs: ["label"] }, { kind: "directive", type: i4$1.TuiMultiSelectGroupDirective, selector: "[tuiMultiSelectGroup]" }, { kind: "component", type: i3$1.TuiDataListComponent, selector: "tui-data-list", inputs: ["emptyContent", "size"] }, { kind: "directive", type: i3$1.TuiOption, selector: "button[tuiOption], a[tuiOption], label[tuiOption]", inputs: ["disabled"] }, { kind: "directive", type: i3$1.TuiOptionWithValue, selector: "button[tuiOption][value], a[tuiOption][value], label[tuiOption][value]", inputs: ["disabled", "value"] }, { kind: "directive", type: i3$1.TuiOptGroup, selector: "tui-opt-group", inputs: ["label"] }, { kind: "pipe", type: TuiStringifyContentPipe, name: "tuiStringifyContent" }] });
|
|
1869
|
+
}
|
|
1870
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableSelectFilter, decorators: [{
|
|
1871
|
+
type: Component,
|
|
1872
|
+
args: [{ selector: 'ezui-table-selectfilter', imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiMultiSelect, TuiDataList], template: `
|
|
1873
|
+
@if(column){
|
|
1874
|
+
<tui-badged-content>
|
|
1875
|
+
@if(filterApplied()){
|
|
1876
|
+
<tui-badge-notification
|
|
1877
|
+
size="s"
|
|
1878
|
+
tuiSlot="top"
|
|
1879
|
+
>
|
|
1880
|
+
1
|
|
1881
|
+
</tui-badge-notification>
|
|
1882
|
+
}
|
|
1883
|
+
<button
|
|
1884
|
+
tuiButton size="s"
|
|
1885
|
+
iconStart="funnel"
|
|
1886
|
+
appearance="flat-grayscale"
|
|
1887
|
+
style="opacity:0.72"
|
|
1888
|
+
[tuiDropdown]="filterPop"
|
|
1889
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
1890
|
+
(click)="filterVisible.set(true)"
|
|
1891
|
+
></button>
|
|
1892
|
+
</tui-badged-content>
|
|
1893
|
+
|
|
1894
|
+
<ng-template #filterPop>
|
|
1895
|
+
<div class="filterPopContainer">
|
|
1896
|
+
<button
|
|
1897
|
+
appearance="outline-grayscale"
|
|
1898
|
+
size="s"
|
|
1899
|
+
tuiButton
|
|
1900
|
+
tuiButtonSelect
|
|
1901
|
+
[(ngModel)]="filterType"
|
|
1902
|
+
>
|
|
1903
|
+
{{ filterType.label }}
|
|
1904
|
+
<tui-data-list-wrapper
|
|
1905
|
+
*tuiDropdown
|
|
1906
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
1907
|
+
[items]="filterTypes"
|
|
1908
|
+
/>
|
|
1909
|
+
</button>
|
|
1910
|
+
|
|
1911
|
+
<button
|
|
1912
|
+
appearance="secondary-grayscale"
|
|
1913
|
+
size="s"
|
|
1914
|
+
tuiButton
|
|
1915
|
+
tuiButtonSelect
|
|
1916
|
+
[(ngModel)]="selected"
|
|
1917
|
+
>
|
|
1918
|
+
{{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
|
|
1919
|
+
|
|
1920
|
+
<tui-data-list *tuiDropdown>
|
|
1921
|
+
<tui-opt-group
|
|
1922
|
+
label="Options"
|
|
1923
|
+
tuiMultiSelectGroup
|
|
1924
|
+
>
|
|
1925
|
+
@for (option of options; track option) {
|
|
1926
|
+
<button
|
|
1927
|
+
tuiOption
|
|
1928
|
+
type="button"
|
|
1929
|
+
[value]="option"
|
|
1930
|
+
>
|
|
1931
|
+
{{ option }}
|
|
1932
|
+
</button>
|
|
1933
|
+
}
|
|
1934
|
+
</tui-opt-group>
|
|
1935
|
+
</tui-data-list>
|
|
1936
|
+
</button>
|
|
1937
|
+
|
|
1938
|
+
<button
|
|
1939
|
+
tuiButton size="s"
|
|
1940
|
+
iconStart="funnel"
|
|
1941
|
+
tuiButton
|
|
1942
|
+
(click)="applyFilter(filterType.expression)"
|
|
1943
|
+
>
|
|
1944
|
+
Apply
|
|
1945
|
+
</button>
|
|
1946
|
+
|
|
1947
|
+
@if(filterApplied()){
|
|
1948
|
+
<button
|
|
1949
|
+
tuiButton size="s"
|
|
1950
|
+
iconStart="circle-x"
|
|
1951
|
+
tuiButton
|
|
1952
|
+
(click)="clearFilter()"
|
|
1953
|
+
>
|
|
1954
|
+
Clear
|
|
1955
|
+
</button>
|
|
1956
|
+
}
|
|
1957
|
+
</div>
|
|
1958
|
+
</ng-template>
|
|
1959
|
+
}
|
|
1960
|
+
`, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"] }]
|
|
1961
|
+
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
1962
|
+
type: Input
|
|
1963
|
+
}], options: [{
|
|
1964
|
+
type: Input
|
|
1965
|
+
}] } });
|
|
1966
|
+
|
|
1967
|
+
class EzUITableTextFilter {
|
|
1968
|
+
column;
|
|
1969
|
+
filterApplied = signal(false, /* @ts-ignore */
|
|
1970
|
+
...(ngDevMode ? [{ debugName: "filterApplied" }] : /* istanbul ignore next */ []));
|
|
1971
|
+
filterVisible = signal(false, /* @ts-ignore */
|
|
1972
|
+
...(ngDevMode ? [{ debugName: "filterVisible" }] : /* istanbul ignore next */ []));
|
|
1973
|
+
table;
|
|
1974
|
+
value = '';
|
|
1975
|
+
filterType;
|
|
1976
|
+
filterTypes;
|
|
1977
|
+
stringify = (item) => `${item.label}`;
|
|
1978
|
+
constructor(table) {
|
|
1979
|
+
this.table = table;
|
|
1980
|
+
this.filterTypes = [
|
|
1981
|
+
{
|
|
1982
|
+
label: 'Contains',
|
|
1983
|
+
expression: 'str;con'
|
|
1984
|
+
},
|
|
1985
|
+
{
|
|
1986
|
+
label: 'Not Contains',
|
|
1987
|
+
expression: 'str;ncon'
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
label: 'Starts With',
|
|
1991
|
+
expression: 'str;sta'
|
|
1992
|
+
},
|
|
1993
|
+
{
|
|
1994
|
+
label: 'Ends With',
|
|
1995
|
+
expression: 'str;end'
|
|
1996
|
+
}
|
|
1997
|
+
];
|
|
1998
|
+
this.filterType = this.filterTypes[0];
|
|
1999
|
+
this.table.onPresetChange.subscribe(x => {
|
|
2000
|
+
if (!x) {
|
|
2001
|
+
this.filterType = this.filterTypes[0];
|
|
2002
|
+
this.value = "";
|
|
2003
|
+
this.filterApplied.set(false);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
var filter = x.filters.find(x => x.column == this.column);
|
|
2007
|
+
if (!filter) {
|
|
2008
|
+
this.filterType = this.filterTypes[0];
|
|
2009
|
+
this.value = "";
|
|
2010
|
+
this.filterApplied.set(false);
|
|
2011
|
+
return;
|
|
2012
|
+
}
|
|
2013
|
+
var type = this.filterTypes.find(x => x.expression == filter.expression);
|
|
2014
|
+
if (!type) {
|
|
2015
|
+
this.filterType = this.filterTypes[0];
|
|
2016
|
+
this.value = "";
|
|
2017
|
+
this.filterApplied.set(false);
|
|
2018
|
+
return;
|
|
2019
|
+
}
|
|
2020
|
+
this.filterType = type;
|
|
2021
|
+
this.value = filter.value;
|
|
2022
|
+
this.filterApplied.set(true);
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
applyFilter(expression) {
|
|
2026
|
+
this.table.setFilter({
|
|
2027
|
+
column: this.column,
|
|
2028
|
+
value: this.value,
|
|
2029
|
+
expression: expression,
|
|
2030
|
+
});
|
|
2031
|
+
this.filterVisible.set(false);
|
|
2032
|
+
this.filterApplied.set(true);
|
|
2033
|
+
}
|
|
2034
|
+
clearFilter() {
|
|
2035
|
+
this.table.clearFilter(this.column);
|
|
2036
|
+
this.filterVisible.set(false);
|
|
2037
|
+
this.filterApplied.set(false);
|
|
2038
|
+
}
|
|
2039
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableTextFilter, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
2040
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITableTextFilter, isStandalone: true, selector: "ezui-table-textfilter", inputs: { column: "column" }, ngImport: i0, template: `
|
|
2041
|
+
@if(column){
|
|
2042
|
+
<tui-badged-content>
|
|
2043
|
+
@if(filterApplied()){
|
|
2044
|
+
<tui-badge-notification
|
|
2045
|
+
size="s"
|
|
2046
|
+
tuiSlot="top"
|
|
2047
|
+
>
|
|
2048
|
+
1
|
|
2049
|
+
</tui-badge-notification>
|
|
2050
|
+
}
|
|
2051
|
+
<button
|
|
2052
|
+
tuiButton size="s"
|
|
2053
|
+
iconStart="funnel"
|
|
2054
|
+
appearance="flat-grayscale"
|
|
2055
|
+
style="opacity:0.72"
|
|
2056
|
+
[tuiDropdown]="filterPop"
|
|
2057
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
2058
|
+
(click)="filterVisible.set(true)"
|
|
2059
|
+
></button>
|
|
2060
|
+
</tui-badged-content>
|
|
2061
|
+
|
|
2062
|
+
<ng-template #filterPop>
|
|
2063
|
+
<div class="filterPopContainer">
|
|
2064
|
+
<button
|
|
2065
|
+
appearance="outline-grayscale"
|
|
2066
|
+
size="s"
|
|
2067
|
+
tuiButton
|
|
2068
|
+
tuiButtonSelect
|
|
2069
|
+
[(ngModel)]="filterType"
|
|
2070
|
+
>
|
|
2071
|
+
{{ filterType.label }}
|
|
2072
|
+
<tui-data-list-wrapper
|
|
2073
|
+
*tuiDropdown
|
|
2074
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
2075
|
+
[items]="filterTypes"
|
|
2076
|
+
/>
|
|
2077
|
+
</button>
|
|
2078
|
+
|
|
2079
|
+
<tui-textfield tuiTextfieldSize="s" (keydown.enter)="applyFilter(filterType.expression)">
|
|
2080
|
+
<input tuiInput [(ngModel)]="value"/>
|
|
2081
|
+
</tui-textfield>
|
|
2082
|
+
<button
|
|
2083
|
+
tuiButton size="s"
|
|
2084
|
+
iconStart="funnel"
|
|
2085
|
+
tuiButton
|
|
2086
|
+
(click)="applyFilter(filterType.expression)"
|
|
2087
|
+
>
|
|
2088
|
+
Apply
|
|
2089
|
+
</button>
|
|
2090
|
+
|
|
2091
|
+
@if(filterApplied()){
|
|
2092
|
+
<button
|
|
2093
|
+
tuiButton size="s"
|
|
2094
|
+
iconStart="circle-x"
|
|
2095
|
+
tuiButton
|
|
2096
|
+
(click)="clearFilter()"
|
|
2097
|
+
>
|
|
2098
|
+
Clear
|
|
2099
|
+
</button>
|
|
2100
|
+
}
|
|
2101
|
+
</div>
|
|
2102
|
+
</ng-template>
|
|
2103
|
+
}
|
|
2104
|
+
`, isInline: true, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i3$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: i3$1.TuiDropdownContent, selector: "ng-template[tuiDropdown]" }, { kind: "component", type: i4$1.TuiDataListWrapperComponent, selector: "tui-data-list-wrapper:not([labels])", inputs: ["items", "emptyContent", "size", "itemContent"], outputs: ["itemClick"] }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }, { kind: "directive", type: TuiButtonSelect, selector: "button[tuiButtonSelect]" }, { kind: "component", type: TuiBadgeNotification, selector: "tui-badge-notification", inputs: ["size"] }, { kind: "directive", type: i4$1.TuiBadgedContentDirective, selector: "[tuiSlot]", inputs: ["tuiSlot"] }, { kind: "component", type: i4$1.TuiBadgedContentComponent, selector: "tui-badged-content" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i3$1.TuiInputDirective, selector: "input[tuiInput]", inputs: ["readOnly", "invalid", "focused", "state"] }, { kind: "pipe", type: TuiStringifyContentPipe, name: "tuiStringifyContent" }] });
|
|
2105
|
+
}
|
|
2106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITableTextFilter, decorators: [{
|
|
2107
|
+
type: Component,
|
|
2108
|
+
args: [{ selector: 'ezui-table-textfilter', imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput], template: `
|
|
2109
|
+
@if(column){
|
|
2110
|
+
<tui-badged-content>
|
|
2111
|
+
@if(filterApplied()){
|
|
2112
|
+
<tui-badge-notification
|
|
2113
|
+
size="s"
|
|
2114
|
+
tuiSlot="top"
|
|
2115
|
+
>
|
|
2116
|
+
1
|
|
2117
|
+
</tui-badge-notification>
|
|
2118
|
+
}
|
|
2119
|
+
<button
|
|
2120
|
+
tuiButton size="s"
|
|
2121
|
+
iconStart="funnel"
|
|
2122
|
+
appearance="flat-grayscale"
|
|
2123
|
+
style="opacity:0.72"
|
|
2124
|
+
[tuiDropdown]="filterPop"
|
|
2125
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
2126
|
+
(click)="filterVisible.set(true)"
|
|
2127
|
+
></button>
|
|
2128
|
+
</tui-badged-content>
|
|
2129
|
+
|
|
2130
|
+
<ng-template #filterPop>
|
|
2131
|
+
<div class="filterPopContainer">
|
|
2132
|
+
<button
|
|
2133
|
+
appearance="outline-grayscale"
|
|
2134
|
+
size="s"
|
|
2135
|
+
tuiButton
|
|
2136
|
+
tuiButtonSelect
|
|
2137
|
+
[(ngModel)]="filterType"
|
|
2138
|
+
>
|
|
2139
|
+
{{ filterType.label }}
|
|
2140
|
+
<tui-data-list-wrapper
|
|
2141
|
+
*tuiDropdown
|
|
2142
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
2143
|
+
[items]="filterTypes"
|
|
2144
|
+
/>
|
|
2145
|
+
</button>
|
|
2146
|
+
|
|
2147
|
+
<tui-textfield tuiTextfieldSize="s" (keydown.enter)="applyFilter(filterType.expression)">
|
|
2148
|
+
<input tuiInput [(ngModel)]="value"/>
|
|
2149
|
+
</tui-textfield>
|
|
2150
|
+
<button
|
|
2151
|
+
tuiButton size="s"
|
|
2152
|
+
iconStart="funnel"
|
|
2153
|
+
tuiButton
|
|
2154
|
+
(click)="applyFilter(filterType.expression)"
|
|
2155
|
+
>
|
|
2156
|
+
Apply
|
|
2157
|
+
</button>
|
|
2158
|
+
|
|
2159
|
+
@if(filterApplied()){
|
|
2160
|
+
<button
|
|
2161
|
+
tuiButton size="s"
|
|
2162
|
+
iconStart="circle-x"
|
|
2163
|
+
tuiButton
|
|
2164
|
+
(click)="clearFilter()"
|
|
2165
|
+
>
|
|
2166
|
+
Clear
|
|
2167
|
+
</button>
|
|
2168
|
+
}
|
|
2169
|
+
</div>
|
|
2170
|
+
</ng-template>
|
|
2171
|
+
}
|
|
2172
|
+
`, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"] }]
|
|
2173
|
+
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
2174
|
+
type: Input
|
|
2175
|
+
}] } });
|
|
2176
|
+
|
|
2177
|
+
class EzUITTableSortableColumn {
|
|
2178
|
+
column;
|
|
2179
|
+
table;
|
|
2180
|
+
state = 'none';
|
|
2181
|
+
icon = signal("text-align-justify", /* @ts-ignore */
|
|
2182
|
+
...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
2183
|
+
constructor(table) {
|
|
2184
|
+
this.table = table;
|
|
2185
|
+
this.table.onPresetChange.subscribe(x => {
|
|
2186
|
+
if (!x) {
|
|
2187
|
+
this.state = 'none';
|
|
2188
|
+
this.icon.set('text-align-justify');
|
|
2189
|
+
return;
|
|
2190
|
+
}
|
|
2191
|
+
var sort = x.sorts.find(x => x.column == this.column);
|
|
2192
|
+
if (!sort) {
|
|
2193
|
+
this.state = 'none';
|
|
2194
|
+
this.icon.set('text-align-justify');
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
this.state = sort.state;
|
|
2198
|
+
switch (sort.state) {
|
|
2199
|
+
case 'none':
|
|
2200
|
+
this.icon.set('text-align-justify');
|
|
2201
|
+
break;
|
|
2202
|
+
case 'asc':
|
|
2203
|
+
this.icon.set('arrow-up-wide-narrow');
|
|
2204
|
+
break;
|
|
2205
|
+
case 'desc':
|
|
2206
|
+
this.icon.set('arrow-down-wide-narrow');
|
|
2207
|
+
break;
|
|
2208
|
+
}
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
sort() {
|
|
2212
|
+
switch (this.state) {
|
|
2213
|
+
case 'none':
|
|
2214
|
+
this.state = 'asc';
|
|
2215
|
+
this.table.setSort({ column: this.column, state: this.state });
|
|
2216
|
+
this.icon.set('arrow-up-wide-narrow');
|
|
2217
|
+
break;
|
|
2218
|
+
case 'asc':
|
|
2219
|
+
this.state = 'desc';
|
|
2220
|
+
this.table.setSort({ column: this.column, state: this.state });
|
|
2221
|
+
this.icon.set('arrow-down-wide-narrow');
|
|
2222
|
+
break;
|
|
2223
|
+
case 'desc':
|
|
2224
|
+
this.state = 'none';
|
|
2225
|
+
this.table.clearSort(this.column);
|
|
2226
|
+
this.icon.set('text-align-justify');
|
|
2227
|
+
break;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITTableSortableColumn, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
2231
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITTableSortableColumn, isStandalone: true, selector: "ezui-table-sortable", inputs: { column: "column" }, ngImport: i0, template: `
|
|
2232
|
+
@if(column){
|
|
2233
|
+
<button tuiButton style="opacity:0.72" [iconStart]="icon()" size="s" appearance="flat-grayscale" (click)="sort()"></button>
|
|
2234
|
+
}
|
|
2235
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: TuiButton, selector: "a[tuiButton],button[tuiButton],a[tuiIconButton],button[tuiIconButton]", inputs: ["size"] }] });
|
|
2236
|
+
}
|
|
2237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITTableSortableColumn, decorators: [{
|
|
2238
|
+
type: Component,
|
|
2239
|
+
args: [{
|
|
2240
|
+
selector: 'ezui-table-sortable',
|
|
2241
|
+
imports: [CommonModule, TuiButton],
|
|
2242
|
+
template: `
|
|
2243
|
+
@if(column){
|
|
2244
|
+
<button tuiButton style="opacity:0.72" [iconStart]="icon()" size="s" appearance="flat-grayscale" (click)="sort()"></button>
|
|
2245
|
+
}
|
|
2246
|
+
`
|
|
2247
|
+
}]
|
|
2248
|
+
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
2249
|
+
type: Input
|
|
2250
|
+
}] } });
|
|
2251
|
+
|
|
2252
|
+
class EzUITextInput {
|
|
2253
|
+
icon = '';
|
|
2254
|
+
label = '';
|
|
2255
|
+
size = 'm';
|
|
2256
|
+
disabled = false;
|
|
2257
|
+
value = "";
|
|
2258
|
+
valueChange = new EventEmitter();
|
|
2259
|
+
ngOnChanges(changes) {
|
|
2260
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
2261
|
+
this.value = changes['value'].currentValue;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2265
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: EzUITextInput, isStandalone: true, selector: "ezui-textinput", inputs: { icon: "icon", label: "label", size: "size", disabled: "disabled", value: "value" }, outputs: { valueChange: "valueChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
2266
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
2267
|
+
@if(label){
|
|
2268
|
+
<label tuiLabel>{{label}}</label>
|
|
2269
|
+
}
|
|
2270
|
+
<input tuiInput [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
2271
|
+
</tui-textfield>
|
|
2272
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.TuiLabel, selector: "label[tuiLabel]" }, { kind: "component", type: i3.TuiTextfieldComponent, selector: "tui-textfield:not([multi])", inputs: ["content", "filler"] }, { kind: "directive", type: i3.TuiTextfieldOptionsDirective, selector: "[tuiTextfieldAppearance],[tuiTextfieldSize],[tuiTextfieldCleaner]", inputs: ["tuiTextfieldAppearance", "tuiTextfieldSize", "tuiTextfieldCleaner"] }, { kind: "directive", type: i3$1.TuiInputDirective, selector: "input[tuiInput]", inputs: ["readOnly", "invalid", "focused", "state"] }] });
|
|
2273
|
+
}
|
|
2274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITextInput, decorators: [{
|
|
2275
|
+
type: Component,
|
|
2276
|
+
args: [{ selector: 'ezui-textinput', imports: [
|
|
2277
|
+
FormsModule,
|
|
2278
|
+
CommonModule,
|
|
2279
|
+
TuiInput
|
|
2280
|
+
], template: `
|
|
2281
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
2282
|
+
@if(label){
|
|
2283
|
+
<label tuiLabel>{{label}}</label>
|
|
2284
|
+
}
|
|
2285
|
+
<input tuiInput [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
2286
|
+
</tui-textfield>
|
|
2287
|
+
` }]
|
|
2288
|
+
}], propDecorators: { icon: [{
|
|
2289
|
+
type: Input
|
|
2290
|
+
}], label: [{
|
|
2291
|
+
type: Input
|
|
2292
|
+
}], size: [{
|
|
2293
|
+
type: Input
|
|
2294
|
+
}], disabled: [{
|
|
2295
|
+
type: Input
|
|
2296
|
+
}], value: [{
|
|
2297
|
+
type: Input
|
|
2298
|
+
}], valueChange: [{
|
|
2299
|
+
type: Output
|
|
2300
|
+
}] } });
|
|
2301
|
+
|
|
2302
|
+
class BaseCRUDInterface {
|
|
2303
|
+
http;
|
|
2304
|
+
messageService;
|
|
2305
|
+
confirmationService;
|
|
2306
|
+
isLoading = signal(false, /* @ts-ignore */
|
|
2307
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
2308
|
+
allItems = signal([], /* @ts-ignore */
|
|
2309
|
+
...(ngDevMode ? [{ debugName: "allItems" }] : /* istanbul ignore next */ []));
|
|
2310
|
+
currentItem = signal({}, /* @ts-ignore */
|
|
2311
|
+
...(ngDevMode ? [{ debugName: "currentItem" }] : /* istanbul ignore next */ []));
|
|
2312
|
+
newItemTemplate() {
|
|
2313
|
+
return {};
|
|
2314
|
+
}
|
|
2315
|
+
getAllEndpoint = '';
|
|
2316
|
+
getEndpoint = '';
|
|
2317
|
+
patchEndpoint = '';
|
|
2318
|
+
postEndpoint = '';
|
|
2319
|
+
deleteEndpoint = '';
|
|
2320
|
+
canRead = true;
|
|
2321
|
+
canWrite = true;
|
|
2322
|
+
showDialog = signal(false, /* @ts-ignore */
|
|
2323
|
+
...(ngDevMode ? [{ debugName: "showDialog" }] : /* istanbul ignore next */ []));
|
|
2324
|
+
loadOnInit = true;
|
|
2325
|
+
showDeleteDialog = true;
|
|
2326
|
+
deleteDialogMessage = "Are you sure you want to delete this item?";
|
|
2327
|
+
showSaveDialog = false;
|
|
2328
|
+
savewDialogMessage = "Are you sure you want to save this item?";
|
|
2329
|
+
constructor(http, messageService, confirmationService) {
|
|
2330
|
+
this.http = http;
|
|
2331
|
+
this.messageService = messageService;
|
|
2332
|
+
this.confirmationService = confirmationService;
|
|
2333
|
+
}
|
|
2334
|
+
async ngOnInit() {
|
|
2335
|
+
if (this.canRead && this.loadOnInit)
|
|
2336
|
+
await this.loadItems();
|
|
2337
|
+
}
|
|
2338
|
+
async loadItems() {
|
|
2339
|
+
if (!this.canRead)
|
|
2340
|
+
throw new Error('You do not have read permissions!');
|
|
2341
|
+
this.isLoading.set(true);
|
|
2342
|
+
try {
|
|
2343
|
+
this.allItems.set(await firstValueFrom(this.http.get(this.getAllEndpoint)));
|
|
2344
|
+
}
|
|
2345
|
+
catch {
|
|
2346
|
+
this.messageService.open("Failed to load all items!", {
|
|
2347
|
+
label: "Load Error",
|
|
2348
|
+
appearance: 'negative',
|
|
2349
|
+
icon: 'circle-x',
|
|
2350
|
+
autoClose: 10000
|
|
2351
|
+
}).subscribe();
|
|
2352
|
+
}
|
|
2353
|
+
this.isLoading.set(false);
|
|
2354
|
+
}
|
|
2355
|
+
async saveItem() {
|
|
2356
|
+
if (!this.canWrite)
|
|
2357
|
+
throw new Error('You do not have write permissions!');
|
|
2358
|
+
if (this.showSaveDialog) {
|
|
2359
|
+
this.confirmationService.open(TUI_CONFIRM, {
|
|
2360
|
+
label: this.savewDialogMessage,
|
|
2361
|
+
size: 's'
|
|
2362
|
+
})
|
|
2363
|
+
.pipe(switchMap(async (response) => {
|
|
2364
|
+
if (response === true)
|
|
2365
|
+
await this.saveItemInner();
|
|
2366
|
+
}))
|
|
2367
|
+
.subscribe();
|
|
2368
|
+
}
|
|
2369
|
+
else
|
|
2370
|
+
await this.saveItemInner();
|
|
2371
|
+
}
|
|
2372
|
+
async saveItemInner() {
|
|
2373
|
+
this.isLoading.set(true);
|
|
2374
|
+
try {
|
|
2375
|
+
var current = this.currentItem();
|
|
2376
|
+
if (current.id != '') {
|
|
2377
|
+
await firstValueFrom(this.http.patch(this.patchEndpoint, current));
|
|
2378
|
+
this.messageService.open("The item was updated with the new values", {
|
|
2379
|
+
label: "Item Updated",
|
|
2380
|
+
appearance: 'positive',
|
|
2381
|
+
icon: 'circle-x',
|
|
2382
|
+
autoClose: 1000
|
|
2383
|
+
}).subscribe();
|
|
2384
|
+
}
|
|
2385
|
+
else {
|
|
2386
|
+
await firstValueFrom(this.http.post(this.postEndpoint, current));
|
|
2387
|
+
this.messageService.open("A new items was created", {
|
|
2388
|
+
label: "Item Created",
|
|
2389
|
+
appearance: 'positive',
|
|
2390
|
+
icon: 'circle-x',
|
|
2391
|
+
autoClose: 1000
|
|
2392
|
+
}).subscribe();
|
|
2393
|
+
}
|
|
2394
|
+
this.showDialog.set(false);
|
|
2395
|
+
await this.loadItems();
|
|
2396
|
+
}
|
|
2397
|
+
catch {
|
|
2398
|
+
this.messageService.open("Save failed!", {
|
|
2399
|
+
label: "Save Error",
|
|
2400
|
+
appearance: 'negative',
|
|
2401
|
+
icon: 'circle-x',
|
|
2402
|
+
autoClose: 10000
|
|
2403
|
+
}).subscribe();
|
|
2404
|
+
}
|
|
2405
|
+
this.isLoading.set(false);
|
|
2406
|
+
}
|
|
2407
|
+
async deleteItem() {
|
|
2408
|
+
if (!this.canWrite)
|
|
2409
|
+
throw new Error('You do not have write permissions!');
|
|
2410
|
+
if (this.showDeleteDialog) {
|
|
2411
|
+
this.confirmationService.open(TUI_CONFIRM, {
|
|
2412
|
+
label: this.deleteDialogMessage,
|
|
2413
|
+
size: 's'
|
|
2414
|
+
})
|
|
2415
|
+
.pipe(switchMap(async (response) => {
|
|
2416
|
+
if (response === true)
|
|
2417
|
+
await this.deleteItemInner();
|
|
2418
|
+
}))
|
|
2419
|
+
.subscribe();
|
|
2420
|
+
}
|
|
2421
|
+
else
|
|
2422
|
+
await this.deleteItemInner();
|
|
2423
|
+
}
|
|
2424
|
+
async deleteItemInner() {
|
|
2425
|
+
this.isLoading.set(true);
|
|
2426
|
+
try {
|
|
2427
|
+
await firstValueFrom(this.http.delete(this.deleteEndpoint + '?ID=' + this.currentItem().id));
|
|
2428
|
+
this.messageService.open("The item was successfully deleted", {
|
|
2429
|
+
label: "Item Deleted",
|
|
2430
|
+
appearance: 'positive',
|
|
2431
|
+
icon: 'circle-x',
|
|
2432
|
+
autoClose: 1000
|
|
2433
|
+
}).subscribe();
|
|
2434
|
+
this.showDialog.set(false);
|
|
2435
|
+
await this.loadItems();
|
|
2436
|
+
}
|
|
2437
|
+
catch {
|
|
2438
|
+
this.messageService.open("Delete failed!", {
|
|
2439
|
+
label: "Delete Error",
|
|
2440
|
+
appearance: 'negative',
|
|
2441
|
+
icon: 'circle-x',
|
|
2442
|
+
autoClose: 10000
|
|
2443
|
+
}).subscribe();
|
|
2444
|
+
}
|
|
2445
|
+
this.isLoading.set(false);
|
|
2446
|
+
}
|
|
2447
|
+
async showEditItem(id) {
|
|
2448
|
+
if (!this.canRead)
|
|
2449
|
+
throw new Error('You do not have read permissions!');
|
|
2450
|
+
this.isLoading.set(true);
|
|
2451
|
+
try {
|
|
2452
|
+
var fetched = await firstValueFrom(this.http.get(this.getEndpoint + '?ID=' + id));
|
|
2453
|
+
this.currentItem.set(fetched);
|
|
2454
|
+
this.showDialog.set(true);
|
|
2455
|
+
}
|
|
2456
|
+
catch {
|
|
2457
|
+
this.messageService.open("Loading failed!", {
|
|
2458
|
+
label: "Load Error",
|
|
2459
|
+
appearance: 'negative',
|
|
2460
|
+
icon: 'circle-x',
|
|
2461
|
+
autoClose: 10000
|
|
2462
|
+
}).subscribe();
|
|
2463
|
+
}
|
|
2464
|
+
this.isLoading.set(false);
|
|
2465
|
+
}
|
|
2466
|
+
async showAddItem() {
|
|
2467
|
+
this.currentItem.set(this.newItemTemplate());
|
|
2468
|
+
this.showDialog.set(true);
|
|
2469
|
+
}
|
|
2470
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseCRUDInterface, deps: [{ token: i1$1.HttpClient }, { token: i3$1.TuiNotificationService }, { token: i3$3.TuiResponsiveDialogService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2471
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: BaseCRUDInterface, isStandalone: true, ngImport: i0 });
|
|
2472
|
+
}
|
|
2473
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseCRUDInterface, decorators: [{
|
|
2474
|
+
type: Directive
|
|
2475
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i3$1.TuiNotificationService }, { type: i3$3.TuiResponsiveDialogService }] });
|
|
2476
|
+
|
|
2477
|
+
class BaseListService {
|
|
2478
|
+
http;
|
|
2479
|
+
items = signal([], /* @ts-ignore */
|
|
2480
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
2481
|
+
getAllEndpoint = '';
|
|
2482
|
+
getEndpoint = '';
|
|
2483
|
+
isLoaded = false;
|
|
2484
|
+
isLoading = false;
|
|
2485
|
+
onUpdated = new EventEmitter();
|
|
2486
|
+
constructor(http) {
|
|
2487
|
+
this.http = http;
|
|
2488
|
+
}
|
|
2489
|
+
async Load() {
|
|
2490
|
+
if (!this.isLoading) {
|
|
2491
|
+
this.isLoaded = false;
|
|
2492
|
+
this.isLoading = true;
|
|
2493
|
+
var value = await firstValueFrom(this.http.get(this.getAllEndpoint));
|
|
2494
|
+
this.items.set(value);
|
|
2495
|
+
this.isLoading = false;
|
|
2496
|
+
this.isLoaded = true;
|
|
2497
|
+
this.onUpdated.emit();
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
async List() {
|
|
2501
|
+
if (!this.isLoaded)
|
|
2502
|
+
await this.waitForValue(() => this.isLoaded === true);
|
|
2503
|
+
return this.items();
|
|
2504
|
+
}
|
|
2505
|
+
async ListGet(id) {
|
|
2506
|
+
if (!this.isLoaded)
|
|
2507
|
+
await this.waitForValue(() => this.isLoaded === true);
|
|
2508
|
+
var target = this.items().find(x => x.id == id);
|
|
2509
|
+
if (target)
|
|
2510
|
+
return target;
|
|
2511
|
+
return null;
|
|
2512
|
+
}
|
|
2513
|
+
async Get(id) {
|
|
2514
|
+
var item = await firstValueFrom(this.http.get(this.getEndpoint + "?ID=" + id));
|
|
2515
|
+
return item;
|
|
2516
|
+
}
|
|
2517
|
+
async waitForValue(test) {
|
|
2518
|
+
const delayMs = 500;
|
|
2519
|
+
while (!test())
|
|
2520
|
+
await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
2521
|
+
}
|
|
2522
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseListService, deps: [{ token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2523
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: BaseListService, isStandalone: true, ngImport: i0 });
|
|
2524
|
+
}
|
|
2525
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseListService, decorators: [{
|
|
2526
|
+
type: Directive
|
|
2527
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }] });
|
|
2528
|
+
|
|
2529
|
+
// Components
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* Generated bundle index. Do not edit.
|
|
2533
|
+
*/
|
|
2534
|
+
|
|
2535
|
+
export { BaseCRUDInterface, BaseListService, EzUIDateInput, EzUIFileInput, EzUIFilterHelpers, EzUIMarkdownEditor, EzUIMultiSelect, EzUINumberInput, EzUIPasswordInput, EzUITTableSortableColumn, EzUITable, EzUITableDateFilter, EzUITableFilterService, EzUITableSelectFilter, EzUITableTextFilter, EzUITextInput, compressImage };
|
|
2536
|
+
//# sourceMappingURL=kris701-ez-ui.mjs.map
|