@reltio/components 1.4.2260 → 1.4.2262
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/AttributesValuesEditor/AttributesValuesEditor.js +8 -2
- package/DataTypeValue/DataTypeValue.js +7 -3
- package/DataTypeValue/DataTypeValue.test.js +26 -2
- package/FilterValueEditor/FilterValueEditor.js +9 -3
- package/FilterValueEditor/helpers.d.ts +6 -2
- package/FilterValueEditor/helpers.js +40 -24
- package/FilterValueEditor/helpers.test.d.ts +1 -0
- package/FilterValueEditor/helpers.test.js +30 -0
- package/HOCs/withFilter/components/ColumnFilter/ColumnFilter.js +10 -3
- package/HOCs/withFilter/components/FilterChip/FilterChip.js +13 -3
- package/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.js +14 -4
- package/SimpleAttributeEditor/SimpleAttributeEditor.js +8 -4
- package/SimpleAttributeEditor/helpers.d.ts +7 -1
- package/SimpleAttributeEditor/helpers.js +10 -8
- package/SimpleAttributeEditor/helpers.test.js +52 -9
- package/cjs/AttributesValuesEditor/AttributesValuesEditor.js +7 -1
- package/cjs/DataTypeValue/DataTypeValue.js +5 -1
- package/cjs/DataTypeValue/DataTypeValue.test.js +26 -2
- package/cjs/FilterValueEditor/FilterValueEditor.js +8 -2
- package/cjs/FilterValueEditor/helpers.d.ts +6 -2
- package/cjs/FilterValueEditor/helpers.js +40 -24
- package/cjs/FilterValueEditor/helpers.test.d.ts +1 -0
- package/cjs/FilterValueEditor/helpers.test.js +32 -0
- package/cjs/HOCs/withFilter/components/ColumnFilter/ColumnFilter.js +9 -2
- package/cjs/HOCs/withFilter/components/FilterChip/FilterChip.js +11 -1
- package/cjs/InlineSimpleAttributeEditor/InlineSimpleAttributeEditor.js +13 -3
- package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.js +6 -2
- package/cjs/SimpleAttributeEditor/helpers.d.ts +7 -1
- package/cjs/SimpleAttributeEditor/helpers.js +11 -8
- package/cjs/SimpleAttributeEditor/helpers.test.js +51 -8
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/cjs/contexts/MdmModuleContext/hooks.js +5 -1
- package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/index.js +2 -1
- package/cjs/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.js +4 -1
- package/cjs/features/activity-log/hooks/useSegmentReadableQuery.js +6 -1
- package/cjs/features/activity-log/utils/activities.d.ts +3 -1
- package/cjs/features/activity-log/utils/activities.js +8 -3
- package/cjs/features/activity-log/utils/activities.test.js +21 -0
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.js +8 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +4 -4
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +8 -4
- package/cjs/helpers/attributesView.d.ts +6 -5
- package/cjs/helpers/attributesView.js +24 -10
- package/cjs/helpers/attributesView.test.js +68 -0
- package/cjs/helpers/basicTable.d.ts +5 -2
- package/cjs/helpers/basicTable.js +9 -9
- package/cjs/helpers/basicTable.test.js +56 -0
- package/cjs/hooks/useReadableSearchState/useReadableSearchState.js +4 -2
- package/cjs/hooks/useReadableSearchState/useReadableSearchState.test.js +2 -2
- package/contexts/MdmModuleContext/context.d.ts +2 -0
- package/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/contexts/MdmModuleContext/hooks.js +3 -0
- package/contexts/MdmModuleContext/index.d.ts +1 -1
- package/contexts/MdmModuleContext/index.js +1 -1
- package/features/activity-log/RecordUpdates/components/DeltaField/DeltaField.js +5 -2
- package/features/activity-log/hooks/useSegmentReadableQuery.js +7 -2
- package/features/activity-log/utils/activities.d.ts +3 -1
- package/features/activity-log/utils/activities.js +9 -4
- package/features/activity-log/utils/activities.test.js +21 -0
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +2 -2
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.js +8 -1
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +4 -4
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.js +8 -4
- package/helpers/attributesView.d.ts +6 -5
- package/helpers/attributesView.js +24 -10
- package/helpers/attributesView.test.js +69 -1
- package/helpers/basicTable.d.ts +5 -2
- package/helpers/basicTable.js +10 -10
- package/helpers/basicTable.test.js +57 -1
- package/hooks/useReadableSearchState/useReadableSearchState.js +5 -3
- package/hooks/useReadableSearchState/useReadableSearchState.test.js +2 -2
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { formatDataTypeValue, findAttributeTypeByUri, makeAttrTypeUri, getAttrDataTypeDefinition } from '@reltio/mdm-sdk';
|
|
12
|
+
import { formatDataTypeValue, findAttributeTypeByUri, makeAttrTypeUri, getAttrDataTypeDefinition, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
13
13
|
import { filter, groupBy, ifElse, map, path, pipe, propOr, values, isNil, includes, reject } from 'ramda';
|
|
14
14
|
import i18n from 'ui-i18n';
|
|
15
15
|
import { ActivityTypes } from '../types';
|
|
@@ -35,10 +35,15 @@ export var splitActivityByType = function (activity) {
|
|
|
35
35
|
return length > 1;
|
|
36
36
|
}, map(function (items) { return (__assign(__assign({}, activity), { items: items, itemsTotal: items.length })); }), function () { return [activity]; }))(activity);
|
|
37
37
|
};
|
|
38
|
-
export var stringifyDeltaValue = function (deltaValue, attributeTypeUri, metadata, attributesPresentation) {
|
|
38
|
+
export var stringifyDeltaValue = function (deltaValue, attributeTypeUri, metadata, attributesPresentation, options) {
|
|
39
|
+
if (options === void 0) { options = {}; }
|
|
39
40
|
var attributeType = findAttributeTypeByUri(metadata, attributeTypeUri);
|
|
40
41
|
var dataTypeDefinition = getAttrDataTypeDefinition(attributeType);
|
|
41
|
-
var formatValue = formatDataTypeValue({
|
|
42
|
+
var formatValue = formatDataTypeValue({
|
|
43
|
+
attributesPresentation: attributesPresentation,
|
|
44
|
+
dataTypeDefinition: dataTypeDefinition,
|
|
45
|
+
disableTimestampLocalization: shouldDisableTimestampLocalizationForAttribute(attributeType, options)
|
|
46
|
+
});
|
|
42
47
|
if (isNil(deltaValue)) {
|
|
43
48
|
return '';
|
|
44
49
|
}
|
|
@@ -49,7 +54,7 @@ export var stringifyDeltaValue = function (deltaValue, attributeTypeUri, metadat
|
|
|
49
54
|
.flatMap(function (_a) {
|
|
50
55
|
var attributeTypeName = _a[0], deltaValues = _a[1];
|
|
51
56
|
return deltaValues.map(function (deltaValue) {
|
|
52
|
-
return stringifyDeltaValue(deltaValue.value, makeAttrTypeUri(attributeTypeUri, attributeTypeName), metadata, attributesPresentation);
|
|
57
|
+
return stringifyDeltaValue(deltaValue.value, makeAttrTypeUri(attributeTypeUri, attributeTypeName), metadata, attributesPresentation, options);
|
|
53
58
|
});
|
|
54
59
|
})
|
|
55
60
|
.join(', ');
|
|
@@ -11,8 +11,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import i18n from 'ui-i18n';
|
|
13
13
|
import { identity } from 'ramda';
|
|
14
|
+
import { formatDataTypeValue } from '@reltio/mdm-sdk';
|
|
14
15
|
import { ActivityTypes } from '../types';
|
|
15
16
|
import { getActivityType, isValidActivityType, removeIgnoredItems, splitActivityByType, stringifyDeltaValue } from './activities';
|
|
17
|
+
jest.mock('@reltio/mdm-sdk', function () {
|
|
18
|
+
var actual = jest.requireActual('@reltio/mdm-sdk');
|
|
19
|
+
return __assign(__assign({}, actual), { formatDataTypeValue: jest.fn(actual.formatDataTypeValue) });
|
|
20
|
+
});
|
|
21
|
+
var formatDataTypeValueMock = formatDataTypeValue;
|
|
16
22
|
describe('activities utils tests', function () {
|
|
17
23
|
var activityWithDataTypes = {
|
|
18
24
|
uri: 'activities/711d84f6-f96b-4b93-b06f-a165c1776914',
|
|
@@ -369,6 +375,7 @@ describe('activities utils tests', function () {
|
|
|
369
375
|
});
|
|
370
376
|
afterEach(function () {
|
|
371
377
|
i18nDateSpy.mockReset();
|
|
378
|
+
formatDataTypeValueMock.mockClear();
|
|
372
379
|
});
|
|
373
380
|
var metadata = {
|
|
374
381
|
entityTypes: [
|
|
@@ -545,6 +552,20 @@ describe('activities utils tests', function () {
|
|
|
545
552
|
]
|
|
546
553
|
}, attributeTypeUri, metadata)).toBe('2022-12-02, 12,345, String 2, $5,000, String, Yes, 2020-12-01T15:12:00.000+0000');
|
|
547
554
|
});
|
|
555
|
+
describe('disableTimestampLocalization', function () {
|
|
556
|
+
var middleOfUtcDayMs = Date.UTC(2019, 10, 1, 14, 30, 0);
|
|
557
|
+
var regularTimestampUri = 'configuration/entityTypes/HCP/attributes/Timestamp';
|
|
558
|
+
it('forwards disableTimestampLocalization=true to formatDataTypeValue for regular Timestamp', function () {
|
|
559
|
+
stringifyDeltaValue(String(middleOfUtcDayMs), regularTimestampUri, metadata, undefined, {
|
|
560
|
+
disableTimestampLocalization: true
|
|
561
|
+
});
|
|
562
|
+
expect(formatDataTypeValueMock).toHaveBeenCalledWith(expect.objectContaining({ disableTimestampLocalization: true }));
|
|
563
|
+
});
|
|
564
|
+
it('forwards disableTimestampLocalization=false for regular Timestamp when option is missing', function () {
|
|
565
|
+
stringifyDeltaValue(String(middleOfUtcDayMs), regularTimestampUri, metadata);
|
|
566
|
+
expect(formatDataTypeValueMock).toHaveBeenCalledWith(expect.objectContaining({ disableTimestampLocalization: false }));
|
|
567
|
+
});
|
|
568
|
+
});
|
|
548
569
|
});
|
|
549
570
|
describe('removeIgnoredItems', function () {
|
|
550
571
|
var consoleWarnMock;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AttributeType, ChangeValue, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeType, ChangeValue, LookupValue, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
3
|
import { LineDataValue } from '../../../types';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
7
|
-
onChange: (value: SimpleAttributeValue | string[] | PrimitiveValue) => void;
|
|
7
|
+
onChange: (value: SimpleAttributeValue | string[] | PrimitiveValue | LookupValue) => void;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare const DCRValueEditor: ({ attributeType, value, onChange, disabled }: Props) => React.JSX.Element;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
2
3
|
import { DCRValueEditorFactory } from '../DCRValueEditorFactory';
|
|
4
|
+
import { useMdmDisableTimestampLocalization } from '../../../../../contexts/MdmModuleContext';
|
|
3
5
|
import styles from './DCRValueEditor.module.css';
|
|
4
6
|
export var DCRValueEditor = function (_a) {
|
|
5
7
|
var attributeType = _a.attributeType, value = _a.value, onChange = _a.onChange, _b = _a.disabled, disabled = _b === void 0 ? false : _b;
|
|
8
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
9
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(attributeType, {
|
|
10
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
11
|
+
});
|
|
6
12
|
return (React.createElement("div", { className: styles.editor }, DCRValueEditorFactory.build({
|
|
7
13
|
attributeType: attributeType,
|
|
8
14
|
value: value,
|
|
9
15
|
onChange: onChange,
|
|
10
|
-
disabled: disabled
|
|
16
|
+
disabled: disabled,
|
|
17
|
+
disableTimestampLocalization: disableTimestampLocalization
|
|
11
18
|
})));
|
|
12
19
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type AttributeType, type ChangeValue, type
|
|
2
|
+
import { type AttributeType, type ChangeValue, type LookupValue, type PrimitiveValue, type SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
3
|
import type { LineDataValue } from '../../../types';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
7
|
-
onChange: (value: SimpleAttributeValue | string[] | PrimitiveValue) => void;
|
|
8
|
-
dataTypeDefinition?: DataTypeDefinition;
|
|
7
|
+
onChange: (value: SimpleAttributeValue | string[] | PrimitiveValue | LookupValue) => void;
|
|
9
8
|
disabled?: boolean;
|
|
9
|
+
disableTimestampLocalization?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare class DCRValueEditorFactory {
|
|
12
|
-
static build({ attributeType, value, onChange, disabled }: Props): React.JSX.Element;
|
|
12
|
+
static build({ attributeType, value, onChange, disabled, disableTimestampLocalization }: Props): React.JSX.Element;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -10,7 +10,7 @@ var DCRValueEditorFactory = /** @class */ (function () {
|
|
|
10
10
|
function DCRValueEditorFactory() {
|
|
11
11
|
}
|
|
12
12
|
DCRValueEditorFactory.build = function (_a) {
|
|
13
|
-
var attributeType = _a.attributeType, value = _a.value, onChange = _a.onChange, _b = _a.disabled, disabled = _b === void 0 ? false : _b;
|
|
13
|
+
var attributeType = _a.attributeType, value = _a.value, onChange = _a.onChange, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.disableTimestampLocalization, disableTimestampLocalization = _c === void 0 ? false : _c;
|
|
14
14
|
var dcrValue = getAttributeValue(value);
|
|
15
15
|
switch (attributeType.uri) {
|
|
16
16
|
case EntityAttrTypes.roles.uri: {
|
|
@@ -25,10 +25,14 @@ var DCRValueEditorFactory = /** @class */ (function () {
|
|
|
25
25
|
default: {
|
|
26
26
|
var dataTypeDefinition = getDataTypeDefinition(attributeType, dcrValue);
|
|
27
27
|
var editorValue = value && dataTypeDefinition
|
|
28
|
-
? attributeValueToEditorValue(value, dataTypeDefinition
|
|
28
|
+
? attributeValueToEditorValue(value, dataTypeDefinition, {
|
|
29
|
+
disableTimestampLocalization: disableTimestampLocalization
|
|
30
|
+
})
|
|
29
31
|
: null;
|
|
30
|
-
var handleChange = function (
|
|
31
|
-
var valueConvertedToAttributeValue = editorValueToAttributeValue(attributeType,
|
|
32
|
+
var handleChange = function (newValue) {
|
|
33
|
+
var valueConvertedToAttributeValue = editorValueToAttributeValue(attributeType, newValue, {
|
|
34
|
+
disableTimestampLocalization: disableTimestampLocalization
|
|
35
|
+
});
|
|
32
36
|
onChange(valueConvertedToAttributeValue);
|
|
33
37
|
};
|
|
34
38
|
return (React.createElement(DataTypeValueEditor, { fieldName: attributeType.uri, value: editorValue, dataTypeDefinition: dataTypeDefinition, onChange: handleChange, fullWidth: true, disabled: disabled }));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributeType, DataTypeDefinition, Metadata, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
1
|
+
import { AttributeType, DataTypeDefinition, LookupValue, Metadata, NestedAttributeValue, PrimitiveValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
2
2
|
import { AttributeSelectorItem } from '../types';
|
|
3
3
|
export declare const getFilteredAttrTypes: (metadata: Metadata, type: string, includeUris: string[], excludeUris: string[]) => any;
|
|
4
4
|
type PagersData = {
|
|
@@ -6,11 +6,12 @@ type PagersData = {
|
|
|
6
6
|
values: (SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue | string | number)[];
|
|
7
7
|
};
|
|
8
8
|
export declare const splitPagersData: (fixedTypeUris: string[], pagersData: PagersData[]) => [PagersData[], PagersData[]];
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
lookupCode: string;
|
|
9
|
+
export type AttributeValueConversionOptions = {
|
|
10
|
+
disableTimestampLocalization?: boolean;
|
|
12
11
|
};
|
|
13
|
-
export
|
|
12
|
+
export type EditorValue = PrimitiveValue | Date | LookupValue | null;
|
|
13
|
+
export declare const attributeValueToEditorValue: (attributeValue: SimpleAttributeValue, { type }: DataTypeDefinition, { disableTimestampLocalization }?: AttributeValueConversionOptions) => EditorValue;
|
|
14
|
+
export declare const editorValueToAttributeValue: (attributeType: AttributeType, editorValue: EditorValue, { disableTimestampLocalization }?: AttributeValueConversionOptions) => PrimitiveValue | LookupValue;
|
|
14
15
|
export declare const isEqualAttributes: any;
|
|
15
16
|
export declare const checkAttributeIncludes: (attribute: AttributeSelectorItem, selectedAttributes: AttributeSelectorItem[]) => boolean;
|
|
16
17
|
export {};
|
|
@@ -16,9 +16,10 @@ export var getFilteredAttrTypes = function (metadata, type, includeUris, exclude
|
|
|
16
16
|
export var splitPagersData = function (fixedTypeUris, pagersData) {
|
|
17
17
|
return partition(pipe(path(['attrType', 'uri']), includes(__, fixedTypeUris)), pagersData);
|
|
18
18
|
};
|
|
19
|
-
export var attributeValueToEditorValue = function (attributeValue, _a) {
|
|
19
|
+
export var attributeValueToEditorValue = function (attributeValue, _a, _b) {
|
|
20
20
|
var type = _a.type;
|
|
21
|
-
var
|
|
21
|
+
var _c = _b === void 0 ? {} : _b, _d = _c.disableTimestampLocalization, disableTimestampLocalization = _d === void 0 ? false : _d;
|
|
22
|
+
var _e = attributeValue || {}, value = _e.value, lookupCode = _e.lookupCode;
|
|
22
23
|
switch (type) {
|
|
23
24
|
case DataTypes.TYPE_BOOLEAN:
|
|
24
25
|
case DataTypes.TYPE_BOOLEAN_RADIO:
|
|
@@ -27,8 +28,16 @@ export var attributeValueToEditorValue = function (attributeValue, _a) {
|
|
|
27
28
|
}
|
|
28
29
|
case DataTypes.TYPE_DATE:
|
|
29
30
|
return (value && utils.dates.toLocalDate(value)) || null;
|
|
31
|
+
case DataTypes.TYPE_TIMESTAMP: {
|
|
32
|
+
if (!value) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (disableTimestampLocalization) {
|
|
36
|
+
return utils.dates.toLocalDate(value);
|
|
37
|
+
}
|
|
38
|
+
return new Date(value);
|
|
39
|
+
}
|
|
30
40
|
case DataTypes.TYPE_LOCAL_DATE:
|
|
31
|
-
case DataTypes.TYPE_TIMESTAMP:
|
|
32
41
|
case DataTypes.TYPE_ACTIVENESS_DATE: {
|
|
33
42
|
return (value && new Date(value)) || null;
|
|
34
43
|
}
|
|
@@ -40,7 +49,8 @@ export var attributeValueToEditorValue = function (attributeValue, _a) {
|
|
|
40
49
|
return value;
|
|
41
50
|
}
|
|
42
51
|
};
|
|
43
|
-
export var editorValueToAttributeValue = function (attributeType, editorValue) {
|
|
52
|
+
export var editorValueToAttributeValue = function (attributeType, editorValue, _a) {
|
|
53
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.disableTimestampLocalization, disableTimestampLocalization = _c === void 0 ? false : _c;
|
|
44
54
|
var type = getAttrDataTypeDefinition(attributeType).type;
|
|
45
55
|
switch (type) {
|
|
46
56
|
case DataTypes.TYPE_BOOLEAN:
|
|
@@ -50,17 +60,21 @@ export var editorValueToAttributeValue = function (attributeType, editorValue) {
|
|
|
50
60
|
case DataTypes.TYPE_DATE:
|
|
51
61
|
return (editorValue && moment(editorValue).format('YYYY-MM-DD')) || '';
|
|
52
62
|
case DataTypes.TYPE_TIMESTAMP: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
if (!editorValue) {
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
if (disableTimestampLocalization) {
|
|
67
|
+
return moment.utc(utils.dates.toUtcDate(editorValue)).format();
|
|
68
|
+
}
|
|
69
|
+
return moment(editorValue)
|
|
70
|
+
.utc()
|
|
71
|
+
.format();
|
|
58
72
|
}
|
|
59
73
|
case DataTypes.TYPE_ACTIVENESS_DATE:
|
|
60
74
|
case DataTypes.TYPE_LOCAL_DATE:
|
|
61
75
|
return editorValue && editorValue.valueOf();
|
|
62
76
|
default:
|
|
63
|
-
return editorValue || '';
|
|
77
|
+
return (editorValue || '');
|
|
64
78
|
}
|
|
65
79
|
};
|
|
66
80
|
export var isEqualAttributes = eqBy(pick(['fieldName', 'uri', 'entityTypeUri']));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from '@reltio/mdm-sdk';
|
|
2
|
-
import { attributeValueToEditorValue } from './attributesView';
|
|
2
|
+
import { attributeValueToEditorValue, editorValueToAttributeValue } from './attributesView';
|
|
3
3
|
describe('attributesView tests', function () {
|
|
4
4
|
describe('attributeValueToEditorValue', function () {
|
|
5
5
|
it('should return true if attribute is boolean and value is string', function () {
|
|
@@ -73,6 +73,48 @@ describe('attributesView tests', function () {
|
|
|
73
73
|
};
|
|
74
74
|
expect(attributeValueToEditorValue(attributeValue, attributeType)).toBe(null);
|
|
75
75
|
});
|
|
76
|
+
describe('TYPE_TIMESTAMP', function () {
|
|
77
|
+
var attributeType = {
|
|
78
|
+
type: DataTypes.TYPE_TIMESTAMP,
|
|
79
|
+
uri: 'configuration/entityTypes/HCP/attributes/Updated',
|
|
80
|
+
name: 'Updated'
|
|
81
|
+
};
|
|
82
|
+
it('returns Date constructed from value when flag is off', function () {
|
|
83
|
+
var ms = Date.UTC(2020, 1, 20, 7, 0, 0);
|
|
84
|
+
var result = attributeValueToEditorValue({ value: ms, uri: '' }, attributeType);
|
|
85
|
+
expect(result).toEqual(new Date(ms));
|
|
86
|
+
});
|
|
87
|
+
it('uses toLocalDate (UTC parts as local) when flag is on (numeric input)', function () {
|
|
88
|
+
var ms = Date.UTC(2020, 1, 20, 7, 15, 30);
|
|
89
|
+
var result = attributeValueToEditorValue({ value: ms, uri: '' }, attributeType, {
|
|
90
|
+
disableTimestampLocalization: true
|
|
91
|
+
});
|
|
92
|
+
expect(result.getFullYear()).toBe(2020);
|
|
93
|
+
expect(result.getMonth()).toBe(1);
|
|
94
|
+
expect(result.getDate()).toBe(20);
|
|
95
|
+
expect(result.getHours()).toBe(7);
|
|
96
|
+
expect(result.getMinutes()).toBe(15);
|
|
97
|
+
expect(result.getSeconds()).toBe(30);
|
|
98
|
+
});
|
|
99
|
+
it('uses toLocalDate when flag is on (ISO string input)', function () {
|
|
100
|
+
var value = '2020-02-20T07:15:30.000+0000';
|
|
101
|
+
var result = attributeValueToEditorValue({ value: value, uri: '' }, attributeType, {
|
|
102
|
+
disableTimestampLocalization: true
|
|
103
|
+
});
|
|
104
|
+
expect(result.getFullYear()).toBe(2020);
|
|
105
|
+
expect(result.getMonth()).toBe(1);
|
|
106
|
+
expect(result.getDate()).toBe(20);
|
|
107
|
+
expect(result.getHours()).toBe(7);
|
|
108
|
+
expect(result.getMinutes()).toBe(15);
|
|
109
|
+
expect(result.getSeconds()).toBe(30);
|
|
110
|
+
});
|
|
111
|
+
it('returns null when value is missing', function () {
|
|
112
|
+
expect(attributeValueToEditorValue({ value: undefined, uri: '' }, attributeType)).toBeNull();
|
|
113
|
+
expect(attributeValueToEditorValue({ value: undefined, uri: '' }, attributeType, {
|
|
114
|
+
disableTimestampLocalization: true
|
|
115
|
+
})).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
});
|
|
76
118
|
it('should return lookup value+lookupCode if attribute is lookup', function () {
|
|
77
119
|
var attributeValue = {
|
|
78
120
|
value: 'KT',
|
|
@@ -90,4 +132,30 @@ describe('attributesView tests', function () {
|
|
|
90
132
|
});
|
|
91
133
|
});
|
|
92
134
|
});
|
|
135
|
+
describe('editorValueToAttributeValue TYPE_TIMESTAMP', function () {
|
|
136
|
+
var attributeType = {
|
|
137
|
+
type: DataTypes.TYPE_TIMESTAMP,
|
|
138
|
+
uri: 'configuration/entityTypes/HCP/attributes/Updated',
|
|
139
|
+
name: 'Updated'
|
|
140
|
+
};
|
|
141
|
+
it('returns ISO UTC string from local Date when flag is off', function () {
|
|
142
|
+
var localDate = new Date(2020, 1, 20, 7, 0, 0);
|
|
143
|
+
var result = editorValueToAttributeValue(attributeType, localDate);
|
|
144
|
+
expect(typeof result).toBe('string');
|
|
145
|
+
expect(result).toMatch(/Z$|\+00:?00$/);
|
|
146
|
+
expect(new Date(result).getTime()).toBe(localDate.getTime());
|
|
147
|
+
});
|
|
148
|
+
it('preserves local parts as UTC when flag is on', function () {
|
|
149
|
+
var localDate = new Date(2020, 1, 20, 7, 0, 0);
|
|
150
|
+
var result = editorValueToAttributeValue(attributeType, localDate, {
|
|
151
|
+
disableTimestampLocalization: true
|
|
152
|
+
});
|
|
153
|
+
var expectedMs = Date.UTC(localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds());
|
|
154
|
+
expect(new Date(result).getTime()).toBe(expectedMs);
|
|
155
|
+
});
|
|
156
|
+
it('returns empty string when editor value is empty', function () {
|
|
157
|
+
expect(editorValueToAttributeValue(attributeType, null)).toBe('');
|
|
158
|
+
expect(editorValueToAttributeValue(attributeType, null, { disableTimestampLocalization: true })).toBe('');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
93
161
|
});
|
package/helpers/basicTable.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FacetFilter } from '@reltio/mdm-sdk';
|
|
2
2
|
import { ColumnData, ColumnFilter, ColumnSize } from '../types/basicTable';
|
|
3
3
|
import { ColumnsSizeById } from '../types/preferences';
|
|
4
|
+
export type BuildColumnsFilterOptions = {
|
|
5
|
+
disableTimestampLocalization?: boolean;
|
|
6
|
+
};
|
|
4
7
|
export declare const defaultGetRowCellHeight: ({ columnData, cell }: {
|
|
5
8
|
columnData: any;
|
|
6
9
|
cell: any;
|
|
@@ -10,6 +13,6 @@ export declare const defaultRenderRowCell: ({ cell, CellValueRenderer, ...otherP
|
|
|
10
13
|
cell: any;
|
|
11
14
|
CellValueRenderer: any;
|
|
12
15
|
}) => any;
|
|
13
|
-
export declare const columnFilterToMdmFilter: (columnData: Pick<ColumnData, "id" | "dataTypeDefinition">, columnFilter?: ColumnFilter) => FacetFilter;
|
|
14
|
-
export declare const buildColumnsFilter: (columnsData: ColumnData[], filters?: Record<string, ColumnFilter
|
|
16
|
+
export declare const columnFilterToMdmFilter: (columnData: Pick<ColumnData, "id" | "dataTypeDefinition">, columnFilter?: ColumnFilter, { disableTimestampLocalization }?: BuildColumnsFilterOptions) => FacetFilter;
|
|
17
|
+
export declare const buildColumnsFilter: (columnsData: ColumnData[], filters?: Record<string, ColumnFilter>, options?: BuildColumnsFilterOptions) => string;
|
|
15
18
|
export declare const buildColumnsSizeById: (columnsSize?: ColumnSize[]) => ColumnsSizeById;
|
package/helpers/basicTable.js
CHANGED
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import { propEq, identity } from 'ramda';
|
|
25
|
-
import { DataTypes, buildFilterQueryString, Maybe } from '@reltio/mdm-sdk';
|
|
25
|
+
import { DataTypes, buildFilterQueryString, Maybe, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
26
26
|
var BLOB_HEIGHT = 100;
|
|
27
27
|
var IMAGE_HEIGHT = 64;
|
|
28
28
|
var PADDING = 15;
|
|
@@ -45,23 +45,23 @@ export var defaultRenderRowCell = function (_a) {
|
|
|
45
45
|
var cell = _a.cell, CellValueRenderer = _a.CellValueRenderer, otherProps = __rest(_a, ["cell", "CellValueRenderer"]);
|
|
46
46
|
return cell.values.map(function (value, index) { return React.createElement(CellValueRenderer, __assign({ key: index, value: value }, otherProps)); });
|
|
47
47
|
};
|
|
48
|
-
export var columnFilterToMdmFilter = function (columnData, columnFilter) {
|
|
48
|
+
export var columnFilterToMdmFilter = function (columnData, columnFilter, _a) {
|
|
49
49
|
if (columnFilter === void 0) { columnFilter = {}; }
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
50
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.disableTimestampLocalization, disableTimestampLocalization = _c === void 0 ? false : _c;
|
|
51
|
+
var dataTypeDefinition = columnData.dataTypeDefinition;
|
|
52
|
+
return __assign({ fieldName: columnData.id, filter: columnFilter.filter, values: [columnFilter.value], type: dataTypeDefinition.type }, (shouldDisableTimestampLocalizationForAttribute(dataTypeDefinition, { disableTimestampLocalization: disableTimestampLocalization })
|
|
53
|
+
? { disableTimestampLocalization: true }
|
|
54
|
+
: {}));
|
|
56
55
|
};
|
|
57
|
-
export var buildColumnsFilter = function (columnsData, filters) {
|
|
56
|
+
export var buildColumnsFilter = function (columnsData, filters, options) {
|
|
57
|
+
if (options === void 0) { options = {}; }
|
|
58
58
|
return Maybe.fromNull(filters)
|
|
59
59
|
.map(function (filters) {
|
|
60
60
|
return Object.entries(filters)
|
|
61
61
|
.map(function (_a) {
|
|
62
62
|
var columnId = _a[0], columnFilter = _a[1];
|
|
63
63
|
var columnData = columnsData.find(propEq('id', columnId));
|
|
64
|
-
return columnData && columnFilterToMdmFilter(columnData, columnFilter);
|
|
64
|
+
return columnData && columnFilterToMdmFilter(columnData, columnFilter, options);
|
|
65
65
|
})
|
|
66
66
|
.filter(identity);
|
|
67
67
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { DataTypes } from '@reltio/mdm-sdk';
|
|
4
|
-
import { buildColumnsFilter, defaultRenderRowCell } from './basicTable';
|
|
4
|
+
import { buildColumnsFilter, columnFilterToMdmFilter, defaultRenderRowCell } from './basicTable';
|
|
5
5
|
describe('basicTable tests', function () {
|
|
6
6
|
describe('defaultRenderRowCell', function () {
|
|
7
7
|
it('should call CellValueRenderer with all cell values', function () {
|
|
@@ -31,5 +31,61 @@ describe('basicTable tests', function () {
|
|
|
31
31
|
it('should return correct filter string', function () {
|
|
32
32
|
expect(buildColumnsFilter(columnsData, filters)).toBe("equals(label,'123') and lte(directional,'852163199999')");
|
|
33
33
|
});
|
|
34
|
+
it('should produce UTC day boundaries for Timestamp column when disableTimestampLocalization is on', function () {
|
|
35
|
+
var middleOfUtcDayMs = Date.UTC(2019, 10, 1, 14, 30, 0);
|
|
36
|
+
var utcDayStart = Date.UTC(2019, 10, 1, 0, 0, 0, 0);
|
|
37
|
+
var utcDayEnd = Date.UTC(2019, 10, 1, 23, 59, 59, 999);
|
|
38
|
+
var tsColumns = [
|
|
39
|
+
{
|
|
40
|
+
id: 'attributes.UpdatedDate',
|
|
41
|
+
label: 'Updated date',
|
|
42
|
+
dataTypeDefinition: {
|
|
43
|
+
type: DataTypes.TYPE_TIMESTAMP,
|
|
44
|
+
uri: 'configuration/entityTypes/HCP/attributes/UpdatedDate'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
var tsFilters = { 'attributes.UpdatedDate': { filter: 'on', value: middleOfUtcDayMs } };
|
|
49
|
+
expect(buildColumnsFilter(tsColumns, tsFilters, { disableTimestampLocalization: true })).toBe("range(attributes.UpdatedDate,".concat(utcDayStart, ",").concat(utcDayEnd, ")"));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('columnFilterToMdmFilter disableTimestampLocalization', function () {
|
|
53
|
+
var middleOfUtcDayMs = Date.UTC(2019, 10, 1, 14, 30, 0);
|
|
54
|
+
var regularTimestampColumn = {
|
|
55
|
+
id: 'attributes.UpdatedDate',
|
|
56
|
+
dataTypeDefinition: {
|
|
57
|
+
type: DataTypes.TYPE_TIMESTAMP,
|
|
58
|
+
uri: 'configuration/entityTypes/HCP/attributes/UpdatedDate'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var specialTimestampColumn = {
|
|
62
|
+
id: 'createdTime',
|
|
63
|
+
dataTypeDefinition: { type: DataTypes.TYPE_TIMESTAMP, uri: 'createdTime' }
|
|
64
|
+
};
|
|
65
|
+
var stringColumn = {
|
|
66
|
+
id: 'attributes.Name',
|
|
67
|
+
dataTypeDefinition: { type: DataTypes.TYPE_STRING, uri: 'configuration/entityTypes/HCP/attributes/Name' }
|
|
68
|
+
};
|
|
69
|
+
var onFilter = { filter: 'on', value: middleOfUtcDayMs };
|
|
70
|
+
it('adds disableTimestampLocalization to filter for regular timestamp column when flag is on', function () {
|
|
71
|
+
var result = columnFilterToMdmFilter(regularTimestampColumn, onFilter, {
|
|
72
|
+
disableTimestampLocalization: true
|
|
73
|
+
});
|
|
74
|
+
expect(result).toMatchObject({ disableTimestampLocalization: true });
|
|
75
|
+
});
|
|
76
|
+
it('does not add disableTimestampLocalization for regular timestamp column when flag is off', function () {
|
|
77
|
+
var result = columnFilterToMdmFilter(regularTimestampColumn, onFilter);
|
|
78
|
+
expect(result).not.toHaveProperty('disableTimestampLocalization');
|
|
79
|
+
});
|
|
80
|
+
it('does not add disableTimestampLocalization for special timestamp column even when flag is on', function () {
|
|
81
|
+
var result = columnFilterToMdmFilter(specialTimestampColumn, onFilter, {
|
|
82
|
+
disableTimestampLocalization: true
|
|
83
|
+
});
|
|
84
|
+
expect(result).not.toHaveProperty('disableTimestampLocalization');
|
|
85
|
+
});
|
|
86
|
+
it('does not add disableTimestampLocalization for non-timestamp column when flag is on', function () {
|
|
87
|
+
var result = columnFilterToMdmFilter(stringColumn, { filter: 'equals', value: 'John' }, { disableTimestampLocalization: true });
|
|
88
|
+
expect(result).not.toHaveProperty('disableTimestampLocalization');
|
|
89
|
+
});
|
|
34
90
|
});
|
|
35
91
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { andThen, chain, pipe } from 'ramda';
|
|
3
3
|
import { buildReadableQueryToString, getKeywordFromSearchState, getUnresolvedLookupsListFromSearchGroups, resolveLookupsList, getGroupsFromSearchState, buildReadableQuery } from '@reltio/mdm-sdk';
|
|
4
|
-
import { useMdmAction, useMdmAttributesPresentation, useMdmDataTenants, useMdmLookups, useMdmMetadata } from '../../contexts/MdmModuleContext';
|
|
4
|
+
import { useMdmAction, useMdmAttributesPresentation, useMdmDataTenants, useMdmDisableTimestampLocalization, useMdmLookups, useMdmMetadata } from '../../contexts/MdmModuleContext';
|
|
5
5
|
export var useReadableSearchState = function (searchState) {
|
|
6
6
|
var lookupsListResolved = useMdmAction('lookupsListResolved');
|
|
7
7
|
var metadata = useMdmMetadata();
|
|
8
8
|
var dataTenants = useMdmDataTenants();
|
|
9
9
|
var attributesPresentation = useMdmAttributesPresentation();
|
|
10
10
|
var lookups = useMdmLookups();
|
|
11
|
+
var disableTimestampLocalization = useMdmDisableTimestampLocalization();
|
|
12
|
+
var formatOptions = { disableTimestampLocalization: disableTimestampLocalization };
|
|
11
13
|
var map = searchState.map;
|
|
12
14
|
var keyword = getKeywordFromSearchState(searchState);
|
|
13
15
|
var groups = getGroupsFromSearchState(metadata, dataTenants, true, searchState);
|
|
@@ -21,7 +23,7 @@ export var useReadableSearchState = function (searchState) {
|
|
|
21
23
|
}
|
|
22
24
|
}, [searchState]); // eslint-disable-line
|
|
23
25
|
return {
|
|
24
|
-
readableQuery: buildReadableQuery(metadata, attributesPresentation, lookups, groups, keyword, map),
|
|
25
|
-
readableQueryString: buildReadableQueryToString(metadata, attributesPresentation, lookups, groups, keyword, map)
|
|
26
|
+
readableQuery: buildReadableQuery(metadata, attributesPresentation, lookups, groups, keyword, map, formatOptions),
|
|
27
|
+
readableQueryString: buildReadableQueryToString(metadata, attributesPresentation, lookups, groups, keyword, map, formatOptions)
|
|
26
28
|
};
|
|
27
29
|
};
|
|
@@ -108,8 +108,8 @@ describe('useReadableSearchState tests', function () {
|
|
|
108
108
|
expect(getKeywordFromSearchState).toHaveBeenCalledWith(searchState);
|
|
109
109
|
expect(getGroupsFromSearchState).toHaveBeenCalledWith(metadata, dataTenants, true, searchState);
|
|
110
110
|
expect(getUnresolvedLookupsListFromSearchGroups).toHaveBeenCalledWith(groups, lookups);
|
|
111
|
-
expect(buildReadableQueryToString).toHaveBeenCalledWith(metadata, attributesPresentation, lookups, groups, keyword, map);
|
|
112
|
-
expect(buildReadableQuery).toHaveBeenCalledWith(metadata, attributesPresentation, lookups, groups, keyword, map);
|
|
111
|
+
expect(buildReadableQueryToString).toHaveBeenCalledWith(metadata, attributesPresentation, lookups, groups, keyword, map, { disableTimestampLocalization: false });
|
|
112
|
+
expect(buildReadableQuery).toHaveBeenCalledWith(metadata, attributesPresentation, lookups, groups, keyword, map, { disableTimestampLocalization: false });
|
|
113
113
|
expect(resolveLookupsList).not.toHaveBeenCalled();
|
|
114
114
|
expect(result.current).toEqual({
|
|
115
115
|
readableQueryString: searchStateString,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2262",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
12
12
|
"@googlemaps/markerclusterer": "^2.5.3",
|
|
13
13
|
"@react-sigma/core": "3.4.0",
|
|
14
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
14
|
+
"@reltio/mdm-sdk": "^1.4.2043",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|