@kris701/ez-ui 0.0.2 → 0.0.4
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/ng-package.json +9 -1
- package/package.json +1 -1
- package/src/components/floattable/filters/tuiThDateFilter.ts +159 -159
- package/src/components/floattable/filters/tuiThSelectFilter.ts +178 -178
- package/src/components/floattable/filters/tuiThTextFilter.ts +161 -161
- package/src/components/floattable/floattable.presets.ts +197 -197
- package/src/components/floattable/helpers/floattable.filterhelpers.ts +23 -23
- package/src/components/floattable/models/FloatTableFilter.ts +5 -5
- package/src/components/floattable/models/FloatTableFilterMethod.ts +5 -5
- package/src/components/floattable/models/FloatTableSort.ts +4 -4
- package/src/components/floattable/models/FloatTableSortFilterPreset.ts +10 -10
- package/src/components/floattable/models/FloatTableSortFilterPresetSave.ts +6 -6
- package/src/components/floattable/models/FloatTableSortMethod.ts +4 -4
- package/src/components/floattable/services/floattable.filterservice.ts +110 -110
- package/src/public-api.ts +15 -15
package/ng-package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,159 +1,159 @@
|
|
|
1
|
-
import { CommonModule } from "@angular/common";
|
|
2
|
-
import { Component, Input, signal } from "@angular/core";
|
|
3
|
-
import { FormsModule } from "@angular/forms";
|
|
4
|
-
import { TuiDay, TuiTime } from "@taiga-ui/cdk/date-time";
|
|
5
|
-
import { TuiButton, TuiDropdown, TuiInput } from "@taiga-ui/core";
|
|
6
|
-
import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiInputDateTime, TuiStringifyContentPipe } from "@taiga-ui/kit";
|
|
7
|
-
import { FloatTable } from "../floattable";
|
|
8
|
-
import { FloatTableFilter } from "../models/FloatTableFilter";
|
|
9
|
-
|
|
10
|
-
@Component({
|
|
11
|
-
selector: 'tuiThDateFilter',
|
|
12
|
-
imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiInputDateTime],
|
|
13
|
-
template: `
|
|
14
|
-
@if(tuiThDateFilter){
|
|
15
|
-
<tui-badged-content>
|
|
16
|
-
@if(filterApplied()){
|
|
17
|
-
<tui-badge-notification
|
|
18
|
-
size="s"
|
|
19
|
-
tuiSlot="top"
|
|
20
|
-
>
|
|
21
|
-
1
|
|
22
|
-
</tui-badge-notification>
|
|
23
|
-
}
|
|
24
|
-
<button
|
|
25
|
-
tuiButton size="s"
|
|
26
|
-
iconStart="funnel"
|
|
27
|
-
appearance="flat-grayscale"
|
|
28
|
-
style="opacity:0.72"
|
|
29
|
-
[tuiDropdown]="filterPop"
|
|
30
|
-
[(tuiDropdownOpen)]="filterVisible"
|
|
31
|
-
(click)="filterVisible.set(true)"
|
|
32
|
-
></button>
|
|
33
|
-
</tui-badged-content>
|
|
34
|
-
|
|
35
|
-
<ng-template #filterPop>
|
|
36
|
-
<div class="flex flex-col gap-2 p-4" style="min-width:20rem">
|
|
37
|
-
<button
|
|
38
|
-
appearance="outline-grayscale"
|
|
39
|
-
size="s"
|
|
40
|
-
tuiButton
|
|
41
|
-
tuiButtonSelect
|
|
42
|
-
[(ngModel)]="filterType"
|
|
43
|
-
>
|
|
44
|
-
{{ filterType.label }}
|
|
45
|
-
<tui-data-list-wrapper
|
|
46
|
-
*tuiDropdown
|
|
47
|
-
[itemContent]="stringify | tuiStringifyContent"
|
|
48
|
-
[items]="filterTypes"
|
|
49
|
-
/>
|
|
50
|
-
</button>
|
|
51
|
-
|
|
52
|
-
<tui-textfield (keydown.enter)="applyFilter(filterType.expression)">
|
|
53
|
-
<label tuiLabel>Choose a date</label>
|
|
54
|
-
<input
|
|
55
|
-
tuiInputDateTime
|
|
56
|
-
[(ngModel)]="value"
|
|
57
|
-
/>
|
|
58
|
-
<tui-calendar *tuiDropdown />
|
|
59
|
-
</tui-textfield>
|
|
60
|
-
<button
|
|
61
|
-
tuiButton size="s"
|
|
62
|
-
iconStart="funnel"
|
|
63
|
-
tuiButton
|
|
64
|
-
(click)="applyFilter(filterType.expression)"
|
|
65
|
-
>
|
|
66
|
-
Apply
|
|
67
|
-
</button>
|
|
68
|
-
|
|
69
|
-
@if(filterApplied()){
|
|
70
|
-
<button
|
|
71
|
-
tuiButton size="s"
|
|
72
|
-
iconStart="circle-x"
|
|
73
|
-
tuiButton
|
|
74
|
-
(click)="clearFilter()"
|
|
75
|
-
>
|
|
76
|
-
Clear
|
|
77
|
-
</button>
|
|
78
|
-
}
|
|
79
|
-
</div>
|
|
80
|
-
</ng-template>
|
|
81
|
-
}
|
|
82
|
-
`
|
|
83
|
-
})
|
|
84
|
-
export class TableDateFilter {
|
|
85
|
-
@Input() tuiThDateFilter!: string;
|
|
86
|
-
|
|
87
|
-
filterApplied = signal<boolean>(false);
|
|
88
|
-
filterVisible = signal<boolean>(false);
|
|
89
|
-
|
|
90
|
-
table : FloatTable;
|
|
91
|
-
|
|
92
|
-
value : [TuiDay, TuiTime] = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
93
|
-
filterType : any;
|
|
94
|
-
filterTypes : any[];
|
|
95
|
-
|
|
96
|
-
protected readonly stringify = (item: any): string => `${item.label}`;
|
|
97
|
-
|
|
98
|
-
constructor(table : FloatTable){
|
|
99
|
-
this.table = table;
|
|
100
|
-
|
|
101
|
-
this.filterTypes = [
|
|
102
|
-
{
|
|
103
|
-
label: 'After',
|
|
104
|
-
expression: 'dat;aft'
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
label: 'Before',
|
|
108
|
-
expression: 'dat;bef'
|
|
109
|
-
}
|
|
110
|
-
];
|
|
111
|
-
this.filterType = this.filterTypes[0];
|
|
112
|
-
|
|
113
|
-
this.table.onPresetChange.subscribe(x => {
|
|
114
|
-
if (!x)
|
|
115
|
-
{
|
|
116
|
-
this.filterType = this.filterTypes[0];
|
|
117
|
-
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
118
|
-
this.filterApplied.set(false);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
var filter = x.filters.find(x => x.column == this.tuiThDateFilter);
|
|
122
|
-
if (!filter)
|
|
123
|
-
{
|
|
124
|
-
this.filterType = this.filterTypes[0];
|
|
125
|
-
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
126
|
-
this.filterApplied.set(false);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
var type = this.filterTypes.find(x => x.expression == filter!.expression);
|
|
130
|
-
if (!type)
|
|
131
|
-
{
|
|
132
|
-
this.filterType = this.filterTypes[0];
|
|
133
|
-
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
134
|
-
this.filterApplied.set(false);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
this.filterType = type;
|
|
139
|
-
this.value = filter.value;
|
|
140
|
-
this.filterApplied.set(true);
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
applyFilter(expression : string){
|
|
145
|
-
this.table.setFilter({
|
|
146
|
-
column: this.tuiThDateFilter,
|
|
147
|
-
value: this.value,
|
|
148
|
-
expression: expression,
|
|
149
|
-
} as FloatTableFilter);
|
|
150
|
-
this.filterVisible.set(false);
|
|
151
|
-
this.filterApplied.set(true);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
clearFilter(){
|
|
155
|
-
this.table.clearFilter(this.tuiThDateFilter);
|
|
156
|
-
this.filterVisible.set(false);
|
|
157
|
-
this.filterApplied.set(false);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
1
|
+
import { CommonModule } from "@angular/common";
|
|
2
|
+
import { Component, Input, signal } from "@angular/core";
|
|
3
|
+
import { FormsModule } from "@angular/forms";
|
|
4
|
+
import { TuiDay, TuiTime } from "@taiga-ui/cdk/date-time";
|
|
5
|
+
import { TuiButton, TuiDropdown, TuiInput } from "@taiga-ui/core";
|
|
6
|
+
import { TuiBadgeNotification, TuiBadgedContent, TuiButtonSelect, TuiDataListWrapper, TuiInputDateTime, TuiStringifyContentPipe } from "@taiga-ui/kit";
|
|
7
|
+
import { FloatTable } from "../floattable";
|
|
8
|
+
import { FloatTableFilter } from "../models/FloatTableFilter";
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'tuiThDateFilter',
|
|
12
|
+
imports: [CommonModule, FormsModule, TuiDropdown, TuiDataListWrapper, TuiButton, TuiButtonSelect, TuiStringifyContentPipe, TuiBadgeNotification, TuiBadgedContent, TuiInput, TuiInputDateTime],
|
|
13
|
+
template: `
|
|
14
|
+
@if(tuiThDateFilter){
|
|
15
|
+
<tui-badged-content>
|
|
16
|
+
@if(filterApplied()){
|
|
17
|
+
<tui-badge-notification
|
|
18
|
+
size="s"
|
|
19
|
+
tuiSlot="top"
|
|
20
|
+
>
|
|
21
|
+
1
|
|
22
|
+
</tui-badge-notification>
|
|
23
|
+
}
|
|
24
|
+
<button
|
|
25
|
+
tuiButton size="s"
|
|
26
|
+
iconStart="funnel"
|
|
27
|
+
appearance="flat-grayscale"
|
|
28
|
+
style="opacity:0.72"
|
|
29
|
+
[tuiDropdown]="filterPop"
|
|
30
|
+
[(tuiDropdownOpen)]="filterVisible"
|
|
31
|
+
(click)="filterVisible.set(true)"
|
|
32
|
+
></button>
|
|
33
|
+
</tui-badged-content>
|
|
34
|
+
|
|
35
|
+
<ng-template #filterPop>
|
|
36
|
+
<div class="flex flex-col gap-2 p-4" style="min-width:20rem">
|
|
37
|
+
<button
|
|
38
|
+
appearance="outline-grayscale"
|
|
39
|
+
size="s"
|
|
40
|
+
tuiButton
|
|
41
|
+
tuiButtonSelect
|
|
42
|
+
[(ngModel)]="filterType"
|
|
43
|
+
>
|
|
44
|
+
{{ filterType.label }}
|
|
45
|
+
<tui-data-list-wrapper
|
|
46
|
+
*tuiDropdown
|
|
47
|
+
[itemContent]="stringify | tuiStringifyContent"
|
|
48
|
+
[items]="filterTypes"
|
|
49
|
+
/>
|
|
50
|
+
</button>
|
|
51
|
+
|
|
52
|
+
<tui-textfield (keydown.enter)="applyFilter(filterType.expression)">
|
|
53
|
+
<label tuiLabel>Choose a date</label>
|
|
54
|
+
<input
|
|
55
|
+
tuiInputDateTime
|
|
56
|
+
[(ngModel)]="value"
|
|
57
|
+
/>
|
|
58
|
+
<tui-calendar *tuiDropdown />
|
|
59
|
+
</tui-textfield>
|
|
60
|
+
<button
|
|
61
|
+
tuiButton size="s"
|
|
62
|
+
iconStart="funnel"
|
|
63
|
+
tuiButton
|
|
64
|
+
(click)="applyFilter(filterType.expression)"
|
|
65
|
+
>
|
|
66
|
+
Apply
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
@if(filterApplied()){
|
|
70
|
+
<button
|
|
71
|
+
tuiButton size="s"
|
|
72
|
+
iconStart="circle-x"
|
|
73
|
+
tuiButton
|
|
74
|
+
(click)="clearFilter()"
|
|
75
|
+
>
|
|
76
|
+
Clear
|
|
77
|
+
</button>
|
|
78
|
+
}
|
|
79
|
+
</div>
|
|
80
|
+
</ng-template>
|
|
81
|
+
}
|
|
82
|
+
`
|
|
83
|
+
})
|
|
84
|
+
export class TableDateFilter {
|
|
85
|
+
@Input() tuiThDateFilter!: string;
|
|
86
|
+
|
|
87
|
+
filterApplied = signal<boolean>(false);
|
|
88
|
+
filterVisible = signal<boolean>(false);
|
|
89
|
+
|
|
90
|
+
table : FloatTable;
|
|
91
|
+
|
|
92
|
+
value : [TuiDay, TuiTime] = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
93
|
+
filterType : any;
|
|
94
|
+
filterTypes : any[];
|
|
95
|
+
|
|
96
|
+
protected readonly stringify = (item: any): string => `${item.label}`;
|
|
97
|
+
|
|
98
|
+
constructor(table : FloatTable){
|
|
99
|
+
this.table = table;
|
|
100
|
+
|
|
101
|
+
this.filterTypes = [
|
|
102
|
+
{
|
|
103
|
+
label: 'After',
|
|
104
|
+
expression: 'dat;aft'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: 'Before',
|
|
108
|
+
expression: 'dat;bef'
|
|
109
|
+
}
|
|
110
|
+
];
|
|
111
|
+
this.filterType = this.filterTypes[0];
|
|
112
|
+
|
|
113
|
+
this.table.onPresetChange.subscribe(x => {
|
|
114
|
+
if (!x)
|
|
115
|
+
{
|
|
116
|
+
this.filterType = this.filterTypes[0];
|
|
117
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
118
|
+
this.filterApplied.set(false);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var filter = x.filters.find(x => x.column == this.tuiThDateFilter);
|
|
122
|
+
if (!filter)
|
|
123
|
+
{
|
|
124
|
+
this.filterType = this.filterTypes[0];
|
|
125
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
126
|
+
this.filterApplied.set(false);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
var type = this.filterTypes.find(x => x.expression == filter!.expression);
|
|
130
|
+
if (!type)
|
|
131
|
+
{
|
|
132
|
+
this.filterType = this.filterTypes[0];
|
|
133
|
+
this.value = [TuiDay.currentLocal(), TuiTime.currentLocal()];
|
|
134
|
+
this.filterApplied.set(false);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.filterType = type;
|
|
139
|
+
this.value = filter.value;
|
|
140
|
+
this.filterApplied.set(true);
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
applyFilter(expression : string){
|
|
145
|
+
this.table.setFilter({
|
|
146
|
+
column: this.tuiThDateFilter,
|
|
147
|
+
value: this.value,
|
|
148
|
+
expression: expression,
|
|
149
|
+
} as FloatTableFilter);
|
|
150
|
+
this.filterVisible.set(false);
|
|
151
|
+
this.filterApplied.set(true);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
clearFilter(){
|
|
155
|
+
this.table.clearFilter(this.tuiThDateFilter);
|
|
156
|
+
this.filterVisible.set(false);
|
|
157
|
+
this.filterApplied.set(false);
|
|
158
|
+
}
|
|
159
|
+
}
|