@kris701/ez-ui 1.1.9 → 1.1.11
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.
|
@@ -3246,30 +3246,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
3246
3246
|
}] } });
|
|
3247
3247
|
|
|
3248
3248
|
class EzUIFilterHelpers {
|
|
3249
|
-
static
|
|
3249
|
+
static genericFilter(values, fn, column) {
|
|
3250
3250
|
const filtered = [];
|
|
3251
3251
|
for (const value of values) {
|
|
3252
|
-
const
|
|
3253
|
-
if (
|
|
3254
|
-
|
|
3252
|
+
const base = value[column];
|
|
3253
|
+
if (Array.isArray(base)) {
|
|
3254
|
+
for (let item of base) {
|
|
3255
|
+
const asGeneric = item;
|
|
3256
|
+
if (fn(asGeneric)) {
|
|
3257
|
+
filtered.push(value);
|
|
3258
|
+
break;
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
else {
|
|
3263
|
+
const asGeneric = base;
|
|
3264
|
+
if (fn(asGeneric))
|
|
3265
|
+
filtered.push(value);
|
|
3266
|
+
}
|
|
3255
3267
|
}
|
|
3256
3268
|
return filtered;
|
|
3257
3269
|
}
|
|
3258
3270
|
static dateFilter(values, fn, column) {
|
|
3259
3271
|
const filtered = [];
|
|
3260
3272
|
for (const value of values) {
|
|
3261
|
-
const
|
|
3262
|
-
if (
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
+
const base = value[column];
|
|
3274
|
+
if (Array.isArray(base)) {
|
|
3275
|
+
for (let item of base) {
|
|
3276
|
+
const asDate = new Date(item);
|
|
3277
|
+
if (fn(asDate)) {
|
|
3278
|
+
filtered.push(value);
|
|
3279
|
+
break;
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
else {
|
|
3284
|
+
const asDate = new Date(base);
|
|
3285
|
+
if (fn(asDate))
|
|
3286
|
+
filtered.push(value);
|
|
3287
|
+
}
|
|
3273
3288
|
}
|
|
3274
3289
|
return filtered;
|
|
3275
3290
|
}
|
|
@@ -3303,33 +3318,33 @@ class EzUITableFilterService {
|
|
|
3303
3318
|
{
|
|
3304
3319
|
key: 'str',
|
|
3305
3320
|
action: 'con',
|
|
3306
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3321
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => i.includes(value), column)
|
|
3307
3322
|
},
|
|
3308
3323
|
{
|
|
3309
3324
|
key: 'str',
|
|
3310
3325
|
action: 'ncon',
|
|
3311
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3326
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => !i.includes(value), column)
|
|
3312
3327
|
},
|
|
3313
3328
|
{
|
|
3314
3329
|
key: 'str',
|
|
3315
3330
|
action: 'sta',
|
|
3316
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3331
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => i.startsWith(value), column)
|
|
3317
3332
|
},
|
|
3318
3333
|
{
|
|
3319
3334
|
key: 'str',
|
|
3320
3335
|
action: 'end',
|
|
3321
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3336
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => i.endsWith(value), column)
|
|
3322
3337
|
},
|
|
3323
3338
|
// Select filters
|
|
3324
3339
|
{
|
|
3325
3340
|
key: 'sel',
|
|
3326
3341
|
action: 'con',
|
|
3327
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3342
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => value.includes(i), column)
|
|
3328
3343
|
},
|
|
3329
3344
|
{
|
|
3330
3345
|
key: 'sel',
|
|
3331
3346
|
action: 'ncon',
|
|
3332
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3347
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => !value.includes(i), column)
|
|
3333
3348
|
},
|
|
3334
3349
|
// Date filters
|
|
3335
3350
|
{
|
|
@@ -3354,7 +3369,7 @@ class EzUITableFilterService {
|
|
|
3354
3369
|
{
|
|
3355
3370
|
key: 'bol',
|
|
3356
3371
|
action: 'true',
|
|
3357
|
-
filter: (values, column, value) => EzUIFilterHelpers.
|
|
3372
|
+
filter: (values, column, value) => EzUIFilterHelpers.genericFilter(values, (i) => i === value, column)
|
|
3358
3373
|
},
|
|
3359
3374
|
];
|
|
3360
3375
|
sort(values, sort) {
|
|
@@ -4122,11 +4137,28 @@ class EzUITableSelectFilter {
|
|
|
4122
4137
|
filterVisible = signal(false, /* @ts-ignore */
|
|
4123
4138
|
...(ngDevMode ? [{ debugName: "filterVisible" }] : /* istanbul ignore next */ []));
|
|
4124
4139
|
table;
|
|
4140
|
+
optionLabel = undefined;
|
|
4141
|
+
optionValue = undefined;
|
|
4125
4142
|
options = [];
|
|
4126
4143
|
selected = [];
|
|
4127
4144
|
filterType;
|
|
4128
4145
|
filterTypes;
|
|
4129
|
-
|
|
4146
|
+
stringifyOption = (item) => `${item.label}`;
|
|
4147
|
+
stringifyValue = (value) => this.getOptionLabel(this.options.find((item) => this.getOptionValue(item) === value));
|
|
4148
|
+
getOptionLabel(item) {
|
|
4149
|
+
if (!item)
|
|
4150
|
+
return "";
|
|
4151
|
+
if (this.optionLabel == undefined || this.optionLabel == '')
|
|
4152
|
+
return item;
|
|
4153
|
+
return item[this.optionLabel];
|
|
4154
|
+
}
|
|
4155
|
+
getOptionValue(item) {
|
|
4156
|
+
if (!item)
|
|
4157
|
+
return "";
|
|
4158
|
+
if (this.optionValue == undefined || this.optionValue == '')
|
|
4159
|
+
return item;
|
|
4160
|
+
return item[this.optionValue];
|
|
4161
|
+
}
|
|
4130
4162
|
constructor(table) {
|
|
4131
4163
|
this.table = table;
|
|
4132
4164
|
this.filterTypes = [
|
|
@@ -4181,7 +4213,7 @@ class EzUITableSelectFilter {
|
|
|
4181
4213
|
this.filterApplied.set(false);
|
|
4182
4214
|
}
|
|
4183
4215
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: EzUITableSelectFilter, deps: [{ token: EzUITable }], target: i0.ɵɵFactoryTarget.Component });
|
|
4184
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: EzUITableSelectFilter, isStandalone: true, selector: "ezui-table-selectfilter", inputs: { column: "column", options: "options" }, ngImport: i0, template: `
|
|
4216
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: EzUITableSelectFilter, isStandalone: true, selector: "ezui-table-selectfilter", inputs: { column: "column", optionLabel: "optionLabel", optionValue: "optionValue", options: "options" }, ngImport: i0, template: `
|
|
4185
4217
|
@if(column){
|
|
4186
4218
|
<tui-badged-content>
|
|
4187
4219
|
@if(filterApplied()){
|
|
@@ -4215,7 +4247,7 @@ class EzUITableSelectFilter {
|
|
|
4215
4247
|
{{ filterType.label }}
|
|
4216
4248
|
<tui-data-list-wrapper
|
|
4217
4249
|
*tuiDropdown
|
|
4218
|
-
[itemContent]="
|
|
4250
|
+
[itemContent]="stringifyOption | tuiStringifyContent"
|
|
4219
4251
|
[items]="filterTypes"
|
|
4220
4252
|
/>
|
|
4221
4253
|
</button>
|
|
@@ -4227,20 +4259,20 @@ class EzUITableSelectFilter {
|
|
|
4227
4259
|
tuiButtonSelect
|
|
4228
4260
|
[(ngModel)]="selected"
|
|
4229
4261
|
>
|
|
4230
|
-
{{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
|
|
4262
|
+
{{selected.length === 1 ? stringifyValue(selected[0]) : 'Selected ' + selected.length}}
|
|
4231
4263
|
|
|
4232
4264
|
<tui-data-list *tuiDropdown>
|
|
4233
4265
|
<tui-opt-group
|
|
4234
4266
|
label="Options"
|
|
4235
4267
|
tuiMultiSelectGroup
|
|
4236
4268
|
>
|
|
4237
|
-
@for (option of options; track option) {
|
|
4269
|
+
@for (option of options; track getOptionValue(option)) {
|
|
4238
4270
|
<button
|
|
4239
4271
|
tuiOption
|
|
4240
4272
|
type="button"
|
|
4241
|
-
[value]="option"
|
|
4273
|
+
[value]="getOptionValue(option)"
|
|
4242
4274
|
>
|
|
4243
|
-
{{ option }}
|
|
4275
|
+
{{ getOptionLabel(option) }}
|
|
4244
4276
|
</button>
|
|
4245
4277
|
}
|
|
4246
4278
|
</tui-opt-group>
|
|
@@ -4308,7 +4340,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
4308
4340
|
{{ filterType.label }}
|
|
4309
4341
|
<tui-data-list-wrapper
|
|
4310
4342
|
*tuiDropdown
|
|
4311
|
-
[itemContent]="
|
|
4343
|
+
[itemContent]="stringifyOption | tuiStringifyContent"
|
|
4312
4344
|
[items]="filterTypes"
|
|
4313
4345
|
/>
|
|
4314
4346
|
</button>
|
|
@@ -4320,20 +4352,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
4320
4352
|
tuiButtonSelect
|
|
4321
4353
|
[(ngModel)]="selected"
|
|
4322
4354
|
>
|
|
4323
|
-
{{selected.length === 1 ? selected[0] : 'Selected ' + selected.length}}
|
|
4355
|
+
{{selected.length === 1 ? stringifyValue(selected[0]) : 'Selected ' + selected.length}}
|
|
4324
4356
|
|
|
4325
4357
|
<tui-data-list *tuiDropdown>
|
|
4326
4358
|
<tui-opt-group
|
|
4327
4359
|
label="Options"
|
|
4328
4360
|
tuiMultiSelectGroup
|
|
4329
4361
|
>
|
|
4330
|
-
@for (option of options; track option) {
|
|
4362
|
+
@for (option of options; track getOptionValue(option)) {
|
|
4331
4363
|
<button
|
|
4332
4364
|
tuiOption
|
|
4333
4365
|
type="button"
|
|
4334
|
-
[value]="option"
|
|
4366
|
+
[value]="getOptionValue(option)"
|
|
4335
4367
|
>
|
|
4336
|
-
{{ option }}
|
|
4368
|
+
{{ getOptionLabel(option) }}
|
|
4337
4369
|
</button>
|
|
4338
4370
|
}
|
|
4339
4371
|
</tui-opt-group>
|
|
@@ -4366,6 +4398,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
4366
4398
|
`, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"] }]
|
|
4367
4399
|
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
4368
4400
|
type: Input
|
|
4401
|
+
}], optionLabel: [{
|
|
4402
|
+
type: Input
|
|
4403
|
+
}], optionValue: [{
|
|
4404
|
+
type: Input
|
|
4369
4405
|
}], options: [{
|
|
4370
4406
|
type: Input
|
|
4371
4407
|
}] } });
|