@seniorsistemas/angular-components 19.6.2 → 19.7.1
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/dynamic-form/dynamic-form/components/lookup/lookup.component.d.ts +2 -1
- package/dynamic-form/dynamic-form/components/lookup/types/lookup-models.d.ts +2 -1
- package/dynamic-form/dynamic-form/form-field/configurations/fields/number-field.d.ts +1 -1
- package/dynamic-form/dynamic-form/form-field/fields/bignumber/bignumber-field.component.d.ts +1 -1
- package/dynamic-form/dynamic-form/form-field/fields/currency/currency-field.component.d.ts +1 -1
- package/dynamic-form/dynamic-form/form-field/fields/text/text-field.component.d.ts +1 -2
- package/esm2022/alert/lib/alert/alert.component.mjs +3 -3
- package/esm2022/dynamic-form/dynamic-form/components/lookup/lookup.component.mjs +1 -1
- package/esm2022/dynamic-form/dynamic-form/components/lookup/types/lookup-models.mjs +1 -1
- package/esm2022/dynamic-form/dynamic-form/form-field/configurations/fields/number-field.mjs +1 -1
- package/esm2022/dynamic-form/dynamic-form/form-field/fields/bignumber/bignumber-field.component.mjs +16 -17
- package/esm2022/dynamic-form/dynamic-form/form-field/fields/currency/currency-field.component.mjs +20 -23
- package/esm2022/dynamic-form/dynamic-form/form-field/fields/number/number-field.component.mjs +9 -10
- package/esm2022/dynamic-form/dynamic-form/form-field/fields/text/text-field.component.mjs +9 -15
- package/esm2022/inline-edit/lib/inline-edit/components/fields/inline-edit-number/inline-edit-number.component.mjs +4 -4
- package/esm2022/inline-edit/lib/inline-edit/fields/inline-edit-number-field.mjs +1 -1
- package/esm2022/inline-edit/lib/inline-edit/inline-edit.module.mjs +4 -5
- package/esm2022/input-mask/lib/input-mask/input-mask.directive.mjs +460 -0
- package/esm2022/input-mask/lib/input-mask/input-mask.module.mjs +16 -0
- package/esm2022/input-mask/public-api.mjs +3 -0
- package/esm2022/input-mask/seniorsistemas-angular-components-input-mask.mjs +5 -0
- package/esm2022/lib/locale/fallback.mjs +3 -1
- package/esm2022/table/lib/table/table-column/column-number-format.utils.mjs +24 -0
- package/esm2022/table/lib/table/table-paging/export-number-format.mjs +104 -0
- package/esm2022/table/lib/table/table-paging/models/export-number-format.enum.mjs +6 -0
- package/esm2022/table/lib/table/table-paging/models/index.mjs +2 -2
- package/esm2022/table/lib/table/table-paging/table-paging.component.mjs +58 -99
- package/fesm2022/seniorsistemas-angular-components-alert.mjs +2 -2
- package/fesm2022/seniorsistemas-angular-components-alert.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components-dynamic-form.mjs +53 -62
- package/fesm2022/seniorsistemas-angular-components-dynamic-form.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components-inline-edit.mjs +6 -7
- package/fesm2022/seniorsistemas-angular-components-inline-edit.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components-input-mask.mjs +480 -0
- package/fesm2022/seniorsistemas-angular-components-input-mask.mjs.map +1 -0
- package/fesm2022/seniorsistemas-angular-components-table.mjs +181 -98
- package/fesm2022/seniorsistemas-angular-components-table.mjs.map +1 -1
- package/fesm2022/seniorsistemas-angular-components.mjs +2 -0
- package/fesm2022/seniorsistemas-angular-components.mjs.map +1 -1
- package/inline-edit/lib/inline-edit/fields/inline-edit-number-field.d.ts +2 -2
- package/inline-edit/lib/inline-edit/inline-edit.module.d.ts +2 -2
- package/input-mask/README.md +183 -0
- package/input-mask/index.d.ts +5 -0
- package/input-mask/lib/input-mask/input-mask.directive.d.ts +103 -0
- package/input-mask/lib/input-mask/input-mask.module.d.ts +7 -0
- package/input-mask/public-api.d.ts +2 -0
- package/package.json +18 -12
- package/schematics/migrations/migrate-dynamic-form-v19/index.d.ts +2 -0
- package/schematics/migrations/migrate-dynamic-form-v19/index.js +964 -0
- package/schematics/migrations/migrate-dynamic-form-v19/index.js.map +1 -0
- package/schematics/migrations/migrate-dynamic-form-v19/index.test.d.ts +1 -0
- package/schematics/migrations/migrate-dynamic-form-v19/index.test.js +888 -0
- package/schematics/migrations/migrate-dynamic-form-v19/index.test.js.map +1 -0
- package/schematics/migrations/migrate-p-datepicker/index.js +4 -8
- package/schematics/migrations/migrate-p-datepicker/index.js.map +1 -1
- package/schematics/migrations/migrate-p-editor/index.d.ts +2 -0
- package/schematics/migrations/migrate-p-editor/index.js +301 -0
- package/schematics/migrations/migrate-p-editor/index.js.map +1 -0
- package/schematics/migrations/migrate-p-editor/index.test.d.ts +1 -0
- package/schematics/migrations/migrate-p-editor/index.test.js +393 -0
- package/schematics/migrations/migrate-p-editor/index.test.js.map +1 -0
- package/schematics/migrations.json +11 -0
- package/schematics/utils/ast-utils.d.ts +7 -0
- package/schematics/utils/ast-utils.js +20 -0
- package/schematics/utils/ast-utils.js.map +1 -1
- package/schematics/utils/html-utils.d.ts +6 -0
- package/schematics/utils/html-utils.js +15 -0
- package/schematics/utils/html-utils.js.map +1 -0
- package/table/README.md +28 -0
- package/table/lib/table/table-column/column-number-format.utils.d.ts +5 -0
- package/table/lib/table/table-paging/export-number-format.d.ts +15 -0
- package/table/lib/table/table-paging/models/export-number-format.enum.d.ts +4 -0
- package/table/lib/table/table-paging/models/index.d.ts +1 -0
- package/table/lib/table/table-paging/table-paging.component.d.ts +10 -27
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Directive, HostListener, inject, Input, ViewContainerRef, Component, ViewChild,
|
|
2
|
+
import { Directive, HostListener, inject, Input, ViewContainerRef, Component, ViewChild, input, NgModule } from '@angular/core';
|
|
3
3
|
import { RowToggler, Table } from 'primeng/table';
|
|
4
4
|
import { TranslateService, TranslateModule } from '@ngx-translate/core';
|
|
5
5
|
import { HostProjectConfigsInjectionToken } from '@seniorsistemas/angular-components/common';
|
|
6
6
|
import { LocaleService, applyLocalizedMask } from '@seniorsistemas/angular-components/locale';
|
|
7
7
|
import { NumericService } from '@seniorsistemas/angular-components/numeric';
|
|
8
8
|
import { deepClone, isNullOrUndefined } from '@seniorsistemas/angular-components/utils';
|
|
9
|
-
import BigNumber
|
|
9
|
+
import BigNumber from 'bignumber.js';
|
|
10
10
|
import moment from 'moment';
|
|
11
11
|
import * as i1 from '@angular/common';
|
|
12
12
|
import { CommonModule } from '@angular/common';
|
|
@@ -477,7 +477,7 @@ class TableColumnsComponent {
|
|
|
477
477
|
return '';
|
|
478
478
|
}
|
|
479
479
|
isNumber(value) {
|
|
480
|
-
return !new BigNumber
|
|
480
|
+
return !new BigNumber(value).isNaN();
|
|
481
481
|
}
|
|
482
482
|
getTokens(values) {
|
|
483
483
|
if (!this.isArray(values)) {
|
|
@@ -527,6 +527,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
527
527
|
type: Input
|
|
528
528
|
}] } });
|
|
529
529
|
|
|
530
|
+
var ExportNumberFormat;
|
|
531
|
+
(function (ExportNumberFormat) {
|
|
532
|
+
ExportNumberFormat["Raw"] = "raw";
|
|
533
|
+
ExportNumberFormat["Localized"] = "localized";
|
|
534
|
+
})(ExportNumberFormat || (ExportNumberFormat = {}));
|
|
535
|
+
|
|
530
536
|
class ExportUtils {
|
|
531
537
|
static addClass(element, className) {
|
|
532
538
|
element.nativeElement.className = `${element.nativeElement.className} ${className}`;
|
|
@@ -638,6 +644,127 @@ class ExportUtils {
|
|
|
638
644
|
}
|
|
639
645
|
const isObject = (obj) => obj !== null && typeof obj === 'object';
|
|
640
646
|
|
|
647
|
+
function isNumericColumnType(type) {
|
|
648
|
+
return type === EnumColumnFieldType.NUMBER || type === EnumColumnFieldType.CURRENCY;
|
|
649
|
+
}
|
|
650
|
+
function isNumericValue(value) {
|
|
651
|
+
return !new BigNumber(value).isNaN();
|
|
652
|
+
}
|
|
653
|
+
function resolveColumnNumberFormatOptions(column, rowValue, cellNumberFormatOptions) {
|
|
654
|
+
if (cellNumberFormatOptions) {
|
|
655
|
+
return cellNumberFormatOptions;
|
|
656
|
+
}
|
|
657
|
+
return typeof column.numberFormatOptions === 'function'
|
|
658
|
+
? column.numberFormatOptions({ rowData: rowValue })
|
|
659
|
+
: column.numberFormatOptions;
|
|
660
|
+
}
|
|
661
|
+
function resolveColumnScale(column, rowValue, fallback = 0) {
|
|
662
|
+
if (isNullOrUndefined(column.scale)) {
|
|
663
|
+
return fallback;
|
|
664
|
+
}
|
|
665
|
+
return typeof column.scale === 'function' ? column.scale(rowValue) : column.scale;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function isRowValueFormatOption(cell) {
|
|
669
|
+
return !isNullOrUndefined(cell) && typeof cell === 'object' && 'value' in cell;
|
|
670
|
+
}
|
|
671
|
+
function swapDecimalSeparator(value, decimalSeparator) {
|
|
672
|
+
// toFixed() (sem argumento) preserva a precisão total e nunca usa notação exponencial,
|
|
673
|
+
// ao contrário de toString(), que passa a notação científica para valores muito grandes/pequenos.
|
|
674
|
+
return new BigNumber(value).toFixed().replace('.', decimalSeparator);
|
|
675
|
+
}
|
|
676
|
+
// column.attributes é a fonte preferencial (é o que table-columns.component.ts usa pra formatar
|
|
677
|
+
// a mesma coluna na tela), mas colunas configuradas só com `field` (sem `attributes`) também
|
|
678
|
+
// precisam ser resolvidas — mesmo fallback que mapCustomExport/mapColumnsTranslations já usam.
|
|
679
|
+
function resolveColumnAttributes(column) {
|
|
680
|
+
if (column.attributes?.length) {
|
|
681
|
+
return column.attributes;
|
|
682
|
+
}
|
|
683
|
+
const field = column.field;
|
|
684
|
+
if (isNullOrUndefined(field)) {
|
|
685
|
+
return [];
|
|
686
|
+
}
|
|
687
|
+
return Array.isArray(field) ? field : [field];
|
|
688
|
+
}
|
|
689
|
+
function mapExportValuesRaw(columns, tableData) {
|
|
690
|
+
const numericColumns = columns.filter((column) => isNumericColumnType(column.type));
|
|
691
|
+
if (!numericColumns.length) {
|
|
692
|
+
return tableData;
|
|
693
|
+
}
|
|
694
|
+
return tableData.map((rowData) => {
|
|
695
|
+
const newRow = { ...rowData };
|
|
696
|
+
for (const column of numericColumns) {
|
|
697
|
+
for (const attribute of resolveColumnAttributes(column)) {
|
|
698
|
+
const cell = newRow[attribute];
|
|
699
|
+
if (isRowValueFormatOption(cell)) {
|
|
700
|
+
newRow[attribute] = cell.value ?? null;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return newRow;
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
function mapExportValuesLocalized(columns, tableData, numericService, localeOptions) {
|
|
708
|
+
const numericColumns = columns.filter((column) => isNumericColumnType(column.type));
|
|
709
|
+
if (!numericColumns.length) {
|
|
710
|
+
return tableData;
|
|
711
|
+
}
|
|
712
|
+
return tableData.map((rowData) => {
|
|
713
|
+
const newRow = { ...rowData };
|
|
714
|
+
for (const column of numericColumns) {
|
|
715
|
+
for (const attribute of resolveColumnAttributes(column)) {
|
|
716
|
+
const cell = newRow[attribute];
|
|
717
|
+
if (isNullOrUndefined(cell)) {
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
const isRichValue = isRowValueFormatOption(cell);
|
|
721
|
+
const rawValue = isRichValue ? cell.value : cell;
|
|
722
|
+
if (isNullOrUndefined(rawValue)) {
|
|
723
|
+
// Rich-value com value ausente representa um número "não informado" — desembrulha
|
|
724
|
+
// pra null em vez de deixar o objeto { value, options } intocado (viraria
|
|
725
|
+
// "[object Object]" no CSV), igual ao que mapExportValuesRaw já faz.
|
|
726
|
+
newRow[attribute] = null;
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
const cellNumberFormatOptions = isRichValue ? cell.options?.numberFormatOptions : undefined;
|
|
730
|
+
const numberFormatOptions = resolveColumnNumberFormatOptions(column, rowData, cellNumberFormatOptions);
|
|
731
|
+
if (numberFormatOptions) {
|
|
732
|
+
const valueToFormat = numberFormatOptions.style === 'percent'
|
|
733
|
+
? new BigNumber(rawValue).times(100).toNumber()
|
|
734
|
+
: rawValue;
|
|
735
|
+
newRow[attribute] = numericService.instant(valueToFormat, {
|
|
736
|
+
locale: localeOptions?.locale,
|
|
737
|
+
numberFormatOptions: {
|
|
738
|
+
...numberFormatOptions,
|
|
739
|
+
style: 'decimal',
|
|
740
|
+
useGrouping: false,
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
const decimalSeparator = localeOptions?.number.decimalSeparator ?? ',';
|
|
746
|
+
if (isNullOrUndefined(column.scale)) {
|
|
747
|
+
// Sem scale configurado, não há uma quantidade de casas decimais "correta" a impor:
|
|
748
|
+
// só troca o separador, preservando a precisão original do dado (evita perda de dados no export).
|
|
749
|
+
newRow[attribute] = isNumericValue(rawValue)
|
|
750
|
+
? swapDecimalSeparator(rawValue, decimalSeparator)
|
|
751
|
+
: rawValue;
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
newRow[attribute] = applyLocalizedMask(rawValue, {
|
|
755
|
+
decimalSeparator,
|
|
756
|
+
thousandsSeparator: '',
|
|
757
|
+
scale: resolveColumnScale(column, rowData),
|
|
758
|
+
prefix: '',
|
|
759
|
+
suffix: '',
|
|
760
|
+
allowNegative: true,
|
|
761
|
+
}, isNumericValue(rawValue));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return newRow;
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
|
|
641
768
|
class TablePagingComponent {
|
|
642
769
|
translate = inject(TranslateService);
|
|
643
770
|
hostProjectConfigs = inject(HostProjectConfigsInjectionToken);
|
|
@@ -650,8 +777,10 @@ class TablePagingComponent {
|
|
|
650
777
|
loadAllRecords;
|
|
651
778
|
loadCurrentPageRecords;
|
|
652
779
|
loadSelectedRecords;
|
|
780
|
+
exportNumberFormat = input();
|
|
653
781
|
totalRecordsText = '';
|
|
654
|
-
localeService =
|
|
782
|
+
localeService = inject(LocaleService);
|
|
783
|
+
numericService = inject(NumericService);
|
|
655
784
|
ngOnChanges(changes) {
|
|
656
785
|
if (changes['totalRecords']?.currentValue) {
|
|
657
786
|
this.totalRecordsText = this.translate.instant(`${this.getTranslatePrefix()}total_records`, {
|
|
@@ -667,25 +796,13 @@ class TablePagingComponent {
|
|
|
667
796
|
}
|
|
668
797
|
getActions() {
|
|
669
798
|
const actions = [
|
|
670
|
-
{
|
|
671
|
-
dataKey: 'exportCurrentPage',
|
|
672
|
-
label: this.translate.instant(`${this.getTranslatePrefix()}export_current_page`),
|
|
673
|
-
command: () => this.exportCurrentPage(),
|
|
674
|
-
},
|
|
799
|
+
this.buildScopeAction('exportCurrentPage', `${this.getTranslatePrefix()}export_current_page`, (format) => this.exportCurrentPage(format)),
|
|
675
800
|
];
|
|
676
801
|
if (this.enableExportSelectedRecords) {
|
|
677
|
-
actions.push({
|
|
678
|
-
dataKey: 'exportSelected',
|
|
679
|
-
label: this.translate.instant(`${this.getTranslatePrefix()}export_selected_records`),
|
|
680
|
-
command: () => this.exportSelectedRecords(),
|
|
681
|
-
});
|
|
802
|
+
actions.push(this.buildScopeAction('exportSelected', `${this.getTranslatePrefix()}export_selected_records`, (format) => this.exportSelectedRecords(format)));
|
|
682
803
|
}
|
|
683
804
|
if (this.loadAllRecords) {
|
|
684
|
-
actions.push({
|
|
685
|
-
dataKey: 'exportAll',
|
|
686
|
-
label: this.translate.instant(`${this.getTranslatePrefix()}export_all_records`),
|
|
687
|
-
command: () => this.exportAllRecords(),
|
|
688
|
-
});
|
|
805
|
+
actions.push(this.buildScopeAction('exportAll', `${this.getTranslatePrefix()}export_all_records`, (format) => this.exportAllRecords(format)));
|
|
689
806
|
}
|
|
690
807
|
if (this.customActions?.length) {
|
|
691
808
|
const customMenus = this.customActions.map((p, $index) => ({
|
|
@@ -697,6 +814,32 @@ class TablePagingComponent {
|
|
|
697
814
|
}
|
|
698
815
|
return actions;
|
|
699
816
|
}
|
|
817
|
+
buildScopeAction(dataKey, label, run) {
|
|
818
|
+
const fixedFormat = this.exportNumberFormat();
|
|
819
|
+
if (fixedFormat) {
|
|
820
|
+
return {
|
|
821
|
+
dataKey,
|
|
822
|
+
label: this.translate.instant(label),
|
|
823
|
+
command: () => run(fixedFormat),
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
return {
|
|
827
|
+
dataKey,
|
|
828
|
+
label: this.translate.instant(label),
|
|
829
|
+
submenu: [
|
|
830
|
+
{
|
|
831
|
+
dataKey: `${dataKey}_raw`,
|
|
832
|
+
label: this.translate.instant('platform.angular_components.export_raw_data'),
|
|
833
|
+
command: () => run(ExportNumberFormat.Raw),
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
dataKey: `${dataKey}_localized`,
|
|
837
|
+
label: this.translate.instant('platform.angular_components.export_localized_data'),
|
|
838
|
+
command: () => run(ExportNumberFormat.Localized),
|
|
839
|
+
},
|
|
840
|
+
],
|
|
841
|
+
};
|
|
842
|
+
}
|
|
700
843
|
validateComponent() {
|
|
701
844
|
if (!this.table) {
|
|
702
845
|
throw new Error('Table component not defined');
|
|
@@ -727,22 +870,29 @@ class TablePagingComponent {
|
|
|
727
870
|
return exportColumn;
|
|
728
871
|
});
|
|
729
872
|
}
|
|
730
|
-
getCurrentPageRowsToExport(columns) {
|
|
873
|
+
getCurrentPageRowsToExport(columns, format) {
|
|
731
874
|
let tableData = deepClone(this.table.value);
|
|
732
875
|
if (this.loadCurrentPageRecords) {
|
|
733
876
|
tableData = this.loadCurrentPageRecords();
|
|
734
877
|
}
|
|
735
|
-
tableData = this.
|
|
878
|
+
tableData = this.mapCustomExport(columns, tableData);
|
|
879
|
+
tableData = this.mapNumberFormat(columns, tableData, format);
|
|
736
880
|
return this.mapColumnsTranslations(columns, tableData);
|
|
737
881
|
}
|
|
738
|
-
getSelectedRowsToExport(columns) {
|
|
882
|
+
getSelectedRowsToExport(columns, format) {
|
|
739
883
|
let tableData = deepClone(this.table.selection);
|
|
740
884
|
if (this.loadSelectedRecords) {
|
|
741
885
|
tableData = this.loadSelectedRecords();
|
|
742
886
|
}
|
|
743
|
-
tableData = this.
|
|
887
|
+
tableData = this.mapCustomExport(columns, tableData);
|
|
888
|
+
tableData = this.mapNumberFormat(columns, tableData, format);
|
|
744
889
|
return this.mapColumnsTranslations(columns, tableData);
|
|
745
890
|
}
|
|
891
|
+
mapNumberFormat(columns, tableData, format) {
|
|
892
|
+
return format === ExportNumberFormat.Raw
|
|
893
|
+
? mapExportValuesRaw(columns, tableData)
|
|
894
|
+
: mapExportValuesLocalized(columns, tableData, this.numericService, this.localeService.getLocaleOptions());
|
|
895
|
+
}
|
|
746
896
|
getPropertyValue(obj, path) {
|
|
747
897
|
return path
|
|
748
898
|
.split('.')
|
|
@@ -831,19 +981,19 @@ class TablePagingComponent {
|
|
|
831
981
|
const formattedTime = date.toLocaleTimeString(lang).replace(' ', '-');
|
|
832
982
|
return `${fileName}_${formattedDate}_${formattedTime}`;
|
|
833
983
|
}
|
|
834
|
-
exportCurrentPage() {
|
|
984
|
+
exportCurrentPage(format = ExportNumberFormat.Localized) {
|
|
835
985
|
this.validateComponent();
|
|
836
986
|
const columns = this.getColumnsToExport();
|
|
837
|
-
const dataToExport = this.getCurrentPageRowsToExport(columns);
|
|
987
|
+
const dataToExport = this.getCurrentPageRowsToExport(columns, format);
|
|
838
988
|
ExportUtils.exportCSV(columns, dataToExport, undefined, this.getExportFileName());
|
|
839
989
|
}
|
|
840
|
-
exportSelectedRecords() {
|
|
990
|
+
exportSelectedRecords(format = ExportNumberFormat.Localized) {
|
|
841
991
|
this.validateComponent();
|
|
842
992
|
const columns = this.getColumnsToExport();
|
|
843
|
-
const dataToExport = this.getSelectedRowsToExport(columns);
|
|
993
|
+
const dataToExport = this.getSelectedRowsToExport(columns, format);
|
|
844
994
|
ExportUtils.exportCSV(columns, dataToExport, undefined, this.getExportFileName());
|
|
845
995
|
}
|
|
846
|
-
async exportAllRecords() {
|
|
996
|
+
async exportAllRecords(format = ExportNumberFormat.Localized) {
|
|
847
997
|
this.validateComponent();
|
|
848
998
|
if (!this.loadAllRecords) {
|
|
849
999
|
return;
|
|
@@ -851,79 +1001,12 @@ class TablePagingComponent {
|
|
|
851
1001
|
let serverData = await this.loadAllRecords();
|
|
852
1002
|
const columns = this.getColumnsToExport();
|
|
853
1003
|
serverData = this.mapCustomExport(columns, serverData);
|
|
854
|
-
serverData = this.
|
|
1004
|
+
serverData = this.mapNumberFormat(columns, serverData, format);
|
|
855
1005
|
const dataToExport = this.mapColumnsTranslations(columns, serverData);
|
|
856
1006
|
ExportUtils.exportCSV(columns, dataToExport, undefined, this.getExportFileName());
|
|
857
1007
|
}
|
|
858
|
-
/**
|
|
859
|
-
* The purpose of this method is to map values
|
|
860
|
-
* from the TableColumnsComponent, which uses the numberFormatOptions
|
|
861
|
-
* field, along with rows that have a custom numberFormatOptions,
|
|
862
|
-
* to ensure the correct values are exported by the TablePagingComponent.
|
|
863
|
-
*
|
|
864
|
-
* @returns Returns the correctly mapped tableData.
|
|
865
|
-
*/
|
|
866
|
-
mapNumberFormatOptionsExport(columns, tableData) {
|
|
867
|
-
const hasNumberFormatOptionsColumns = columns.some((column) => column.numberFormatOptions);
|
|
868
|
-
const hasNumberFormatOptionsRows = tableData.some((rowData) => Object.keys(rowData).some((key) => rowData[key]?.options?.numberFormatOptions));
|
|
869
|
-
if (!hasNumberFormatOptionsColumns && !hasNumberFormatOptionsRows)
|
|
870
|
-
return tableData;
|
|
871
|
-
if (hasNumberFormatOptionsColumns) {
|
|
872
|
-
tableData = tableData.map((rowData) => {
|
|
873
|
-
const columnsWithNumberFormatOptions = columns.filter((column) => column.numberFormatOptions);
|
|
874
|
-
for (const column of columnsWithNumberFormatOptions) {
|
|
875
|
-
const attributes = column.attributes;
|
|
876
|
-
const numberFormatOptions = typeof column.numberFormatOptions === 'function'
|
|
877
|
-
? column.numberFormatOptions({
|
|
878
|
-
rowData,
|
|
879
|
-
})
|
|
880
|
-
: column.numberFormatOptions;
|
|
881
|
-
for (const attribute of attributes) {
|
|
882
|
-
if (isNullOrUndefined(rowData[attribute]))
|
|
883
|
-
continue;
|
|
884
|
-
if (rowData[attribute].options?.numberFormatOptions) {
|
|
885
|
-
continue;
|
|
886
|
-
}
|
|
887
|
-
const value = rowData[attribute];
|
|
888
|
-
const mappedValue = numberFormatOptions?.style === 'percent'
|
|
889
|
-
? new BigNumber(value).times(100)
|
|
890
|
-
: new BigNumber(value);
|
|
891
|
-
const numberFormat = new Intl.NumberFormat(this.localeService.getLocaleOptions().locale, {
|
|
892
|
-
...numberFormatOptions,
|
|
893
|
-
style: 'decimal',
|
|
894
|
-
useGrouping: false,
|
|
895
|
-
roundingMode: 'trunc',
|
|
896
|
-
});
|
|
897
|
-
rowData[attribute] = numberFormat.format(mappedValue.toNumber());
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
return rowData;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
if (hasNumberFormatOptionsRows) {
|
|
904
|
-
tableData = tableData.map((rowData) => {
|
|
905
|
-
const keysWithNumberFormatOptions = Object.keys(rowData).filter((key) => rowData[key]?.options?.numberFormatOptions);
|
|
906
|
-
for (const key of keysWithNumberFormatOptions) {
|
|
907
|
-
const value = rowData[key].value;
|
|
908
|
-
const numberFormatOptions = rowData[key].options?.numberFormatOptions;
|
|
909
|
-
const mappedValue = numberFormatOptions?.style === 'percent'
|
|
910
|
-
? new BigNumber(value).times(100)
|
|
911
|
-
: new BigNumber(value);
|
|
912
|
-
const numberFormat = new Intl.NumberFormat(this.localeService.getLocaleOptions().locale, {
|
|
913
|
-
...numberFormatOptions,
|
|
914
|
-
style: 'decimal',
|
|
915
|
-
useGrouping: false,
|
|
916
|
-
roundingMode: 'trunc',
|
|
917
|
-
});
|
|
918
|
-
rowData[key] = numberFormat.format(mappedValue.toNumber());
|
|
919
|
-
}
|
|
920
|
-
return rowData;
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
return tableData;
|
|
924
|
-
}
|
|
925
1008
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TablePagingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
926
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: TablePagingComponent, selector: "s-table-paging", inputs: { totalRecords: "totalRecords", exportFileName: "exportFileName", table: "table", exportable: "exportable", enableExportSelectedRecords: "enableExportSelectedRecords", customActions: "customActions", loadAllRecords: "loadAllRecords", loadCurrentPageRecords: "loadCurrentPageRecords", loadSelectedRecords: "loadSelectedRecords" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"paging-container\">\n <span class=\"total-records\">\n {{ totalRecordsText }}\n </span>\n @if (exportable) {\n <s-button\n class=\"export-button\"\n priority=\"default\"\n iconClass=\"fa fa-fw fa-file-export\"\n [disabled]=\"false\"\n [auxiliary]=\"true\"\n [tooltip]=\"getTooltipText()\"\n [menuOptions]=\"getActions()\"\n >\n </s-button>\n }\n</div>\n", styles: [".paging-container{display:flex;align-items:center}.export-button{margin-left:6px}\n"], dependencies: [{ kind: "component", type: i1$1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked"] }] });
|
|
1009
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: TablePagingComponent, selector: "s-table-paging", inputs: { totalRecords: { classPropertyName: "totalRecords", publicName: "totalRecords", isSignal: false, isRequired: false, transformFunction: null }, exportFileName: { classPropertyName: "exportFileName", publicName: "exportFileName", isSignal: false, isRequired: false, transformFunction: null }, table: { classPropertyName: "table", publicName: "table", isSignal: false, isRequired: false, transformFunction: null }, exportable: { classPropertyName: "exportable", publicName: "exportable", isSignal: false, isRequired: false, transformFunction: null }, enableExportSelectedRecords: { classPropertyName: "enableExportSelectedRecords", publicName: "enableExportSelectedRecords", isSignal: false, isRequired: false, transformFunction: null }, customActions: { classPropertyName: "customActions", publicName: "customActions", isSignal: false, isRequired: false, transformFunction: null }, loadAllRecords: { classPropertyName: "loadAllRecords", publicName: "loadAllRecords", isSignal: false, isRequired: false, transformFunction: null }, loadCurrentPageRecords: { classPropertyName: "loadCurrentPageRecords", publicName: "loadCurrentPageRecords", isSignal: false, isRequired: false, transformFunction: null }, loadSelectedRecords: { classPropertyName: "loadSelectedRecords", publicName: "loadSelectedRecords", isSignal: false, isRequired: false, transformFunction: null }, exportNumberFormat: { classPropertyName: "exportNumberFormat", publicName: "exportNumberFormat", isSignal: true, isRequired: false, transformFunction: null } }, usesOnChanges: true, ngImport: i0, template: "<div class=\"paging-container\">\n <span class=\"total-records\">\n {{ totalRecordsText }}\n </span>\n @if (exportable) {\n <s-button\n class=\"export-button\"\n priority=\"default\"\n iconClass=\"fa fa-fw fa-file-export\"\n [disabled]=\"false\"\n [auxiliary]=\"true\"\n [tooltip]=\"getTooltipText()\"\n [menuOptions]=\"getActions()\"\n >\n </s-button>\n }\n</div>\n", styles: [".paging-container{display:flex;align-items:center}.export-button{margin-left:6px}\n"], dependencies: [{ kind: "component", type: i1$1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor", "menuAriaLabel", "ariaLabel"], outputs: ["clicked"] }] });
|
|
927
1010
|
}
|
|
928
1011
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TablePagingComponent, decorators: [{
|
|
929
1012
|
type: Component,
|
|
@@ -988,5 +1071,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImpo
|
|
|
988
1071
|
* Generated bundle index. Do not edit.
|
|
989
1072
|
*/
|
|
990
1073
|
|
|
991
|
-
export { EnumBadgeColors, EnumColumnFieldType, ExportUtils, NavigationDirective, RowTogllerDirective, TableColumnsComponent, TableModule, TablePagingComponent };
|
|
1074
|
+
export { EnumBadgeColors, EnumColumnFieldType, ExportNumberFormat, ExportUtils, NavigationDirective, RowTogllerDirective, TableColumnsComponent, TableModule, TablePagingComponent };
|
|
992
1075
|
//# sourceMappingURL=seniorsistemas-angular-components-table.mjs.map
|