@mediusinc/mng-commons 5.3.0-rc.3 → 5.3.0-rc.5
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/core/data-list/data-list.model.d.ts +1 -1
- package/core/data-providers/lookup.data-provider.d.ts +5 -5
- package/core/descriptors/lookup.descriptor.d.ts +3 -3
- package/core/descriptors/table.descriptor.d.ts +1 -1
- package/esm2022/core/data-list/data-list-params-helpers.mjs +1 -1
- package/esm2022/core/data-list/data-list.model.mjs +1 -1
- package/esm2022/core/data-providers/lookup.data-provider.mjs +1 -1
- package/esm2022/core/descriptors/lookup.descriptor.mjs +1 -1
- package/esm2022/core/descriptors/table.descriptor.mjs +1 -1
- package/esm2022/filter/descriptors/filter-lookup.descriptor.mjs +60 -2
- package/esm2022/filter/descriptors/filter.descriptor.mjs +118 -8
- package/esm2022/form/api/data-providers/lookup-data-provider.factory.mjs +17 -6
- package/esm2022/form/api/data-providers/lookup.data-provider.mjs +1 -1
- package/esm2022/form/components/autocomplete/autocomplete.component.mjs +1 -1
- package/esm2022/form/components/dropdown/dropdown.component.mjs +1 -1
- package/esm2022/model/helpers/model.mjs +1 -1
- package/esm2022/table/api/data-providers/table-data-provider.factory.mjs +16 -7
- package/esm2022/table/api/descriptors/column.descriptor.mjs +125 -4
- package/esm2022/table/api/descriptors/sort.descriptor.mjs +23 -1
- package/esm2022/table/api/descriptors/table-descriptor.factory.mjs +1 -1
- package/esm2022/table/api/descriptors/table.descriptor.mjs +424 -43
- package/esm2022/table/api/helpers/table-data-provider-descriptor-convert.mjs +7 -0
- package/esm2022/table/api/index.mjs +2 -1
- package/esm2022/table/api/models/table-columns.model.mjs +1 -1
- package/esm2022/table/components/table/table.component.mjs +4 -4
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +6 -6
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +2 -2
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +1 -1
- package/esm2022/tableview/api/index.mjs +2 -1
- package/esm2022/tableview/api/tableview/data-providers/tableview-data-provider.factory.mjs +16 -7
- package/esm2022/tableview/api/tableview/descriptors/tableview-descriptor.factory.mjs +1 -1
- package/esm2022/tableview/api/tableview/descriptors/tableview.descriptor.mjs +5 -5
- package/esm2022/tableview/api/tableview/helpers/tableview-data-provider-descriptor-convert.mjs +7 -0
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +1 -1
- package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-filter.mjs +176 -8
- package/fesm2022/mediusinc-mng-commons-filter.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form-api.mjs +16 -5
- package/fesm2022/mediusinc-mng-commons-form-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-model.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table-api.mjs +591 -52
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +3 -3
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +32 -17
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
- package/filter/descriptors/filter-lookup.descriptor.d.ts +70 -12
- package/filter/descriptors/filter.descriptor.d.ts +116 -5
- package/form/api/data-providers/lookup-data-provider.factory.d.ts +16 -12
- package/form/api/data-providers/lookup.data-provider.d.ts +5 -5
- package/form/components/autocomplete/autocomplete.component.d.ts +1 -1
- package/form/components/dropdown/dropdown.component.d.ts +1 -1
- package/model/helpers/model.d.ts +1 -1
- package/package.json +1 -1
- package/table/api/data-providers/table-data-provider.factory.d.ts +9 -5
- package/table/api/descriptors/column.descriptor.d.ts +126 -5
- package/table/api/descriptors/sort.descriptor.d.ts +22 -0
- package/table/api/descriptors/table-descriptor.factory.d.ts +8 -4
- package/table/api/descriptors/table.descriptor.d.ts +421 -27
- package/table/api/helpers/table-data-provider-descriptor-convert.d.ts +20 -0
- package/table/api/index.d.ts +1 -0
- package/table/api/models/table-columns.model.d.ts +6 -6
- package/table/components/column-filter/column-filter.component.d.ts +1 -1
- package/table/components/filter/filter-form/filter-form.component.d.ts +1 -1
- package/tableview/action/components/localization/data-language-dropdown.component.d.ts +1 -1
- package/tableview/api/editor/descriptors/editor.descriptor.d.ts +11 -11
- package/tableview/api/editor/descriptors/field-base.descriptor.d.ts +1 -1
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +12 -12
- package/tableview/api/index.d.ts +1 -0
- package/tableview/api/tableview/data-providers/tableview-data-provider.factory.d.ts +9 -5
- package/tableview/api/tableview/descriptors/tableview-descriptor.factory.d.ts +10 -6
- package/tableview/api/tableview/descriptors/tableview.descriptor.d.ts +17 -17
- package/tableview/api/tableview/helpers/tableview-data-provider-descriptor-convert.d.ts +20 -0
- package/version-info.json +6 -6
|
@@ -51,18 +51,27 @@ class TableDataProvider extends TableDataProviderInst {
|
|
|
51
51
|
return tableDataProviderWithService(serviceType);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
function tableDataProvider(type,
|
|
55
|
-
|
|
54
|
+
function tableDataProvider(type, serviceTypeOrOpts,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
56
|
+
opts) {
|
|
57
|
+
if (serviceTypeOrOpts === undefined || typeof serviceTypeOrOpts === 'function') {
|
|
58
|
+
return new TableDataProviderInst(undefined, serviceTypeOrOpts);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return new TableDataProviderInst(undefined, undefined);
|
|
62
|
+
}
|
|
56
63
|
}
|
|
57
|
-
function tableDataProviderWithService(serviceType
|
|
64
|
+
function tableDataProviderWithService(serviceType,
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
+
opts) {
|
|
58
67
|
return new TableDataProviderInst(undefined, serviceType);
|
|
59
68
|
}
|
|
60
69
|
function tableDataProviderFromClass(type, serviceType) {
|
|
61
70
|
return new TableDataProviderInst(type, serviceType);
|
|
62
71
|
}
|
|
63
|
-
function tableDataProviderFromModel(model,
|
|
64
|
-
return typeof
|
|
65
|
-
? new TableDataProviderInst(model.type,
|
|
72
|
+
function tableDataProviderFromModel(model, serviceTypeOrOpts, opts) {
|
|
73
|
+
return typeof serviceTypeOrOpts === 'function'
|
|
74
|
+
? new TableDataProviderInst(model.type, serviceTypeOrOpts)
|
|
66
75
|
: new TableDataProviderInst(model.type, undefined);
|
|
67
76
|
}
|
|
68
77
|
|
|
@@ -308,9 +317,10 @@ class ColumnDescriptor {
|
|
|
308
317
|
}
|
|
309
318
|
/**
|
|
310
319
|
* Converts column to given type with additional arguments
|
|
311
|
-
*
|
|
312
|
-
* @param
|
|
313
|
-
* @param
|
|
320
|
+
*
|
|
321
|
+
* @param type Column type enum.
|
|
322
|
+
* @param displayType Column display type
|
|
323
|
+
* @param args Any additional arguments that might be needed for specific target type.
|
|
314
324
|
*/
|
|
315
325
|
asType(type, displayType, ...args) {
|
|
316
326
|
switch (type) {
|
|
@@ -329,6 +339,11 @@ class ColumnDescriptor {
|
|
|
329
339
|
return this;
|
|
330
340
|
}
|
|
331
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Set column display as number.
|
|
344
|
+
*
|
|
345
|
+
* @param opts Options for number display.
|
|
346
|
+
*/
|
|
332
347
|
asNumber(opts) {
|
|
333
348
|
this._columnType = ColumnTypeEnum.Number;
|
|
334
349
|
this._columnDisplayType = ColumnDisplayTypeEnum.Number;
|
|
@@ -339,12 +354,24 @@ class ColumnDescriptor {
|
|
|
339
354
|
this._locale = opts?.locale;
|
|
340
355
|
return this;
|
|
341
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Set column display as currency.
|
|
359
|
+
*
|
|
360
|
+
* @param opts Options for currency display.
|
|
361
|
+
*/
|
|
342
362
|
asCurrency(opts) {
|
|
343
363
|
return this.asCurrencyUnsafe({
|
|
344
364
|
...opts,
|
|
345
365
|
currencyProperty: opts?.currencyProperty ? opts.currencyProperty : undefined
|
|
346
366
|
});
|
|
347
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Set column display as currency.
|
|
370
|
+
*
|
|
371
|
+
* This function is UNSAFE!
|
|
372
|
+
*
|
|
373
|
+
* @param opts Options for currency display.
|
|
374
|
+
*/
|
|
348
375
|
asCurrencyUnsafe(opts) {
|
|
349
376
|
this._columnType = ColumnTypeEnum.Number;
|
|
350
377
|
this._columnDisplayType = ColumnDisplayTypeEnum.Currency;
|
|
@@ -358,12 +385,24 @@ class ColumnDescriptor {
|
|
|
358
385
|
this._locale = opts?.locale;
|
|
359
386
|
return this;
|
|
360
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Set column display as date.
|
|
390
|
+
*
|
|
391
|
+
* @param displayFormat Date display format (in Angular date formatting).
|
|
392
|
+
*/
|
|
361
393
|
asDate(displayFormat = 'dd.MM.yyyy') {
|
|
362
394
|
this._columnType = ColumnTypeEnum.Date;
|
|
363
395
|
this._columnDisplayType = ColumnDisplayTypeEnum.Date;
|
|
364
396
|
this._displayFormat = displayFormat;
|
|
365
397
|
return this;
|
|
366
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Set column display as boolean.
|
|
401
|
+
*
|
|
402
|
+
* @param yes Translation key for true value.
|
|
403
|
+
* @param no Translation key for false value.
|
|
404
|
+
* @param asIcon Use true/false texts as icon.
|
|
405
|
+
*/
|
|
367
406
|
asBoolean(yes, no, asIcon = false) {
|
|
368
407
|
this._columnType = ColumnTypeEnum.Boolean;
|
|
369
408
|
this._columnDisplayType = ColumnDisplayTypeEnum.Boolean;
|
|
@@ -372,38 +411,76 @@ class ColumnDescriptor {
|
|
|
372
411
|
this._booleanNo = no;
|
|
373
412
|
return this;
|
|
374
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* Set column display as enum.
|
|
416
|
+
*
|
|
417
|
+
* @param enumDesc Enum descriptor for value display.
|
|
418
|
+
*/
|
|
375
419
|
asEnumUnsafe(enumDesc) {
|
|
376
420
|
this._columnType = ColumnTypeEnum.Enum;
|
|
377
421
|
this._columnDisplayType = ColumnDisplayTypeEnum.Enum;
|
|
378
422
|
this._enum = enumDesc;
|
|
379
423
|
return this;
|
|
380
424
|
}
|
|
425
|
+
/**
|
|
426
|
+
* Set column display with custom component.
|
|
427
|
+
*
|
|
428
|
+
* @param customComponentType Component type to be used for display. Must implement {IColumnValueComponent}.
|
|
429
|
+
*/
|
|
381
430
|
asCustomComponent(customComponentType) {
|
|
382
431
|
this._columnType = ColumnTypeEnum.Custom;
|
|
383
432
|
this._columnDisplayType = ColumnDisplayTypeEnum.Component;
|
|
384
433
|
this._customComponentType = customComponentType;
|
|
385
434
|
return this;
|
|
386
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Sets columns display as HTML using Angular innerHTML.
|
|
438
|
+
*/
|
|
387
439
|
asHtml() {
|
|
388
440
|
this._columnDisplayType = ColumnDisplayTypeEnum.Html;
|
|
389
441
|
return this;
|
|
390
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Sets the class names for the column.
|
|
445
|
+
*
|
|
446
|
+
* @param className - The class name for the element column.
|
|
447
|
+
* @param headerClassName - The class name for the header element of the column.
|
|
448
|
+
* @param classNameMapFn - A function to return class name based on the current class name and row item value.
|
|
449
|
+
*/
|
|
391
450
|
withClassName(className, headerClassName, classNameMapFn) {
|
|
392
451
|
this._className = className ?? '';
|
|
393
452
|
this._headerClassName = headerClassName ?? '';
|
|
394
453
|
this._classNameMapFn = classNameMapFn;
|
|
395
454
|
return this;
|
|
396
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* Sets the width for the column.
|
|
458
|
+
*
|
|
459
|
+
* @param width - The desired width in percents (relative to table width).
|
|
460
|
+
* @param minWidth - The minimum width of column in pixels.
|
|
461
|
+
* @param maxWidth - The maximum width of column in pixels.
|
|
462
|
+
*/
|
|
397
463
|
withWidth(width, minWidth, maxWidth) {
|
|
398
464
|
this._width = width ?? null;
|
|
399
465
|
this._minWidth = minWidth ?? null;
|
|
400
466
|
this._maxWidth = maxWidth ?? null;
|
|
401
467
|
return this;
|
|
402
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* Sets the title for the column. If title is undefined, then the title will be calculated based on table model (i18nBase) and column property.
|
|
471
|
+
*
|
|
472
|
+
* @param title - The title of the column.
|
|
473
|
+
*/
|
|
403
474
|
withTitle(title) {
|
|
404
475
|
this._title = title;
|
|
405
476
|
return this;
|
|
406
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Enables button that copies column value to the clipboard.
|
|
480
|
+
*
|
|
481
|
+
* @param hasCopyToClipboard - Flag to enable/disable the feature.
|
|
482
|
+
* @param clipboardValueGetter - Optional getter function to adjust the value to be copied to clipboard.
|
|
483
|
+
*/
|
|
407
484
|
withCopyToClipboard(hasCopyToClipboard = true, clipboardValueGetter) {
|
|
408
485
|
this._hasCopyToClipboard = hasCopyToClipboard;
|
|
409
486
|
if (clipboardValueGetter) {
|
|
@@ -411,31 +488,81 @@ class ColumnDescriptor {
|
|
|
411
488
|
}
|
|
412
489
|
return this;
|
|
413
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* Sets the template for displaying value.
|
|
493
|
+
*
|
|
494
|
+
* Use `{{}}` syntax for string interpolation within template.
|
|
495
|
+
* Use `item` key to access value of row item.
|
|
496
|
+
*
|
|
497
|
+
* Example interpolates row item's title within some text:
|
|
498
|
+
* ```
|
|
499
|
+
* This template shows {{item.title}} value in column.
|
|
500
|
+
* ```
|
|
501
|
+
*
|
|
502
|
+
* @param {string} template - The template to set.
|
|
503
|
+
*
|
|
504
|
+
* @usageNotes
|
|
505
|
+
* Display item's title property within some text:
|
|
506
|
+
*
|
|
507
|
+
* ```
|
|
508
|
+
* This template shows {{item.title}} value in column.
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
414
511
|
withTemplate(template) {
|
|
415
512
|
this._template = template;
|
|
416
513
|
return this;
|
|
417
514
|
}
|
|
515
|
+
/**
|
|
516
|
+
* Sets the getter function for adjusting the column value for display.
|
|
517
|
+
*
|
|
518
|
+
* @param {GetterFn<ColumnValue, TableModel>} getter - The getter function to be used.
|
|
519
|
+
*/
|
|
418
520
|
withGetter(getter) {
|
|
419
521
|
this._getter = getter;
|
|
420
522
|
return this;
|
|
421
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Show text in multiple lines (useful for displaying of long texts).
|
|
526
|
+
*
|
|
527
|
+
* @param isMultiline Enables/disabled the feature.
|
|
528
|
+
*/
|
|
422
529
|
withMultiline(isMultiline = true) {
|
|
423
530
|
this._isMultiline = isMultiline;
|
|
424
531
|
return this;
|
|
425
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Shows the whole display value as text (usefule when display values are expected to be to long and/or are overflown).
|
|
535
|
+
*
|
|
536
|
+
* @param valueAsTooltip Enables/disabled the feature.
|
|
537
|
+
*/
|
|
426
538
|
withValueAsTooltip(valueAsTooltip = true) {
|
|
427
539
|
this._hasValueAsTooltip = valueAsTooltip;
|
|
428
540
|
return this;
|
|
429
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Enables ordering of column.
|
|
544
|
+
*
|
|
545
|
+
* @param isReorderable Flag to enable/disable reordering.
|
|
546
|
+
*/
|
|
430
547
|
withReorderable(isReorderable = true) {
|
|
431
548
|
this._isReorderable = isReorderable;
|
|
432
549
|
return this;
|
|
433
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Enables toggling column visibility.
|
|
553
|
+
*
|
|
554
|
+
* @param isReorderable Flag to enable/disable visibility toggle.
|
|
555
|
+
*/
|
|
434
556
|
withToggleable(isToggleable = true, isVisible = true) {
|
|
435
557
|
this._isToggleable = isToggleable;
|
|
436
558
|
this._isVisible = isVisible;
|
|
437
559
|
return this;
|
|
438
560
|
}
|
|
561
|
+
/**
|
|
562
|
+
* Enables localization of column by displaying flag if the column value is localized (or just displaying default fallback text).
|
|
563
|
+
*
|
|
564
|
+
* @param existsProperty Property to mark
|
|
565
|
+
*/
|
|
439
566
|
localized(existsProperty) {
|
|
440
567
|
if (existsProperty) {
|
|
441
568
|
this._localizationExistsProperty = existsProperty;
|
|
@@ -445,6 +572,9 @@ class ColumnDescriptor {
|
|
|
445
572
|
}
|
|
446
573
|
return this;
|
|
447
574
|
}
|
|
575
|
+
/**
|
|
576
|
+
* Copies current descriptor to a new instance.
|
|
577
|
+
*/
|
|
448
578
|
copy() {
|
|
449
579
|
const descriptor = new ColumnDescriptor(this._property);
|
|
450
580
|
this.copyFieldsTo(descriptor);
|
|
@@ -559,19 +689,41 @@ class SortDescriptor {
|
|
|
559
689
|
get defaultOrder() {
|
|
560
690
|
return this._defaultOrder;
|
|
561
691
|
}
|
|
692
|
+
/**
|
|
693
|
+
* Shows sort on column for giver property.
|
|
694
|
+
*
|
|
695
|
+
* @param property Column property.
|
|
696
|
+
*/
|
|
562
697
|
withShowOnColumn(property) {
|
|
563
698
|
return this.withShowOnColumnUnsafe(property);
|
|
564
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Shows sort on column for giver property.
|
|
702
|
+
*
|
|
703
|
+
* This function is UNSAFE!
|
|
704
|
+
*
|
|
705
|
+
* @param property Column property.
|
|
706
|
+
*/
|
|
565
707
|
withShowOnColumnUnsafe(property) {
|
|
566
708
|
this._showOnColumn = property;
|
|
567
709
|
return this;
|
|
568
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* Sets the default sort for this descriptor.
|
|
713
|
+
*
|
|
714
|
+
* @param {boolean} enabled - Enables/disables the feature. Default is true.
|
|
715
|
+
* @param {boolean} [ascending] - If the sort is ascending. Default is true.
|
|
716
|
+
* @param {number} [order] - Order index in case of multiple default sorts.
|
|
717
|
+
*/
|
|
569
718
|
withDefaultSort(enabled = true, ascending, order) {
|
|
570
719
|
this._defaultIsEnabled = enabled;
|
|
571
720
|
this._defaultIsAscending = ascending ?? true;
|
|
572
721
|
this._defaultOrder = order;
|
|
573
722
|
return this;
|
|
574
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* Copies current descriptor to a new instance.
|
|
726
|
+
*/
|
|
575
727
|
copy() {
|
|
576
728
|
const descriptor = new SortDescriptor(this._property);
|
|
577
729
|
descriptor._defaultIsEnabled = this._defaultIsEnabled;
|
|
@@ -673,12 +825,6 @@ class TableDescriptorInst {
|
|
|
673
825
|
get size() {
|
|
674
826
|
return this._size;
|
|
675
827
|
}
|
|
676
|
-
get tableFullHeightOffset() {
|
|
677
|
-
return this._tableFullHeightOffset;
|
|
678
|
-
}
|
|
679
|
-
get rowHeight() {
|
|
680
|
-
return this._rowHeight;
|
|
681
|
-
}
|
|
682
828
|
get hasHover() {
|
|
683
829
|
return this._hasHover;
|
|
684
830
|
}
|
|
@@ -734,7 +880,7 @@ class TableDescriptorInst {
|
|
|
734
880
|
return this._rowExpandableComponentType;
|
|
735
881
|
}
|
|
736
882
|
/**
|
|
737
|
-
*
|
|
883
|
+
* Identifier is used for the purpose of combined saving user preferences in localstorage if 2 tables have the same track properties they will share the same localstorage entry.
|
|
738
884
|
* Similarly, this property can also be used to differentiate two tables of the same model on the same url (so that they have separate entries in localstorage).
|
|
739
885
|
* @param identifier
|
|
740
886
|
*/
|
|
@@ -742,112 +888,236 @@ class TableDescriptorInst {
|
|
|
742
888
|
this._identifier = identifier;
|
|
743
889
|
return this;
|
|
744
890
|
}
|
|
891
|
+
/**
|
|
892
|
+
* Sets the track property (identifier of table row) for the table.
|
|
893
|
+
*
|
|
894
|
+
* @param {keyof TableModel} property - The property to track the row items by.
|
|
895
|
+
*/
|
|
745
896
|
withTrackProperty(property) {
|
|
746
897
|
return this.withTrackPropertyUnsafe(property);
|
|
747
898
|
}
|
|
899
|
+
/**
|
|
900
|
+
* Sets the track property (identifier of table row) for the table.
|
|
901
|
+
*
|
|
902
|
+
* This function is UNSAFE!
|
|
903
|
+
*
|
|
904
|
+
* @param {string} property - The property to set '_trackProperty' to.
|
|
905
|
+
*/
|
|
748
906
|
withTrackPropertyUnsafe(property) {
|
|
749
907
|
this._trackProperty = property;
|
|
750
908
|
return this;
|
|
751
909
|
}
|
|
910
|
+
/**
|
|
911
|
+
* Retrieves the column descriptor for the given property.
|
|
912
|
+
*
|
|
913
|
+
* @param {keyof TableModel} property - The property for column descriptor.
|
|
914
|
+
*
|
|
915
|
+
* @return The column descriptor.
|
|
916
|
+
*/
|
|
752
917
|
getColumn(property) {
|
|
753
918
|
return this.getColumnUnsafe(property);
|
|
754
919
|
}
|
|
920
|
+
/**
|
|
921
|
+
* Retrieves the column descriptor for the given property.
|
|
922
|
+
*
|
|
923
|
+
* This function is UNSAFE!
|
|
924
|
+
*
|
|
925
|
+
* @param {keyof TableModel} property - The property for column descriptor.
|
|
926
|
+
*
|
|
927
|
+
* @return The column descriptor.
|
|
928
|
+
*/
|
|
755
929
|
getColumnUnsafe(property) {
|
|
756
930
|
return this._columns.find(col => col.property === property) ?? null;
|
|
757
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Removes the column descriptor for the given property.
|
|
934
|
+
*
|
|
935
|
+
* @param {keyof TableModel} property - The property for column descriptor.
|
|
936
|
+
*/
|
|
758
937
|
removeColumn(property) {
|
|
759
938
|
this.removeColumnUnsafe(property);
|
|
760
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* Removes the column descriptor for the given property.
|
|
942
|
+
*
|
|
943
|
+
* This function is UNSAFE!
|
|
944
|
+
*
|
|
945
|
+
* @param {keyof TableModel} property - The property for column descriptor.
|
|
946
|
+
*/
|
|
761
947
|
removeColumnUnsafe(property) {
|
|
762
948
|
const columnIdx = this._columns.findIndex(c => c.property === property);
|
|
763
949
|
this._columns.splice(columnIdx, 1);
|
|
764
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Adds column descriptor to table columns.
|
|
953
|
+
*
|
|
954
|
+
* @param {ColumnDescriptor<ColumnModel, TableModel, ColumnValue>} column - The property for column descriptor.
|
|
955
|
+
*/
|
|
765
956
|
withColumn(column) {
|
|
766
957
|
this._columns.push(column);
|
|
767
958
|
return this;
|
|
768
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* Adds a column to the table.
|
|
962
|
+
*
|
|
963
|
+
* @param {PropertyKey} property - The property key of the column in the table model.
|
|
964
|
+
*
|
|
965
|
+
* @returns The newly added column descriptor.
|
|
966
|
+
*/
|
|
769
967
|
addColumn(property) {
|
|
770
968
|
const column = new ColumnDescriptor(property);
|
|
771
969
|
this._columns.push(column);
|
|
772
970
|
return column;
|
|
773
971
|
}
|
|
972
|
+
/**
|
|
973
|
+
* Adds a column with enum display to the table.
|
|
974
|
+
*
|
|
975
|
+
* @param {PropertyKey} property - The property key of the table model.
|
|
976
|
+
* @param {EnumDescriptor<Enum>} enumDesc - The enum descriptor for column display.
|
|
977
|
+
* @return {ColumnDescriptor<Enum, TableModel, TableModel[PropertyKey]>} - The added column descriptor.
|
|
978
|
+
*/
|
|
774
979
|
addColumnEnum(property, enumDesc) {
|
|
775
980
|
const column = new ColumnDescriptor(property);
|
|
776
981
|
column.asEnumUnsafe(enumDesc);
|
|
777
982
|
this._columns.push(column);
|
|
778
983
|
return column;
|
|
779
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Adds a column to the table.
|
|
987
|
+
*
|
|
988
|
+
* This function is UNSAFE!
|
|
989
|
+
*
|
|
990
|
+
* @param {string} property - The property key of the column in the table model.
|
|
991
|
+
*
|
|
992
|
+
* @returns The newly added column descriptor.
|
|
993
|
+
*/
|
|
780
994
|
addColumnUnsafe(property) {
|
|
781
995
|
const column = new ColumnDescriptor(property);
|
|
782
996
|
this._columns.push(column);
|
|
783
997
|
return column;
|
|
784
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Adds one or more columns to the table model.
|
|
1001
|
+
*
|
|
1002
|
+
* @param properties - An array of property names to add as columns.
|
|
1003
|
+
*/
|
|
785
1004
|
withColumns(...properties) {
|
|
786
1005
|
properties.forEach(p => this.addColumn(p));
|
|
787
1006
|
return this;
|
|
788
1007
|
}
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1008
|
+
/**
|
|
1009
|
+
* Set the pagination mode for the table.
|
|
1010
|
+
*
|
|
1011
|
+
* @param {TablePaginationModeEnum} paginationMode - The pagination mode to set. Must be one of the values from the TablePaginationModeEnum.
|
|
1012
|
+
*/
|
|
793
1013
|
withPaginationMode(paginationMode) {
|
|
794
1014
|
this._paginationMode = paginationMode;
|
|
795
1015
|
return this;
|
|
796
1016
|
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Sets the number of rows per page for a paginated display.
|
|
1019
|
+
*
|
|
1020
|
+
* @param {number} rows - The default number of rows to display per page.
|
|
1021
|
+
* @param {Array<number>} [options] - Rows per page options to be available in table paginator.
|
|
1022
|
+
*/
|
|
797
1023
|
withRowsPerPage(rows, options) {
|
|
798
1024
|
this._defaultNumRows = rows;
|
|
799
1025
|
this._rowsPerPageOptions = options;
|
|
800
1026
|
return this;
|
|
801
1027
|
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Sets the title for an instance of the class.
|
|
1030
|
+
*
|
|
1031
|
+
* @param {string} [title] - The title value to be set. It undefiend, no title will be displayed.
|
|
1032
|
+
*/
|
|
802
1033
|
withTitle(title) {
|
|
803
1034
|
this._title = title;
|
|
804
1035
|
return this;
|
|
805
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Shows/hides the header row with column titles.
|
|
1039
|
+
*
|
|
1040
|
+
* @param {boolean} hideHeader - A boolean value indicating whether to hide the header.
|
|
1041
|
+
*/
|
|
806
1042
|
withHideHeader(hideHeader = true) {
|
|
807
1043
|
this._hideHeader = hideHeader;
|
|
808
1044
|
return this;
|
|
809
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Adjusts loading display with custom text and/or icon.
|
|
1048
|
+
*
|
|
1049
|
+
* @param {string} [text] - Text to be displayed when loading indicator is shown.
|
|
1050
|
+
* @param {string | null} [icon] - Icon to be used when loading indicator is shown.
|
|
1051
|
+
*/
|
|
810
1052
|
withLoading(text, icon) {
|
|
811
1053
|
this._loadingText = text;
|
|
812
1054
|
this._loadingIcon = icon === undefined ? 'pi pi-spinner' : icon;
|
|
813
1055
|
return this;
|
|
814
1056
|
}
|
|
815
1057
|
/**
|
|
816
|
-
*
|
|
817
|
-
*
|
|
1058
|
+
* Retrieves the sort descriptor for a given property.
|
|
1059
|
+
*
|
|
1060
|
+
* @param {Sorts} property - The property to retrieve the sort for.
|
|
1061
|
+
*
|
|
1062
|
+
* @return {SortDescriptor<TableModel> | null} The sort descriptor or null.
|
|
818
1063
|
*/
|
|
819
|
-
withCurrentColumnsReorderable(columnsReorderable = true) {
|
|
820
|
-
for (const col of this.columns) {
|
|
821
|
-
col.withReorderable(columnsReorderable);
|
|
822
|
-
}
|
|
823
|
-
return this;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Helper method that enables/disables toggleable property on all columns currently in the descriptor.
|
|
827
|
-
* @param columnsToggleable
|
|
828
|
-
*/
|
|
829
|
-
withCurrentColumnsToggleable(columnsToggleable = true) {
|
|
830
|
-
for (const col of this.columns) {
|
|
831
|
-
col.withToggleable(columnsToggleable);
|
|
832
|
-
}
|
|
833
|
-
return this;
|
|
834
|
-
}
|
|
835
1064
|
getSort(property) {
|
|
836
1065
|
return this.getSortUnsafe(property);
|
|
837
1066
|
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Retrieves the sort descriptor for a given property.
|
|
1069
|
+
*
|
|
1070
|
+
* This function is UNSAFE!
|
|
1071
|
+
*
|
|
1072
|
+
* @param {Sorts} property - The property to retrieve the sort for.
|
|
1073
|
+
*
|
|
1074
|
+
* @return {SortDescriptor<TableModel> | null} The sort descriptor or null.
|
|
1075
|
+
*/
|
|
838
1076
|
getSortUnsafe(property) {
|
|
839
1077
|
return this._sorts.find(s => s.property === property) ?? null;
|
|
840
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Removes the sort for a given property.
|
|
1081
|
+
*
|
|
1082
|
+
* @param {Sorts} property - The property to remove the sort for.
|
|
1083
|
+
*/
|
|
841
1084
|
removeSort(property) {
|
|
842
1085
|
return this.removeSortUnsafe(property);
|
|
843
1086
|
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Removes the sort for a given property.
|
|
1089
|
+
*
|
|
1090
|
+
* This function is UNSAFE!
|
|
1091
|
+
*
|
|
1092
|
+
* @param {Sorts} property - The property to remove the sort for.
|
|
1093
|
+
*/
|
|
844
1094
|
removeSortUnsafe(property) {
|
|
845
1095
|
const sortIdx = this._sorts.findIndex(c => c.property === property);
|
|
846
1096
|
this._sorts.splice(sortIdx, 1);
|
|
847
1097
|
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Adds sort for the given property.
|
|
1100
|
+
*
|
|
1101
|
+
* @param property Property to add the sort for.
|
|
1102
|
+
* @param isDefault If default sorting is enabled.
|
|
1103
|
+
* @param ascending If default sort should be ascending.
|
|
1104
|
+
*
|
|
1105
|
+
* @return Created sort descriptor.
|
|
1106
|
+
*/
|
|
848
1107
|
addSort(property, isDefault = false, ascending) {
|
|
849
1108
|
return this.addSortUnsafe(property, isDefault, ascending);
|
|
850
1109
|
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Adds sort for the given property.
|
|
1112
|
+
*
|
|
1113
|
+
* This function is UNSAFE!
|
|
1114
|
+
*
|
|
1115
|
+
* @param property Property to add the sort for.
|
|
1116
|
+
* @param isDefault If default sorting is enabled.
|
|
1117
|
+
* @param ascending If default sort should be ascending.
|
|
1118
|
+
|
|
1119
|
+
* @return Created sort descriptor.
|
|
1120
|
+
*/
|
|
851
1121
|
addSortUnsafe(property, isDefault = false, ascending) {
|
|
852
1122
|
const sort = new SortDescriptor(property);
|
|
853
1123
|
if (isDefault) {
|
|
@@ -859,16 +1129,50 @@ class TableDescriptorInst {
|
|
|
859
1129
|
this._sorts.push(sort);
|
|
860
1130
|
return sort;
|
|
861
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* Adds sort for the given property.
|
|
1134
|
+
*
|
|
1135
|
+
* @param property Property to add the sort for.
|
|
1136
|
+
* @param isDefault If default sorting is enabled.
|
|
1137
|
+
* @param ascending If default sort should be ascending.
|
|
1138
|
+
*/
|
|
862
1139
|
withSort(property, isDefault = false, ascending) {
|
|
863
1140
|
return this.withSortUnsafe(property, isDefault, ascending);
|
|
864
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Adds sort for the given property.
|
|
1144
|
+
*
|
|
1145
|
+
* This function is UNSAFE!
|
|
1146
|
+
*
|
|
1147
|
+
* @param property Property to add the sort for.
|
|
1148
|
+
* @param isDefault If default sorting is enabled.
|
|
1149
|
+
* @param ascending If default sort should be ascending.
|
|
1150
|
+
*/
|
|
865
1151
|
withSortUnsafe(property, isDefault = false, ascending) {
|
|
866
1152
|
this.addSortUnsafe(property, isDefault, ascending);
|
|
867
1153
|
return this;
|
|
868
1154
|
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Sets the default sorting for the property.
|
|
1157
|
+
*
|
|
1158
|
+
* @param property - The property to set default sort for.
|
|
1159
|
+
* @param ascending - If the sorting should be ascending (default: true).
|
|
1160
|
+
* @param order - The order for this default sort (default: 0).
|
|
1161
|
+
* @param enabled - Enables/disabled the default sort.
|
|
1162
|
+
*/
|
|
869
1163
|
withDefaultSort(property, ascending, order, enabled) {
|
|
870
1164
|
return this.withDefaultSortUnsafe(property, ascending, order, enabled);
|
|
871
1165
|
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Sets the default sorting for the property.
|
|
1168
|
+
*
|
|
1169
|
+
* This function is UNSAFE!
|
|
1170
|
+
*
|
|
1171
|
+
* @param property - The property to set default sort for.
|
|
1172
|
+
* @param ascending - If the sorting should be ascending (default: true).
|
|
1173
|
+
* @param order - The order for this default sort (default: 0).
|
|
1174
|
+
* @param enabled - Enables/disabled the default sort.
|
|
1175
|
+
*/
|
|
872
1176
|
withDefaultSortUnsafe(property, ascending, order, enabled) {
|
|
873
1177
|
let sort = this._sorts.find(s => s.property === property);
|
|
874
1178
|
if (!sort) {
|
|
@@ -878,39 +1182,115 @@ class TableDescriptorInst {
|
|
|
878
1182
|
sort.withDefaultSort(enabled ?? true, ascending, order);
|
|
879
1183
|
return this;
|
|
880
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Add sorts for more properties.
|
|
1187
|
+
*
|
|
1188
|
+
* @param properties Properties to add the sorts for.
|
|
1189
|
+
*/
|
|
881
1190
|
withSorts(...properties) {
|
|
882
1191
|
return this.withSortsUnsafe(...properties);
|
|
883
1192
|
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Add sorts for more properties.
|
|
1195
|
+
*
|
|
1196
|
+
* This function is UNSAFE!
|
|
1197
|
+
*
|
|
1198
|
+
* @param properties Properties to add the sorts for.
|
|
1199
|
+
*/
|
|
884
1200
|
withSortsUnsafe(...properties) {
|
|
885
1201
|
properties.forEach(p => {
|
|
886
1202
|
this._sorts.push(new SortDescriptor(p));
|
|
887
1203
|
});
|
|
888
1204
|
return this;
|
|
889
1205
|
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Gets filter descriptor for given property.
|
|
1208
|
+
*
|
|
1209
|
+
* @param property Filter property
|
|
1210
|
+
*
|
|
1211
|
+
* @return Filter descriptor for property or null if not exists.
|
|
1212
|
+
*/
|
|
890
1213
|
getFilter(property) {
|
|
891
1214
|
return this.getFilterUnsafe(property);
|
|
892
1215
|
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Gets filter descriptor for given property.
|
|
1218
|
+
*
|
|
1219
|
+
* This function is UNSAFE!
|
|
1220
|
+
*
|
|
1221
|
+
* @param property Filter property
|
|
1222
|
+
*
|
|
1223
|
+
* @return Filter descriptor for property or null if not exists.
|
|
1224
|
+
*/
|
|
893
1225
|
getFilterUnsafe(property) {
|
|
894
1226
|
return this._filters.find(s => s.property === property) ?? null;
|
|
895
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Removes filter descriptor for given property.
|
|
1230
|
+
*
|
|
1231
|
+
* @param property Filter property
|
|
1232
|
+
*/
|
|
896
1233
|
removeFilter(property) {
|
|
897
1234
|
return this.removeFilterUnsafe(property);
|
|
898
1235
|
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Removes filter descriptor for given property.
|
|
1238
|
+
*
|
|
1239
|
+
* This function is UNSAFE!
|
|
1240
|
+
*
|
|
1241
|
+
* @param property Filter property
|
|
1242
|
+
*/
|
|
899
1243
|
removeFilterUnsafe(property) {
|
|
900
1244
|
const filterIdx = this._filters.findIndex(c => c.property === property);
|
|
901
1245
|
this._filters.splice(filterIdx, 1);
|
|
902
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Creates filter descriptor for the given property.
|
|
1249
|
+
*
|
|
1250
|
+
* @param property Filter property.
|
|
1251
|
+
*
|
|
1252
|
+
* @return Created filter descriptor.
|
|
1253
|
+
*/
|
|
903
1254
|
addFilter(property) {
|
|
904
1255
|
return this.addFilterUnsafe(property);
|
|
905
1256
|
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Creates filter descriptor for the given property.
|
|
1259
|
+
*
|
|
1260
|
+
* This function is UNSAFE!
|
|
1261
|
+
*
|
|
1262
|
+
* @param property Filter property.
|
|
1263
|
+
*
|
|
1264
|
+
* @return Created filter descriptor.
|
|
1265
|
+
*/
|
|
906
1266
|
addFilterUnsafe(property) {
|
|
907
1267
|
const filter = new FilterDescriptor(property);
|
|
908
1268
|
this._filters.push(filter);
|
|
909
1269
|
return filter;
|
|
910
1270
|
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Creates filter lookup descriptor for the given property.
|
|
1273
|
+
*
|
|
1274
|
+
* @param property Filter property.
|
|
1275
|
+
* @param provider Lookup provider.
|
|
1276
|
+
* @param optionsValueProperty Property on lookup provider's item (FilterModel) that will be used as filter value.
|
|
1277
|
+
*
|
|
1278
|
+
* @return Created filter lookup descriptor.
|
|
1279
|
+
*/
|
|
911
1280
|
addFilterLookup(property, provider, optionsValueProperty) {
|
|
912
1281
|
return this.addFilterLookupUnsafe(property, provider, optionsValueProperty);
|
|
913
1282
|
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Creates filter lookup descriptor for the given property.
|
|
1285
|
+
*
|
|
1286
|
+
* This function is UNSAFE!
|
|
1287
|
+
*
|
|
1288
|
+
* @param property Filter property.
|
|
1289
|
+
* @param provider Lookup provider.
|
|
1290
|
+
* @param optionsValueProperty Property on lookup provider's item (FilterModel) that will be used as filter value.
|
|
1291
|
+
*
|
|
1292
|
+
* @return Created filter lookup descriptor.
|
|
1293
|
+
*/
|
|
914
1294
|
addFilterLookupUnsafe(property, provider, optionsValueProperty) {
|
|
915
1295
|
const filter = new FilterLookupDescriptor(property, {
|
|
916
1296
|
dataProvider: provider,
|
|
@@ -919,26 +1299,86 @@ class TableDescriptorInst {
|
|
|
919
1299
|
this._filters.push(filter);
|
|
920
1300
|
return filter;
|
|
921
1301
|
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Creates filter lookup enum descriptor for the given property.
|
|
1304
|
+
*
|
|
1305
|
+
* @param property Filter property.
|
|
1306
|
+
* @param enumDesc Descriptor for enum.
|
|
1307
|
+
* @param options Optional options of enum values to be available to filter by.
|
|
1308
|
+
*
|
|
1309
|
+
* @return Created filter lookup enum descriptor.
|
|
1310
|
+
*/
|
|
922
1311
|
addFilterLookupEnum(property, enumDesc, options) {
|
|
923
1312
|
return this.addFilterLookupEnumUnsafe(property, enumDesc, options);
|
|
924
1313
|
}
|
|
1314
|
+
/**
|
|
1315
|
+
* Creates filter lookup enum descriptor for the given property.
|
|
1316
|
+
*
|
|
1317
|
+
* This function is UNSAFE!
|
|
1318
|
+
*
|
|
1319
|
+
* @param property Filter property.
|
|
1320
|
+
* @param enumDesc Descriptor for enum.
|
|
1321
|
+
* @param options Optional options of enum values to be available to filter by.
|
|
1322
|
+
*
|
|
1323
|
+
* @return Created filter lookup enum descriptor.
|
|
1324
|
+
*/
|
|
925
1325
|
addFilterLookupEnumUnsafe(property, enumDesc, options) {
|
|
926
1326
|
const filter = new FilterLookupEnumDescriptor(property, enumDesc, options);
|
|
927
1327
|
this._filters.push(filter);
|
|
928
1328
|
return filter;
|
|
929
1329
|
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Creates filter descriptor from column. The column must exist on table descriptor.
|
|
1332
|
+
*
|
|
1333
|
+
* @param property Column property to add filter for.
|
|
1334
|
+
* @param displayType Optional display type setting.
|
|
1335
|
+
* @param forceSimple Forces simple creation of filter (no lookup or lookup enum filters).
|
|
1336
|
+
*
|
|
1337
|
+
* @throws {CommonsInternalError} If column for property doesn't exist.
|
|
1338
|
+
*
|
|
1339
|
+
* @return Created filter descriptor
|
|
1340
|
+
*/
|
|
930
1341
|
addFilterFromColumn(property, displayType, forceSimple = false) {
|
|
931
1342
|
return this.addFilterFromColumnUnsafe(property, displayType, forceSimple);
|
|
932
1343
|
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Creates filter descriptors from columns. The columns must exist on table descriptor.
|
|
1346
|
+
*
|
|
1347
|
+
* @param properties Column properties to add filters for.
|
|
1348
|
+
*
|
|
1349
|
+
* @throws {CommonsInternalError} If column for property doesn't exist.
|
|
1350
|
+
*/
|
|
933
1351
|
withFiltersFromColumns(...properties) {
|
|
934
1352
|
return this.withFiltersFromColumnsUnsafe(...properties);
|
|
935
1353
|
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Creates filter descriptors from columns. The columns must exist on table descriptor.
|
|
1356
|
+
*
|
|
1357
|
+
* This function is UNSAFE!
|
|
1358
|
+
*
|
|
1359
|
+
* @param properties Column properties to add filters for.
|
|
1360
|
+
*
|
|
1361
|
+
* @throws {CommonsInternalError} If column for property doesn't exist.
|
|
1362
|
+
*/
|
|
936
1363
|
withFiltersFromColumnsUnsafe(...properties) {
|
|
937
1364
|
properties.forEach(p => {
|
|
938
1365
|
this.addFilterFromColumnUnsafe(p);
|
|
939
1366
|
});
|
|
940
1367
|
return this;
|
|
941
1368
|
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Creates filter descriptor from column. The column must exist on table descriptor.
|
|
1371
|
+
*
|
|
1372
|
+
* This function is UNSAFE!
|
|
1373
|
+
*
|
|
1374
|
+
* @param property Column property to add filter for.
|
|
1375
|
+
* @param displayType Optional display type setting.
|
|
1376
|
+
* @param forceSimple Forces simple creation of filter (no lookup or lookup enum filters).
|
|
1377
|
+
*
|
|
1378
|
+
* @throws {CommonsInternalError} If column for property doesn't exist.
|
|
1379
|
+
*
|
|
1380
|
+
* @return Created filter descriptor
|
|
1381
|
+
*/
|
|
942
1382
|
addFilterFromColumnUnsafe(property, displayType, forceSimple = false) {
|
|
943
1383
|
const column = this.getColumnUnsafe(property);
|
|
944
1384
|
if (!column) {
|
|
@@ -949,6 +1389,18 @@ class TableDescriptorInst {
|
|
|
949
1389
|
filter.withDisplayType(displayType);
|
|
950
1390
|
return filter;
|
|
951
1391
|
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Creates filter descriptor from provided column descriptor.
|
|
1394
|
+
*
|
|
1395
|
+
* This function is UNSAFE!
|
|
1396
|
+
*
|
|
1397
|
+
* @param column Column descriptor.
|
|
1398
|
+
* @param forceSimple Forces simple creation of filter (no lookup or lookup enum filters).
|
|
1399
|
+
*
|
|
1400
|
+
* @throws {CommonsInternalError} If column for property doesn't exist.
|
|
1401
|
+
*
|
|
1402
|
+
* @return Created filter descriptor
|
|
1403
|
+
*/
|
|
952
1404
|
addFilterFromColumnDescriptorUnsafe(column, forceSimple = false) {
|
|
953
1405
|
let filterDescriptor = new FilterDescriptor(column.property);
|
|
954
1406
|
let filterType;
|
|
@@ -984,42 +1436,90 @@ class TableDescriptorInst {
|
|
|
984
1436
|
this._filters.push(filterDescriptor);
|
|
985
1437
|
return filterDescriptor;
|
|
986
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Adds filter descriptor for the given property.
|
|
1441
|
+
*
|
|
1442
|
+
* @param property Filter property.
|
|
1443
|
+
* @param filter Descriptor for property.
|
|
1444
|
+
*/
|
|
987
1445
|
withFilter(property, filter) {
|
|
988
1446
|
if (filter.property !== property) {
|
|
989
1447
|
throw new CommonsInternalError(`Filter property "${property}" and Filter descriptor property "${filter.property}" do not match.`);
|
|
990
1448
|
}
|
|
991
1449
|
return this.withFilterUnsafe(filter);
|
|
992
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Adds filter descriptor for the given property.
|
|
1453
|
+
*
|
|
1454
|
+
* This function is UNSAFE!
|
|
1455
|
+
*
|
|
1456
|
+
* @param filter Descriptor for property.
|
|
1457
|
+
*/
|
|
993
1458
|
withFilterUnsafe(filter) {
|
|
994
1459
|
this._filters.push(filter);
|
|
995
1460
|
return this;
|
|
996
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Sets classes for table component.
|
|
1464
|
+
*
|
|
1465
|
+
* @param className Class names.
|
|
1466
|
+
*/
|
|
997
1467
|
withClassName(className) {
|
|
998
1468
|
this._className = className;
|
|
999
1469
|
return this;
|
|
1000
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Sets table sizing.
|
|
1473
|
+
*
|
|
1474
|
+
* @param size Table size.
|
|
1475
|
+
*/
|
|
1001
1476
|
withSize(size = TableSizeEnum.Normal) {
|
|
1002
1477
|
this._size = size;
|
|
1003
1478
|
return this;
|
|
1004
1479
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1480
|
+
/**
|
|
1481
|
+
* Enables hover effect on table rows.
|
|
1482
|
+
*
|
|
1483
|
+
* @param hover Enables/disables the hover.
|
|
1484
|
+
*/
|
|
1485
|
+
withHover(hover = true) {
|
|
1486
|
+
this._hasHover = hover;
|
|
1007
1487
|
return this;
|
|
1008
1488
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1489
|
+
/**
|
|
1490
|
+
* Enables gridlines on table.
|
|
1491
|
+
*
|
|
1492
|
+
* @param gridlines Enables/disables the gridlines.
|
|
1493
|
+
*/
|
|
1494
|
+
withGridlines(gridlines = true) {
|
|
1495
|
+
this._hasGridlines = gridlines;
|
|
1011
1496
|
return this;
|
|
1012
1497
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1498
|
+
/**
|
|
1499
|
+
* Enables/disables reorderable property on all columns currently in the descriptor.
|
|
1500
|
+
*
|
|
1501
|
+
* @param {boolean} [columnsReorderable] - Boolean flag to set reordering on columns to.
|
|
1502
|
+
*/
|
|
1503
|
+
withCurrentColumnsReorderable(columnsReorderable = true) {
|
|
1504
|
+
for (const col of this.columns) {
|
|
1505
|
+
col.withReorderable(columnsReorderable);
|
|
1506
|
+
}
|
|
1015
1507
|
return this;
|
|
1016
1508
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1509
|
+
/**
|
|
1510
|
+
* Enables/disables toggleable property on all columns currently in the descriptor.
|
|
1511
|
+
*
|
|
1512
|
+
* @param {boolean} [columnsToggleable] - Boolean flag to set toggleable on columns to.
|
|
1513
|
+
*/
|
|
1514
|
+
withCurrentColumnsToggleable(columnsToggleable = true) {
|
|
1515
|
+
for (const col of this.columns) {
|
|
1516
|
+
col.withToggleable(columnsToggleable);
|
|
1517
|
+
}
|
|
1019
1518
|
return this;
|
|
1020
1519
|
}
|
|
1021
1520
|
/**
|
|
1022
|
-
*
|
|
1521
|
+
* Enables/disabled column resize feature with columnResizeMode on all columns.
|
|
1522
|
+
*
|
|
1023
1523
|
* @param resizableColumns True if enabled
|
|
1024
1524
|
* @param columnResizeMode 'fit' or 'expand' mode
|
|
1025
1525
|
*/
|
|
@@ -1030,6 +1530,7 @@ class TableDescriptorInst {
|
|
|
1030
1530
|
}
|
|
1031
1531
|
/**
|
|
1032
1532
|
* Sets column to (un)frozen.
|
|
1533
|
+
*
|
|
1033
1534
|
* @param selectionColumnFrozen True to freeze selection column, false to unfreeze it.
|
|
1034
1535
|
* @param actionColumnFrozen True to freeze action column, false to unfreeze it.
|
|
1035
1536
|
*/
|
|
@@ -1038,24 +1539,50 @@ class TableDescriptorInst {
|
|
|
1038
1539
|
this._actionColumnFrozen = actionColumnFrozen;
|
|
1039
1540
|
return this;
|
|
1040
1541
|
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Sets the class name for rows in the table.
|
|
1544
|
+
*
|
|
1545
|
+
* @param {string} rowClassName - The CSS class name to be applied to each row.
|
|
1546
|
+
* @param {function} [classNameMapFn] - Optional function to map the class name dynamically based on row's item and current class name.
|
|
1547
|
+
*/
|
|
1041
1548
|
withRowClassName(rowClassName, classNameMapFn) {
|
|
1042
1549
|
this._rowClassName = rowClassName;
|
|
1043
1550
|
this._rowClassNameMapFn = classNameMapFn;
|
|
1044
1551
|
return this;
|
|
1045
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Sets header row class name.
|
|
1555
|
+
*
|
|
1556
|
+
* @param headerClassName Class name.
|
|
1557
|
+
*/
|
|
1046
1558
|
withHeaderClassName(headerClassName) {
|
|
1047
1559
|
this._headerClassName = headerClassName;
|
|
1048
1560
|
return this;
|
|
1049
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Enables localization of the table.
|
|
1564
|
+
*/
|
|
1050
1565
|
withLocalized() {
|
|
1051
1566
|
this._isLocalized = true;
|
|
1052
1567
|
return this;
|
|
1053
1568
|
}
|
|
1054
|
-
|
|
1569
|
+
/**
|
|
1570
|
+
* Sets locale property for localization.
|
|
1571
|
+
*
|
|
1572
|
+
* @param property Locale property
|
|
1573
|
+
*/
|
|
1574
|
+
withLocalizationLocaleProperty(property) {
|
|
1055
1575
|
this._isLocalized = true;
|
|
1056
|
-
this._localizationLocaleProperty =
|
|
1576
|
+
this._localizationLocaleProperty = property;
|
|
1057
1577
|
return this;
|
|
1058
1578
|
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Enables row expanding.
|
|
1581
|
+
*
|
|
1582
|
+
* @param property Property to check if row can be expanded.
|
|
1583
|
+
* @param colSpan set custom row span for expanded row.
|
|
1584
|
+
* @param componentType Component to be displayed on row expand.
|
|
1585
|
+
*/
|
|
1059
1586
|
withRowExpandable(property, colSpan, componentType) {
|
|
1060
1587
|
this._rowExpandable = true;
|
|
1061
1588
|
if (property) {
|
|
@@ -1069,6 +1596,11 @@ class TableDescriptorInst {
|
|
|
1069
1596
|
}
|
|
1070
1597
|
return this;
|
|
1071
1598
|
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Enables row reordering.
|
|
1601
|
+
*
|
|
1602
|
+
* @param reordable Enables/disables feature.
|
|
1603
|
+
*/
|
|
1072
1604
|
withRowReorderable(reordable = true) {
|
|
1073
1605
|
this._rowReorderable = reordable;
|
|
1074
1606
|
return this;
|
|
@@ -1081,8 +1613,6 @@ class TableDescriptorInst {
|
|
|
1081
1613
|
obj._sorts = this._sorts.map(s => s.copy());
|
|
1082
1614
|
obj._className = this._className;
|
|
1083
1615
|
obj._size = this._size;
|
|
1084
|
-
obj._tableFullHeightOffset = this._tableFullHeightOffset;
|
|
1085
|
-
obj._rowHeight = this._rowHeight;
|
|
1086
1616
|
obj._hasHover = this._hasHover;
|
|
1087
1617
|
obj._hasGridlines = this._hasGridlines;
|
|
1088
1618
|
obj._hasResizableColumns = this._hasResizableColumns;
|
|
@@ -1099,6 +1629,9 @@ class TableDescriptorInst {
|
|
|
1099
1629
|
obj._rowExpandableComponentType = this._rowExpandableComponentType;
|
|
1100
1630
|
obj._rowReorderable = this._rowReorderable;
|
|
1101
1631
|
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Copies current descriptor to a new instance.
|
|
1634
|
+
*/
|
|
1102
1635
|
copy() {
|
|
1103
1636
|
const descriptor = new TableDescriptorInst(this.model.copy());
|
|
1104
1637
|
this.copyFieldsTo(descriptor);
|
|
@@ -1432,11 +1965,17 @@ function tableDynamicDescriptor(modelOrOpts) {
|
|
|
1432
1965
|
: new TableDynamicDescriptorInst(new ModelDescriptor(undefined, modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
1433
1966
|
}
|
|
1434
1967
|
|
|
1968
|
+
function tableToDataProvider(descriptor, serviceType) {
|
|
1969
|
+
return typeof serviceType !== 'undefined'
|
|
1970
|
+
? new TableDataProviderInst(undefined, serviceType)
|
|
1971
|
+
: new TableDataProviderInst(undefined, undefined);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1435
1974
|
// data providers
|
|
1436
1975
|
|
|
1437
1976
|
/**
|
|
1438
1977
|
* Generated bundle index. Do not edit.
|
|
1439
1978
|
*/
|
|
1440
1979
|
|
|
1441
|
-
export { ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, SortDescriptor, TableDataProvider, TableDataProviderInst, TableDescriptor, TableDescriptorInst, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableDynamicDescriptorInst, TablePaginationModeEnum, TableSizeEnum, columnToDateNumberOrBoolean, expandClassAttributeDefWithTableDef, getColumnDisplayTypeFromColumnType, getColumnTypeFromClassAttributeDefType, getTableClassAttributeDef, modifyTableClassAttributeColumnEnum, modifyTableClassAttributeColumnType, modifyTableClassAttributeColumnTypeUnsafe, modifyTableColumnFilterLookup, modifyTableColumnFilterLookupUnsafe, tableDataProvider, tableDataProviderFromClass, tableDataProviderFromModel, tableDataProviderWithService, tableDescriptor, tableDescriptorFromClass, tableDescriptorFromClassAttrsDef, tableDescriptorModifyEnumColumnUnsafe, tableDynamicDescriptor, upsertTableColumnFromAttributeDef };
|
|
1980
|
+
export { ColumnDescriptor, ColumnDisplayTypeEnum, ColumnDynamicDescriptor, ColumnTypeEnum, SortDescriptor, TableDataProvider, TableDataProviderInst, TableDescriptor, TableDescriptorInst, TableDynamicColumnsModeEnum, TableDynamicDescriptor, TableDynamicDescriptorInst, TablePaginationModeEnum, TableSizeEnum, columnToDateNumberOrBoolean, expandClassAttributeDefWithTableDef, getColumnDisplayTypeFromColumnType, getColumnTypeFromClassAttributeDefType, getTableClassAttributeDef, modifyTableClassAttributeColumnEnum, modifyTableClassAttributeColumnType, modifyTableClassAttributeColumnTypeUnsafe, modifyTableColumnFilterLookup, modifyTableColumnFilterLookupUnsafe, tableDataProvider, tableDataProviderFromClass, tableDataProviderFromModel, tableDataProviderWithService, tableDescriptor, tableDescriptorFromClass, tableDescriptorFromClassAttrsDef, tableDescriptorModifyEnumColumnUnsafe, tableDynamicDescriptor, tableToDataProvider, upsertTableColumnFromAttributeDef };
|
|
1442
1981
|
//# sourceMappingURL=mediusinc-mng-commons-table-api.mjs.map
|