@kris701/ez-ui 1.1.9 → 1.1.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.
|
@@ -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,27 @@ 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
|
-
stringify = (item) =>
|
|
4146
|
+
stringify = (value) => this.getOptionLabel(this.options.find((item) => this.getOptionValue(item) === value));
|
|
4147
|
+
getOptionLabel(item) {
|
|
4148
|
+
if (!item)
|
|
4149
|
+
return "";
|
|
4150
|
+
if (this.optionLabel == undefined || this.optionLabel == '')
|
|
4151
|
+
return item;
|
|
4152
|
+
return item[this.optionLabel];
|
|
4153
|
+
}
|
|
4154
|
+
getOptionValue(item) {
|
|
4155
|
+
if (!item)
|
|
4156
|
+
return "";
|
|
4157
|
+
if (this.optionValue == undefined || this.optionValue == '')
|
|
4158
|
+
return item;
|
|
4159
|
+
return item[this.optionValue];
|
|
4160
|
+
}
|
|
4130
4161
|
constructor(table) {
|
|
4131
4162
|
this.table = table;
|
|
4132
4163
|
this.filterTypes = [
|
|
@@ -4181,7 +4212,7 @@ class EzUITableSelectFilter {
|
|
|
4181
4212
|
this.filterApplied.set(false);
|
|
4182
4213
|
}
|
|
4183
4214
|
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: `
|
|
4215
|
+
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
4216
|
@if(column){
|
|
4186
4217
|
<tui-badged-content>
|
|
4187
4218
|
@if(filterApplied()){
|
|
@@ -4234,13 +4265,13 @@ class EzUITableSelectFilter {
|
|
|
4234
4265
|
label="Options"
|
|
4235
4266
|
tuiMultiSelectGroup
|
|
4236
4267
|
>
|
|
4237
|
-
@for (option of options; track option) {
|
|
4268
|
+
@for (option of options; track getOptionValue(option)) {
|
|
4238
4269
|
<button
|
|
4239
4270
|
tuiOption
|
|
4240
4271
|
type="button"
|
|
4241
|
-
[value]="option"
|
|
4272
|
+
[value]="getOptionValue(option)"
|
|
4242
4273
|
>
|
|
4243
|
-
{{ option }}
|
|
4274
|
+
{{ getOptionLabel(option) }}
|
|
4244
4275
|
</button>
|
|
4245
4276
|
}
|
|
4246
4277
|
</tui-opt-group>
|
|
@@ -4327,13 +4358,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
4327
4358
|
label="Options"
|
|
4328
4359
|
tuiMultiSelectGroup
|
|
4329
4360
|
>
|
|
4330
|
-
@for (option of options; track option) {
|
|
4361
|
+
@for (option of options; track getOptionValue(option)) {
|
|
4331
4362
|
<button
|
|
4332
4363
|
tuiOption
|
|
4333
4364
|
type="button"
|
|
4334
|
-
[value]="option"
|
|
4365
|
+
[value]="getOptionValue(option)"
|
|
4335
4366
|
>
|
|
4336
|
-
{{ option }}
|
|
4367
|
+
{{ getOptionLabel(option) }}
|
|
4337
4368
|
</button>
|
|
4338
4369
|
}
|
|
4339
4370
|
</tui-opt-group>
|
|
@@ -4366,6 +4397,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImpor
|
|
|
4366
4397
|
`, styles: [".filterPopContainer{display:flex;flex-direction:column;gap:10px;padding:10px;min-width:20rem}\n"] }]
|
|
4367
4398
|
}], ctorParameters: () => [{ type: EzUITable }], propDecorators: { column: [{
|
|
4368
4399
|
type: Input
|
|
4400
|
+
}], optionLabel: [{
|
|
4401
|
+
type: Input
|
|
4402
|
+
}], optionValue: [{
|
|
4403
|
+
type: Input
|
|
4369
4404
|
}], options: [{
|
|
4370
4405
|
type: Input
|
|
4371
4406
|
}] } });
|