@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
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from "@angular/common";
|
|
2
|
-
import { Component, Input, signal } from "@angular/core";
|
|
3
|
-
import { FormsModule } from "@angular/forms";
|
|
4
|
-
import { TuiButton, TuiDataList, TuiDropdown, TuiInput } from "@taiga-ui/core";
|
|
5
|
-
import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiMultiSelect, TuiStringifyContentPipe } from "@taiga-ui/kit";
|
|
6
|
-
import { FloatTable } from "../floattable";
|
|
7
|
-
import { FloatTableFilter } from "../models/FloatTableFilter";
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'tuiThSelectFilter',
|
|
11
|
-
imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiMultiSelect, TuiDataList],
|
|
12
|
-
template: `
|
|
13
|
-
@if(tuiThSelectFilter){
|
|
14
|
-
<tui-badged-content>
|
|
15
|
-
@if(filterApplied()){
|
|
16
|
-
<tui-badge-notification
|
|
17
|
-
size="s"
|
|
18
|
-
tuiSlot="top"
|
|
19
|
-
>
|
|
20
|
-
1
|
|
21
|
-
</tui-badge-notification>
|
|
22
|
-
}
|
|
23
|
-
<button
|
|
24
|
-
tuiButton size="s"
|
|
25
|
-
iconStart="funnel"
|
|
26
|
-
appearance="flat-grayscale"
|
|
27
|
-
style="opacity:0.72"
|
|
28
|
-
[tuiDropdown]="filterPop"
|
|
29
|
-
[(tuiDropdownOpen)]="filterVisible"
|
|
30
|
-
(click)="filterVisible.set(true)"
|
|
31
|
-
></button>
|
|
32
|
-
</tui-badged-content>
|
|
33
|
-
|
|
34
|
-
<ng-template #filterPop>
|
|
35
|
-
<div class="flex flex-col gap-2 p-4" style="min-width:20rem">
|
|
36
|
-
<button
|
|
37
|
-
appearance="outline-grayscale"
|
|
38
|
-
size="s"
|
|
39
|
-
tuiButton
|
|
40
|
-
tuiButtonSelect
|
|
41
|
-
[(ngModel)]="filterType"
|
|
42
|
-
>
|
|
43
|
-
{{ filterType.label }}
|
|
44
|
-
<tui-data-list-wrapper
|
|
45
|
-
*tuiDropdown
|
|
46
|
-
[itemContent]="stringify | tuiStringifyContent"
|
|
47
|
-
[items]="filterTypes"
|
|
48
|
-
/>
|
|
49
|
-
</button>
|
|
50
|
-
|
|
51
|
-
<button
|
|
52
|
-
appearance="secondary-grayscale"
|
|
53
|
-
size="s"
|
|
54
|
-
tuiButton
|
|
55
|
-
tuiButtonSelect
|
|
56
|
-
[(ngModel)]="selected"
|
|
57
|
-
>
|
|
58
|
-
{{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
|
|
59
|
-
|
|
60
|
-
<tui-data-list *tuiDropdown>
|
|
61
|
-
<tui-opt-group
|
|
62
|
-
label="Options"
|
|
63
|
-
tuiMultiSelectGroup
|
|
64
|
-
>
|
|
65
|
-
@for (option of options; track option) {
|
|
66
|
-
<button
|
|
67
|
-
tuiOption
|
|
68
|
-
type="button"
|
|
69
|
-
[value]="option"
|
|
70
|
-
>
|
|
71
|
-
{{ option }}
|
|
72
|
-
</button>
|
|
73
|
-
}
|
|
74
|
-
</tui-opt-group>
|
|
75
|
-
</tui-data-list>
|
|
76
|
-
</button>
|
|
77
|
-
|
|
78
|
-
<button
|
|
79
|
-
tuiButton size="s"
|
|
80
|
-
iconStart="funnel"
|
|
81
|
-
tuiButton
|
|
82
|
-
(click)="applyFilter(filterType.expression)"
|
|
83
|
-
>
|
|
84
|
-
Apply
|
|
85
|
-
</button>
|
|
86
|
-
|
|
87
|
-
@if(filterApplied()){
|
|
88
|
-
<button
|
|
89
|
-
tuiButton size="s"
|
|
90
|
-
iconStart="circle-x"
|
|
91
|
-
tuiButton
|
|
92
|
-
(click)="clearFilter()"
|
|
93
|
-
>
|
|
94
|
-
Clear
|
|
95
|
-
</button>
|
|
96
|
-
}
|
|
97
|
-
</div>
|
|
98
|
-
</ng-template>
|
|
99
|
-
}
|
|
100
|
-
`
|
|
101
|
-
})
|
|
102
|
-
export class TableSelectFilter {
|
|
103
|
-
@Input() tuiThSelectFilter!: string;
|
|
104
|
-
|
|
105
|
-
filterApplied = signal<boolean>(false);
|
|
106
|
-
filterVisible = signal<boolean>(false);
|
|
107
|
-
|
|
108
|
-
table : FloatTable;
|
|
109
|
-
|
|
110
|
-
@Input() options : string[] = [];
|
|
111
|
-
selected : string[] = [];
|
|
112
|
-
filterType : any;
|
|
113
|
-
filterTypes : any[];
|
|
114
|
-
|
|
115
|
-
protected readonly stringify = (item: any): string => `${item.label}`;
|
|
116
|
-
|
|
117
|
-
constructor(table : FloatTable){
|
|
118
|
-
this.table = table;
|
|
119
|
-
|
|
120
|
-
this.filterTypes = [
|
|
121
|
-
{
|
|
122
|
-
label: 'Contains',
|
|
123
|
-
expression: 'sel;con'
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
label: 'Not Contains',
|
|
127
|
-
expression: 'sel;ncon'
|
|
128
|
-
}
|
|
129
|
-
];
|
|
130
|
-
this.filterType = this.filterTypes[0];
|
|
131
|
-
|
|
132
|
-
this.table.onPresetChange.subscribe(x => {
|
|
133
|
-
if (!x)
|
|
134
|
-
{
|
|
135
|
-
this.filterType = this.filterTypes[0];
|
|
136
|
-
this.selected = [];
|
|
137
|
-
this.filterApplied.set(false);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
var filter = x.filters.find(x => x.column == this.tuiThSelectFilter);
|
|
141
|
-
if (!filter)
|
|
142
|
-
{
|
|
143
|
-
this.filterType = this.filterTypes[0];
|
|
144
|
-
this.selected = [];
|
|
145
|
-
this.filterApplied.set(false);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
var type = this.filterTypes.find(x => x.expression == filter!.expression);
|
|
149
|
-
if (!type)
|
|
150
|
-
{
|
|
151
|
-
this.filterType = this.filterTypes[0];
|
|
152
|
-
this.selected = [];
|
|
153
|
-
this.filterApplied.set(false);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.filterType = type;
|
|
158
|
-
this.selected = filter.value;
|
|
159
|
-
this.filterApplied.set(true);
|
|
160
|
-
})
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
applyFilter(expression : string){
|
|
164
|
-
this.table.setFilter({
|
|
165
|
-
column: this.tuiThSelectFilter,
|
|
166
|
-
value: this.selected,
|
|
167
|
-
expression: expression,
|
|
168
|
-
} as FloatTableFilter);
|
|
169
|
-
this.filterVisible.set(false);
|
|
170
|
-
this.filterApplied.set(true);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
clearFilter(){
|
|
174
|
-
this.table.clearFilter(this.tuiThSelectFilter);
|
|
175
|
-
this.filterVisible.set(false);
|
|
176
|
-
this.filterApplied.set(false);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from "@angular/common";
|
|
2
|
-
import { Component, Input, signal } from "@angular/core";
|
|
3
|
-
import { FormsModule } from "@angular/forms";
|
|
4
|
-
import { TuiButton, TuiDropdown, TuiInput } from "@taiga-ui/core";
|
|
5
|
-
import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiStringifyContentPipe } from "@taiga-ui/kit";
|
|
6
|
-
import { FloatTable } from "../floattable";
|
|
7
|
-
import { FloatTableFilter } from "../models/FloatTableFilter";
|
|
8
|
-
|
|
9
|
-
@Component({
|
|
10
|
-
selector: 'tuiThTextFilter',
|
|
11
|
-
imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput],
|
|
12
|
-
template: `
|
|
13
|
-
@if(tuiThTextFilter){
|
|
14
|
-
<tui-badged-content>
|
|
15
|
-
@if(filterApplied()){
|
|
16
|
-
<tui-badge-notification
|
|
17
|
-
size="s"
|
|
18
|
-
tuiSlot="top"
|
|
19
|
-
>
|
|
20
|
-
1
|
|
21
|
-
</tui-badge-notification>
|
|
22
|
-
}
|
|
23
|
-
<button
|
|
24
|
-
tuiButton size="s"
|
|
25
|
-
iconStart="funnel"
|
|
26
|
-
appearance="flat-grayscale"
|
|
27
|
-
style="opacity:0.72"
|
|
28
|
-
[tuiDropdown]="filterPop"
|
|
29
|
-
[(tuiDropdownOpen)]="filterVisible"
|
|
30
|
-
(click)="filterVisible.set(true)"
|
|
31
|
-
></button>
|
|
32
|
-
</tui-badged-content>
|
|
33
|
-
|
|
34
|
-
<ng-template #filterPop>
|
|
35
|
-
<div class="flex flex-col gap-2 p-4" style="min-width:20rem">
|
|
36
|
-
<button
|
|
37
|
-
appearance="outline-grayscale"
|
|
38
|
-
size="s"
|
|
39
|
-
tuiButton
|
|
40
|
-
tuiButtonSelect
|
|
41
|
-
[(ngModel)]="filterType"
|
|
42
|
-
>
|
|
43
|
-
{{ filterType.label }}
|
|
44
|
-
<tui-data-list-wrapper
|
|
45
|
-
*tuiDropdown
|
|
46
|
-
[itemContent]="stringify | tuiStringifyContent"
|
|
47
|
-
[items]="filterTypes"
|
|
48
|
-
/>
|
|
49
|
-
</button>
|
|
50
|
-
|
|
51
|
-
<tui-textfield tuiTextfieldSize="s" (keydown.enter)="applyFilter(filterType.expression)">
|
|
52
|
-
<input tuiInput [(ngModel)]="value"/>
|
|
53
|
-
</tui-textfield>
|
|
54
|
-
<button
|
|
55
|
-
tuiButton size="s"
|
|
56
|
-
iconStart="funnel"
|
|
57
|
-
tuiButton
|
|
58
|
-
(click)="applyFilter(filterType.expression)"
|
|
59
|
-
>
|
|
60
|
-
Apply
|
|
61
|
-
</button>
|
|
62
|
-
|
|
63
|
-
@if(filterApplied()){
|
|
64
|
-
<button
|
|
65
|
-
tuiButton size="s"
|
|
66
|
-
iconStart="circle-x"
|
|
67
|
-
tuiButton
|
|
68
|
-
(click)="clearFilter()"
|
|
69
|
-
>
|
|
70
|
-
Clear
|
|
71
|
-
</button>
|
|
72
|
-
}
|
|
73
|
-
</div>
|
|
74
|
-
</ng-template>
|
|
75
|
-
}
|
|
76
|
-
`
|
|
77
|
-
})
|
|
78
|
-
export class TableTextFilter {
|
|
79
|
-
@Input() tuiThTextFilter!: string;
|
|
80
|
-
|
|
81
|
-
filterApplied = signal<boolean>(false);
|
|
82
|
-
filterVisible = signal<boolean>(false);
|
|
83
|
-
|
|
84
|
-
table : FloatTable;
|
|
85
|
-
|
|
86
|
-
value : string = '';
|
|
87
|
-
filterType : any;
|
|
88
|
-
filterTypes : any[];
|
|
89
|
-
|
|
90
|
-
protected readonly stringify = (item: any): string => `${item.label}`;
|
|
91
|
-
|
|
92
|
-
constructor(table : FloatTable){
|
|
93
|
-
this.table = table;
|
|
94
|
-
|
|
95
|
-
this.filterTypes = [
|
|
96
|
-
{
|
|
97
|
-
label: 'Contains',
|
|
98
|
-
expression: 'str;con'
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
label: 'Not Contains',
|
|
102
|
-
expression: 'str;ncon'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
label: 'Starts With',
|
|
106
|
-
expression: 'str;sta'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: 'Ends With',
|
|
110
|
-
expression: 'str;end'
|
|
111
|
-
}
|
|
112
|
-
];
|
|
113
|
-
this.filterType = this.filterTypes[0];
|
|
114
|
-
|
|
115
|
-
this.table.onPresetChange.subscribe(x => {
|
|
116
|
-
if (!x)
|
|
117
|
-
{
|
|
118
|
-
this.filterType = this.filterTypes[0];
|
|
119
|
-
this.value = "";
|
|
120
|
-
this.filterApplied.set(false);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
var filter = x.filters.find(x => x.column == this.tuiThTextFilter);
|
|
124
|
-
if (!filter)
|
|
125
|
-
{
|
|
126
|
-
this.filterType = this.filterTypes[0];
|
|
127
|
-
this.value = "";
|
|
128
|
-
this.filterApplied.set(false);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
var type = this.filterTypes.find(x => x.expression == filter!.expression);
|
|
132
|
-
if (!type)
|
|
133
|
-
{
|
|
134
|
-
this.filterType = this.filterTypes[0];
|
|
135
|
-
this.value = "";
|
|
136
|
-
this.filterApplied.set(false);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
this.filterType = type;
|
|
141
|
-
this.value = filter.value;
|
|
142
|
-
this.filterApplied.set(true);
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
applyFilter(expression : string){
|
|
147
|
-
this.table.setFilter({
|
|
148
|
-
column: this.tuiThTextFilter,
|
|
149
|
-
value: this.value,
|
|
150
|
-
expression: expression,
|
|
151
|
-
} as FloatTableFilter);
|
|
152
|
-
this.filterVisible.set(false);
|
|
153
|
-
this.filterApplied.set(true);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
clearFilter(){
|
|
157
|
-
this.table.clearFilter(this.tuiThTextFilter);
|
|
158
|
-
this.filterVisible.set(false);
|
|
159
|
-
this.filterApplied.set(false);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
|
-
import { Component, EventEmitter, Input, OnChanges, Output, signal, SimpleChanges } from '@angular/core';
|
|
3
|
-
import { FormsModule } from '@angular/forms';
|
|
4
|
-
import { TuiButton, TuiGroup, TuiHint, TuiInput, TuiScrollbar } from "@taiga-ui/core";
|
|
5
|
-
import { TuiBadge, TuiStatus } from '@taiga-ui/kit';
|
|
6
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
7
|
-
import { FloatTable } from './floattable';
|
|
8
|
-
import { FloatTableSortFilterPreset } from './models/FloatTableSortFilterPreset';
|
|
9
|
-
import { FloatTableSortFilterPresetSave } from './models/FloatTableSortFilterPresetSave';
|
|
10
|
-
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'app-floattable-presets',
|
|
13
|
-
imports: [FormsModule, CommonModule, TuiScrollbar, TuiButton, TuiGroup, TuiBadge, TuiStatus, TuiInput, TuiHint],
|
|
14
|
-
template: `
|
|
15
|
-
<button tuiButton iconStart="plus" size="s" appearance="secondary" (click)="createPreset()" tuiHint="Create new preset from current filters"></button>
|
|
16
|
-
|
|
17
|
-
<tui-scrollbar class="w-full">
|
|
18
|
-
@let current = currentPreset();
|
|
19
|
-
@for(preset of presets(); track preset.id){
|
|
20
|
-
<div tuiGroup [collapsed]="true" [rounded]="true">
|
|
21
|
-
@let isActive = current?.id == preset.id;
|
|
22
|
-
@if(isActive){
|
|
23
|
-
@if(preset.edit){
|
|
24
|
-
<tui-textfield style="width:10rem" tuiTextfieldSize="s" (keydown.enter)="preset.edit = false;saveCurrentPreset()">
|
|
25
|
-
<input tuiInput [(ngModel)]="preset.name"/>
|
|
26
|
-
</tui-textfield>
|
|
27
|
-
<button style="flex: 0 0 auto;" tuiButton iconStart="save" size="s" appearance="info" (click)="preset.edit = false;saveCurrentPreset()" tuiHint="Save"></button>
|
|
28
|
-
}
|
|
29
|
-
@else {
|
|
30
|
-
<div class="h-full" appearance="positive" tuiBadge tuiStatus>
|
|
31
|
-
{{preset.name}}
|
|
32
|
-
</div>
|
|
33
|
-
<button style="flex: 0 0 auto;" tuiButton iconStart="square-pen" size="s" appearance="info" (click)="preset.edit = true" tuiHint="Edit"></button>
|
|
34
|
-
}
|
|
35
|
-
<button style="flex: 0 0 auto;" tuiButton iconStart="x" size="s" appearance="negative" (click)="removePreset(preset.id)" tuiHint="Delete"></button>
|
|
36
|
-
}
|
|
37
|
-
@else {
|
|
38
|
-
<button style="flex: 0 0 auto;" tuiButton appearance="secondary" size="s" (click)="selectPreset(preset.id)">{{preset.name}}</button>
|
|
39
|
-
}
|
|
40
|
-
</div>
|
|
41
|
-
}
|
|
42
|
-
</tui-scrollbar>
|
|
43
|
-
`,
|
|
44
|
-
host: {
|
|
45
|
-
class:'flex flex-row gap-2 p-2',
|
|
46
|
-
style:"padding-bottom:0px;padding-top:0px"
|
|
47
|
-
},
|
|
48
|
-
styles: `
|
|
49
|
-
::ng-deep tui-scrollbar {
|
|
50
|
-
> .t-content {
|
|
51
|
-
display:flex;
|
|
52
|
-
gap:10px;
|
|
53
|
-
width:0px;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
`
|
|
57
|
-
})
|
|
58
|
-
export class FloatTablePresets implements OnChanges {
|
|
59
|
-
@Input() storageKey: string | null = null;
|
|
60
|
-
currentPreset = signal<FloatTableSortFilterPreset | null>(null);
|
|
61
|
-
presets = signal<FloatTableSortFilterPreset[]>([])
|
|
62
|
-
|
|
63
|
-
constructor(private table : FloatTable){
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async ngOnChanges(changes: SimpleChanges) {
|
|
68
|
-
if (changes['storageKey'] && changes['storageKey'].previousValue != changes['storageKey'].currentValue) {
|
|
69
|
-
this.storageKey = changes['storageKey'].currentValue;
|
|
70
|
-
if (this.storageKey){
|
|
71
|
-
var item = localStorage.getItem(this.storageKey)
|
|
72
|
-
if (item){
|
|
73
|
-
var parsed : FloatTableSortFilterPresetSave = JSON.parse(item)
|
|
74
|
-
if (parsed){
|
|
75
|
-
this.presets.set(parsed.presets);
|
|
76
|
-
if (parsed.current){
|
|
77
|
-
var target = (parsed.presets).find(x => x.id == parsed.current);
|
|
78
|
-
if (target)
|
|
79
|
-
this.selectPreset(target.id)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
ngOnInit(){
|
|
88
|
-
setTimeout(
|
|
89
|
-
() => {
|
|
90
|
-
var current = this.currentPreset();
|
|
91
|
-
if (current)
|
|
92
|
-
this.onPresetChange.emit(current);
|
|
93
|
-
},
|
|
94
|
-
500
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@Output() onPresetChange: EventEmitter<FloatTableSortFilterPreset | null> = new EventEmitter<FloatTableSortFilterPreset | null>();
|
|
99
|
-
|
|
100
|
-
saveCurrentPreset(){
|
|
101
|
-
var currentPreset = this.currentPreset();
|
|
102
|
-
if (currentPreset){
|
|
103
|
-
currentPreset.sorts = [...this.table.sorts()];
|
|
104
|
-
currentPreset.filters = [...this.table.filters()];
|
|
105
|
-
this.currentPreset.set(currentPreset);
|
|
106
|
-
|
|
107
|
-
var presets = this.presets();
|
|
108
|
-
var target = this.presets().findIndex(x => x.id == currentPreset?.id)
|
|
109
|
-
if (target != -1)
|
|
110
|
-
presets[target] = currentPreset;
|
|
111
|
-
this.presets.set(presets);
|
|
112
|
-
|
|
113
|
-
this.savePresets();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
selectPreset(id : string){
|
|
118
|
-
var presets = this.presets();
|
|
119
|
-
var target = presets.findIndex(x => x.id == id);
|
|
120
|
-
if (target != -1)
|
|
121
|
-
{
|
|
122
|
-
var preset = presets[target];
|
|
123
|
-
this.currentPreset.set(preset);
|
|
124
|
-
this.table.sorts.set(preset.sorts);
|
|
125
|
-
this.table.filters.set(preset.filters);
|
|
126
|
-
this.onPresetChange.emit(preset);
|
|
127
|
-
this.table.applyFilter();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.savePresets();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
createPreset(){
|
|
134
|
-
this.saveCurrentPreset();
|
|
135
|
-
|
|
136
|
-
var preset = {
|
|
137
|
-
id: uuidv4(),
|
|
138
|
-
name: 'New Preset',
|
|
139
|
-
sorts : [...this.table.sorts()],
|
|
140
|
-
filters: [...this.table.filters()]
|
|
141
|
-
} as FloatTableSortFilterPreset
|
|
142
|
-
this.currentPreset.set(preset);
|
|
143
|
-
|
|
144
|
-
var presets = this.presets();
|
|
145
|
-
presets.push(preset);
|
|
146
|
-
this.presets.set(presets);
|
|
147
|
-
|
|
148
|
-
this.savePresets();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
removePreset(id : string){
|
|
152
|
-
var presets = this.presets();
|
|
153
|
-
var target = presets.findIndex(x => x.id == id);
|
|
154
|
-
if (target != -1)
|
|
155
|
-
presets.splice(target, 1);
|
|
156
|
-
this.presets.set(presets);
|
|
157
|
-
|
|
158
|
-
var current = this.currentPreset();
|
|
159
|
-
if (current?.id == id){
|
|
160
|
-
if (presets.length > 0)
|
|
161
|
-
{
|
|
162
|
-
this.currentPreset.set(presets[0]);
|
|
163
|
-
this.onPresetChange.emit(presets[0]);
|
|
164
|
-
}
|
|
165
|
-
else
|
|
166
|
-
{
|
|
167
|
-
this.currentPreset.set(null);
|
|
168
|
-
this.onPresetChange.emit(null);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
this.savePresets();
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
savePresets(){
|
|
177
|
-
if(this.storageKey){
|
|
178
|
-
var saveBody = {
|
|
179
|
-
current: this.currentPreset()?.id,
|
|
180
|
-
presets: [...this.presets()]
|
|
181
|
-
} as FloatTableSortFilterPresetSave
|
|
182
|
-
localStorage.setItem(
|
|
183
|
-
this.storageKey,
|
|
184
|
-
JSON.stringify(saveBody));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
clearFilters(){
|
|
189
|
-
this.currentPreset.set(null);
|
|
190
|
-
this.onPresetChange.emit(null);
|
|
191
|
-
this.table.sorts.set([])
|
|
192
|
-
this.table.filters.set([])
|
|
193
|
-
this.savePresets();
|
|
194
|
-
this.table.applyFilter();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|