@reltio/components 1.4.2260 → 1.4.2261
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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { memo, useMemo, useCallback } from 'react';
|
|
2
|
-
import { checkIfOptionHasValues, getAttrDataTypeDefinition, getDataTypeDefinitionForFilterValue } from '@reltio/mdm-sdk';
|
|
2
|
+
import { checkIfOptionHasValues, getAttrDataTypeDefinition, getDataTypeDefinitionForFilterValue, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
3
3
|
import { FilterValueEditor } from '../FilterValueEditor';
|
|
4
|
+
import { useMdmDisableTimestampLocalization } from '../contexts/MdmModuleContext';
|
|
4
5
|
import { useStyles } from './styles';
|
|
5
6
|
var AttributesValuesEditor = function (_a) {
|
|
6
7
|
var rowData = _a.rowData, rowContext = _a.rowContext;
|
|
@@ -8,8 +9,13 @@ var AttributesValuesEditor = function (_a) {
|
|
|
8
9
|
var canFilterAcceptValues = (rowData === null || rowData === void 0 ? void 0 : rowData.attribute) && checkIfOptionHasValues(rowData.filter);
|
|
9
10
|
var changeFilter = rowContext.changeFilter;
|
|
10
11
|
var _b = (rowData || {}), _c = _b.values, values = _c === void 0 ? [] : _c, _d = _b.attribute, _e = _d === void 0 ? {} : _d, attrType = _e.attrType, _f = _e.fieldName, fieldName = _f === void 0 ? null : _f, filter = _b.filter, id = _b.id, operator = _b.operator;
|
|
12
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
13
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(attrType, {
|
|
14
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
15
|
+
});
|
|
11
16
|
var valueDataTypeDefinition = attrType && getAttrDataTypeDefinition(attrType);
|
|
12
|
-
var filterValueDataTypeDefinition = valueDataTypeDefinition &&
|
|
17
|
+
var filterValueDataTypeDefinition = valueDataTypeDefinition &&
|
|
18
|
+
getDataTypeDefinitionForFilterValue(valueDataTypeDefinition, filter, { disableTimestampLocalization: disableTimestampLocalization });
|
|
13
19
|
var editorFilter = useMemo(function () { return ({
|
|
14
20
|
filter: filter,
|
|
15
21
|
fieldName: fieldName,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import moment from 'moment';
|
|
4
|
-
import { formatDataTypeValue, isAttributeValueLink,
|
|
4
|
+
import { addProtocolToLink, formatDataTypeValue, isAttributeValueLink, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
5
5
|
import Link from '@mui/material/Link';
|
|
6
6
|
import { SearchHighlighter } from '../SearchHighlighter';
|
|
7
|
-
import { useMdmAttributesPresentation, useMdmDateMask, useMdmDateTimeMask } from '../contexts/MdmModuleContext';
|
|
7
|
+
import { useMdmAttributesPresentation, useMdmDateMask, useMdmDateTimeMask, useMdmDisableTimestampLocalization } from '../contexts/MdmModuleContext';
|
|
8
8
|
export var DataTypeValue = function (_a) {
|
|
9
9
|
var _b = _a.value, value = _b === void 0 ? null : _b, dataTypeDefinition = _a.dataTypeDefinition, _c = _a.rich, rich = _c === void 0 ? true : _c;
|
|
10
10
|
var localeDateFormat = moment.localeData().longDateFormat('L');
|
|
@@ -12,7 +12,11 @@ export var DataTypeValue = function (_a) {
|
|
|
12
12
|
var attributesPresentation = useMdmAttributesPresentation();
|
|
13
13
|
var dateMask = useMdmDateMask() || localeDateFormat;
|
|
14
14
|
var dateTimeMask = useMdmDateTimeMask() || localeDateFormat + ' ' + localeTimeFormat;
|
|
15
|
-
var
|
|
15
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
16
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(dataTypeDefinition, {
|
|
17
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
18
|
+
});
|
|
19
|
+
var formattedValue = formatDataTypeValue({ attributesPresentation: attributesPresentation, dataTypeDefinition: dataTypeDefinition, dateMask: dateMask, dateTimeMask: dateTimeMask, disableTimestampLocalization: disableTimestampLocalization }, value);
|
|
16
20
|
return rich && isAttributeValueLink(dataTypeDefinition, value) ? (React.createElement(Link, { target: "_blank", href: addProtocolToLink(formattedValue), underline: "none" },
|
|
17
21
|
React.createElement(SearchHighlighter, { text: formattedValue }))) : (React.createElement(SearchHighlighter, { text: formattedValue }));
|
|
18
22
|
};
|
|
@@ -34,8 +34,8 @@ var setUp = function (props, mdmValues) {
|
|
|
34
34
|
};
|
|
35
35
|
describe('DataTypeValue tests', function () {
|
|
36
36
|
var checkFormatDataTypeCall = function (_a) {
|
|
37
|
-
var _b = _a.attributesPresentation, attributesPresentation = _b === void 0 ? defaultAttributesPresentation : _b, _c = _a.dateMask, dateMask = _c === void 0 ? defaultDateMask : _c, _d = _a.dateTimeMask, dateTimeMask = _d === void 0 ? defaultDateTimeMask : _d, dataTypeDefinition = _a.dataTypeDefinition, value = _a.value;
|
|
38
|
-
expect(formatDataTypeValue).toHaveBeenCalledWith({ attributesPresentation: attributesPresentation, dateMask: dateMask, dateTimeMask: dateTimeMask, dataTypeDefinition: dataTypeDefinition }, value);
|
|
37
|
+
var _b = _a.attributesPresentation, attributesPresentation = _b === void 0 ? defaultAttributesPresentation : _b, _c = _a.dateMask, dateMask = _c === void 0 ? defaultDateMask : _c, _d = _a.dateTimeMask, dateTimeMask = _d === void 0 ? defaultDateTimeMask : _d, dataTypeDefinition = _a.dataTypeDefinition, _e = _a.disableTimestampLocalization, disableTimestampLocalization = _e === void 0 ? false : _e, value = _a.value;
|
|
38
|
+
expect(formatDataTypeValue).toHaveBeenCalledWith({ attributesPresentation: attributesPresentation, dateMask: dateMask, dateTimeMask: dateTimeMask, dataTypeDefinition: dataTypeDefinition, disableTimestampLocalization: disableTimestampLocalization }, value);
|
|
39
39
|
};
|
|
40
40
|
afterEach(function () {
|
|
41
41
|
jest.clearAllMocks();
|
|
@@ -138,4 +138,28 @@ describe('DataTypeValue tests', function () {
|
|
|
138
138
|
screen.getByText(value);
|
|
139
139
|
checkFormatDataTypeCall({ dataTypeDefinition: dataTypeDefinition, value: value });
|
|
140
140
|
});
|
|
141
|
+
it('should not crash and keep localization on when dataTypeDefinition has no uri and flag is enabled', function () {
|
|
142
|
+
var value = '2025-07-09T23:10:09.000+0000';
|
|
143
|
+
var dataTypeDefinition = { type: 'Timestamp' };
|
|
144
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { disableTimestampLocalization: true });
|
|
145
|
+
setUp({ value: value, dataTypeDefinition: dataTypeDefinition }, mdmValues);
|
|
146
|
+
checkFormatDataTypeCall({ dataTypeDefinition: dataTypeDefinition, value: value, disableTimestampLocalization: false });
|
|
147
|
+
});
|
|
148
|
+
it('should disable localization for regular Timestamp attribute when flag is enabled', function () {
|
|
149
|
+
var value = '2025-07-09T23:10:09.000+0000';
|
|
150
|
+
var dataTypeDefinition = {
|
|
151
|
+
type: 'Timestamp',
|
|
152
|
+
uri: 'configuration/entityTypes/Individual/attributes/HireDate'
|
|
153
|
+
};
|
|
154
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { disableTimestampLocalization: true });
|
|
155
|
+
setUp({ value: value, dataTypeDefinition: dataTypeDefinition }, mdmValues);
|
|
156
|
+
checkFormatDataTypeCall({ dataTypeDefinition: dataTypeDefinition, value: value, disableTimestampLocalization: true });
|
|
157
|
+
});
|
|
158
|
+
it('should keep localization on for system Timestamp attribute even when flag is enabled', function () {
|
|
159
|
+
var value = '2025-07-09T23:10:09.000+0000';
|
|
160
|
+
var dataTypeDefinition = { type: 'Timestamp', uri: 'createdTime' };
|
|
161
|
+
var mdmValues = __assign(__assign({}, defaultMdmValues), { disableTimestampLocalization: true });
|
|
162
|
+
setUp({ value: value, dataTypeDefinition: dataTypeDefinition }, mdmValues);
|
|
163
|
+
checkFormatDataTypeCall({ dataTypeDefinition: dataTypeDefinition, value: value, disableTimestampLocalization: false });
|
|
164
|
+
});
|
|
141
165
|
});
|
|
@@ -22,17 +22,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import i18n from 'ui-i18n';
|
|
25
|
-
import { isDateRangeFilterOption, isMultiValueOption, isRangeFilterOption, mapFilterValue, wrapInArray } from '@reltio/mdm-sdk';
|
|
25
|
+
import { isDateRangeFilterOption, isMultiValueOption, isRangeFilterOption, mapFilterValue, shouldDisableTimestampLocalizationForAttribute, wrapInArray } from '@reltio/mdm-sdk';
|
|
26
26
|
import { pipe } from 'ramda';
|
|
27
27
|
import { DateRangeEditor } from '../DateRangeEditor';
|
|
28
28
|
import { DataTypeValueEditor } from '../DataTypeValueEditor';
|
|
29
|
+
import { useMdmDisableTimestampLocalization } from '../contexts/MdmModuleContext';
|
|
29
30
|
import { RangeDataTypeValueEditor } from './components/RangeDataTypeValueEditor';
|
|
30
31
|
import { fromEditorValue, toEditorValue } from './helpers';
|
|
31
32
|
export var FilterValueEditor = function (_a) {
|
|
32
33
|
var _b = _a.filter, _c = _b.values, values = _c === void 0 ? [] : _c, fieldName = _b.fieldName, filter = _b.filter, onChange = _a.onChange, dataTypeDefinition = _a.dataTypeDefinition, orientation = _a.orientation, TextFieldProps = _a.TextFieldProps, otherProps = __rest(_a, ["filter", "onChange", "dataTypeDefinition", "orientation", "TextFieldProps"]);
|
|
33
34
|
var dataType = dataTypeDefinition.type;
|
|
34
|
-
var
|
|
35
|
-
var
|
|
35
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
36
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(dataTypeDefinition, {
|
|
37
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
38
|
+
});
|
|
39
|
+
var conversionOptions = { disableTimestampLocalization: disableTimestampLocalization };
|
|
40
|
+
var value = mapFilterValue(toEditorValue(dataType, conversionOptions))(values[0]);
|
|
41
|
+
var handleChange = pipe(mapFilterValue(fromEditorValue(dataType, conversionOptions)), wrapInArray, onChange);
|
|
36
42
|
if (isDateRangeFilterOption(filter)) {
|
|
37
43
|
return (React.createElement(DateRangeEditor, __assign({}, otherProps, { values: value, onChange: handleChange, dataTypeDefinition: dataTypeDefinition, label: i18n.text('Date Range') })));
|
|
38
44
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export function toEditorValue(dataType: any
|
|
2
|
-
|
|
1
|
+
export function toEditorValue(dataType: any, { disableTimestampLocalization }?: {
|
|
2
|
+
disableTimestampLocalization?: boolean;
|
|
3
|
+
}): (value: any) => any;
|
|
4
|
+
export function fromEditorValue(dataType: any, { disableTimestampLocalization }?: {
|
|
5
|
+
disableTimestampLocalization?: boolean;
|
|
6
|
+
}): (value: any) => any;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import { DataTypes, isDateRangeValue, utils } from '@reltio/mdm-sdk';
|
|
2
|
-
export var toEditorValue = function (dataType
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
export var toEditorValue = function (dataType, _a) {
|
|
3
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.disableTimestampLocalization, disableTimestampLocalization = _c === void 0 ? false : _c;
|
|
4
|
+
return function (value) {
|
|
5
|
+
switch (dataType) {
|
|
6
|
+
case DataTypes.TYPE_DATE:
|
|
7
|
+
return isDateRangeValue(value) ? value : utils.dates.toLocalDate(value);
|
|
8
|
+
case DataTypes.TYPE_TIMESTAMP:
|
|
9
|
+
if (isDateRangeValue(value)) {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
return disableTimestampLocalization ? utils.dates.toLocalDate(value) : new Date(value);
|
|
13
|
+
case DataTypes.TYPE_LOCAL_DATE:
|
|
14
|
+
case DataTypes.TYPE_ACTIVENESS_DATE:
|
|
15
|
+
return isDateRangeValue(value) ? value : new Date(value);
|
|
16
|
+
default:
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export var fromEditorValue = function (dataType, _a) {
|
|
22
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.disableTimestampLocalization, disableTimestampLocalization = _c === void 0 ? false : _c;
|
|
23
|
+
return function (value) {
|
|
24
|
+
switch (dataType) {
|
|
25
|
+
case DataTypes.TYPE_DATE:
|
|
26
|
+
return isDateRangeValue(value)
|
|
27
|
+
? value
|
|
28
|
+
: Date.UTC(value.getFullYear(), value.getMonth(), value.getDate());
|
|
29
|
+
case DataTypes.TYPE_TIMESTAMP:
|
|
30
|
+
if (isDateRangeValue(value)) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
return disableTimestampLocalization ? utils.dates.toUtcDate(value).getTime() : value.valueOf();
|
|
34
|
+
case DataTypes.TYPE_LOCAL_DATE:
|
|
35
|
+
case DataTypes.TYPE_ACTIVENESS_DATE:
|
|
36
|
+
return isDateRangeValue(value) ? value : value.valueOf();
|
|
37
|
+
default:
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DataTypes } from '@reltio/mdm-sdk';
|
|
2
|
+
import { fromEditorValue, toEditorValue } from './helpers';
|
|
3
|
+
describe('FilterValueEditor helpers', function () {
|
|
4
|
+
describe('TYPE_TIMESTAMP', function () {
|
|
5
|
+
it('toEditorValue returns Date constructed from value when flag is off', function () {
|
|
6
|
+
var ms = Date.UTC(2020, 1, 20, 7, 0, 0);
|
|
7
|
+
expect(toEditorValue(DataTypes.TYPE_TIMESTAMP)(ms)).toEqual(new Date(ms));
|
|
8
|
+
});
|
|
9
|
+
it('toEditorValue uses toLocalDate when flag is on (numeric input)', function () {
|
|
10
|
+
var ms = Date.UTC(2020, 1, 20, 7, 0, 0);
|
|
11
|
+
var result = toEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })(ms);
|
|
12
|
+
var utcDate = new Date(ms);
|
|
13
|
+
var expected = new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate(), utcDate.getUTCHours(), utcDate.getUTCMinutes(), utcDate.getUTCSeconds(), utcDate.getUTCMilliseconds());
|
|
14
|
+
expect(result.getTime()).toBe(expected.getTime());
|
|
15
|
+
});
|
|
16
|
+
it('fromEditorValue returns local epoch ms when flag is off', function () {
|
|
17
|
+
var localDate = new Date(2020, 1, 20, 7, 0, 0);
|
|
18
|
+
expect(fromEditorValue(DataTypes.TYPE_TIMESTAMP)(localDate)).toBe(localDate.valueOf());
|
|
19
|
+
});
|
|
20
|
+
it('fromEditorValue preserves local parts as UTC when flag is on', function () {
|
|
21
|
+
var localDate = new Date(2020, 1, 20, 7, 0, 0);
|
|
22
|
+
var result = fromEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })(localDate);
|
|
23
|
+
expect(result).toBe(Date.UTC(localDate.getFullYear(), localDate.getMonth(), localDate.getDate(), localDate.getHours(), localDate.getMinutes(), localDate.getSeconds(), localDate.getMilliseconds()));
|
|
24
|
+
});
|
|
25
|
+
it('passes through DateRange values regardless of flag', function () {
|
|
26
|
+
expect(toEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
|
|
27
|
+
expect(fromEditorValue(DataTypes.TYPE_TIMESTAMP, { disableTimestampLocalization: true })('lastDay')).toBe('lastDay');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { defaultTo, pipe, prop, propEq } from 'ramda';
|
|
3
|
-
import { checkBasicMetadataPermission, getDataTypeDefinitionForFilterValue, getFilterOptionLabel, getFilterOptionsForDataTypeDefinition, MetadataPermissions, validateFilter } from '@reltio/mdm-sdk';
|
|
3
|
+
import { checkBasicMetadataPermission, getDataTypeDefinitionForFilterValue, getFilterOptionLabel, getFilterOptionsForDataTypeDefinition, MetadataPermissions, shouldDisableTimestampLocalizationForAttribute, validateFilter } from '@reltio/mdm-sdk';
|
|
4
4
|
import Popover from '@mui/material/Popover';
|
|
5
5
|
import IconButton from '@mui/material/IconButton';
|
|
6
6
|
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
|
7
7
|
import { FilterChip } from '../FilterChip';
|
|
8
8
|
import { FilterEditor } from '../../../../FilterEditor';
|
|
9
|
+
import { useMdmDisableTimestampLocalization } from '../../../../contexts/MdmModuleContext';
|
|
9
10
|
import { columnFilterToMdmFilter } from '../../../../helpers/basicTable';
|
|
10
11
|
import { mdmFilterToColumnFilter } from './helpers';
|
|
11
12
|
import { useStyles } from '../../styles';
|
|
@@ -13,6 +14,8 @@ export var ColumnFilter = function (_a) {
|
|
|
13
14
|
var _b;
|
|
14
15
|
var columnId = _a.columnId, dataTypeDefinition = _a.dataTypeDefinition, filter = _a.filter, filterOptionsData = _a.filterOptionsData, onFilter = _a.onFilter;
|
|
15
16
|
var styles = useStyles();
|
|
17
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
18
|
+
var disableTimestampLocalizationForFilterValue = shouldDisableTimestampLocalizationForAttribute(dataTypeDefinition, { disableTimestampLocalization: disableTimestampLocalizationFlag });
|
|
16
19
|
var _c = useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
17
20
|
var openFilterPopup = function (event) { return setAnchorEl(event.currentTarget); };
|
|
18
21
|
var closeFilterPopup = function () { return setAnchorEl(null); };
|
|
@@ -21,7 +24,9 @@ export var ColumnFilter = function (_a) {
|
|
|
21
24
|
setColumnFilter(filter);
|
|
22
25
|
}, [filter]);
|
|
23
26
|
var containerRef = useRef(null);
|
|
24
|
-
var mdmFilter = columnFilterToMdmFilter({ id: columnId, dataTypeDefinition: dataTypeDefinition }, columnFilter
|
|
27
|
+
var mdmFilter = columnFilterToMdmFilter({ id: columnId, dataTypeDefinition: dataTypeDefinition }, columnFilter, {
|
|
28
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
29
|
+
});
|
|
25
30
|
var applyFilterChange = function (newFilter) {
|
|
26
31
|
if (newFilter !== filter) {
|
|
27
32
|
onFilter({ columnId: columnId, filter: newFilter });
|
|
@@ -52,7 +57,9 @@ export var ColumnFilter = function (_a) {
|
|
|
52
57
|
return pipe(getFilterOptionData, prop('label'), defaultTo(getFilterOptionLabel(filterOption)))(filterOption);
|
|
53
58
|
};
|
|
54
59
|
var getFilterDataTypeDefinition = function (filterOption) {
|
|
55
|
-
return pipe(getFilterOptionData, prop('dataTypeDefinition'), defaultTo(getDataTypeDefinitionForFilterValue(dataTypeDefinition, filterOption
|
|
60
|
+
return pipe(getFilterOptionData, prop('dataTypeDefinition'), defaultTo(getDataTypeDefinitionForFilterValue(dataTypeDefinition, filterOption, {
|
|
61
|
+
disableTimestampLocalization: disableTimestampLocalizationForFilterValue
|
|
62
|
+
})))(filterOption);
|
|
56
63
|
};
|
|
57
64
|
var filterOptionValues = (_b = filterOptionsData === null || filterOptionsData === void 0 ? void 0 : filterOptionsData.map(function (filterOption) { return filterOption.value; })) !== null && _b !== void 0 ? _b : getFilterOptionsForDataTypeDefinition(dataTypeDefinition);
|
|
58
65
|
var filterOptions = filterOptionValues.map(function (value) { return ({ value: value, label: getFilterLabel(value) }); });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Chip from '@mui/material/Chip';
|
|
3
|
-
import { checkIfOptionHasValues, formatDataTypeValue, getFilterValueLabel, mapFilterValue } from '@reltio/mdm-sdk';
|
|
3
|
+
import { checkIfOptionHasValues, formatDataTypeValue, getFilterValueLabel, mapFilterValue, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
4
4
|
import { ExpandedValueTooltip } from '../../../../ExpandedValueTooltip';
|
|
5
|
-
import { useMdmAttributesPresentation, useMdmDateMask, useMdmDateTimeMask } from '../../../../contexts/MdmModuleContext';
|
|
5
|
+
import { useMdmAttributesPresentation, useMdmDateMask, useMdmDateTimeMask, useMdmDisableTimestampLocalization } from '../../../../contexts/MdmModuleContext';
|
|
6
6
|
import { useStyles } from './styles';
|
|
7
7
|
export var FilterChip = function (_a) {
|
|
8
8
|
var filterOption = _a.filterOption, filterValue = _a.filterValue, onDelete = _a.onDelete, dataTypeDefinition = _a.dataTypeDefinition;
|
|
@@ -10,9 +10,19 @@ export var FilterChip = function (_a) {
|
|
|
10
10
|
var attributesPresentation = useMdmAttributesPresentation();
|
|
11
11
|
var dateMask = useMdmDateMask();
|
|
12
12
|
var dateTimeMask = useMdmDateTimeMask();
|
|
13
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
14
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(dataTypeDefinition, {
|
|
15
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
16
|
+
});
|
|
13
17
|
var canFilterAcceptValues = checkIfOptionHasValues(filterOption.value);
|
|
14
18
|
var optionLabel = filterOption.label + (canFilterAcceptValues ? ': ' : '');
|
|
15
|
-
var formatValue = formatDataTypeValue({
|
|
19
|
+
var formatValue = formatDataTypeValue({
|
|
20
|
+
attributesPresentation: attributesPresentation,
|
|
21
|
+
dataTypeDefinition: dataTypeDefinition,
|
|
22
|
+
dateMask: dateMask,
|
|
23
|
+
dateTimeMask: dateTimeMask,
|
|
24
|
+
disableTimestampLocalization: disableTimestampLocalization
|
|
25
|
+
});
|
|
16
26
|
var convertedValue = mapFilterValue(formatValue, filterValue);
|
|
17
27
|
var filterLabel = canFilterAcceptValues ? getFilterValueLabel(filterOption.value, convertedValue) : '';
|
|
18
28
|
return (React.createElement(Chip, { label: React.createElement(ExpandedValueTooltip, { value: optionLabel + filterLabel },
|
|
@@ -11,11 +11,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { useState } from 'react';
|
|
13
13
|
import Popover from '@mui/material/Popover';
|
|
14
|
-
import { attributeUriToSearchUri, DataTypes, getAttrDataTypeDefinition, isBooleanType, isLookupAttrType, isNumericType, isTimestampBasedType } from '@reltio/mdm-sdk';
|
|
14
|
+
import { attributeUriToSearchUri, DataTypes, getAttrDataTypeDefinition, isBooleanType, isLookupAttrType, isNumericType, isTimestampBasedType, shouldDisableTimestampLocalizationForAttribute } from '@reltio/mdm-sdk';
|
|
15
15
|
import classnames from 'classnames';
|
|
16
16
|
import { equals, isNil } from 'ramda';
|
|
17
17
|
import { DataTypeValueEditor } from '../DataTypeValueEditor';
|
|
18
18
|
import { attributeValueToEditorValue, editorValueToAttributeValue } from '../helpers/attributesView';
|
|
19
|
+
import { useMdmDisableTimestampLocalization } from '../contexts/MdmModuleContext';
|
|
19
20
|
import { useStyles } from './styles';
|
|
20
21
|
var DATA_TYPES_WITH_MULTILINE_EDITOR = [DataTypes.TYPE_TEXT, DataTypes.TYPE_BLOB];
|
|
21
22
|
export var InlineSimpleAttributeEditor = function (_a) {
|
|
@@ -26,7 +27,13 @@ export var InlineSimpleAttributeEditor = function (_a) {
|
|
|
26
27
|
containerWidth: containerRef.current ? containerRef.current.getBoundingClientRect().width : 0
|
|
27
28
|
});
|
|
28
29
|
var dataTypeDefinition = getAttrDataTypeDefinition(attributeType);
|
|
29
|
-
var
|
|
30
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
31
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(attributeType, {
|
|
32
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
33
|
+
});
|
|
34
|
+
var initEditorValue = attributeValueToEditorValue(attributeValue, dataTypeDefinition, {
|
|
35
|
+
disableTimestampLocalization: disableTimestampLocalization
|
|
36
|
+
});
|
|
30
37
|
var _c = useState(initEditorValue), editorValue = _c[0], changeEditorValue = _c[1];
|
|
31
38
|
var isTemporaryWithDefaultValue = !isNil(attributeType.defaultValue) && isTemporary;
|
|
32
39
|
var TextFieldProps = {
|
|
@@ -42,7 +49,8 @@ export var InlineSimpleAttributeEditor = function (_a) {
|
|
|
42
49
|
autoFocus: true
|
|
43
50
|
};
|
|
44
51
|
var applyChangesAndClose = function () {
|
|
45
|
-
var editedValue = !isNil(editorValue) &&
|
|
52
|
+
var editedValue = !isNil(editorValue) &&
|
|
53
|
+
editorValueToAttributeValue(attributeType, editorValue, { disableTimestampLocalization: disableTimestampLocalization });
|
|
46
54
|
if ((!isNil(editorValue) && !equals(editorValue, initEditorValue)) || isTemporaryWithDefaultValue) {
|
|
47
55
|
var editedAttributeValue = isLookupAttrType(attributeType)
|
|
48
56
|
? {
|
|
@@ -50,7 +58,9 @@ export var InlineSimpleAttributeEditor = function (_a) {
|
|
|
50
58
|
lookupCode: editedValue.lookupCode
|
|
51
59
|
}
|
|
52
60
|
: {
|
|
53
|
-
value: editorValue === '' && isNumericType(dataTypeDefinition.type)
|
|
61
|
+
value: (editorValue === '' && isNumericType(dataTypeDefinition.type)
|
|
62
|
+
? null
|
|
63
|
+
: editedValue)
|
|
54
64
|
};
|
|
55
65
|
onEdit(__assign(__assign({}, attributeValue), editedAttributeValue));
|
|
56
66
|
}
|
|
@@ -28,7 +28,7 @@ import AddIcon from '@mui/icons-material/Add';
|
|
|
28
28
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
29
29
|
import Typography from '@mui/material/Typography';
|
|
30
30
|
import i18n from 'ui-i18n';
|
|
31
|
-
import { attributeUriToSearchUri, ErrorType, getAttributeValue, getAttrDataTypeDefinition, getErrorId, getErrorMessage, getErrorType, isDependentLookupAttrType, isEditableMode as checkIsEditableMode, Mode, DataTypes } from '@reltio/mdm-sdk';
|
|
31
|
+
import { attributeUriToSearchUri, ErrorType, getAttributeValue, getAttrDataTypeDefinition, getErrorId, getErrorMessage, getErrorType, isDependentLookupAttrType, isEditableMode as checkIsEditableMode, shouldDisableTimestampLocalizationForAttribute, Mode, DataTypes } from '@reltio/mdm-sdk';
|
|
32
32
|
import { DataTypeValue } from '../DataTypeValue';
|
|
33
33
|
import { DataTypeValueEditor } from '../DataTypeValueEditor';
|
|
34
34
|
import { ErrorWrapper } from '../ErrorWrapper';
|
|
@@ -39,7 +39,7 @@ import { withAsyncMount } from '../HOCs/withAsyncMount';
|
|
|
39
39
|
import { withContext } from '../HOCs/withContext';
|
|
40
40
|
import { ProfilePerspectiveViewContext } from '../contexts/ProfilePerspectiveViewContext';
|
|
41
41
|
import { ScrollToElementContext, isHighlightedErrorType } from '../contexts/ScrollToElementContext';
|
|
42
|
-
import { useMdmDependentLookupEditorContext } from '../contexts/MdmModuleContext';
|
|
42
|
+
import { useMdmDependentLookupEditorContext, useMdmDisableTimestampLocalization } from '../contexts/MdmModuleContext';
|
|
43
43
|
import { useScrollToAttributeError } from '../hooks/useScrollToAttributeError';
|
|
44
44
|
import { useAutopopulationContextValue } from './useAutopopulationContextValue';
|
|
45
45
|
import { useAttributeValuePermissions } from './useAttributeValuePermissions';
|
|
@@ -69,6 +69,10 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
69
69
|
var showToEdit = canEdit && isEditableMode && !attributeValue.masked;
|
|
70
70
|
var errorMessage = getErrorMessage(ownError);
|
|
71
71
|
var dependentLookupEditorContext = useMdmDependentLookupEditorContext(attributeValue, attributeType);
|
|
72
|
+
var disableTimestampLocalizationFlag = useMdmDisableTimestampLocalization();
|
|
73
|
+
var disableTimestampLocalization = shouldDisableTimestampLocalizationForAttribute(attributeType, {
|
|
74
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
75
|
+
});
|
|
72
76
|
var isAutocompleteTriggerAttribute = useContextSelector(AddressAutoCompleteContext, function (c) { return c === null || c === void 0 ? void 0 : c.isAutocompleteTriggerAttribute; });
|
|
73
77
|
var _g = useScrollToAttributeError({ highlightedError: highlightedError, isSimple: true }), ref = _g.ref, errorClassName = _g.errorClassName;
|
|
74
78
|
useEffect(function () {
|
|
@@ -89,13 +93,13 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
89
93
|
}
|
|
90
94
|
return dataTypeDefinition;
|
|
91
95
|
}, [attributeType, isAutocompleteTriggerAttribute, isFirstEditor]);
|
|
92
|
-
var value = useMemo(function () { return attributeValueToEditorValue(attributeValue, dataTypeDefinition); }, [attributeValue, dataTypeDefinition]);
|
|
96
|
+
var value = useMemo(function () { return attributeValueToEditorValue(attributeValue, dataTypeDefinition, { disableTimestampLocalization: disableTimestampLocalization }); }, [attributeValue, dataTypeDefinition, disableTimestampLocalization]);
|
|
93
97
|
var deactivateError = useCallback(function () {
|
|
94
98
|
if (ownError) {
|
|
95
99
|
onDeactivateError(getErrorId(ownError));
|
|
96
100
|
}
|
|
97
101
|
}, [ownError, onDeactivateError]);
|
|
98
|
-
var onValueEditorChange = useCallback(pipe(prepareChangeData(attributeValue, attributeType), onChangeAttribute, deactivateError), [attributeValue, attributeType, onChangeAttribute, deactivateError]);
|
|
102
|
+
var onValueEditorChange = useCallback(pipe(prepareChangeData(attributeValue, attributeType, { disableTimestampLocalization: disableTimestampLocalization }), onChangeAttribute, deactivateError), [attributeValue, attributeType, onChangeAttribute, deactivateError, disableTimestampLocalization]);
|
|
99
103
|
var onDelete = function () {
|
|
100
104
|
onDeleteAttribute({ uri: attributeValue.uri, attributeType: attributeType });
|
|
101
105
|
if (getErrorType(ownError) !== ErrorType.missed) {
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { AttributeType, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
2
|
+
import { AttributeValueConversionOptions, EditorValue } from '../helpers/attributesView';
|
|
3
|
+
export declare const prepareChangeData: (attributeValue: SimpleAttributeValue, attributeType: AttributeType, options?: AttributeValueConversionOptions) => (editorValue: EditorValue) => {
|
|
4
|
+
value: import("@reltio/mdm-sdk").PrimitiveValue | import("@reltio/mdm-sdk").LookupValue;
|
|
5
|
+
uri: string;
|
|
6
|
+
attributeType: AttributeType;
|
|
7
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { curry } from 'ramda';
|
|
2
1
|
import { editorValueToAttributeValue } from '../helpers/attributesView';
|
|
3
|
-
export var prepareChangeData =
|
|
4
|
-
|
|
5
|
-
return {
|
|
6
|
-
value
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export var prepareChangeData = function (attributeValue, attributeType, options) {
|
|
3
|
+
if (options === void 0) { options = {}; }
|
|
4
|
+
return function (editorValue) {
|
|
5
|
+
var value = editorValueToAttributeValue(attributeType, editorValue, options);
|
|
6
|
+
return {
|
|
7
|
+
value: value,
|
|
8
|
+
uri: attributeValue.uri,
|
|
9
|
+
attributeType: attributeType
|
|
10
|
+
};
|
|
9
11
|
};
|
|
10
|
-
}
|
|
12
|
+
};
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { DataTypes } from '@reltio/mdm-sdk';
|
|
1
|
+
import { DataTypes, utils } from '@reltio/mdm-sdk';
|
|
2
2
|
import { prepareChangeData } from './helpers';
|
|
3
3
|
describe('helpers', function () {
|
|
4
4
|
describe('prepareChangeData', function () {
|
|
5
|
+
afterEach(function () {
|
|
6
|
+
jest.restoreAllMocks();
|
|
7
|
+
});
|
|
5
8
|
it('should return "true" as a string, if attribute is boolean', function () {
|
|
6
9
|
var attributeValue = {
|
|
7
10
|
value: 'false',
|
|
8
11
|
uri: 'uri1'
|
|
9
12
|
};
|
|
10
13
|
var attributeType = {
|
|
14
|
+
name: 'Flag',
|
|
15
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Flag',
|
|
11
16
|
type: DataTypes.TYPE_BOOLEAN
|
|
12
17
|
};
|
|
13
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
18
|
+
expect(prepareChangeData(attributeValue, attributeType)(true)).toEqual({
|
|
14
19
|
value: 'true',
|
|
15
20
|
uri: attributeValue.uri,
|
|
16
21
|
attributeType: attributeType
|
|
@@ -22,9 +27,11 @@ describe('helpers', function () {
|
|
|
22
27
|
uri: 'uri1'
|
|
23
28
|
};
|
|
24
29
|
var attributeType = {
|
|
30
|
+
name: 'Flag',
|
|
31
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Flag',
|
|
25
32
|
type: DataTypes.TYPE_BOOLEAN
|
|
26
33
|
};
|
|
27
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
34
|
+
expect(prepareChangeData(attributeValue, attributeType)(false)).toEqual({
|
|
28
35
|
value: 'false',
|
|
29
36
|
uri: attributeValue.uri,
|
|
30
37
|
attributeType: attributeType
|
|
@@ -36,9 +43,11 @@ describe('helpers', function () {
|
|
|
36
43
|
uri: 'uri1'
|
|
37
44
|
};
|
|
38
45
|
var attributeType = {
|
|
46
|
+
name: 'Date',
|
|
47
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Date',
|
|
39
48
|
type: DataTypes.TYPE_DATE
|
|
40
49
|
};
|
|
41
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
50
|
+
expect(prepareChangeData(attributeValue, attributeType)(new Date('02-14-2019'))).toEqual({
|
|
42
51
|
value: '2019-02-14',
|
|
43
52
|
uri: attributeValue.uri,
|
|
44
53
|
attributeType: attributeType
|
|
@@ -50,9 +59,11 @@ describe('helpers', function () {
|
|
|
50
59
|
uri: 'uri1'
|
|
51
60
|
};
|
|
52
61
|
var attributeType = {
|
|
62
|
+
name: 'Date',
|
|
63
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Date',
|
|
53
64
|
type: DataTypes.TYPE_DATE
|
|
54
65
|
};
|
|
55
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
66
|
+
expect(prepareChangeData(attributeValue, attributeType)(null)).toEqual({
|
|
56
67
|
value: '',
|
|
57
68
|
uri: attributeValue.uri,
|
|
58
69
|
attributeType: attributeType
|
|
@@ -64,9 +75,11 @@ describe('helpers', function () {
|
|
|
64
75
|
uri: 'uri1'
|
|
65
76
|
};
|
|
66
77
|
var attributeType = {
|
|
78
|
+
name: 'Timestamp',
|
|
79
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Timestamp',
|
|
67
80
|
type: DataTypes.TYPE_TIMESTAMP
|
|
68
81
|
};
|
|
69
|
-
var value = prepareChangeData(attributeValue, attributeType
|
|
82
|
+
var value = prepareChangeData(attributeValue, attributeType)(new Date('2019-02-14T03:20:40+04:00'));
|
|
70
83
|
expect(value).toMatchObject({
|
|
71
84
|
uri: attributeValue.uri,
|
|
72
85
|
attributeType: attributeType,
|
|
@@ -79,20 +92,48 @@ describe('helpers', function () {
|
|
|
79
92
|
uri: 'uri1'
|
|
80
93
|
};
|
|
81
94
|
var attributeType = {
|
|
95
|
+
name: 'Timestamp',
|
|
96
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Timestamp',
|
|
82
97
|
type: DataTypes.TYPE_TIMESTAMP
|
|
83
98
|
};
|
|
84
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
99
|
+
expect(prepareChangeData(attributeValue, attributeType)(null)).toEqual({
|
|
85
100
|
value: '',
|
|
86
101
|
uri: attributeValue.uri,
|
|
87
102
|
attributeType: attributeType
|
|
88
103
|
});
|
|
89
104
|
});
|
|
105
|
+
it('routes through utils.dates.toUtcDate when disableTimestampLocalization is on', function () {
|
|
106
|
+
var toUtcDateSpy = jest.spyOn(utils.dates, 'toUtcDate');
|
|
107
|
+
var attributeValue = { value: '2018-01-11T07:00:00.000+0000', uri: 'uri1' };
|
|
108
|
+
var attributeType = {
|
|
109
|
+
name: 'Timestamp',
|
|
110
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Timestamp',
|
|
111
|
+
type: DataTypes.TYPE_TIMESTAMP
|
|
112
|
+
};
|
|
113
|
+
var editorDate = new Date(2019, 1, 14, 3, 20, 40);
|
|
114
|
+
prepareChangeData(attributeValue, attributeType, { disableTimestampLocalization: true })(editorDate);
|
|
115
|
+
expect(toUtcDateSpy).toHaveBeenCalledWith(editorDate);
|
|
116
|
+
});
|
|
117
|
+
it('does not invoke utils.dates.toUtcDate when flag is off (baseline)', function () {
|
|
118
|
+
var toUtcDateSpy = jest.spyOn(utils.dates, 'toUtcDate');
|
|
119
|
+
var attributeValue = { value: '2018-01-11T07:00:00.000+0000', uri: 'uri1' };
|
|
120
|
+
var attributeType = {
|
|
121
|
+
name: 'Timestamp',
|
|
122
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Timestamp',
|
|
123
|
+
type: DataTypes.TYPE_TIMESTAMP
|
|
124
|
+
};
|
|
125
|
+
var editorDate = new Date(2019, 1, 14, 3, 20, 40);
|
|
126
|
+
prepareChangeData(attributeValue, attributeType)(editorDate);
|
|
127
|
+
expect(toUtcDateSpy).not.toHaveBeenCalledWith(editorDate);
|
|
128
|
+
});
|
|
90
129
|
it('should return new value as is, if attribute is lookup', function () {
|
|
91
130
|
var attributeValue = {
|
|
92
131
|
value: 'KT',
|
|
93
132
|
uri: 'uri1'
|
|
94
133
|
};
|
|
95
134
|
var attributeType = {
|
|
135
|
+
name: 'Unit',
|
|
136
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Unit',
|
|
96
137
|
type: DataTypes.TYPE_STRING,
|
|
97
138
|
lookupCode: 'Units Of Measures'
|
|
98
139
|
};
|
|
@@ -100,7 +141,7 @@ describe('helpers', function () {
|
|
|
100
141
|
value: 'G',
|
|
101
142
|
lookupCode: 'Units Of Measures'
|
|
102
143
|
};
|
|
103
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
144
|
+
expect(prepareChangeData(attributeValue, attributeType)(newValue)).toEqual({
|
|
104
145
|
value: newValue,
|
|
105
146
|
uri: attributeValue.uri,
|
|
106
147
|
attributeType: attributeType
|
|
@@ -112,11 +153,13 @@ describe('helpers', function () {
|
|
|
112
153
|
uri: 'uri1'
|
|
113
154
|
};
|
|
114
155
|
var attributeType = {
|
|
156
|
+
name: 'Unit',
|
|
157
|
+
uri: 'configuration/entityTypes/HasContacts/attributes/Unit',
|
|
115
158
|
type: DataTypes.TYPE_STRING,
|
|
116
159
|
lookupCode: 'Units Of Measures'
|
|
117
160
|
};
|
|
118
161
|
var newValue = null;
|
|
119
|
-
expect(prepareChangeData(attributeValue, attributeType
|
|
162
|
+
expect(prepareChangeData(attributeValue, attributeType)(newValue)).toEqual({
|
|
120
163
|
value: '',
|
|
121
164
|
uri: attributeValue.uri,
|
|
122
165
|
attributeType: attributeType
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
var react_1 = __importStar(require("react"));
|
|
27
27
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
28
28
|
var FilterValueEditor_1 = require("../FilterValueEditor");
|
|
29
|
+
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
29
30
|
var styles_1 = require("./styles");
|
|
30
31
|
var AttributesValuesEditor = function (_a) {
|
|
31
32
|
var rowData = _a.rowData, rowContext = _a.rowContext;
|
|
@@ -33,8 +34,13 @@ var AttributesValuesEditor = function (_a) {
|
|
|
33
34
|
var canFilterAcceptValues = (rowData === null || rowData === void 0 ? void 0 : rowData.attribute) && (0, mdm_sdk_1.checkIfOptionHasValues)(rowData.filter);
|
|
34
35
|
var changeFilter = rowContext.changeFilter;
|
|
35
36
|
var _b = (rowData || {}), _c = _b.values, values = _c === void 0 ? [] : _c, _d = _b.attribute, _e = _d === void 0 ? {} : _d, attrType = _e.attrType, _f = _e.fieldName, fieldName = _f === void 0 ? null : _f, filter = _b.filter, id = _b.id, operator = _b.operator;
|
|
37
|
+
var disableTimestampLocalizationFlag = (0, MdmModuleContext_1.useMdmDisableTimestampLocalization)();
|
|
38
|
+
var disableTimestampLocalization = (0, mdm_sdk_1.shouldDisableTimestampLocalizationForAttribute)(attrType, {
|
|
39
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
40
|
+
});
|
|
36
41
|
var valueDataTypeDefinition = attrType && (0, mdm_sdk_1.getAttrDataTypeDefinition)(attrType);
|
|
37
|
-
var filterValueDataTypeDefinition = valueDataTypeDefinition &&
|
|
42
|
+
var filterValueDataTypeDefinition = valueDataTypeDefinition &&
|
|
43
|
+
(0, mdm_sdk_1.getDataTypeDefinitionForFilterValue)(valueDataTypeDefinition, filter, { disableTimestampLocalization: disableTimestampLocalization });
|
|
38
44
|
var editorFilter = (0, react_1.useMemo)(function () { return ({
|
|
39
45
|
filter: filter,
|
|
40
46
|
fieldName: fieldName,
|
|
@@ -18,7 +18,11 @@ var DataTypeValue = function (_a) {
|
|
|
18
18
|
var attributesPresentation = (0, MdmModuleContext_1.useMdmAttributesPresentation)();
|
|
19
19
|
var dateMask = (0, MdmModuleContext_1.useMdmDateMask)() || localeDateFormat;
|
|
20
20
|
var dateTimeMask = (0, MdmModuleContext_1.useMdmDateTimeMask)() || localeDateFormat + ' ' + localeTimeFormat;
|
|
21
|
-
var
|
|
21
|
+
var disableTimestampLocalizationFlag = (0, MdmModuleContext_1.useMdmDisableTimestampLocalization)();
|
|
22
|
+
var disableTimestampLocalization = (0, mdm_sdk_1.shouldDisableTimestampLocalizationForAttribute)(dataTypeDefinition, {
|
|
23
|
+
disableTimestampLocalization: disableTimestampLocalizationFlag
|
|
24
|
+
});
|
|
25
|
+
var formattedValue = (0, mdm_sdk_1.formatDataTypeValue)({ attributesPresentation: attributesPresentation, dataTypeDefinition: dataTypeDefinition, dateMask: dateMask, dateTimeMask: dateTimeMask, disableTimestampLocalization: disableTimestampLocalization }, value);
|
|
22
26
|
return rich && (0, mdm_sdk_1.isAttributeValueLink)(dataTypeDefinition, value) ? (react_1.default.createElement(Link_1.default, { target: "_blank", href: (0, mdm_sdk_1.addProtocolToLink)(formattedValue), underline: "none" },
|
|
23
27
|
react_1.default.createElement(SearchHighlighter_1.SearchHighlighter, { text: formattedValue }))) : (react_1.default.createElement(SearchHighlighter_1.SearchHighlighter, { text: formattedValue }));
|
|
24
28
|
};
|