@mediusinc/mng-commons 5.3.0-rc.2 → 5.3.0-rc.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/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 +3 -3
- 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 +435 -44
- package/esm2022/table/api/helpers/table-data-provider-descriptor-convert.mjs +7 -0
- package/esm2022/table/api/index.mjs +3 -1
- package/esm2022/table/api/models/row-expandable-component.model.mjs +2 -0
- package/esm2022/table/api/models/table-columns.model.mjs +1 -1
- package/esm2022/table/components/column-value/column-value.component.mjs +3 -3
- package/esm2022/table/components/filter/filter-overlay-with-tag/filter-overlay-with-tag.component.mjs +3 -3
- package/esm2022/table/components/table/table.component.mjs +6 -6
- package/esm2022/tableview/action/components/action/action.component.mjs +3 -3
- package/esm2022/tableview/action/components/table/action-table.component.mjs +3 -3
- package/esm2022/tableview/api/editor/descriptors/editor.descriptor.mjs +6 -6
- package/esm2022/tableview/api/editor/descriptors/field-base.descriptor.mjs +2 -4
- package/esm2022/tableview/api/editor/descriptors/field-lookup.descriptor.mjs +1 -1
- package/esm2022/tableview/api/editor/descriptors/field.descriptor.mjs +14 -1
- package/esm2022/tableview/api/editor/models/field-image-preview.model.mjs +2 -0
- package/esm2022/tableview/api/index.mjs +3 -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-autocomplete/formly-field-autocomplete.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-datepicker/formly-field-datepicker.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.mjs +9 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-lookup-dialog/formly-field-lookup-dialog.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +3 -3
- package/esm2022/tableview/editor/components/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +3 -3
- 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 +2 -2
- 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 +602 -53
- package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-table.mjs +9 -9
- package/fesm2022/mediusinc-mng-commons-table.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +45 -19
- package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
- package/fesm2022/mediusinc-mng-commons-tableview.mjs +23 -18
- 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 +7 -7
- 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 +429 -28
- package/table/api/helpers/table-data-provider-descriptor-convert.d.ts +20 -0
- package/table/api/index.d.ts +2 -0
- package/table/api/models/row-expandable-component.model.d.ts +4 -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 +5 -5
- package/tableview/api/editor/descriptors/field-lookup.descriptor.d.ts +12 -12
- package/tableview/api/editor/descriptors/field.descriptor.d.ts +10 -0
- package/tableview/api/editor/models/field-image-preview.model.d.ts +4 -0
- package/tableview/api/index.d.ts +2 -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/tableview/editor/components/formly/fields/formly-field-input/formly-field-input.component.d.ts +1 -0
- package/version-info.json +5 -5
|
@@ -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
|
}
|
|
@@ -728,7 +874,13 @@ class TableDescriptorInst {
|
|
|
728
874
|
return this._rowExpandableProperty;
|
|
729
875
|
}
|
|
730
876
|
/**
|
|
731
|
-
*
|
|
877
|
+
* This property is used to define the type of the custom component that will be used to render the expanded row.
|
|
878
|
+
*/
|
|
879
|
+
get rowExpandableComponentType() {
|
|
880
|
+
return this._rowExpandableComponentType;
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
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.
|
|
732
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).
|
|
733
885
|
* @param identifier
|
|
734
886
|
*/
|
|
@@ -736,112 +888,236 @@ class TableDescriptorInst {
|
|
|
736
888
|
this._identifier = identifier;
|
|
737
889
|
return this;
|
|
738
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
|
+
*/
|
|
739
896
|
withTrackProperty(property) {
|
|
740
897
|
return this.withTrackPropertyUnsafe(property);
|
|
741
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
|
+
*/
|
|
742
906
|
withTrackPropertyUnsafe(property) {
|
|
743
907
|
this._trackProperty = property;
|
|
744
908
|
return this;
|
|
745
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
|
+
*/
|
|
746
917
|
getColumn(property) {
|
|
747
918
|
return this.getColumnUnsafe(property);
|
|
748
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
|
+
*/
|
|
749
929
|
getColumnUnsafe(property) {
|
|
750
930
|
return this._columns.find(col => col.property === property) ?? null;
|
|
751
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Removes the column descriptor for the given property.
|
|
934
|
+
*
|
|
935
|
+
* @param {keyof TableModel} property - The property for column descriptor.
|
|
936
|
+
*/
|
|
752
937
|
removeColumn(property) {
|
|
753
938
|
this.removeColumnUnsafe(property);
|
|
754
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
|
+
*/
|
|
755
947
|
removeColumnUnsafe(property) {
|
|
756
948
|
const columnIdx = this._columns.findIndex(c => c.property === property);
|
|
757
949
|
this._columns.splice(columnIdx, 1);
|
|
758
950
|
}
|
|
951
|
+
/**
|
|
952
|
+
* Adds column descriptor to table columns.
|
|
953
|
+
*
|
|
954
|
+
* @param {ColumnDescriptor<ColumnModel, TableModel, ColumnValue>} column - The property for column descriptor.
|
|
955
|
+
*/
|
|
759
956
|
withColumn(column) {
|
|
760
957
|
this._columns.push(column);
|
|
761
958
|
return this;
|
|
762
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
|
+
*/
|
|
763
967
|
addColumn(property) {
|
|
764
968
|
const column = new ColumnDescriptor(property);
|
|
765
969
|
this._columns.push(column);
|
|
766
970
|
return column;
|
|
767
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
|
+
*/
|
|
768
979
|
addColumnEnum(property, enumDesc) {
|
|
769
980
|
const column = new ColumnDescriptor(property);
|
|
770
981
|
column.asEnumUnsafe(enumDesc);
|
|
771
982
|
this._columns.push(column);
|
|
772
983
|
return column;
|
|
773
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
|
+
*/
|
|
774
994
|
addColumnUnsafe(property) {
|
|
775
995
|
const column = new ColumnDescriptor(property);
|
|
776
996
|
this._columns.push(column);
|
|
777
997
|
return column;
|
|
778
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
|
+
*/
|
|
779
1004
|
withColumns(...properties) {
|
|
780
1005
|
properties.forEach(p => this.addColumn(p));
|
|
781
1006
|
return this;
|
|
782
1007
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
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
|
+
*/
|
|
787
1013
|
withPaginationMode(paginationMode) {
|
|
788
1014
|
this._paginationMode = paginationMode;
|
|
789
1015
|
return this;
|
|
790
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
|
+
*/
|
|
791
1023
|
withRowsPerPage(rows, options) {
|
|
792
1024
|
this._defaultNumRows = rows;
|
|
793
1025
|
this._rowsPerPageOptions = options;
|
|
794
1026
|
return this;
|
|
795
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
|
+
*/
|
|
796
1033
|
withTitle(title) {
|
|
797
1034
|
this._title = title;
|
|
798
1035
|
return this;
|
|
799
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
|
+
*/
|
|
800
1042
|
withHideHeader(hideHeader = true) {
|
|
801
1043
|
this._hideHeader = hideHeader;
|
|
802
1044
|
return this;
|
|
803
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
|
+
*/
|
|
804
1052
|
withLoading(text, icon) {
|
|
805
1053
|
this._loadingText = text;
|
|
806
1054
|
this._loadingIcon = icon === undefined ? 'pi pi-spinner' : icon;
|
|
807
1055
|
return this;
|
|
808
1056
|
}
|
|
809
1057
|
/**
|
|
810
|
-
*
|
|
811
|
-
*
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
col.withReorderable(columnsReorderable);
|
|
816
|
-
}
|
|
817
|
-
return this;
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Helper method that enables/disables toggleable property on all columns currently in the descriptor.
|
|
821
|
-
* @param columnsToggleable
|
|
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.
|
|
822
1063
|
*/
|
|
823
|
-
withCurrentColumnsToggleable(columnsToggleable = true) {
|
|
824
|
-
for (const col of this.columns) {
|
|
825
|
-
col.withToggleable(columnsToggleable);
|
|
826
|
-
}
|
|
827
|
-
return this;
|
|
828
|
-
}
|
|
829
1064
|
getSort(property) {
|
|
830
1065
|
return this.getSortUnsafe(property);
|
|
831
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
|
+
*/
|
|
832
1076
|
getSortUnsafe(property) {
|
|
833
1077
|
return this._sorts.find(s => s.property === property) ?? null;
|
|
834
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Removes the sort for a given property.
|
|
1081
|
+
*
|
|
1082
|
+
* @param {Sorts} property - The property to remove the sort for.
|
|
1083
|
+
*/
|
|
835
1084
|
removeSort(property) {
|
|
836
1085
|
return this.removeSortUnsafe(property);
|
|
837
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
|
+
*/
|
|
838
1094
|
removeSortUnsafe(property) {
|
|
839
1095
|
const sortIdx = this._sorts.findIndex(c => c.property === property);
|
|
840
1096
|
this._sorts.splice(sortIdx, 1);
|
|
841
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
|
+
*/
|
|
842
1107
|
addSort(property, isDefault = false, ascending) {
|
|
843
1108
|
return this.addSortUnsafe(property, isDefault, ascending);
|
|
844
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
|
+
*/
|
|
845
1121
|
addSortUnsafe(property, isDefault = false, ascending) {
|
|
846
1122
|
const sort = new SortDescriptor(property);
|
|
847
1123
|
if (isDefault) {
|
|
@@ -853,16 +1129,50 @@ class TableDescriptorInst {
|
|
|
853
1129
|
this._sorts.push(sort);
|
|
854
1130
|
return sort;
|
|
855
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
|
+
*/
|
|
856
1139
|
withSort(property, isDefault = false, ascending) {
|
|
857
1140
|
return this.withSortUnsafe(property, isDefault, ascending);
|
|
858
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
|
+
*/
|
|
859
1151
|
withSortUnsafe(property, isDefault = false, ascending) {
|
|
860
1152
|
this.addSortUnsafe(property, isDefault, ascending);
|
|
861
1153
|
return this;
|
|
862
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
|
+
*/
|
|
863
1163
|
withDefaultSort(property, ascending, order, enabled) {
|
|
864
1164
|
return this.withDefaultSortUnsafe(property, ascending, order, enabled);
|
|
865
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
|
+
*/
|
|
866
1176
|
withDefaultSortUnsafe(property, ascending, order, enabled) {
|
|
867
1177
|
let sort = this._sorts.find(s => s.property === property);
|
|
868
1178
|
if (!sort) {
|
|
@@ -872,39 +1182,115 @@ class TableDescriptorInst {
|
|
|
872
1182
|
sort.withDefaultSort(enabled ?? true, ascending, order);
|
|
873
1183
|
return this;
|
|
874
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Add sorts for more properties.
|
|
1187
|
+
*
|
|
1188
|
+
* @param properties Properties to add the sorts for.
|
|
1189
|
+
*/
|
|
875
1190
|
withSorts(...properties) {
|
|
876
1191
|
return this.withSortsUnsafe(...properties);
|
|
877
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
|
+
*/
|
|
878
1200
|
withSortsUnsafe(...properties) {
|
|
879
1201
|
properties.forEach(p => {
|
|
880
1202
|
this._sorts.push(new SortDescriptor(p));
|
|
881
1203
|
});
|
|
882
1204
|
return this;
|
|
883
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
|
+
*/
|
|
884
1213
|
getFilter(property) {
|
|
885
1214
|
return this.getFilterUnsafe(property);
|
|
886
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
|
+
*/
|
|
887
1225
|
getFilterUnsafe(property) {
|
|
888
1226
|
return this._filters.find(s => s.property === property) ?? null;
|
|
889
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Removes filter descriptor for given property.
|
|
1230
|
+
*
|
|
1231
|
+
* @param property Filter property
|
|
1232
|
+
*/
|
|
890
1233
|
removeFilter(property) {
|
|
891
1234
|
return this.removeFilterUnsafe(property);
|
|
892
1235
|
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Removes filter descriptor for given property.
|
|
1238
|
+
*
|
|
1239
|
+
* This function is UNSAFE!
|
|
1240
|
+
*
|
|
1241
|
+
* @param property Filter property
|
|
1242
|
+
*/
|
|
893
1243
|
removeFilterUnsafe(property) {
|
|
894
1244
|
const filterIdx = this._filters.findIndex(c => c.property === property);
|
|
895
1245
|
this._filters.splice(filterIdx, 1);
|
|
896
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Creates filter descriptor for the given property.
|
|
1249
|
+
*
|
|
1250
|
+
* @param property Filter property.
|
|
1251
|
+
*
|
|
1252
|
+
* @return Created filter descriptor.
|
|
1253
|
+
*/
|
|
897
1254
|
addFilter(property) {
|
|
898
1255
|
return this.addFilterUnsafe(property);
|
|
899
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
|
+
*/
|
|
900
1266
|
addFilterUnsafe(property) {
|
|
901
1267
|
const filter = new FilterDescriptor(property);
|
|
902
1268
|
this._filters.push(filter);
|
|
903
1269
|
return filter;
|
|
904
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
|
+
*/
|
|
905
1280
|
addFilterLookup(property, provider, optionsValueProperty) {
|
|
906
1281
|
return this.addFilterLookupUnsafe(property, provider, optionsValueProperty);
|
|
907
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
|
+
*/
|
|
908
1294
|
addFilterLookupUnsafe(property, provider, optionsValueProperty) {
|
|
909
1295
|
const filter = new FilterLookupDescriptor(property, {
|
|
910
1296
|
dataProvider: provider,
|
|
@@ -913,26 +1299,86 @@ class TableDescriptorInst {
|
|
|
913
1299
|
this._filters.push(filter);
|
|
914
1300
|
return filter;
|
|
915
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
|
+
*/
|
|
916
1311
|
addFilterLookupEnum(property, enumDesc, options) {
|
|
917
1312
|
return this.addFilterLookupEnumUnsafe(property, enumDesc, options);
|
|
918
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
|
+
*/
|
|
919
1325
|
addFilterLookupEnumUnsafe(property, enumDesc, options) {
|
|
920
1326
|
const filter = new FilterLookupEnumDescriptor(property, enumDesc, options);
|
|
921
1327
|
this._filters.push(filter);
|
|
922
1328
|
return filter;
|
|
923
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
|
+
*/
|
|
924
1341
|
addFilterFromColumn(property, displayType, forceSimple = false) {
|
|
925
1342
|
return this.addFilterFromColumnUnsafe(property, displayType, forceSimple);
|
|
926
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
|
+
*/
|
|
927
1351
|
withFiltersFromColumns(...properties) {
|
|
928
1352
|
return this.withFiltersFromColumnsUnsafe(...properties);
|
|
929
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
|
+
*/
|
|
930
1363
|
withFiltersFromColumnsUnsafe(...properties) {
|
|
931
1364
|
properties.forEach(p => {
|
|
932
1365
|
this.addFilterFromColumnUnsafe(p);
|
|
933
1366
|
});
|
|
934
1367
|
return this;
|
|
935
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
|
+
*/
|
|
936
1382
|
addFilterFromColumnUnsafe(property, displayType, forceSimple = false) {
|
|
937
1383
|
const column = this.getColumnUnsafe(property);
|
|
938
1384
|
if (!column) {
|
|
@@ -943,6 +1389,18 @@ class TableDescriptorInst {
|
|
|
943
1389
|
filter.withDisplayType(displayType);
|
|
944
1390
|
return filter;
|
|
945
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
|
+
*/
|
|
946
1404
|
addFilterFromColumnDescriptorUnsafe(column, forceSimple = false) {
|
|
947
1405
|
let filterDescriptor = new FilterDescriptor(column.property);
|
|
948
1406
|
let filterType;
|
|
@@ -978,42 +1436,90 @@ class TableDescriptorInst {
|
|
|
978
1436
|
this._filters.push(filterDescriptor);
|
|
979
1437
|
return filterDescriptor;
|
|
980
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* Adds filter descriptor for the given property.
|
|
1441
|
+
*
|
|
1442
|
+
* @param property Filter property.
|
|
1443
|
+
* @param filter Descriptor for property.
|
|
1444
|
+
*/
|
|
981
1445
|
withFilter(property, filter) {
|
|
982
1446
|
if (filter.property !== property) {
|
|
983
1447
|
throw new CommonsInternalError(`Filter property "${property}" and Filter descriptor property "${filter.property}" do not match.`);
|
|
984
1448
|
}
|
|
985
1449
|
return this.withFilterUnsafe(filter);
|
|
986
1450
|
}
|
|
1451
|
+
/**
|
|
1452
|
+
* Adds filter descriptor for the given property.
|
|
1453
|
+
*
|
|
1454
|
+
* This function is UNSAFE!
|
|
1455
|
+
*
|
|
1456
|
+
* @param filter Descriptor for property.
|
|
1457
|
+
*/
|
|
987
1458
|
withFilterUnsafe(filter) {
|
|
988
1459
|
this._filters.push(filter);
|
|
989
1460
|
return this;
|
|
990
1461
|
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Sets classes for table component.
|
|
1464
|
+
*
|
|
1465
|
+
* @param className Class names.
|
|
1466
|
+
*/
|
|
991
1467
|
withClassName(className) {
|
|
992
1468
|
this._className = className;
|
|
993
1469
|
return this;
|
|
994
1470
|
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Sets table sizing.
|
|
1473
|
+
*
|
|
1474
|
+
* @param size Table size.
|
|
1475
|
+
*/
|
|
995
1476
|
withSize(size = TableSizeEnum.Normal) {
|
|
996
1477
|
this._size = size;
|
|
997
1478
|
return this;
|
|
998
1479
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
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;
|
|
1001
1487
|
return this;
|
|
1002
1488
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1489
|
+
/**
|
|
1490
|
+
* Enables gridlines on table.
|
|
1491
|
+
*
|
|
1492
|
+
* @param gridlines Enables/disables the gridlines.
|
|
1493
|
+
*/
|
|
1494
|
+
withGridlines(gridlines = true) {
|
|
1495
|
+
this._hasGridlines = gridlines;
|
|
1005
1496
|
return this;
|
|
1006
1497
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
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
|
+
}
|
|
1009
1507
|
return this;
|
|
1010
1508
|
}
|
|
1011
|
-
|
|
1012
|
-
|
|
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
|
+
}
|
|
1013
1518
|
return this;
|
|
1014
1519
|
}
|
|
1015
1520
|
/**
|
|
1016
|
-
*
|
|
1521
|
+
* Enables/disabled column resize feature with columnResizeMode on all columns.
|
|
1522
|
+
*
|
|
1017
1523
|
* @param resizableColumns True if enabled
|
|
1018
1524
|
* @param columnResizeMode 'fit' or 'expand' mode
|
|
1019
1525
|
*/
|
|
@@ -1024,6 +1530,7 @@ class TableDescriptorInst {
|
|
|
1024
1530
|
}
|
|
1025
1531
|
/**
|
|
1026
1532
|
* Sets column to (un)frozen.
|
|
1533
|
+
*
|
|
1027
1534
|
* @param selectionColumnFrozen True to freeze selection column, false to unfreeze it.
|
|
1028
1535
|
* @param actionColumnFrozen True to freeze action column, false to unfreeze it.
|
|
1029
1536
|
*/
|
|
@@ -1032,25 +1539,51 @@ class TableDescriptorInst {
|
|
|
1032
1539
|
this._actionColumnFrozen = actionColumnFrozen;
|
|
1033
1540
|
return this;
|
|
1034
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
|
+
*/
|
|
1035
1548
|
withRowClassName(rowClassName, classNameMapFn) {
|
|
1036
1549
|
this._rowClassName = rowClassName;
|
|
1037
1550
|
this._rowClassNameMapFn = classNameMapFn;
|
|
1038
1551
|
return this;
|
|
1039
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Sets header row class name.
|
|
1555
|
+
*
|
|
1556
|
+
* @param headerClassName Class name.
|
|
1557
|
+
*/
|
|
1040
1558
|
withHeaderClassName(headerClassName) {
|
|
1041
1559
|
this._headerClassName = headerClassName;
|
|
1042
1560
|
return this;
|
|
1043
1561
|
}
|
|
1562
|
+
/**
|
|
1563
|
+
* Enables localization of the table.
|
|
1564
|
+
*/
|
|
1044
1565
|
withLocalized() {
|
|
1045
1566
|
this._isLocalized = true;
|
|
1046
1567
|
return this;
|
|
1047
1568
|
}
|
|
1048
|
-
|
|
1569
|
+
/**
|
|
1570
|
+
* Sets locale property for localization.
|
|
1571
|
+
*
|
|
1572
|
+
* @param property Locale property
|
|
1573
|
+
*/
|
|
1574
|
+
withLocalizationLocaleProperty(property) {
|
|
1049
1575
|
this._isLocalized = true;
|
|
1050
|
-
this._localizationLocaleProperty =
|
|
1576
|
+
this._localizationLocaleProperty = property;
|
|
1051
1577
|
return this;
|
|
1052
1578
|
}
|
|
1053
|
-
|
|
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
|
+
*/
|
|
1586
|
+
withRowExpandable(property, colSpan, componentType) {
|
|
1054
1587
|
this._rowExpandable = true;
|
|
1055
1588
|
if (property) {
|
|
1056
1589
|
this._rowExpandableProperty = property;
|
|
@@ -1058,8 +1591,16 @@ class TableDescriptorInst {
|
|
|
1058
1591
|
if (colSpan) {
|
|
1059
1592
|
this._rowExpandableColSpan = colSpan;
|
|
1060
1593
|
}
|
|
1594
|
+
if (componentType) {
|
|
1595
|
+
this._rowExpandableComponentType = componentType;
|
|
1596
|
+
}
|
|
1061
1597
|
return this;
|
|
1062
1598
|
}
|
|
1599
|
+
/**
|
|
1600
|
+
* Enables row reordering.
|
|
1601
|
+
*
|
|
1602
|
+
* @param reordable Enables/disables feature.
|
|
1603
|
+
*/
|
|
1063
1604
|
withRowReorderable(reordable = true) {
|
|
1064
1605
|
this._rowReorderable = reordable;
|
|
1065
1606
|
return this;
|
|
@@ -1072,8 +1613,6 @@ class TableDescriptorInst {
|
|
|
1072
1613
|
obj._sorts = this._sorts.map(s => s.copy());
|
|
1073
1614
|
obj._className = this._className;
|
|
1074
1615
|
obj._size = this._size;
|
|
1075
|
-
obj._tableFullHeightOffset = this._tableFullHeightOffset;
|
|
1076
|
-
obj._rowHeight = this._rowHeight;
|
|
1077
1616
|
obj._hasHover = this._hasHover;
|
|
1078
1617
|
obj._hasGridlines = this._hasGridlines;
|
|
1079
1618
|
obj._hasResizableColumns = this._hasResizableColumns;
|
|
@@ -1087,8 +1626,12 @@ class TableDescriptorInst {
|
|
|
1087
1626
|
obj._rowExpandable = this._rowExpandable;
|
|
1088
1627
|
obj._rowExpandableColSpan = this._rowExpandableColSpan;
|
|
1089
1628
|
obj._rowExpandableProperty = this._rowExpandableProperty;
|
|
1629
|
+
obj._rowExpandableComponentType = this._rowExpandableComponentType;
|
|
1090
1630
|
obj._rowReorderable = this._rowReorderable;
|
|
1091
1631
|
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Copies current descriptor to a new instance.
|
|
1634
|
+
*/
|
|
1092
1635
|
copy() {
|
|
1093
1636
|
const descriptor = new TableDescriptorInst(this.model.copy());
|
|
1094
1637
|
this.copyFieldsTo(descriptor);
|
|
@@ -1422,11 +1965,17 @@ function tableDynamicDescriptor(modelOrOpts) {
|
|
|
1422
1965
|
: new TableDynamicDescriptorInst(new ModelDescriptor(undefined, modelOrOpts?.id, modelOrOpts?.title, modelOrOpts?.i18nBase));
|
|
1423
1966
|
}
|
|
1424
1967
|
|
|
1968
|
+
function tableToDataProvider(descriptor, serviceType) {
|
|
1969
|
+
return typeof serviceType !== 'undefined'
|
|
1970
|
+
? new TableDataProviderInst(undefined, serviceType)
|
|
1971
|
+
: new TableDataProviderInst(undefined, undefined);
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1425
1974
|
// data providers
|
|
1426
1975
|
|
|
1427
1976
|
/**
|
|
1428
1977
|
* Generated bundle index. Do not edit.
|
|
1429
1978
|
*/
|
|
1430
1979
|
|
|
1431
|
-
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 };
|
|
1432
1981
|
//# sourceMappingURL=mediusinc-mng-commons-table-api.mjs.map
|