@pega/custom-dx-components 0.23.29 → 0.23.31
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/package.json +1 -1
- package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/date.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/embed-utils.js.mustache +0 -3
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/repeat-utils.js.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/textformat-utils.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/textformat-utils.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +0 -1
- package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +1 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +0 -2
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.tsx.mustache +1 -1
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Avatar.tsx.mustache +1 -1
- package/src/tasks/init/template/.eslintrc.json +13 -1
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/src/tasks/init/template/tsconfig.json +2 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/date.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -14
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/DateFormatter.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/date.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-time.js +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-utils.js +41 -49
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date.js +54 -69
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/utils.js +12 -11
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/text-url.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/date.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -14
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/DateFormatter.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/date.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-time.js +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-utils.js +41 -49
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date.js +54 -69
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/utils.js +12 -11
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/utils.js +0 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/text-url.jsx +0 -1
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-relative-packages */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
1
|
import dayjs from 'dayjs';
|
|
4
2
|
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
5
3
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
|
|
@@ -11,26 +9,26 @@ dayjs.extend(localizedFormat);
|
|
|
11
9
|
dayjs.extend(utc);
|
|
12
10
|
dayjs.extend(timezone);
|
|
13
11
|
|
|
14
|
-
export const datetimedisplayformatter =
|
|
12
|
+
export const datetimedisplayformatter = formatter => {
|
|
15
13
|
const objectvalues = {};
|
|
16
14
|
switch (formatter) {
|
|
17
|
-
case
|
|
18
|
-
objectvalues.variantVal =
|
|
19
|
-
objectvalues.formatVal =
|
|
15
|
+
case 'DateTime-Long': {
|
|
16
|
+
objectvalues.variantVal = 'datetime';
|
|
17
|
+
objectvalues.formatVal = 'long';
|
|
20
18
|
break;
|
|
21
19
|
}
|
|
22
|
-
case
|
|
23
|
-
objectvalues.variantVal =
|
|
24
|
-
objectvalues.formatVal =
|
|
20
|
+
case 'DateTime-Short': {
|
|
21
|
+
objectvalues.variantVal = 'date';
|
|
22
|
+
objectvalues.formatVal = 'short';
|
|
25
23
|
break;
|
|
26
24
|
}
|
|
27
|
-
case
|
|
28
|
-
objectvalues.variantVal =
|
|
25
|
+
case 'DateTime-Since': {
|
|
26
|
+
objectvalues.variantVal = 'relative';
|
|
29
27
|
break;
|
|
30
28
|
}
|
|
31
|
-
case
|
|
32
|
-
objectvalues.variantVal =
|
|
33
|
-
objectvalues.formatVal =
|
|
29
|
+
case 'Time-Only': {
|
|
30
|
+
objectvalues.variantVal = 'time';
|
|
31
|
+
objectvalues.formatVal = 'short';
|
|
34
32
|
break;
|
|
35
33
|
}
|
|
36
34
|
// no default
|
|
@@ -38,13 +36,8 @@ export const datetimedisplayformatter = (formatter) => {
|
|
|
38
36
|
return objectvalues;
|
|
39
37
|
};
|
|
40
38
|
|
|
41
|
-
export const formatExists =
|
|
42
|
-
const formatterValues = [
|
|
43
|
-
"DateTime-Long",
|
|
44
|
-
"DateTime-Short",
|
|
45
|
-
"DateTime-Since",
|
|
46
|
-
"Time-Only"
|
|
47
|
-
];
|
|
39
|
+
export const formatExists = formatterVal => {
|
|
40
|
+
const formatterValues = ['DateTime-Long', 'DateTime-Short', 'DateTime-Since', 'Time-Only'];
|
|
48
41
|
let isformatter = false;
|
|
49
42
|
if (formatterValues.includes(formatterVal)) {
|
|
50
43
|
isformatter = true;
|
|
@@ -52,8 +45,6 @@ export const formatExists = (formatterVal) => {
|
|
|
52
45
|
return isformatter;
|
|
53
46
|
};
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
|
|
57
48
|
/**
|
|
58
49
|
* Return relative time in fromNow for the given datetime
|
|
59
50
|
* @description Convert and return the given datetime in dayJSObject
|
|
@@ -61,11 +52,11 @@ export const formatExists = (formatterVal) => {
|
|
|
61
52
|
* @param {string} text datetime
|
|
62
53
|
* @returns {object} datetime as a dayjs object
|
|
63
54
|
*/
|
|
64
|
-
export const getDayJSObject =
|
|
55
|
+
export const getDayJSObject = text => {
|
|
65
56
|
const momObj = dayjs(text);
|
|
66
57
|
if (momObj.isValid()) return momObj;
|
|
67
58
|
const timeStamp = text;
|
|
68
|
-
const isDateTime = timeStamp.indexOf(
|
|
59
|
+
const isDateTime = timeStamp.indexOf('GMT') !== -1;
|
|
69
60
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
70
61
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
71
62
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -91,7 +82,7 @@ export const getDayJSObject = (text) => {
|
|
|
91
82
|
}
|
|
92
83
|
|
|
93
84
|
mom = dayjs(
|
|
94
|
-
mom.toLocaleString(
|
|
85
|
+
mom.toLocaleString('en-US', {
|
|
95
86
|
timeZone: CurrentTz
|
|
96
87
|
})
|
|
97
88
|
);
|
|
@@ -105,8 +96,8 @@ export const getDayJSObject = (text) => {
|
|
|
105
96
|
* @param {string} time datetime
|
|
106
97
|
* @returns {object} relative time from now
|
|
107
98
|
*/
|
|
108
|
-
export const getRelativeTime =
|
|
109
|
-
let relativetime =
|
|
99
|
+
export const getRelativeTime = time => {
|
|
100
|
+
let relativetime = '';
|
|
110
101
|
if (dayjs(time).isUTC()) {
|
|
111
102
|
relativetime = dayjs(time).fromNow();
|
|
112
103
|
} else {
|
|
@@ -122,7 +113,7 @@ export const getRelativeTime = (time) => {
|
|
|
122
113
|
* @param {string} value from which Year needs to be taken out
|
|
123
114
|
* @returns {number} year for the date passed
|
|
124
115
|
*/
|
|
125
|
-
export const getFullYear =
|
|
116
|
+
export const getFullYear = value =>
|
|
126
117
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
127
118
|
|
|
128
119
|
/**
|
|
@@ -172,8 +163,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
172
163
|
*
|
|
173
164
|
* @returns {number} clockFormat
|
|
174
165
|
*/
|
|
175
|
-
export const parseClockFormat =
|
|
176
|
-
typeof clockFormat ===
|
|
166
|
+
export const parseClockFormat = clockFormat =>
|
|
167
|
+
typeof clockFormat === 'string' ? parseInt(clockFormat, 10) : clockFormat;
|
|
177
168
|
|
|
178
169
|
/**
|
|
179
170
|
* Return datetime value string off to seconds
|
|
@@ -185,9 +176,9 @@ export const parseClockFormat = (clockFormat) =>
|
|
|
185
176
|
*/
|
|
186
177
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
187
178
|
if (withSeconds) {
|
|
188
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
179
|
+
return `${datetime.substring(0, datetime.indexOf('Z'))}.000Z`;
|
|
189
180
|
}
|
|
190
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
181
|
+
return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
|
|
191
182
|
};
|
|
192
183
|
|
|
193
184
|
/**
|
|
@@ -200,12 +191,9 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
200
191
|
*/
|
|
201
192
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
202
193
|
if (withSeconds) {
|
|
203
|
-
return datetime.substring(datetime.indexOf(
|
|
194
|
+
return datetime.substring(datetime.indexOf('T') + 1, datetime.indexOf('.'));
|
|
204
195
|
}
|
|
205
|
-
return `${datetime.substring(
|
|
206
|
-
datetime.indexOf("T") + 1,
|
|
207
|
-
datetime.lastIndexOf(":")
|
|
208
|
-
)}:00`;
|
|
196
|
+
return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
|
|
209
197
|
};
|
|
210
198
|
|
|
211
199
|
/**
|
|
@@ -228,14 +216,13 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
228
216
|
propName,
|
|
229
217
|
pConn
|
|
230
218
|
) => {
|
|
231
|
-
|
|
232
219
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
233
220
|
// above triggerFieldChange should have validated this
|
|
234
221
|
if (errorState) {
|
|
235
222
|
pConn.getValidationApi().validate(errorState);
|
|
236
223
|
}
|
|
237
224
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
238
|
-
else{
|
|
225
|
+
else {
|
|
239
226
|
if (formattedValue !== actualValue) {
|
|
240
227
|
actions.updateFieldValue(propName, formattedValue);
|
|
241
228
|
}
|
|
@@ -256,27 +243,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
256
243
|
.formatToParts()
|
|
257
244
|
.map(({ type, value }) => {
|
|
258
245
|
switch (type) {
|
|
259
|
-
case
|
|
260
|
-
return
|
|
261
|
-
case
|
|
262
|
-
return
|
|
263
|
-
case
|
|
264
|
-
return
|
|
265
|
-
case
|
|
266
|
-
return
|
|
267
|
-
case
|
|
268
|
-
return
|
|
269
|
-
case
|
|
270
|
-
return
|
|
271
|
-
case
|
|
272
|
-
return
|
|
273
|
-
case
|
|
246
|
+
case 'day':
|
|
247
|
+
return 'DD';
|
|
248
|
+
case 'month':
|
|
249
|
+
return 'MM';
|
|
250
|
+
case 'year':
|
|
251
|
+
return 'YYYY';
|
|
252
|
+
case 'hour':
|
|
253
|
+
return 'hh';
|
|
254
|
+
case 'minute':
|
|
255
|
+
return 'mm';
|
|
256
|
+
case 'second':
|
|
257
|
+
return 'ss';
|
|
258
|
+
case 'dayPeriod':
|
|
259
|
+
return 'A';
|
|
260
|
+
case 'literal':
|
|
274
261
|
return value;
|
|
275
262
|
default:
|
|
276
|
-
return
|
|
263
|
+
return '';
|
|
277
264
|
}
|
|
278
265
|
})
|
|
279
|
-
.join(
|
|
266
|
+
.join('');
|
|
280
267
|
};
|
|
281
268
|
|
|
282
269
|
/**
|
|
@@ -286,15 +273,13 @@ export const getDateFormat = (locale, options) => {
|
|
|
286
273
|
* @returns {boolean} True or False for the locale
|
|
287
274
|
* Example : getDateFormat("pl-PL") returns false
|
|
288
275
|
*/
|
|
289
|
-
export const is12HClockFormat =
|
|
276
|
+
export const is12HClockFormat = locale => {
|
|
290
277
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
291
|
-
hour:
|
|
278
|
+
hour: 'numeric'
|
|
292
279
|
})
|
|
293
280
|
.formatToParts()
|
|
294
|
-
.find(({ type }) => type ===
|
|
295
|
-
return !!(meridiem === null || meridiem === undefined
|
|
296
|
-
? undefined
|
|
297
|
-
: meridiem.value);
|
|
281
|
+
.find(({ type }) => type === 'dayPeriod');
|
|
282
|
+
return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
|
|
298
283
|
};
|
|
299
284
|
|
|
300
285
|
/**
|
|
@@ -307,9 +292,9 @@ export const is12HClockFormat = (locale) => {
|
|
|
307
292
|
*/
|
|
308
293
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
309
294
|
return {
|
|
310
|
-
hour:
|
|
311
|
-
minute:
|
|
312
|
-
...(withSeconds && { second:
|
|
295
|
+
hour: 'numeric',
|
|
296
|
+
minute: 'numeric',
|
|
297
|
+
...(withSeconds && { second: 'numeric' }),
|
|
313
298
|
hour12: is12h
|
|
314
299
|
};
|
|
315
300
|
};
|
|
@@ -324,9 +309,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
324
309
|
*/
|
|
325
310
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
326
311
|
return {
|
|
327
|
-
year:
|
|
328
|
-
month:
|
|
329
|
-
day:
|
|
312
|
+
year: 'numeric',
|
|
313
|
+
month: 'numeric',
|
|
314
|
+
day: 'numeric',
|
|
330
315
|
...getTimeOptions(withSeconds, is12h)
|
|
331
316
|
};
|
|
332
317
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable import/no-relative-packages */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
1
|
import { createUID } from '@pega/cosmos-react-core';
|
|
4
2
|
|
|
5
3
|
// import { LazyMap as LazyComponentMap } from '../../components_map';
|
|
@@ -19,15 +17,15 @@ export function getAllFields(pConnect) {
|
|
|
19
17
|
|
|
20
18
|
let allFields = [];
|
|
21
19
|
|
|
22
|
-
const makeField =
|
|
20
|
+
const makeField = f => ({
|
|
23
21
|
...pConnect().resolveConfigProps(f.config),
|
|
24
22
|
type: f.type
|
|
25
23
|
});
|
|
26
24
|
|
|
27
25
|
const hasRegions = !!metadata.children[0]?.children;
|
|
28
26
|
if (hasRegions) {
|
|
29
|
-
allFields = metadata.children.map(
|
|
30
|
-
region.children.map(
|
|
27
|
+
allFields = metadata.children.map(region =>
|
|
28
|
+
region.children.map(field => {
|
|
31
29
|
// Do not resolve the config props if is status work, instead create component here as status badge and mark as status display
|
|
32
30
|
if (field.config?.value === '@P .pyStatusWork') {
|
|
33
31
|
field.type = 'TextInput';
|
|
@@ -112,7 +110,9 @@ export function prepareComponentInCaseSummary(configObject, getPConnect, display
|
|
|
112
110
|
// createdComponent.props.getPConnect().setInheritedProp("hideLabel", true);
|
|
113
111
|
caseSummaryComponentObject.value = createdComponent;
|
|
114
112
|
if (type === 'reference') {
|
|
115
|
-
caseSummaryComponentObject.name = createdComponent.props
|
|
113
|
+
caseSummaryComponentObject.name = createdComponent.props
|
|
114
|
+
.getPConnect()
|
|
115
|
+
.getInheritedProps().label;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
return caseSummaryComponentObject;
|
|
@@ -131,12 +131,12 @@ export function getFilteredFields(getPConnect) {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// Filter out fields that are not visible and unsupported types for primary fields (for CaseSummary)
|
|
134
|
-
primaryFieldsRaw = primaryFieldsRaw.filter(
|
|
134
|
+
primaryFieldsRaw = primaryFieldsRaw.filter(item => {
|
|
135
135
|
const resolvedItem = getPConnect().resolveConfigProps(item.config);
|
|
136
136
|
return resolvedItem.visibility !== false && item.type !== 'TextContent';
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
secondaryFieldsRaw = secondaryFieldsRaw.filter(
|
|
139
|
+
secondaryFieldsRaw = secondaryFieldsRaw.filter(item => {
|
|
140
140
|
const resolvedItem = getPConnect().resolveConfigProps(item.config);
|
|
141
141
|
return resolvedItem.visibility !== false && item.type !== 'TextContent';
|
|
142
142
|
});
|
|
@@ -163,7 +163,9 @@ export function getLayoutDataFromRegion(regionData) {
|
|
|
163
163
|
const itemPConnect = item?.getPConnect();
|
|
164
164
|
|
|
165
165
|
return {
|
|
166
|
-
id: itemPConnect?.getComponentName()
|
|
166
|
+
id: itemPConnect?.getComponentName()
|
|
167
|
+
? `${itemPConnect.getComponentName()}--${index}`
|
|
168
|
+
: `item--${index}`,
|
|
167
169
|
content: itemPConnect?.getComponent(),
|
|
168
170
|
layoutConfig: {
|
|
169
171
|
...defaultLayoutConfig,
|
|
@@ -214,9 +216,8 @@ export function getInstructions(pConnect, instructions = 'casestep') {
|
|
|
214
216
|
|
|
215
217
|
// If the annotation wasn't processed correctly, don't return any instruction text
|
|
216
218
|
if (instructions?.startsWith('@PARAGRAPH')) {
|
|
217
|
-
/* eslint-disable no-console */
|
|
218
219
|
console.error('@PARAGRAPH annotation was not processed. Hiding custom instructions.');
|
|
219
|
-
|
|
220
|
+
|
|
220
221
|
return undefined;
|
|
221
222
|
}
|
|
222
223
|
|
package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable no-undef */import dayjs from "dayjs";
|
|
1
|
+
import dayjs from 'dayjs';
|
|
3
2
|
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
4
3
|
import localizedFormat from 'dayjs/plugin/localizedFormat.js';
|
|
5
4
|
import utc from 'dayjs/plugin/utc.js';
|
|
@@ -17,11 +16,11 @@ dayjs.extend(timezone);
|
|
|
17
16
|
* @param {string} text datetime
|
|
18
17
|
* @returns {object} datetime as a dayjs object
|
|
19
18
|
*/
|
|
20
|
-
export const getDayJSObject =
|
|
19
|
+
export const getDayJSObject = text => {
|
|
21
20
|
const momObj = dayjs(text);
|
|
22
21
|
if (momObj.isValid()) return momObj;
|
|
23
22
|
const timeStamp = text;
|
|
24
|
-
const isDateTime = timeStamp.indexOf(
|
|
23
|
+
const isDateTime = timeStamp.indexOf('GMT') !== -1;
|
|
25
24
|
const year = parseInt(timeStamp.substr(0, 4), 10);
|
|
26
25
|
const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
|
|
27
26
|
const day = parseInt(timeStamp.substr(6, 2), 10);
|
|
@@ -47,7 +46,7 @@ export const getDayJSObject = (text) => {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
mom = dayjs(
|
|
50
|
-
mom.toLocaleString(
|
|
49
|
+
mom.toLocaleString('en-US', {
|
|
51
50
|
timeZone: CurrentTz
|
|
52
51
|
})
|
|
53
52
|
);
|
|
@@ -61,8 +60,8 @@ export const getDayJSObject = (text) => {
|
|
|
61
60
|
* @param {string} time datetime
|
|
62
61
|
* @returns {object} relative time from now
|
|
63
62
|
*/
|
|
64
|
-
export const getRelativeTime =
|
|
65
|
-
let relativetime =
|
|
63
|
+
export const getRelativeTime = time => {
|
|
64
|
+
let relativetime = '';
|
|
66
65
|
if (dayjs(time).isUTC()) {
|
|
67
66
|
relativetime = dayjs(time).fromNow();
|
|
68
67
|
} else {
|
|
@@ -78,7 +77,7 @@ export const getRelativeTime = (time) => {
|
|
|
78
77
|
* @param {string} value from which Year needs to be taken out
|
|
79
78
|
* @returns {number} year for the date passed
|
|
80
79
|
*/
|
|
81
|
-
export const getFullYear =
|
|
80
|
+
export const getFullYear = value =>
|
|
82
81
|
value ? new Date(value).getFullYear() : new Date().getFullYear();
|
|
83
82
|
|
|
84
83
|
/**
|
|
@@ -128,8 +127,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
|
|
|
128
127
|
*
|
|
129
128
|
* @returns {number} clockFormat
|
|
130
129
|
*/
|
|
131
|
-
export const parseClockFormat =
|
|
132
|
-
typeof clockFormat ===
|
|
130
|
+
export const parseClockFormat = clockFormat =>
|
|
131
|
+
typeof clockFormat === 'string' ? parseInt(clockFormat, 10) : clockFormat;
|
|
133
132
|
|
|
134
133
|
/**
|
|
135
134
|
* Return datetime value string off to seconds
|
|
@@ -141,9 +140,9 @@ export const parseClockFormat = (clockFormat) =>
|
|
|
141
140
|
*/
|
|
142
141
|
export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
143
142
|
if (withSeconds) {
|
|
144
|
-
return `${datetime.substring(0, datetime.indexOf(
|
|
143
|
+
return `${datetime.substring(0, datetime.indexOf('Z'))}.000Z`;
|
|
145
144
|
}
|
|
146
|
-
return `${datetime.substring(0, datetime.lastIndexOf(
|
|
145
|
+
return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
|
|
147
146
|
};
|
|
148
147
|
|
|
149
148
|
/**
|
|
@@ -156,12 +155,9 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
|
|
|
156
155
|
*/
|
|
157
156
|
export const timeCorrectedToSeconds = (datetime, withSeconds) => {
|
|
158
157
|
if (withSeconds) {
|
|
159
|
-
return datetime.substring(datetime.indexOf(
|
|
158
|
+
return datetime.substring(datetime.indexOf('T') + 1, datetime.indexOf('.'));
|
|
160
159
|
}
|
|
161
|
-
return `${datetime.substring(
|
|
162
|
-
datetime.indexOf("T") + 1,
|
|
163
|
-
datetime.lastIndexOf(":")
|
|
164
|
-
)}:00`;
|
|
160
|
+
return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
|
|
165
161
|
};
|
|
166
162
|
|
|
167
163
|
/**
|
|
@@ -184,14 +180,13 @@ export const datetimeFireChangeBlurEvents = (
|
|
|
184
180
|
propName,
|
|
185
181
|
pConn
|
|
186
182
|
) => {
|
|
187
|
-
|
|
188
183
|
// TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
|
|
189
184
|
// above triggerFieldChange should have validated this
|
|
190
185
|
if (errorState) {
|
|
191
186
|
pConn.getValidationApi().validate(errorState);
|
|
192
187
|
}
|
|
193
188
|
// BUG-640834 In errorState presist old values avoiding store update & re-render.
|
|
194
|
-
else{
|
|
189
|
+
else {
|
|
195
190
|
if (formattedValue !== actualValue) {
|
|
196
191
|
actions.updateFieldValue(propName, formattedValue);
|
|
197
192
|
}
|
|
@@ -212,27 +207,27 @@ export const getDateFormat = (locale, options) => {
|
|
|
212
207
|
.formatToParts()
|
|
213
208
|
.map(({ type, value }) => {
|
|
214
209
|
switch (type) {
|
|
215
|
-
case
|
|
216
|
-
return
|
|
217
|
-
case
|
|
218
|
-
return
|
|
219
|
-
case
|
|
220
|
-
return
|
|
221
|
-
case
|
|
222
|
-
return
|
|
223
|
-
case
|
|
224
|
-
return
|
|
225
|
-
case
|
|
226
|
-
return
|
|
227
|
-
case
|
|
228
|
-
return
|
|
229
|
-
case
|
|
210
|
+
case 'day':
|
|
211
|
+
return 'DD';
|
|
212
|
+
case 'month':
|
|
213
|
+
return 'MM';
|
|
214
|
+
case 'year':
|
|
215
|
+
return 'YYYY';
|
|
216
|
+
case 'hour':
|
|
217
|
+
return 'hh';
|
|
218
|
+
case 'minute':
|
|
219
|
+
return 'mm';
|
|
220
|
+
case 'second':
|
|
221
|
+
return 'ss';
|
|
222
|
+
case 'dayPeriod':
|
|
223
|
+
return 'A';
|
|
224
|
+
case 'literal':
|
|
230
225
|
return value;
|
|
231
226
|
default:
|
|
232
|
-
return
|
|
227
|
+
return '';
|
|
233
228
|
}
|
|
234
229
|
})
|
|
235
|
-
.join(
|
|
230
|
+
.join('');
|
|
236
231
|
};
|
|
237
232
|
|
|
238
233
|
/**
|
|
@@ -242,15 +237,13 @@ export const getDateFormat = (locale, options) => {
|
|
|
242
237
|
* @returns {boolean} True or False for the locale
|
|
243
238
|
* Example : getDateFormat("pl-PL") returns false
|
|
244
239
|
*/
|
|
245
|
-
export const is12HClockFormat =
|
|
240
|
+
export const is12HClockFormat = locale => {
|
|
246
241
|
const meridiem = new Intl.DateTimeFormat(locale, {
|
|
247
|
-
hour:
|
|
242
|
+
hour: 'numeric'
|
|
248
243
|
})
|
|
249
244
|
.formatToParts()
|
|
250
|
-
.find(({ type }) => type ===
|
|
251
|
-
return !!(meridiem === null || meridiem === undefined
|
|
252
|
-
? undefined
|
|
253
|
-
: meridiem.value);
|
|
245
|
+
.find(({ type }) => type === 'dayPeriod');
|
|
246
|
+
return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
|
|
254
247
|
};
|
|
255
248
|
|
|
256
249
|
/**
|
|
@@ -263,9 +256,9 @@ export const is12HClockFormat = (locale) => {
|
|
|
263
256
|
*/
|
|
264
257
|
export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
265
258
|
return {
|
|
266
|
-
hour:
|
|
267
|
-
minute:
|
|
268
|
-
...(withSeconds && { second:
|
|
259
|
+
hour: 'numeric',
|
|
260
|
+
minute: 'numeric',
|
|
261
|
+
...(withSeconds && { second: 'numeric' }),
|
|
269
262
|
hour12: is12h
|
|
270
263
|
};
|
|
271
264
|
};
|
|
@@ -280,9 +273,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
|
|
|
280
273
|
*/
|
|
281
274
|
export const getDateTimeOptions = (withSeconds, is12h = false) => {
|
|
282
275
|
return {
|
|
283
|
-
year:
|
|
284
|
-
month:
|
|
285
|
-
day:
|
|
276
|
+
year: 'numeric',
|
|
277
|
+
month: 'numeric',
|
|
278
|
+
day: 'numeric',
|
|
286
279
|
...getTimeOptions(withSeconds, is12h)
|
|
287
280
|
};
|
|
288
281
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
isEmbeddedField,
|
|
3
|
+
isPageListInPath,
|
|
4
|
+
PAGE,
|
|
5
|
+
PAGELIST,
|
|
6
|
+
buildAggOrCalcId
|
|
7
|
+
} from './repeat-utils.js';
|
|
5
8
|
|
|
6
9
|
export const AT_FILTEREDLIST = '@FILTERED_LIST';
|
|
7
10
|
export const AT_PROPERTY = '@P';
|
|
@@ -55,7 +58,7 @@ export function getEmbeddedFieldName(propertyName, classID) {
|
|
|
55
58
|
* @param {Array} metaFields Fields metadata Array. Contains metadata of all the fields.
|
|
56
59
|
*/
|
|
57
60
|
export function updateMetaEmbeddedFieldID(metaFields) {
|
|
58
|
-
return metaFields.forEach(
|
|
61
|
+
return metaFields.forEach(metaField => {
|
|
59
62
|
if (metaField.fieldID?.startsWith(PAGE) || metaField.fieldID?.startsWith(PAGELIST)) {
|
|
60
63
|
metaField.fieldID = getFieldNameFromEmbeddedFieldName(metaField.fieldID);
|
|
61
64
|
}
|
|
@@ -72,7 +75,7 @@ export function updateMetaEmbeddedFieldID(metaFields) {
|
|
|
72
75
|
*/
|
|
73
76
|
export function getConfigEmbeddedFieldsMeta(configFields, classID) {
|
|
74
77
|
const configEmbeddedFieldsMeta = [];
|
|
75
|
-
configFields.forEach(
|
|
78
|
+
configFields.forEach(field => {
|
|
76
79
|
let value = field;
|
|
77
80
|
if (isEmbeddedField(value)) {
|
|
78
81
|
// conversion Page.PageList[].property => Page.PageList.property
|
|
@@ -96,8 +99,8 @@ export function getConfigEmbeddedFieldsMeta(configFields, classID) {
|
|
|
96
99
|
*/
|
|
97
100
|
export function mergeConfigEmbeddedFieldsMeta(configEmbeddedFieldsMeta, metaFields) {
|
|
98
101
|
const mergedMetaFields = [...metaFields];
|
|
99
|
-
configEmbeddedFieldsMeta.forEach(
|
|
100
|
-
const fieldMeta = metaFields.find(
|
|
102
|
+
configEmbeddedFieldsMeta.forEach(configFieldMeta => {
|
|
103
|
+
const fieldMeta = metaFields.find(metaField => metaField.fieldID === configFieldMeta.fieldID);
|
|
101
104
|
if (!fieldMeta) mergedMetaFields.push(configFieldMeta);
|
|
102
105
|
});
|
|
103
106
|
return mergedMetaFields;
|
|
@@ -155,7 +158,7 @@ export function preparePropertyValue(value) {
|
|
|
155
158
|
// FIXME #EmbeddedPropertyPatch
|
|
156
159
|
// TODO: Remove this utility when we have nested response for queryable pageList and supports scalarList component
|
|
157
160
|
export function updatePageListFieldsConfig(configFields) {
|
|
158
|
-
return configFields.forEach(
|
|
161
|
+
return configFields.forEach(item => {
|
|
159
162
|
if (item.type === 'ScalarList') {
|
|
160
163
|
if (!item.config.originalValue) {
|
|
161
164
|
item.config.originalValue = item.config.value;
|
|
@@ -169,7 +172,7 @@ export function updatePageListFieldsConfig(configFields) {
|
|
|
169
172
|
* Update the renderer type for the properties of type Page.
|
|
170
173
|
*/
|
|
171
174
|
export function updatePageFieldsConfig(configFields, parentClassID) {
|
|
172
|
-
return configFields.forEach(
|
|
175
|
+
return configFields.forEach(item => {
|
|
173
176
|
const {
|
|
174
177
|
type,
|
|
175
178
|
config: { value }
|
|
@@ -259,7 +262,7 @@ export function preparePropertyMaps(fields, classID, context) {
|
|
|
259
262
|
export function getPageListFields(fields) {
|
|
260
263
|
const parentPaths = new Set();
|
|
261
264
|
const pageListFields = [];
|
|
262
|
-
fields.forEach(
|
|
265
|
+
fields.forEach(field => {
|
|
263
266
|
const { name } = field;
|
|
264
267
|
if (isPageListProperty(name)) {
|
|
265
268
|
const parentPath = name.substring(0, name.lastIndexOf(':'));
|
|
@@ -272,7 +275,12 @@ export function getPageListFields(fields) {
|
|
|
272
275
|
return pageListFields;
|
|
273
276
|
}
|
|
274
277
|
|
|
275
|
-
export function mergePageListFieldAggregation(
|
|
278
|
+
export function mergePageListFieldAggregation(
|
|
279
|
+
pageListName,
|
|
280
|
+
select,
|
|
281
|
+
existingAggregations,
|
|
282
|
+
existingAggregationsName
|
|
283
|
+
) {
|
|
276
284
|
// Build a dummy genericAggregationId to check if any type of aggregation for that pagelist is included in existing aggregations.
|
|
277
285
|
const genericAggregationId = buildAggOrCalcId(pageListName, '');
|
|
278
286
|
if (existingAggregationsName.includes(genericAggregationId)) {
|
|
@@ -287,7 +295,7 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
|
|
|
287
295
|
const parentPaths = new Set();
|
|
288
296
|
const existingAggregationsName = Object.keys(existingAggregations).toString();
|
|
289
297
|
const pageListFields = [];
|
|
290
|
-
fields.forEach(
|
|
298
|
+
fields.forEach(field => {
|
|
291
299
|
const { name } = field;
|
|
292
300
|
if (isPageListProperty(name)) {
|
|
293
301
|
const parentPath = name.substring(0, name.lastIndexOf(':'));
|
|
@@ -309,5 +317,5 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
|
|
|
309
317
|
* @returns {object | undefined} value of first pageListProperty found
|
|
310
318
|
*/
|
|
311
319
|
export function hasPageListProperty(fieldDefs) {
|
|
312
|
-
return fieldDefs?.find(
|
|
320
|
+
return fieldDefs?.find(field => isPageListProperty(field.name));
|
|
313
321
|
}
|