@cellaware/utils 8.7.5 → 8.7.7
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.
|
@@ -148,7 +148,7 @@ export declare function codifyCondition(condition: DatagridCondition): string;
|
|
|
148
148
|
*
|
|
149
149
|
* https://github.com/cellaware/chatwms-az-swa-ng/blob/development/src/app/utils/data.ts#L126
|
|
150
150
|
*/
|
|
151
|
-
export declare function stripNumericValueFormat(value: string | number | undefined): any;
|
|
151
|
+
export declare function stripNumericValueFormat(value: string | number | null | undefined): any;
|
|
152
152
|
interface HtmlColumnStyle {
|
|
153
153
|
columnName: string;
|
|
154
154
|
styles: string[];
|
package/dist/chatwms/datagrid.js
CHANGED
|
@@ -18,11 +18,14 @@ export function initVisualDatagridState() {
|
|
|
18
18
|
}
|
|
19
19
|
export const DEFAULT_VALUE_FORMAT_VALUE = 'none';
|
|
20
20
|
export function evaluateValueFormat(colFmt, value, locale) {
|
|
21
|
-
|
|
21
|
+
// NOTE: this syntax checks for both undefined and null.
|
|
22
|
+
if (value == null) {
|
|
22
23
|
return value;
|
|
24
|
+
}
|
|
23
25
|
const fmt = colFmt.valueFormat;
|
|
24
|
-
if (!fmt)
|
|
26
|
+
if (!fmt) {
|
|
25
27
|
return value;
|
|
28
|
+
}
|
|
26
29
|
try {
|
|
27
30
|
switch (colFmt.type) {
|
|
28
31
|
case 'text':
|
|
@@ -43,8 +46,9 @@ function formatTextEnabled(fmt) {
|
|
|
43
46
|
return fmt.txtCaseVal !== DEFAULT_VALUE_FORMAT_VALUE;
|
|
44
47
|
}
|
|
45
48
|
function formatText(value, fmt) {
|
|
46
|
-
if (!formatTextEnabled(fmt))
|
|
49
|
+
if (!formatTextEnabled(fmt)) {
|
|
47
50
|
return value;
|
|
51
|
+
}
|
|
48
52
|
const str = String(value);
|
|
49
53
|
switch (fmt.txtCaseVal) {
|
|
50
54
|
case 'lower': return str.toLowerCase();
|
|
@@ -66,11 +70,13 @@ export function formatNumberEnabled(fmt) {
|
|
|
66
70
|
fmt.numRoundVal !== DEFAULT_VALUE_FORMAT_VALUE;
|
|
67
71
|
}
|
|
68
72
|
function formatNumber(value, fmt) {
|
|
69
|
-
if (!formatNumberEnabled(fmt))
|
|
73
|
+
if (!formatNumberEnabled(fmt)) {
|
|
70
74
|
return value;
|
|
75
|
+
}
|
|
71
76
|
let num = parseFloat(value);
|
|
72
|
-
if (isNaN(num))
|
|
77
|
+
if (isNaN(num)) {
|
|
73
78
|
return value;
|
|
79
|
+
}
|
|
74
80
|
/*
|
|
75
81
|
We need to be intentional about the order of operations for number formatting.
|
|
76
82
|
For example, some formatting operations will transform the number to a string.
|
|
@@ -463,12 +469,18 @@ export function codifyCondition(condition) {
|
|
|
463
469
|
* https://github.com/cellaware/chatwms-az-swa-ng/blob/development/src/app/utils/data.ts#L126
|
|
464
470
|
*/
|
|
465
471
|
export function stripNumericValueFormat(value) {
|
|
466
|
-
|
|
472
|
+
// NOTE: this syntax checks for both undefined and null.
|
|
473
|
+
if (value == null) {
|
|
467
474
|
return null;
|
|
468
|
-
|
|
475
|
+
}
|
|
476
|
+
if (typeof value === 'number') {
|
|
469
477
|
return value;
|
|
478
|
+
}
|
|
470
479
|
// Remove commas, dollar signs, percent signs
|
|
471
480
|
const cleaned = value.replace(/[$,%]/g, '').replace(/,/g, '');
|
|
481
|
+
// NOTE: not sure we need this based on how this function is used in these contexts...
|
|
482
|
+
// const number = parseFloat(cleaned);
|
|
483
|
+
// return isNaN(number) ? null : number;
|
|
472
484
|
return cleaned;
|
|
473
485
|
}
|
|
474
486
|
function buildDatagridConditionEvaluator(condition) {
|
|
@@ -723,8 +735,9 @@ function pivotData(data, rowGroupCols, pivotCols, valueCols) {
|
|
|
723
735
|
function groupAndAggregate(data, rowGroupCols, groupKeys, valueCols) {
|
|
724
736
|
const level = groupKeys.length;
|
|
725
737
|
const groupField = rowGroupCols[level]?.field;
|
|
726
|
-
if (!groupField)
|
|
738
|
+
if (!groupField) {
|
|
727
739
|
return data;
|
|
740
|
+
}
|
|
728
741
|
const grouped = new Map();
|
|
729
742
|
for (const row of data) {
|
|
730
743
|
const key = row[groupField];
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws error if `res` is not ok.
|
|
3
|
+
*
|
|
4
|
+
* **Note:** will throw message 'An error occurred. Please try again in a moment.' if none provided.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertOkResponse(res: Response, message?: string): Response;
|
|
1
7
|
export interface ChatWMSResponse {
|
|
2
8
|
ok: boolean;
|
|
3
9
|
error: string;
|
package/dist/chatwms/response.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
const RESPONSE_ERROR_MESSAGE = 'An error occurred. Please try again in a moment.';
|
|
2
|
+
/**
|
|
3
|
+
* Throws error if `res` is not ok.
|
|
4
|
+
*
|
|
5
|
+
* **Note:** will throw message 'An error occurred. Please try again in a moment.' if none provided.
|
|
6
|
+
*/
|
|
7
|
+
export function assertOkResponse(res, message) {
|
|
8
|
+
if (!res.ok) {
|
|
9
|
+
throw new Error(message ?? RESPONSE_ERROR_MESSAGE);
|
|
10
|
+
}
|
|
11
|
+
return res;
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
14
|
* Initialization:
|
|
3
15
|
* - `ok`: `true`
|