@pega/react-sdk-overrides 0.23.20 → 0.23.22

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.
@@ -0,0 +1,35 @@
1
+ .background-image-style {
2
+ margin-left: -16px;
3
+ margin-right: -16px;
4
+ height: calc(19rem);
5
+ background-size: cover;
6
+ background-position: center center;
7
+ }
8
+
9
+ .background-style {
10
+ background-color: transparent;
11
+ color: rgb(0, 0, 0);
12
+ width: 100%;
13
+ height: 100%;
14
+ text-align: center;
15
+ }
16
+
17
+ .content {
18
+ display: flex;
19
+ flex-direction: column;
20
+ justify-content: center;
21
+ align-items: center;
22
+ gap: calc(0.5rem);
23
+ }
24
+
25
+ .title {
26
+ margin: 0rem;
27
+ font-size: 1.728rem;
28
+ font-weight: 600;
29
+ }
30
+
31
+ .message {
32
+ margin: 0;
33
+ font-size: 1rem;
34
+ font-weight: 400;
35
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import Grid from '@material-ui/core/Grid';
3
+ import './Banner.css';
4
+
5
+ export default function Banner(props) {
6
+ const { a, b, banner } = props;
7
+ const { title, message, backgroundImage } = banner;
8
+ return (
9
+ <div>
10
+ <div
11
+ className='background-image-style'
12
+ style={{ backgroundImage: `url(${backgroundImage})` }}
13
+ >
14
+ <div className='background-style content'>
15
+ <div>
16
+ <h1 className='title'>{title}</h1>
17
+ <p className='message'>{message}</p>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <div style={{ padding: '1rem' }}>
22
+ <Grid container item xs={12} spacing={1}>
23
+ <Grid item xs={8} style={{ padding: '1em' }}>
24
+ {a}
25
+ </Grid>
26
+ <Grid item xs={4} style={{ padding: '1em' }}>
27
+ {b}
28
+ </Grid>
29
+ </Grid>
30
+ </div>
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1 @@
1
+ export { default } from './Banner';
@@ -125,8 +125,7 @@ export default function CaseSummaryFields(props) {
125
125
  case 'date':
126
126
  case 'datetime': {
127
127
  const theDateFormatInfo = getDateFormatInfo();
128
- // eslint-disable-next-line no-console
129
- console.log(`theDateFormatInfo: ${theDateFormatInfo}`);
128
+ // console.log(`theDateFormatInfo: ${theDateFormatInfo}`);
130
129
  const theFormat = (fieldTypeLower === 'datetime') ? `${theDateFormatInfo.dateFormatStringLong} hh:mm a` : theDateFormatInfo.dateFormatStringLong
131
130
 
132
131
  return (
@@ -74,11 +74,12 @@ export default function Currency(props) {
74
74
  return <FieldValueList name={hideLabel ? '' : label} value={formattedValue} variant='stacked' />;
75
75
  }
76
76
 
77
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
77
78
  function currOnChange(event, inValue) {
78
79
  // console.log(`Currency currOnChange inValue: ${inValue}`);
79
80
 
80
81
  // update internal value
81
- setCurrValue(inValue);
82
+ setCurrValue(event?.target?.value);
82
83
  }
83
84
 
84
85
  function currOnBlur(event, inValue) {
@@ -38,19 +38,18 @@ export default function DateTime(props) {
38
38
 
39
39
 
40
40
  if (displayMode === 'LABELS_LEFT') {
41
- const formattedDate = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
42
- return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} />;
41
+ const formattedDateTime = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
42
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} />;
43
43
  }
44
44
 
45
45
  if (displayMode === 'STACKED_LARGE_VAL') {
46
- const formattedDate = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
47
- return <FieldValueList name={hideLabel ? '' : label} value={formattedDate} variant='stacked' />;
46
+ const formattedDateTime = format(props.value, 'datetime', { format: `${dateFormatInfo.dateFormatString} hh:mm a` });
47
+ return <FieldValueList name={hideLabel ? '' : label} value={formattedDateTime} variant='stacked' />;
48
48
  }
49
49
 
50
50
  if (readOnly) {
51
- const formattedDate = format(props.value, 'datetime');
52
- props.value = formattedDate;
53
- return <TextInput {...props} />;
51
+ const formattedDateTime = format(props.value, 'datetime');
52
+ return <TextInput {...props} value={formattedDateTime} />;
54
53
  }
55
54
 
56
55
  const handleChange = date => {
@@ -6,16 +6,15 @@ export function getAllFields(pConnect: any) {
6
6
  const metadata = pConnect.getRawMetadata();
7
7
  let allFields = [];
8
8
  if (metadata.children && metadata.children.map) {
9
- allFields = metadata.children.map((fields) => {
9
+ allFields = metadata.children.map(fields => {
10
10
  const children = fields.children instanceof Array ? fields.children : [];
11
- return children.map((field) => field.config);
11
+ return children.map(field => field.config);
12
12
  });
13
13
  }
14
14
  return allFields;
15
15
  }
16
16
 
17
-
18
- export function filterForFieldValueList(fields : any) {
17
+ export function filterForFieldValueList(fields: any) {
19
18
  return fields
20
19
  .filter(({ visibility }) => visibility !== false)
21
20
  .map(({ value, label }) => ({
@@ -25,12 +24,11 @@ export function filterForFieldValueList(fields : any) {
25
24
  }));
26
25
  }
27
26
 
28
-
29
27
  /**
30
28
  * Determine if the current view is the view of the case step/assignment.
31
29
  * @param {Function} pConnect PConnect object for the component
32
30
  */
33
- export function getIsAssignmentView(pConnect) {
31
+ export function getIsAssignmentView(pConnect) {
34
32
  // Get caseInfo content from the store which contains the view info about the current assignment/step
35
33
  // TODO To be replaced with pConnect.getCaseInfo().getCurrentAssignmentView when it's available
36
34
  const assignmentViewClass = pConnect.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_CLASSID);
@@ -50,7 +48,9 @@ export function filterForFieldValueList(fields : any) {
50
48
  * @param {string} [instructions="casestep"] 'casestep', 'none', or the html content of a Rule-UI-Paragraph rule (processed via core's paragraph annotation handler)
51
49
  */
52
50
  export function getInstructions(pConnect, instructions = 'casestep') {
53
- const caseStepInstructions = pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
51
+ const caseStepInstructions =
52
+ PCore.getConstants().CASE_INFO.INSTRUCTIONS &&
53
+ pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
54
54
 
55
55
  // Determine if this view is the current assignment/step view
56
56
  const isCurrentAssignmentView = getIsAssignmentView(pConnect);
@@ -1,5 +1,5 @@
1
- import React, { useState, useEffect } from "react";
2
- import PropTypes from "prop-types";
1
+ import React, { useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
3
 
4
4
  import AssignmentCard from '@pega/react-sdk-components/lib/components/infra/AssignmentCard';
5
5
  import MultiStep from '@pega/react-sdk-components/lib/components/infra/MultiStep';
@@ -14,7 +14,7 @@ export default function Assignment(props) {
14
14
  const thePConn = getPConnect();
15
15
 
16
16
  const [bHasNavigation, setHasNavigation] = useState(false);
17
- const [actionButtons, setActionButtons] = useState( {} );
17
+ const [actionButtons, setActionButtons] = useState({});
18
18
  const [bIsVertical, setIsVertical] = useState(false);
19
19
  const [arCurrentStepIndicies, setArCurrentStepIndicies] = useState<Array<any>>([]);
20
20
  const [arNavigationSteps, setArNavigationSteps] = useState<Array<any>>([]);
@@ -30,40 +30,38 @@ export default function Assignment(props) {
30
30
  // const showPage = actionsAPI.showPage.bind(actionsAPI);
31
31
 
32
32
  const [showSnackbar, setShowSnackbar] = useState(false);
33
- const [snackbarMessage, setSnackbarMessage] = useState("");
34
-
35
- function findCurrentIndicies(arStepperSteps: Array<any>, arIndicies: Array<number>, depth: number) : Array<number> {
33
+ const [snackbarMessage, setSnackbarMessage] = useState('');
36
34
 
35
+ function findCurrentIndicies(
36
+ arStepperSteps: Array<any>,
37
+ arIndicies: Array<number>,
38
+ depth: number
39
+ ): Array<number> {
37
40
  let count = 0;
38
- arStepperSteps.forEach( (step) => {
39
- if (step.visited_status === "current") {
41
+ arStepperSteps.forEach(step => {
42
+ if (step.visited_status === 'current') {
40
43
  arIndicies[depth] = count;
41
44
 
42
45
  // add in
43
- step["step_status"] = "";
44
- }
45
- else if (step.visited_status === "success") {
46
+ step['step_status'] = '';
47
+ } else if (step.visited_status === 'success') {
46
48
  count += 1;
47
- step.step_status = "completed"
48
- }
49
- else {
49
+ step.step_status = 'completed';
50
+ } else {
50
51
  count += 1;
51
- step.step_status = "";
52
+ step.step_status = '';
52
53
  }
53
54
 
54
55
  if (step.steps) {
55
- arIndicies = findCurrentIndicies(step.steps, arIndicies, depth + 1)
56
+ arIndicies = findCurrentIndicies(step.steps, arIndicies, depth + 1);
56
57
  }
57
58
  });
58
59
 
59
60
  return arIndicies;
60
61
  }
61
62
 
62
-
63
- useEffect( ()=> {
64
-
63
+ useEffect(() => {
65
64
  if (children && children.length > 0) {
66
-
67
65
  // debugger;
68
66
 
69
67
  const oWorkItem = children[0].props.getPConnect();
@@ -77,32 +75,32 @@ export default function Assignment(props) {
77
75
  setActionButtons(oCaseInfo.actionButtons);
78
76
  }
79
77
 
80
- if ( oCaseInfo?.navigation /* was oCaseInfo.navigation != null */) {
78
+ if (oCaseInfo?.navigation /* was oCaseInfo.navigation != null */) {
81
79
  setHasNavigation(true);
82
80
 
83
- if (oCaseInfo.navigation.template && oCaseInfo.navigation.template.toLowerCase() === "standard") {
81
+ if (
82
+ oCaseInfo.navigation.template &&
83
+ oCaseInfo.navigation.template.toLowerCase() === 'standard'
84
+ ) {
84
85
  setHasNavigation(false);
85
- }
86
- else if (oCaseInfo.navigation.template && oCaseInfo.navigation.template.toLowerCase() === "vertical") {
86
+ } else if (
87
+ oCaseInfo.navigation.template &&
88
+ oCaseInfo.navigation.template.toLowerCase() === 'vertical'
89
+ ) {
87
90
  setIsVertical(true);
88
- }
89
- else {
91
+ } else {
90
92
  setIsVertical(false);
91
93
  }
92
94
 
93
95
  setArNavigationSteps(JSON.parse(JSON.stringify(oCaseInfo.navigation.steps)));
94
- setArCurrentStepIndicies(findCurrentIndicies(arNavigationSteps, arCurrentStepIndicies, 0));
95
-
96
+ setArCurrentStepIndicies(
97
+ findCurrentIndicies(arNavigationSteps, arCurrentStepIndicies, 0)
98
+ );
96
99
  }
97
100
  }
98
-
99
101
  }
100
-
101
-
102
102
  }, [children]);
103
103
 
104
-
105
-
106
104
  function showToast(message: string) {
107
105
  const theMessage = `Assignment: ${message}`;
108
106
  // eslint-disable-next-line no-console
@@ -111,61 +109,65 @@ export default function Assignment(props) {
111
109
  setShowSnackbar(true);
112
110
  }
113
111
 
114
-
115
112
  function handleSnackbarClose(event: React.SyntheticEvent | React.MouseEvent, reason?: string) {
116
113
  if (reason === 'clickaway') {
117
114
  return;
118
115
  }
119
116
  setShowSnackbar(false);
120
- };
117
+ }
121
118
 
122
119
  function onSaveActionSuccess(data) {
123
120
  actionsAPI.cancelAssignment(itemKey).then(() => {
124
- PCore.getPubSubUtils().publish(PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.CREATE_STAGE_SAVED, data);
121
+ PCore.getPubSubUtils().publish(
122
+ PCore.getConstants().PUB_SUB_EVENTS.CASE_EVENTS.CREATE_STAGE_SAVED,
123
+ data
124
+ );
125
125
  });
126
126
  }
127
127
 
128
128
  function buttonPress(sAction: string, sButtonType: string) {
129
-
130
- if (sButtonType === "secondary") {
131
-
129
+ if (sButtonType === 'secondary') {
132
130
  switch (sAction) {
133
- case "navigateToStep": {
134
- const navigatePromise = navigateToStep( "previous", itemKey );
131
+ case 'navigateToStep': {
132
+ const navigatePromise = navigateToStep('previous', itemKey);
135
133
 
136
134
  navigatePromise
137
- .then(() => {
138
- })
135
+ .then(() => {})
139
136
  .catch(() => {
140
- showToast( `Navigation failed!`);
137
+ showToast(`Navigation failed!`);
141
138
  });
142
139
 
143
140
  break;
144
141
  }
145
142
 
146
- case "saveAssignment": {
143
+ case 'saveAssignment': {
147
144
  const caseID = thePConn.getCaseInfo().getKey();
148
145
  const assignmentID = thePConn.getCaseInfo().getAssignmentID();
149
146
  const savePromise = saveAssignment(itemKey);
150
147
 
151
148
  savePromise
152
- .then(() => {
153
- const caseType = thePConn.getCaseInfo().c11nEnv.getValue(PCore.getConstants().CASE_INFO.CASE_TYPE_ID);
154
- onSaveActionSuccess({ caseType, caseID, assignmentID });
155
- })
156
- .catch(() => {
157
- showToast('Save failed');
158
- });
149
+ .then(() => {
150
+ const caseType = thePConn
151
+ .getCaseInfo()
152
+ .c11nEnv.getValue(PCore.getConstants().CASE_INFO.CASE_TYPE_ID);
153
+ onSaveActionSuccess({ caseType, caseID, assignmentID });
154
+ })
155
+ .catch(() => {
156
+ showToast('Save failed');
157
+ });
159
158
 
160
159
  break;
161
160
  }
162
161
 
163
- case "cancelAssignment": {
162
+ case 'cancelAssignment': {
164
163
  // check if create stage (modal)
165
164
  const { PUB_SUB_EVENTS } = PCore.getConstants();
166
165
  const { publish } = PCore.getPubSubUtils();
167
166
  const isAssignmentInCreateStage = thePConn.getCaseInfo().isAssignmentInCreateStage();
168
- const isLocalAction = thePConn.getCaseInfo().isLocalAction() || getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION);
167
+ const isLocalAction =
168
+ thePConn.getCaseInfo().isLocalAction() ||
169
+ (PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION &&
170
+ getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION));
169
171
  if (isAssignmentInCreateStage && isInModal && !isLocalAction) {
170
172
  const cancelPromise = cancelCreateStageAssignment(itemKey);
171
173
 
@@ -193,73 +195,89 @@ export default function Assignment(props) {
193
195
  default:
194
196
  break;
195
197
  }
196
- }
197
- else if (sButtonType === "primary") {
198
+ } else if (sButtonType === 'primary') {
198
199
  // eslint-disable-next-line sonarjs/no-small-switch
199
200
  switch (sAction) {
200
- case "finishAssignment" :
201
- {
202
- const finishPromise = finishAssignment(itemKey);
201
+ case 'finishAssignment': {
202
+ const finishPromise = finishAssignment(itemKey);
203
203
 
204
- finishPromise
205
- .then(() => {
206
- })
207
- .catch(() => {
208
- showToast( `Submit failed!`);
209
- });
204
+ finishPromise
205
+ .then(() => {})
206
+ .catch(() => {
207
+ showToast(`Submit failed!`);
208
+ });
210
209
 
211
- break;
212
- }
210
+ break;
211
+ }
213
212
 
214
213
  default:
215
214
  break;
216
215
  }
217
216
  }
218
-
219
217
  }
220
218
 
221
-
222
219
  return (
223
- <div id="Assignment">
224
- { bHasNavigation ?
225
- <React.Fragment>
226
- <MultiStep getPConnect={getPConnect} itemKey={itemKey} actionButtons={actionButtons} onButtonPress={buttonPress}
227
- bIsVertical={bIsVertical} arCurrentStepIndicies={arCurrentStepIndicies} arNavigationSteps={arNavigationSteps}>
228
- {children}
229
- </MultiStep>
230
- <Snackbar
231
- open={showSnackbar}
232
- autoHideDuration={3000}
233
- onClose={handleSnackbarClose}
234
- message={snackbarMessage}
235
- action={
236
- <IconButton size="small" aria-label="close" color="inherit" onClick={handleSnackbarClose}>
237
- <CloseIcon fontSize="small" />
238
- </IconButton>
239
- }
240
- />
241
- </React.Fragment>
242
- : (
243
- <React.Fragment>
244
- <AssignmentCard getPConnect={getPConnect} itemKey={itemKey} actionButtons={actionButtons} onButtonPress={buttonPress} >
245
- {children}
246
- </AssignmentCard>
247
- <Snackbar
248
- open={showSnackbar}
249
- autoHideDuration={3000}
250
- onClose={handleSnackbarClose}
251
- message={snackbarMessage}
252
- action={
253
- <IconButton size="small" aria-label="close" color="inherit" onClick={handleSnackbarClose}>
254
- <CloseIcon fontSize="small" />
255
- </IconButton>
256
- }
257
- />
258
- </React.Fragment>
259
- )
260
- }
220
+ <div id='Assignment'>
221
+ {bHasNavigation ? (
222
+ <React.Fragment>
223
+ <MultiStep
224
+ getPConnect={getPConnect}
225
+ itemKey={itemKey}
226
+ actionButtons={actionButtons}
227
+ onButtonPress={buttonPress}
228
+ bIsVertical={bIsVertical}
229
+ arCurrentStepIndicies={arCurrentStepIndicies}
230
+ arNavigationSteps={arNavigationSteps}
231
+ >
232
+ {children}
233
+ </MultiStep>
234
+ <Snackbar
235
+ open={showSnackbar}
236
+ autoHideDuration={3000}
237
+ onClose={handleSnackbarClose}
238
+ message={snackbarMessage}
239
+ action={
240
+ <IconButton
241
+ size='small'
242
+ aria-label='close'
243
+ color='inherit'
244
+ onClick={handleSnackbarClose}
245
+ >
246
+ <CloseIcon fontSize='small' />
247
+ </IconButton>
248
+ }
249
+ />
250
+ </React.Fragment>
251
+ ) : (
252
+ <React.Fragment>
253
+ <AssignmentCard
254
+ getPConnect={getPConnect}
255
+ itemKey={itemKey}
256
+ actionButtons={actionButtons}
257
+ onButtonPress={buttonPress}
258
+ >
259
+ {children}
260
+ </AssignmentCard>
261
+ <Snackbar
262
+ open={showSnackbar}
263
+ autoHideDuration={3000}
264
+ onClose={handleSnackbarClose}
265
+ message={snackbarMessage}
266
+ action={
267
+ <IconButton
268
+ size='small'
269
+ aria-label='close'
270
+ color='inherit'
271
+ onClick={handleSnackbarClose}
272
+ >
273
+ <CloseIcon fontSize='small' />
274
+ </IconButton>
275
+ }
276
+ />
277
+ </React.Fragment>
278
+ )}
261
279
  </div>
262
- )
280
+ );
263
281
  }
264
282
 
265
283
  // From WC SDK
@@ -286,7 +304,6 @@ export default function Assignment(props) {
286
304
  // </div>`}
287
305
  // `;
288
306
 
289
-
290
307
  Assignment.propTypes = {
291
308
  children: PropTypes.node.isRequired,
292
309
  getPConnect: PropTypes.func.isRequired,