@kris701/ez-ui 0.0.8 → 0.0.10
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 +1074 -0
- package/fesm2022/kris701-ez-ui.mjs.map +1 -0
- package/package.json +19 -7
- package/types/kris701-ez-ui.d.ts +171 -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,1074 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EventEmitter, Output, Input, Component, signal, ViewChild, Directive } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormsModule } from '@angular/forms';
|
|
5
|
+
import { TuiDay } from '@taiga-ui/cdk/date-time';
|
|
6
|
+
import * as i1$1 from '@taiga-ui/core';
|
|
7
|
+
import { TuiInput, TuiOption, TuiDropdown, TuiGroup, TuiButton, TuiScrollbar, TuiSelectLike, TuiDataList, TuiTextfield, TuiIcon } from '@taiga-ui/core';
|
|
8
|
+
import * as i2$1 from '@taiga-ui/kit';
|
|
9
|
+
import { TuiInputDate, TuiChevron, TuiTextarea, TuiMultiSelect, TuiInputNumber, TuiInputChip, TuiPassword, 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 { CommonModule } from '@angular/common';
|
|
15
|
+
import { marked } from 'marked';
|
|
16
|
+
import Compressor from 'compressorjs';
|
|
17
|
+
import * as i7 from '@taiga-ui/cdk/directives/item';
|
|
18
|
+
import { firstValueFrom, switchMap } from 'rxjs';
|
|
19
|
+
import * as i1$2 from '@angular/common/http';
|
|
20
|
+
import * as i3$1 from '@taiga-ui/addon-mobile';
|
|
21
|
+
|
|
22
|
+
class EzUIDateInput {
|
|
23
|
+
icon = '';
|
|
24
|
+
label = '';
|
|
25
|
+
size = 'm';
|
|
26
|
+
disabled = false;
|
|
27
|
+
min = null;
|
|
28
|
+
max = null;
|
|
29
|
+
TuiDay = TuiDay;
|
|
30
|
+
value = new Date;
|
|
31
|
+
valueChange = new EventEmitter();
|
|
32
|
+
internalValue = null;
|
|
33
|
+
ngOnChanges(changes) {
|
|
34
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
35
|
+
this.value = changes['value'].currentValue;
|
|
36
|
+
this.value = new Date(this.value);
|
|
37
|
+
this.internalValue = TuiDay.fromUtcNativeDate(this.value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
updateValue() {
|
|
41
|
+
if (this.internalValue) {
|
|
42
|
+
this.value = this.internalValue?.toUtcNativeDate();
|
|
43
|
+
this.valueChange.emit(this.value);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIDateInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
47
|
+
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: `
|
|
48
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
49
|
+
@if(label){
|
|
50
|
+
<label tuiLabel>{{label}}</label>
|
|
51
|
+
}
|
|
52
|
+
<input tuiInputDate [(ngModel)]="internalValue" (ngModelChange)="updateValue()" [disabled]="disabled" [min]="min ? TuiDay.fromLocalNativeDate(min) : null" [max]="max ? TuiDay.fromLocalNativeDate(max) : null"/>
|
|
53
|
+
<tui-calendar *tuiDropdown />
|
|
54
|
+
</tui-textfield>
|
|
55
|
+
`, 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: i2$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"] }] });
|
|
56
|
+
}
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIDateInput, decorators: [{
|
|
58
|
+
type: Component,
|
|
59
|
+
args: [{ selector: 'ezui-dateinput', imports: [
|
|
60
|
+
FormsModule,
|
|
61
|
+
TuiInput,
|
|
62
|
+
TuiInputDate
|
|
63
|
+
], template: `
|
|
64
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
65
|
+
@if(label){
|
|
66
|
+
<label tuiLabel>{{label}}</label>
|
|
67
|
+
}
|
|
68
|
+
<input tuiInputDate [(ngModel)]="internalValue" (ngModelChange)="updateValue()" [disabled]="disabled" [min]="min ? TuiDay.fromLocalNativeDate(min) : null" [max]="max ? TuiDay.fromLocalNativeDate(max) : null"/>
|
|
69
|
+
<tui-calendar *tuiDropdown />
|
|
70
|
+
</tui-textfield>
|
|
71
|
+
` }]
|
|
72
|
+
}], propDecorators: { icon: [{
|
|
73
|
+
type: Input
|
|
74
|
+
}], label: [{
|
|
75
|
+
type: Input
|
|
76
|
+
}], size: [{
|
|
77
|
+
type: Input
|
|
78
|
+
}], disabled: [{
|
|
79
|
+
type: Input
|
|
80
|
+
}], min: [{
|
|
81
|
+
type: Input
|
|
82
|
+
}], max: [{
|
|
83
|
+
type: Input
|
|
84
|
+
}], value: [{
|
|
85
|
+
type: Input
|
|
86
|
+
}], valueChange: [{
|
|
87
|
+
type: Output
|
|
88
|
+
}] } });
|
|
89
|
+
|
|
90
|
+
const compressImage = async (file, quality, maxHeight, maxWidth, convertSize) => {
|
|
91
|
+
return await new Promise((resolve, reject) => {
|
|
92
|
+
new Compressor(file, {
|
|
93
|
+
quality,
|
|
94
|
+
maxHeight,
|
|
95
|
+
maxWidth,
|
|
96
|
+
convertSize,
|
|
97
|
+
success: resolve,
|
|
98
|
+
error: reject,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
class EzUIMenuBarSubDataList {
|
|
104
|
+
subdatalist = [];
|
|
105
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBarSubDataList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
106
|
+
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: `
|
|
107
|
+
@for(item of subdatalist; track $index){
|
|
108
|
+
@if(item.items){
|
|
109
|
+
<button
|
|
110
|
+
tuiOption
|
|
111
|
+
tuiChevron
|
|
112
|
+
[iconStart]="item.icon"
|
|
113
|
+
[disabled]="item.disabled"
|
|
114
|
+
[tuiDropdown]="dropdownContent"
|
|
115
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
116
|
+
tuiDropdownLimitWidth="fixed"
|
|
117
|
+
tuiDropdownSided="true"
|
|
118
|
+
>
|
|
119
|
+
{{item.label}}
|
|
120
|
+
</button>
|
|
121
|
+
|
|
122
|
+
<ng-template #dropdownContent>
|
|
123
|
+
<tui-data-list
|
|
124
|
+
class="subdatalist"
|
|
125
|
+
[subdatalist]="item.items">
|
|
126
|
+
</tui-data-list>
|
|
127
|
+
</ng-template>
|
|
128
|
+
}
|
|
129
|
+
@else {
|
|
130
|
+
<button
|
|
131
|
+
tuiOption
|
|
132
|
+
[iconStart]="item.icon"
|
|
133
|
+
[disabled]="item.disabled"
|
|
134
|
+
(click)="item.command()"
|
|
135
|
+
>
|
|
136
|
+
{{item.label}}
|
|
137
|
+
</button>
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`, 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: i1$1.TuiDropdownOptionsDirective, selector: "[tuiDropdownAlign], [tuiDropdownAppearance], [tuiDropdownDirection], [tuiDropdownLimitWidth], [tuiDropdownMinHeight], [tuiDropdownMaxHeight], [tuiDropdownOffset]", inputs: ["tuiDropdownAlign", "tuiDropdownAppearance", "tuiDropdownDirection", "tuiDropdownLimitWidth", "tuiDropdownMinHeight", "tuiDropdownMaxHeight", "tuiDropdownOffset"] }, { kind: "directive", type: i1$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i1$1.TuiDropdownOpen, selector: "[tuiDropdown][tuiDropdownAuto],[tuiDropdown][tuiDropdownOpen],[tuiDropdown][tuiDropdownOpenChange]", inputs: ["tuiDropdownEnabled", "tuiDropdownOpen"], outputs: ["tuiDropdownOpenChange"] }, { kind: "directive", type: i1$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"] }] });
|
|
141
|
+
}
|
|
142
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBarSubDataList, decorators: [{
|
|
143
|
+
type: Component,
|
|
144
|
+
args: [{ selector: 'tui-data-list[subdatalist]', standalone: true, imports: [
|
|
145
|
+
TuiDropdown,
|
|
146
|
+
TuiOption,
|
|
147
|
+
TuiChevron
|
|
148
|
+
], template: `
|
|
149
|
+
@for(item of subdatalist; track $index){
|
|
150
|
+
@if(item.items){
|
|
151
|
+
<button
|
|
152
|
+
tuiOption
|
|
153
|
+
tuiChevron
|
|
154
|
+
[iconStart]="item.icon"
|
|
155
|
+
[disabled]="item.disabled"
|
|
156
|
+
[tuiDropdown]="dropdownContent"
|
|
157
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
158
|
+
tuiDropdownLimitWidth="fixed"
|
|
159
|
+
tuiDropdownSided="true"
|
|
160
|
+
>
|
|
161
|
+
{{item.label}}
|
|
162
|
+
</button>
|
|
163
|
+
|
|
164
|
+
<ng-template #dropdownContent>
|
|
165
|
+
<tui-data-list
|
|
166
|
+
class="subdatalist"
|
|
167
|
+
[subdatalist]="item.items">
|
|
168
|
+
</tui-data-list>
|
|
169
|
+
</ng-template>
|
|
170
|
+
}
|
|
171
|
+
@else {
|
|
172
|
+
<button
|
|
173
|
+
tuiOption
|
|
174
|
+
[iconStart]="item.icon"
|
|
175
|
+
[disabled]="item.disabled"
|
|
176
|
+
(click)="item.command()"
|
|
177
|
+
>
|
|
178
|
+
{{item.label}}
|
|
179
|
+
</button>
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`, styles: [".subdatalist{display:flex;flex-direction:column}\n"] }]
|
|
183
|
+
}], propDecorators: { subdatalist: [{
|
|
184
|
+
type: Input
|
|
185
|
+
}] } });
|
|
186
|
+
class EzUIMenuBar {
|
|
187
|
+
items = [];
|
|
188
|
+
ngOnChanges(changes) {
|
|
189
|
+
if (changes['items'] && changes['items'].currentValue != changes['items'].previousValue) {
|
|
190
|
+
this.items = changes['items'].currentValue;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
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: `
|
|
195
|
+
<div tuiGroup class="group" [collapsed]="true">
|
|
196
|
+
@for(item of items; track $index){
|
|
197
|
+
@if(item.items){
|
|
198
|
+
<button
|
|
199
|
+
tuiButton
|
|
200
|
+
tuiChevron
|
|
201
|
+
size="s"
|
|
202
|
+
appearance="outline"
|
|
203
|
+
type="button"
|
|
204
|
+
[iconStart]="item.icon"
|
|
205
|
+
[disabled]="item.disabled"
|
|
206
|
+
[tuiDropdown]="dropdownContent"
|
|
207
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
208
|
+
tuiDropdownLimitWidth="fixed"
|
|
209
|
+
>
|
|
210
|
+
{{item.label}}
|
|
211
|
+
</button>
|
|
212
|
+
|
|
213
|
+
<ng-template #dropdownContent>
|
|
214
|
+
<tui-data-list
|
|
215
|
+
class="subdatalist"
|
|
216
|
+
[subdatalist]="item.items">
|
|
217
|
+
</tui-data-list>
|
|
218
|
+
</ng-template>
|
|
219
|
+
}
|
|
220
|
+
@else {
|
|
221
|
+
<button
|
|
222
|
+
appearance="outline"
|
|
223
|
+
size="s"
|
|
224
|
+
tuiButton
|
|
225
|
+
type="button"
|
|
226
|
+
[iconStart]="item.icon"
|
|
227
|
+
[disabled]="item.disabled"
|
|
228
|
+
(click)="item.command()"
|
|
229
|
+
>
|
|
230
|
+
{{item.label}}
|
|
231
|
+
</button>
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
</div>
|
|
235
|
+
`, 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: i1$1.TuiDropdownOptionsDirective, selector: "[tuiDropdownAlign], [tuiDropdownAppearance], [tuiDropdownDirection], [tuiDropdownLimitWidth], [tuiDropdownMinHeight], [tuiDropdownMaxHeight], [tuiDropdownOffset]", inputs: ["tuiDropdownAlign", "tuiDropdownAppearance", "tuiDropdownDirection", "tuiDropdownLimitWidth", "tuiDropdownMinHeight", "tuiDropdownMaxHeight", "tuiDropdownOffset"] }, { kind: "directive", type: i1$1.TuiDropdownDirective, selector: "[tuiDropdown]:not(ng-container):not(ng-template)", inputs: ["tuiDropdown"], exportAs: ["tuiDropdown"] }, { kind: "directive", type: i1$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"] }] });
|
|
236
|
+
}
|
|
237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMenuBar, decorators: [{
|
|
238
|
+
type: Component,
|
|
239
|
+
args: [{ selector: 'ezui-menubar', standalone: true, imports: [
|
|
240
|
+
FormsModule,
|
|
241
|
+
CommonModule,
|
|
242
|
+
TuiGroup,
|
|
243
|
+
TuiButton,
|
|
244
|
+
TuiDropdown,
|
|
245
|
+
TuiChevron,
|
|
246
|
+
EzUIMenuBarSubDataList
|
|
247
|
+
], template: `
|
|
248
|
+
<div tuiGroup class="group" [collapsed]="true">
|
|
249
|
+
@for(item of items; track $index){
|
|
250
|
+
@if(item.items){
|
|
251
|
+
<button
|
|
252
|
+
tuiButton
|
|
253
|
+
tuiChevron
|
|
254
|
+
size="s"
|
|
255
|
+
appearance="outline"
|
|
256
|
+
type="button"
|
|
257
|
+
[iconStart]="item.icon"
|
|
258
|
+
[disabled]="item.disabled"
|
|
259
|
+
[tuiDropdown]="dropdownContent"
|
|
260
|
+
[(tuiDropdownOpen)]="item.expanded"
|
|
261
|
+
tuiDropdownLimitWidth="fixed"
|
|
262
|
+
>
|
|
263
|
+
{{item.label}}
|
|
264
|
+
</button>
|
|
265
|
+
|
|
266
|
+
<ng-template #dropdownContent>
|
|
267
|
+
<tui-data-list
|
|
268
|
+
class="subdatalist"
|
|
269
|
+
[subdatalist]="item.items">
|
|
270
|
+
</tui-data-list>
|
|
271
|
+
</ng-template>
|
|
272
|
+
}
|
|
273
|
+
@else {
|
|
274
|
+
<button
|
|
275
|
+
appearance="outline"
|
|
276
|
+
size="s"
|
|
277
|
+
tuiButton
|
|
278
|
+
type="button"
|
|
279
|
+
[iconStart]="item.icon"
|
|
280
|
+
[disabled]="item.disabled"
|
|
281
|
+
(click)="item.command()"
|
|
282
|
+
>
|
|
283
|
+
{{item.label}}
|
|
284
|
+
</button>
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
</div>
|
|
288
|
+
`, styles: [".group{width:100%;white-space:nowrap}.subdatalist{display:flex;flex-direction:column}\n"] }]
|
|
289
|
+
}], propDecorators: { items: [{
|
|
290
|
+
type: Input
|
|
291
|
+
}] } });
|
|
292
|
+
|
|
293
|
+
class EzUIMarkdownEditor {
|
|
294
|
+
preview;
|
|
295
|
+
editor;
|
|
296
|
+
fileUpload;
|
|
297
|
+
disabled = false;
|
|
298
|
+
value = null;
|
|
299
|
+
valueChange = new EventEmitter();
|
|
300
|
+
unsavedValue = signal("", /* @ts-ignore */
|
|
301
|
+
...(ngDevMode ? [{ debugName: "unsavedValue" }] : /* istanbul ignore next */ []));
|
|
302
|
+
isFirst = true;
|
|
303
|
+
isEditing = signal(false, /* @ts-ignore */
|
|
304
|
+
...(ngDevMode ? [{ debugName: "isEditing" }] : /* istanbul ignore next */ []));
|
|
305
|
+
items = signal([
|
|
306
|
+
{
|
|
307
|
+
icon: 'save',
|
|
308
|
+
command: async () => await this.toggleEdit(true)
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
icon: 'x',
|
|
312
|
+
command: async () => await this.toggleEdit(false)
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
label: 'B',
|
|
316
|
+
command: async () => {
|
|
317
|
+
if (this.editor) {
|
|
318
|
+
var editor = this.editor.nativeElement;
|
|
319
|
+
var start = editor.selectionStart;
|
|
320
|
+
var finish = editor.selectionEnd;
|
|
321
|
+
var sel = editor.value.substring(start, finish);
|
|
322
|
+
var newStr = "**" + sel + "**";
|
|
323
|
+
await this.replaceSection(newStr, start + 2, finish + 2);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
label: 'I',
|
|
329
|
+
command: async () => {
|
|
330
|
+
if (this.editor) {
|
|
331
|
+
var editor = this.editor.nativeElement;
|
|
332
|
+
var start = editor.selectionStart;
|
|
333
|
+
var finish = editor.selectionEnd;
|
|
334
|
+
var sel = editor.value.substring(start, finish);
|
|
335
|
+
var newStr = "*" + sel + "*";
|
|
336
|
+
await this.replaceSection(newStr, start + 1, finish + 1);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
label: 'H',
|
|
342
|
+
items: [
|
|
343
|
+
{
|
|
344
|
+
label: 'H1',
|
|
345
|
+
command: async () => {
|
|
346
|
+
if (this.editor) {
|
|
347
|
+
var editor = this.editor.nativeElement;
|
|
348
|
+
var start = editor.selectionStart;
|
|
349
|
+
var finish = editor.selectionEnd;
|
|
350
|
+
var sel = editor.value.substring(start, finish);
|
|
351
|
+
var newStr = "# " + sel;
|
|
352
|
+
await this.replaceSection(newStr, start + 2, finish + 2);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
label: 'H2',
|
|
358
|
+
command: async () => {
|
|
359
|
+
if (this.editor) {
|
|
360
|
+
var editor = this.editor.nativeElement;
|
|
361
|
+
var start = editor.selectionStart;
|
|
362
|
+
var finish = editor.selectionEnd;
|
|
363
|
+
var sel = editor.value.substring(start, finish);
|
|
364
|
+
var newStr = "## " + sel;
|
|
365
|
+
await this.replaceSection(newStr, start + 3, finish + 3);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
label: 'H3',
|
|
371
|
+
command: async () => {
|
|
372
|
+
if (this.editor) {
|
|
373
|
+
var editor = this.editor.nativeElement;
|
|
374
|
+
var start = editor.selectionStart;
|
|
375
|
+
var finish = editor.selectionEnd;
|
|
376
|
+
var sel = editor.value.substring(start, finish);
|
|
377
|
+
var newStr = "### " + sel;
|
|
378
|
+
await this.replaceSection(newStr, start + 4, finish + 4);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
]
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
icon: 'link',
|
|
386
|
+
command: async () => {
|
|
387
|
+
if (this.editor) {
|
|
388
|
+
var editor = this.editor.nativeElement;
|
|
389
|
+
var start = editor.selectionStart;
|
|
390
|
+
var finish = editor.selectionEnd;
|
|
391
|
+
var sel = editor.value.substring(start, finish);
|
|
392
|
+
var newStr = "[" + sel + "](link)";
|
|
393
|
+
await this.replaceSection(newStr, start + 1, finish + 1);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
icon: 'image',
|
|
399
|
+
command: async () => {
|
|
400
|
+
if (this.editor) {
|
|
401
|
+
this.fileUpload?.nativeElement.click();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
], /* @ts-ignore */
|
|
406
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
407
|
+
async onFileSelected(event) {
|
|
408
|
+
var files = Array.from(event.target.files);
|
|
409
|
+
if (files && files.length > 0) {
|
|
410
|
+
var file = files[0];
|
|
411
|
+
await this.insertImageInEditor(file);
|
|
412
|
+
this.fileUpload.nativeElement.value = '';
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
toBase65(file) {
|
|
416
|
+
return new Promise((resolve, reject) => {
|
|
417
|
+
var reader = new FileReader();
|
|
418
|
+
reader.readAsDataURL(file);
|
|
419
|
+
reader.onload = () => resolve(reader.result);
|
|
420
|
+
reader.onerror = reject;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
async onPaste(event) {
|
|
424
|
+
const items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
|
425
|
+
let blob = null;
|
|
426
|
+
for (const item of items) {
|
|
427
|
+
if (item.type.indexOf('image') === 0) {
|
|
428
|
+
blob = item.getAsFile();
|
|
429
|
+
await this.insertImageInEditor(blob);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
async insertImageInEditor(file) {
|
|
434
|
+
var compressed = await compressImage(file, 0.5, 300, 300);
|
|
435
|
+
var asBase64 = await this.toBase65(compressed);
|
|
436
|
+
if (asBase64 && this.editor) {
|
|
437
|
+
var editor = this.editor.nativeElement;
|
|
438
|
+
var start = editor.selectionStart;
|
|
439
|
+
var finish = editor.selectionEnd;
|
|
440
|
+
var sel = editor.value.substring(start, finish);
|
|
441
|
+
var newStr = "";
|
|
442
|
+
await this.replaceSection(newStr, start + newStr.length, finish + newStr.length);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
async replaceSection(newStr, finalStart, finalFinish) {
|
|
446
|
+
var editor = this.editor.nativeElement;
|
|
447
|
+
editor.focus();
|
|
448
|
+
document.execCommand("insertText", false, newStr);
|
|
449
|
+
await this.formatPreview();
|
|
450
|
+
editor.focus();
|
|
451
|
+
editor.setSelectionRange(finalStart, finalFinish);
|
|
452
|
+
}
|
|
453
|
+
async ngOnChanges(changes) {
|
|
454
|
+
if (changes['value']) {
|
|
455
|
+
if (changes['value'].currentValue != changes['value'].previousValue) {
|
|
456
|
+
this.value = changes['value'].currentValue;
|
|
457
|
+
await this.formatPreview();
|
|
458
|
+
if (this.isFirst) {
|
|
459
|
+
setTimeout(async () => await this.formatPreview(), 500);
|
|
460
|
+
this.isFirst = false;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
async formatPreview() {
|
|
466
|
+
if (this.preview) {
|
|
467
|
+
if (this.isEditing())
|
|
468
|
+
this.preview.nativeElement.innerHTML = await marked(this.unsavedValue());
|
|
469
|
+
else if (this.value)
|
|
470
|
+
this.preview.nativeElement.innerHTML = await marked(this.value);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
async toggleEdit(save) {
|
|
474
|
+
if (!this.isEditing() && this.value) {
|
|
475
|
+
this.unsavedValue.set(this.value);
|
|
476
|
+
}
|
|
477
|
+
if (save && this.isEditing()) {
|
|
478
|
+
this.value = this.unsavedValue();
|
|
479
|
+
this.valueChange.emit(this.value);
|
|
480
|
+
}
|
|
481
|
+
this.isEditing.set(!this.isEditing());
|
|
482
|
+
setTimeout(async () => await this.formatPreview(), 500);
|
|
483
|
+
}
|
|
484
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMarkdownEditor, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
485
|
+
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: `
|
|
486
|
+
@if(isEditing() && !disabled){
|
|
487
|
+
<div class="editor-container">
|
|
488
|
+
<div class="editor">
|
|
489
|
+
<ezui-menubar [items]="items()"/>
|
|
490
|
+
|
|
491
|
+
<tui-textfield class="editor-field">
|
|
492
|
+
<textarea
|
|
493
|
+
#editor
|
|
494
|
+
placeholder="Markdown Content"
|
|
495
|
+
tuiTextarea
|
|
496
|
+
[(ngModel)]="unsavedValue"
|
|
497
|
+
(input)="formatPreview()"
|
|
498
|
+
></textarea>
|
|
499
|
+
</tui-textfield>
|
|
500
|
+
</div>
|
|
501
|
+
|
|
502
|
+
<div class="preview-container">
|
|
503
|
+
<tui-scrollbar>
|
|
504
|
+
<div class="preview" #preview>Rendering...</div>
|
|
505
|
+
</tui-scrollbar>
|
|
506
|
+
</div>
|
|
507
|
+
|
|
508
|
+
<input type="file" (change)="onFileSelected($event)" #fileUpload [style]="{ display: 'none' }" accept="image/png, image/jpeg" />
|
|
509
|
+
</div>
|
|
510
|
+
}
|
|
511
|
+
@else {
|
|
512
|
+
<div class="preview-readonly-container">
|
|
513
|
+
@if(!disabled){
|
|
514
|
+
<button tuiButton class="edit-button" iconStart="edit" appearance="flat" size="s"(click)="toggleEdit(false)"></button>
|
|
515
|
+
}
|
|
516
|
+
<tui-scrollbar>
|
|
517
|
+
<div class="preview" #preview>Rendering...</div>
|
|
518
|
+
</tui-scrollbar>
|
|
519
|
+
</div>
|
|
520
|
+
}
|
|
521
|
+
`, 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: i2$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"] }] });
|
|
522
|
+
}
|
|
523
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMarkdownEditor, decorators: [{
|
|
524
|
+
type: Component,
|
|
525
|
+
args: [{ selector: 'ezui-markdowneditor', imports: [FormsModule, CommonModule, TuiTextarea, TuiButton, TuiScrollbar, EzUIMenuBar], template: `
|
|
526
|
+
@if(isEditing() && !disabled){
|
|
527
|
+
<div class="editor-container">
|
|
528
|
+
<div class="editor">
|
|
529
|
+
<ezui-menubar [items]="items()"/>
|
|
530
|
+
|
|
531
|
+
<tui-textfield class="editor-field">
|
|
532
|
+
<textarea
|
|
533
|
+
#editor
|
|
534
|
+
placeholder="Markdown Content"
|
|
535
|
+
tuiTextarea
|
|
536
|
+
[(ngModel)]="unsavedValue"
|
|
537
|
+
(input)="formatPreview()"
|
|
538
|
+
></textarea>
|
|
539
|
+
</tui-textfield>
|
|
540
|
+
</div>
|
|
541
|
+
|
|
542
|
+
<div class="preview-container">
|
|
543
|
+
<tui-scrollbar>
|
|
544
|
+
<div class="preview" #preview>Rendering...</div>
|
|
545
|
+
</tui-scrollbar>
|
|
546
|
+
</div>
|
|
547
|
+
|
|
548
|
+
<input type="file" (change)="onFileSelected($event)" #fileUpload [style]="{ display: 'none' }" accept="image/png, image/jpeg" />
|
|
549
|
+
</div>
|
|
550
|
+
}
|
|
551
|
+
@else {
|
|
552
|
+
<div class="preview-readonly-container">
|
|
553
|
+
@if(!disabled){
|
|
554
|
+
<button tuiButton class="edit-button" iconStart="edit" appearance="flat" size="s"(click)="toggleEdit(false)"></button>
|
|
555
|
+
}
|
|
556
|
+
<tui-scrollbar>
|
|
557
|
+
<div class="preview" #preview>Rendering...</div>
|
|
558
|
+
</tui-scrollbar>
|
|
559
|
+
</div>
|
|
560
|
+
}
|
|
561
|
+
`, host: {
|
|
562
|
+
class: 'flex h-full w-full'
|
|
563
|
+
}, 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"] }]
|
|
564
|
+
}], propDecorators: { preview: [{
|
|
565
|
+
type: ViewChild,
|
|
566
|
+
args: ['preview']
|
|
567
|
+
}], editor: [{
|
|
568
|
+
type: ViewChild,
|
|
569
|
+
args: ['editor']
|
|
570
|
+
}], fileUpload: [{
|
|
571
|
+
type: ViewChild,
|
|
572
|
+
args: ['fileUpload']
|
|
573
|
+
}], disabled: [{
|
|
574
|
+
type: Input
|
|
575
|
+
}], value: [{
|
|
576
|
+
type: Input
|
|
577
|
+
}], valueChange: [{
|
|
578
|
+
type: Output
|
|
579
|
+
}] } });
|
|
580
|
+
|
|
581
|
+
class EzUIMultiSelect {
|
|
582
|
+
icon = '';
|
|
583
|
+
label = '';
|
|
584
|
+
size = 'm';
|
|
585
|
+
optionLabel = undefined;
|
|
586
|
+
optionValue = undefined;
|
|
587
|
+
options = [];
|
|
588
|
+
disabled = false;
|
|
589
|
+
selected = undefined;
|
|
590
|
+
selectedChange = new EventEmitter();
|
|
591
|
+
ngOnChanges(changes) {
|
|
592
|
+
if (changes['selected'] && changes['selected'].currentValue != changes['selected'].previousValue) {
|
|
593
|
+
this.selected = changes['selected'].currentValue;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
stringify = (value) => this.getOptionLabel(this.options.find((item) => this.getOptionValue(item) === value));
|
|
597
|
+
getOptionLabel(item) {
|
|
598
|
+
if (!item)
|
|
599
|
+
return "";
|
|
600
|
+
if (this.optionLabel == undefined || this.optionLabel == '')
|
|
601
|
+
return item;
|
|
602
|
+
return item[this.optionLabel];
|
|
603
|
+
}
|
|
604
|
+
getOptionValue(item) {
|
|
605
|
+
if (!item)
|
|
606
|
+
return "";
|
|
607
|
+
if (this.optionValue == undefined || this.optionValue == '')
|
|
608
|
+
return item;
|
|
609
|
+
return item[this.optionValue];
|
|
610
|
+
}
|
|
611
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMultiSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
612
|
+
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: `
|
|
613
|
+
<tui-textfield multi tuiChevron [stringify]="stringify" [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
614
|
+
@if(label != ''){
|
|
615
|
+
<label tuiLabel>{{label}}</label>
|
|
616
|
+
}
|
|
617
|
+
<input tuiInputChip tuiSelectLike [(ngModel)]="selected" (ngModelChange)="selectedChange.emit(this.selected)" [disabled]="disabled"/>
|
|
618
|
+
<tui-input-chip *tuiItem />
|
|
619
|
+
<tui-data-list *tuiDropdown tuiMultiSelectGroup >
|
|
620
|
+
@for (item of options; track getOptionValue(item)) {
|
|
621
|
+
<button tuiOption [value]="getOptionValue(item)">
|
|
622
|
+
{{ getOptionLabel(item) }}
|
|
623
|
+
</button>
|
|
624
|
+
}
|
|
625
|
+
</tui-data-list>
|
|
626
|
+
</tui-textfield>
|
|
627
|
+
`, 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$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: i1$1.TuiDataListComponent, selector: "tui-data-list", inputs: ["emptyContent", "size"] }, { kind: "directive", type: i1$1.TuiOption, selector: "button[tuiOption], a[tuiOption], label[tuiOption]", inputs: ["disabled"] }, { kind: "directive", type: i1$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: i1$1.TuiTextfieldMultiComponent, selector: "tui-textfield[multi]", inputs: ["rows"] }, { kind: "directive", type: i2$1.TuiInputChipDirective, selector: "input[tuiInputChip]", inputs: ["separator", "unique"] }, { kind: "component", type: i2$1.TuiInputChipComponent, selector: "tui-input-chip", inputs: ["editable"] }, { kind: "directive", type: TuiSelectLike, selector: "[tuiSelectLike]" }, { kind: "directive", type: TuiChevron, selector: "[tuiChevron]", inputs: ["tuiChevron"] }] });
|
|
628
|
+
}
|
|
629
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIMultiSelect, decorators: [{
|
|
630
|
+
type: Component,
|
|
631
|
+
args: [{ selector: 'ezui-multiselect', imports: [
|
|
632
|
+
FormsModule,
|
|
633
|
+
CommonModule,
|
|
634
|
+
TuiMultiSelect,
|
|
635
|
+
TuiInputNumber,
|
|
636
|
+
TuiDataList,
|
|
637
|
+
TuiTextfield,
|
|
638
|
+
TuiInputChip,
|
|
639
|
+
TuiSelectLike,
|
|
640
|
+
TuiMultiSelect,
|
|
641
|
+
TuiDropdown,
|
|
642
|
+
TuiChevron
|
|
643
|
+
], template: `
|
|
644
|
+
<tui-textfield multi tuiChevron [stringify]="stringify" [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
645
|
+
@if(label != ''){
|
|
646
|
+
<label tuiLabel>{{label}}</label>
|
|
647
|
+
}
|
|
648
|
+
<input tuiInputChip tuiSelectLike [(ngModel)]="selected" (ngModelChange)="selectedChange.emit(this.selected)" [disabled]="disabled"/>
|
|
649
|
+
<tui-input-chip *tuiItem />
|
|
650
|
+
<tui-data-list *tuiDropdown tuiMultiSelectGroup >
|
|
651
|
+
@for (item of options; track getOptionValue(item)) {
|
|
652
|
+
<button tuiOption [value]="getOptionValue(item)">
|
|
653
|
+
{{ getOptionLabel(item) }}
|
|
654
|
+
</button>
|
|
655
|
+
}
|
|
656
|
+
</tui-data-list>
|
|
657
|
+
</tui-textfield>
|
|
658
|
+
` }]
|
|
659
|
+
}], propDecorators: { icon: [{
|
|
660
|
+
type: Input
|
|
661
|
+
}], label: [{
|
|
662
|
+
type: Input
|
|
663
|
+
}], size: [{
|
|
664
|
+
type: Input
|
|
665
|
+
}], optionLabel: [{
|
|
666
|
+
type: Input
|
|
667
|
+
}], optionValue: [{
|
|
668
|
+
type: Input
|
|
669
|
+
}], options: [{
|
|
670
|
+
type: Input
|
|
671
|
+
}], disabled: [{
|
|
672
|
+
type: Input
|
|
673
|
+
}], selected: [{
|
|
674
|
+
type: Input
|
|
675
|
+
}], selectedChange: [{
|
|
676
|
+
type: Output
|
|
677
|
+
}] } });
|
|
678
|
+
|
|
679
|
+
class EzUINumberInput {
|
|
680
|
+
icon = '';
|
|
681
|
+
label = '';
|
|
682
|
+
size = 'm';
|
|
683
|
+
disabled = false;
|
|
684
|
+
min = null;
|
|
685
|
+
max = null;
|
|
686
|
+
value = "";
|
|
687
|
+
valueChange = new EventEmitter();
|
|
688
|
+
ngOnChanges(changes) {
|
|
689
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
690
|
+
this.value = changes['value'].currentValue;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUINumberInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
694
|
+
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: `
|
|
695
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
696
|
+
@if(label){
|
|
697
|
+
<label tuiLabel>{{label}}</label>
|
|
698
|
+
}
|
|
699
|
+
<input tuiInputNumber [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled" [min]="min" [max]="max"/>
|
|
700
|
+
</tui-textfield>
|
|
701
|
+
`, 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: i2$1.TuiInputNumberDirective, selector: "input[tuiInputNumber]" }] });
|
|
702
|
+
}
|
|
703
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUINumberInput, decorators: [{
|
|
704
|
+
type: Component,
|
|
705
|
+
args: [{ selector: 'ezui-numberinput', imports: [
|
|
706
|
+
FormsModule,
|
|
707
|
+
CommonModule,
|
|
708
|
+
TuiInput,
|
|
709
|
+
TuiInputNumber
|
|
710
|
+
], template: `
|
|
711
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
712
|
+
@if(label){
|
|
713
|
+
<label tuiLabel>{{label}}</label>
|
|
714
|
+
}
|
|
715
|
+
<input tuiInputNumber [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled" [min]="min" [max]="max"/>
|
|
716
|
+
</tui-textfield>
|
|
717
|
+
` }]
|
|
718
|
+
}], propDecorators: { icon: [{
|
|
719
|
+
type: Input
|
|
720
|
+
}], label: [{
|
|
721
|
+
type: Input
|
|
722
|
+
}], size: [{
|
|
723
|
+
type: Input
|
|
724
|
+
}], disabled: [{
|
|
725
|
+
type: Input
|
|
726
|
+
}], min: [{
|
|
727
|
+
type: Input
|
|
728
|
+
}], max: [{
|
|
729
|
+
type: Input
|
|
730
|
+
}], value: [{
|
|
731
|
+
type: Input
|
|
732
|
+
}], valueChange: [{
|
|
733
|
+
type: Output
|
|
734
|
+
}] } });
|
|
735
|
+
|
|
736
|
+
class EzUIPasswordInput {
|
|
737
|
+
icon = '';
|
|
738
|
+
label = '';
|
|
739
|
+
size = 'm';
|
|
740
|
+
disabled = false;
|
|
741
|
+
value = "";
|
|
742
|
+
valueChange = new EventEmitter();
|
|
743
|
+
ngOnChanges(changes) {
|
|
744
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
745
|
+
this.value = changes['value'].currentValue;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIPasswordInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
749
|
+
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: `
|
|
750
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
751
|
+
@if(label){
|
|
752
|
+
<label tuiLabel>{{label}}</label>
|
|
753
|
+
}
|
|
754
|
+
<input tuiInput type="password" [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
755
|
+
<tui-icon tuiPassword />
|
|
756
|
+
</tui-textfield>
|
|
757
|
+
`, 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: i1$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]" }] });
|
|
758
|
+
}
|
|
759
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUIPasswordInput, decorators: [{
|
|
760
|
+
type: Component,
|
|
761
|
+
args: [{ selector: 'ezui-passwordinput', imports: [
|
|
762
|
+
FormsModule,
|
|
763
|
+
CommonModule,
|
|
764
|
+
TuiInput,
|
|
765
|
+
TuiIcon,
|
|
766
|
+
TuiPassword
|
|
767
|
+
], template: `
|
|
768
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
769
|
+
@if(label){
|
|
770
|
+
<label tuiLabel>{{label}}</label>
|
|
771
|
+
}
|
|
772
|
+
<input tuiInput type="password" [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
773
|
+
<tui-icon tuiPassword />
|
|
774
|
+
</tui-textfield>
|
|
775
|
+
` }]
|
|
776
|
+
}], propDecorators: { icon: [{
|
|
777
|
+
type: Input
|
|
778
|
+
}], label: [{
|
|
779
|
+
type: Input
|
|
780
|
+
}], size: [{
|
|
781
|
+
type: Input
|
|
782
|
+
}], disabled: [{
|
|
783
|
+
type: Input
|
|
784
|
+
}], value: [{
|
|
785
|
+
type: Input
|
|
786
|
+
}], valueChange: [{
|
|
787
|
+
type: Output
|
|
788
|
+
}] } });
|
|
789
|
+
|
|
790
|
+
class EzUITextInput {
|
|
791
|
+
icon = '';
|
|
792
|
+
label = '';
|
|
793
|
+
size = 'm';
|
|
794
|
+
disabled = false;
|
|
795
|
+
value = "";
|
|
796
|
+
valueChange = new EventEmitter();
|
|
797
|
+
ngOnChanges(changes) {
|
|
798
|
+
if (changes['value'] && changes['value'].currentValue != changes['value'].previousValue) {
|
|
799
|
+
this.value = changes['value'].currentValue;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITextInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
803
|
+
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: `
|
|
804
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
805
|
+
@if(label){
|
|
806
|
+
<label tuiLabel>{{label}}</label>
|
|
807
|
+
}
|
|
808
|
+
<input tuiInput [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
809
|
+
</tui-textfield>
|
|
810
|
+
`, 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: i1$1.TuiInputDirective, selector: "input[tuiInput]", inputs: ["readOnly", "invalid", "focused", "state"] }] });
|
|
811
|
+
}
|
|
812
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: EzUITextInput, decorators: [{
|
|
813
|
+
type: Component,
|
|
814
|
+
args: [{ selector: 'ezui-textinput', imports: [
|
|
815
|
+
FormsModule,
|
|
816
|
+
CommonModule,
|
|
817
|
+
TuiInput
|
|
818
|
+
], template: `
|
|
819
|
+
<tui-textfield [tuiTextfieldSize]="size" [iconStart]="icon">
|
|
820
|
+
@if(label){
|
|
821
|
+
<label tuiLabel>{{label}}</label>
|
|
822
|
+
}
|
|
823
|
+
<input tuiInput [(ngModel)]="value" (ngModelChange)="valueChange.emit(value)" [disabled]="disabled"/>
|
|
824
|
+
</tui-textfield>
|
|
825
|
+
` }]
|
|
826
|
+
}], propDecorators: { icon: [{
|
|
827
|
+
type: Input
|
|
828
|
+
}], label: [{
|
|
829
|
+
type: Input
|
|
830
|
+
}], size: [{
|
|
831
|
+
type: Input
|
|
832
|
+
}], disabled: [{
|
|
833
|
+
type: Input
|
|
834
|
+
}], value: [{
|
|
835
|
+
type: Input
|
|
836
|
+
}], valueChange: [{
|
|
837
|
+
type: Output
|
|
838
|
+
}] } });
|
|
839
|
+
|
|
840
|
+
class BaseCRUDInterface {
|
|
841
|
+
http;
|
|
842
|
+
messageService;
|
|
843
|
+
confirmationService;
|
|
844
|
+
isLoading = signal(false, /* @ts-ignore */
|
|
845
|
+
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
846
|
+
allItems = signal([], /* @ts-ignore */
|
|
847
|
+
...(ngDevMode ? [{ debugName: "allItems" }] : /* istanbul ignore next */ []));
|
|
848
|
+
currentItem = signal({}, /* @ts-ignore */
|
|
849
|
+
...(ngDevMode ? [{ debugName: "currentItem" }] : /* istanbul ignore next */ []));
|
|
850
|
+
newItemTemplate() {
|
|
851
|
+
return {};
|
|
852
|
+
}
|
|
853
|
+
getAllEndpoint = '';
|
|
854
|
+
getEndpoint = '';
|
|
855
|
+
patchEndpoint = '';
|
|
856
|
+
postEndpoint = '';
|
|
857
|
+
deleteEndpoint = '';
|
|
858
|
+
canRead = true;
|
|
859
|
+
canWrite = true;
|
|
860
|
+
showDialog = signal(false, /* @ts-ignore */
|
|
861
|
+
...(ngDevMode ? [{ debugName: "showDialog" }] : /* istanbul ignore next */ []));
|
|
862
|
+
loadOnInit = true;
|
|
863
|
+
showDeleteDialog = true;
|
|
864
|
+
deleteDialogMessage = "Are you sure you want to delete this item?";
|
|
865
|
+
showSaveDialog = false;
|
|
866
|
+
savewDialogMessage = "Are you sure you want to save this item?";
|
|
867
|
+
constructor(http, messageService, confirmationService) {
|
|
868
|
+
this.http = http;
|
|
869
|
+
this.messageService = messageService;
|
|
870
|
+
this.confirmationService = confirmationService;
|
|
871
|
+
}
|
|
872
|
+
async ngOnInit() {
|
|
873
|
+
if (this.canRead && this.loadOnInit)
|
|
874
|
+
await this.loadItems();
|
|
875
|
+
}
|
|
876
|
+
async loadItems() {
|
|
877
|
+
if (!this.canRead)
|
|
878
|
+
throw new Error('You do not have read permissions!');
|
|
879
|
+
this.isLoading.set(true);
|
|
880
|
+
try {
|
|
881
|
+
this.allItems.set(await firstValueFrom(this.http.get(this.getAllEndpoint)));
|
|
882
|
+
}
|
|
883
|
+
catch {
|
|
884
|
+
this.messageService.open("Failed to load all items!", {
|
|
885
|
+
label: "Load Error",
|
|
886
|
+
appearance: 'negative',
|
|
887
|
+
icon: 'circle-x',
|
|
888
|
+
autoClose: 10000
|
|
889
|
+
}).subscribe();
|
|
890
|
+
}
|
|
891
|
+
this.isLoading.set(false);
|
|
892
|
+
}
|
|
893
|
+
async saveItem() {
|
|
894
|
+
if (!this.canWrite)
|
|
895
|
+
throw new Error('You do not have write permissions!');
|
|
896
|
+
if (this.showSaveDialog) {
|
|
897
|
+
this.confirmationService.open(TUI_CONFIRM, {
|
|
898
|
+
label: this.savewDialogMessage,
|
|
899
|
+
size: 's'
|
|
900
|
+
})
|
|
901
|
+
.pipe(switchMap(async (response) => {
|
|
902
|
+
if (response === true)
|
|
903
|
+
await this.saveItemInner();
|
|
904
|
+
}))
|
|
905
|
+
.subscribe();
|
|
906
|
+
}
|
|
907
|
+
else
|
|
908
|
+
await this.saveItemInner();
|
|
909
|
+
}
|
|
910
|
+
async saveItemInner() {
|
|
911
|
+
this.isLoading.set(true);
|
|
912
|
+
try {
|
|
913
|
+
var current = this.currentItem();
|
|
914
|
+
if (current.id != '') {
|
|
915
|
+
await firstValueFrom(this.http.patch(this.patchEndpoint, current));
|
|
916
|
+
this.messageService.open("The item was updated with the new values", {
|
|
917
|
+
label: "Item Updated",
|
|
918
|
+
appearance: 'positive',
|
|
919
|
+
icon: 'circle-x',
|
|
920
|
+
autoClose: 1000
|
|
921
|
+
}).subscribe();
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
await firstValueFrom(this.http.post(this.postEndpoint, current));
|
|
925
|
+
this.messageService.open("A new items was created", {
|
|
926
|
+
label: "Item Created",
|
|
927
|
+
appearance: 'positive',
|
|
928
|
+
icon: 'circle-x',
|
|
929
|
+
autoClose: 1000
|
|
930
|
+
}).subscribe();
|
|
931
|
+
}
|
|
932
|
+
this.showDialog.set(false);
|
|
933
|
+
await this.loadItems();
|
|
934
|
+
}
|
|
935
|
+
catch {
|
|
936
|
+
this.messageService.open("Save failed!", {
|
|
937
|
+
label: "Save Error",
|
|
938
|
+
appearance: 'negative',
|
|
939
|
+
icon: 'circle-x',
|
|
940
|
+
autoClose: 10000
|
|
941
|
+
}).subscribe();
|
|
942
|
+
}
|
|
943
|
+
this.isLoading.set(false);
|
|
944
|
+
}
|
|
945
|
+
async deleteItem() {
|
|
946
|
+
if (!this.canWrite)
|
|
947
|
+
throw new Error('You do not have write permissions!');
|
|
948
|
+
if (this.showDeleteDialog) {
|
|
949
|
+
this.confirmationService.open(TUI_CONFIRM, {
|
|
950
|
+
label: this.deleteDialogMessage,
|
|
951
|
+
size: 's'
|
|
952
|
+
})
|
|
953
|
+
.pipe(switchMap(async (response) => {
|
|
954
|
+
if (response === true)
|
|
955
|
+
await this.deleteItemInner();
|
|
956
|
+
}))
|
|
957
|
+
.subscribe();
|
|
958
|
+
}
|
|
959
|
+
else
|
|
960
|
+
await this.deleteItemInner();
|
|
961
|
+
}
|
|
962
|
+
async deleteItemInner() {
|
|
963
|
+
this.isLoading.set(true);
|
|
964
|
+
try {
|
|
965
|
+
await firstValueFrom(this.http.delete(this.deleteEndpoint + '?ID=' + this.currentItem().id));
|
|
966
|
+
this.messageService.open("The item was successfully deleted", {
|
|
967
|
+
label: "Item Deleted",
|
|
968
|
+
appearance: 'positive',
|
|
969
|
+
icon: 'circle-x',
|
|
970
|
+
autoClose: 1000
|
|
971
|
+
}).subscribe();
|
|
972
|
+
this.showDialog.set(false);
|
|
973
|
+
await this.loadItems();
|
|
974
|
+
}
|
|
975
|
+
catch {
|
|
976
|
+
this.messageService.open("Delete failed!", {
|
|
977
|
+
label: "Delete Error",
|
|
978
|
+
appearance: 'negative',
|
|
979
|
+
icon: 'circle-x',
|
|
980
|
+
autoClose: 10000
|
|
981
|
+
}).subscribe();
|
|
982
|
+
}
|
|
983
|
+
this.isLoading.set(false);
|
|
984
|
+
}
|
|
985
|
+
async showEditItem(id) {
|
|
986
|
+
if (!this.canRead)
|
|
987
|
+
throw new Error('You do not have read permissions!');
|
|
988
|
+
this.isLoading.set(true);
|
|
989
|
+
try {
|
|
990
|
+
var fetched = await firstValueFrom(this.http.get(this.getEndpoint + '?ID=' + id));
|
|
991
|
+
this.currentItem.set(fetched);
|
|
992
|
+
this.showDialog.set(true);
|
|
993
|
+
}
|
|
994
|
+
catch {
|
|
995
|
+
this.messageService.open("Loading failed!", {
|
|
996
|
+
label: "Load Error",
|
|
997
|
+
appearance: 'negative',
|
|
998
|
+
icon: 'circle-x',
|
|
999
|
+
autoClose: 10000
|
|
1000
|
+
}).subscribe();
|
|
1001
|
+
}
|
|
1002
|
+
this.isLoading.set(false);
|
|
1003
|
+
}
|
|
1004
|
+
async showAddItem() {
|
|
1005
|
+
this.currentItem.set(this.newItemTemplate());
|
|
1006
|
+
this.showDialog.set(true);
|
|
1007
|
+
}
|
|
1008
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseCRUDInterface, deps: [{ token: i1$2.HttpClient }, { token: i1$1.TuiNotificationService }, { token: i3$1.TuiResponsiveDialogService }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1009
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: BaseCRUDInterface, isStandalone: true, ngImport: i0 });
|
|
1010
|
+
}
|
|
1011
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseCRUDInterface, decorators: [{
|
|
1012
|
+
type: Directive
|
|
1013
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }, { type: i1$1.TuiNotificationService }, { type: i3$1.TuiResponsiveDialogService }] });
|
|
1014
|
+
|
|
1015
|
+
class BaseListService {
|
|
1016
|
+
http;
|
|
1017
|
+
items = signal([], /* @ts-ignore */
|
|
1018
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
1019
|
+
getAllEndpoint = '';
|
|
1020
|
+
getEndpoint = '';
|
|
1021
|
+
isLoaded = false;
|
|
1022
|
+
isLoading = false;
|
|
1023
|
+
onUpdated = new EventEmitter();
|
|
1024
|
+
constructor(http) {
|
|
1025
|
+
this.http = http;
|
|
1026
|
+
}
|
|
1027
|
+
async Load() {
|
|
1028
|
+
if (!this.isLoading) {
|
|
1029
|
+
this.isLoaded = false;
|
|
1030
|
+
this.isLoading = true;
|
|
1031
|
+
var value = await firstValueFrom(this.http.get(this.getAllEndpoint));
|
|
1032
|
+
this.items.set(value);
|
|
1033
|
+
this.isLoading = false;
|
|
1034
|
+
this.isLoaded = true;
|
|
1035
|
+
this.onUpdated.emit();
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
async List() {
|
|
1039
|
+
if (!this.isLoaded)
|
|
1040
|
+
await this.waitForValue(() => this.isLoaded === true);
|
|
1041
|
+
return this.items();
|
|
1042
|
+
}
|
|
1043
|
+
async ListGet(id) {
|
|
1044
|
+
if (!this.isLoaded)
|
|
1045
|
+
await this.waitForValue(() => this.isLoaded === true);
|
|
1046
|
+
var target = this.items().find(x => x.id == id);
|
|
1047
|
+
if (target)
|
|
1048
|
+
return target;
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
1051
|
+
async Get(id) {
|
|
1052
|
+
var item = await firstValueFrom(this.http.get(this.getEndpoint + "?ID=" + id));
|
|
1053
|
+
return item;
|
|
1054
|
+
}
|
|
1055
|
+
async waitForValue(test) {
|
|
1056
|
+
const delayMs = 500;
|
|
1057
|
+
while (!test())
|
|
1058
|
+
await new Promise(resolve => setTimeout(resolve, delayMs));
|
|
1059
|
+
}
|
|
1060
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseListService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Directive });
|
|
1061
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: BaseListService, isStandalone: true, ngImport: i0 });
|
|
1062
|
+
}
|
|
1063
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BaseListService, decorators: [{
|
|
1064
|
+
type: Directive
|
|
1065
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }] });
|
|
1066
|
+
|
|
1067
|
+
// Components
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Generated bundle index. Do not edit.
|
|
1071
|
+
*/
|
|
1072
|
+
|
|
1073
|
+
export { BaseCRUDInterface, BaseListService, EzUIDateInput, EzUIMarkdownEditor, EzUIMultiSelect, EzUINumberInput, EzUIPasswordInput, EzUITextInput, compressImage };
|
|
1074
|
+
//# sourceMappingURL=kris701-ez-ui.mjs.map
|