@pega/react-sdk-overrides 0.23.19 → 0.23.21

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.
@@ -1,4 +1,6 @@
1
- import React, { useState } from 'react';
1
+ /* eslint-disable no-shadow */
2
+ /* eslint-disable @typescript-eslint/no-shadow */
3
+ import React, { Fragment, useState } from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
4
6
  import {
@@ -28,7 +30,7 @@ import './ToDo.css';
28
30
 
29
31
  declare const PCore: any;
30
32
 
31
- const isChildCase = (assignment) => {
33
+ const isChildCase = assignment => {
32
34
  return assignment.isChild;
33
35
  };
34
36
 
@@ -58,11 +60,17 @@ const useStyles = makeStyles(theme => ({
58
60
  avatar: {
59
61
  backgroundColor: theme.palette.primary.light,
60
62
  color: theme.palette.getContrastText(theme.palette.primary.light)
63
+ },
64
+ todoWrapper: {
65
+ borderLeft: '6px solid',
66
+ borderLeftColor: theme.palette.primary.light,
67
+ padding: theme.spacing(1),
68
+ margin: theme.spacing(1)
61
69
  }
62
70
  }));
63
71
 
64
72
  export default function ToDo(props) {
65
- const { datasource, getPConnect, headerText, showTodoList, myWorkList, type } = props;
73
+ const { datasource, getPConnect, headerText, showTodoList, myWorkList, type, isConfirm } = props;
66
74
 
67
75
  const CONSTS = PCore.getConstants();
68
76
 
@@ -167,14 +175,28 @@ export default function ToDo(props) {
167
175
  });
168
176
  }
169
177
 
178
+ const renderTaskId = (type, getPConnect, showTodoList, assignment) => {
179
+ const displayID = getID(assignment);
180
+
181
+ if ((showTodoList && type !== CONSTS.TODO) || assignment.isChild === true) {
182
+ /* Supress link for todo inside flow step */
183
+ return (
184
+ <Button size='small' color='primary'>{`${assignment.name} ${getID(assignment)}`}</Button>
185
+ );
186
+ }
187
+ return displayID;
188
+ };
189
+
170
190
  const getListItemComponent = assignment => {
171
191
  if (isDesktop) {
172
192
  return (
173
193
  <>
174
194
  Task in
175
- <Button size='small' color='primary'>{`${assignment.name} ${getID(assignment)}`}</Button>
176
- {` \u2022 `}
177
- <span className='psdk-todo-assignment-status'>{assignment.status}</span>
195
+ {renderTaskId(type, getPConnect, showTodoList, assignment)}
196
+ {type === CONSTS.WORKLIST && assignment.status ? `\u2022 ` : undefined}
197
+ {type === CONSTS.WORKLIST && assignment.status ? (
198
+ <span className='psdk-todo-assignment-status'>{assignment.status}</span>
199
+ ) : undefined}
178
200
  {` \u2022 Urgency ${getPriority(assignment)}`}
179
201
  </>
180
202
  );
@@ -187,53 +209,102 @@ export default function ToDo(props) {
187
209
  );
188
210
  };
189
211
 
190
- return (
191
- <React.Fragment>
192
- <Card className={classes.root}>
193
- {showTodoList && (
194
- <CardHeader
195
- title={
196
- <Badge badgeContent={assignmentCount} color='primary'>
197
- <Typography variant='h6'>{headerText}&nbsp;&nbsp;&nbsp;</Typography>
198
- </Badge>
199
- }
200
- avatar={<Avatar className={classes.avatar}>{currentUserInitials}</Avatar>}
201
- ></CardHeader>
202
- )}
203
- <CardContent>
204
- <List>
205
- {assignments.map(assignment => (
206
- <ListItem
207
- key={getAssignmentId(assignment)}
208
- dense
209
- divider
210
- onClick={() => clickGo(assignment)}
211
- >
212
- <ListItemText
213
- primary={getAssignmentName(assignment)}
214
- secondary={getListItemComponent(assignment)}
215
- />
216
- <ListItemSecondaryAction>
212
+ const toDoContent = (
213
+ <>
214
+ {showTodoList && (
215
+ <CardHeader
216
+ title={
217
+ <Badge badgeContent={assignmentCount} color='primary'>
218
+ <Typography variant='h6'>{headerText}&nbsp;&nbsp;&nbsp;</Typography>
219
+ </Badge>
220
+ }
221
+ ></CardHeader>
222
+ )}
223
+ <List>
224
+ {assignments.map(assignment => (
225
+ <>
226
+ <div className='psdk-todo-avatar-header'>
227
+ <Avatar className={classes.avatar} style={{ marginRight: '16px' }}>
228
+ {currentUserInitials}
229
+ </Avatar>
230
+ <div style={{ display: 'block' }}>
231
+ <Typography variant='h6'>{assignment?.name}</Typography>
232
+ {`Task in ${renderTaskId(
233
+ type,
234
+ getPConnect,
235
+ showTodoList,
236
+ assignment
237
+ )} \u2022 Urgency ${getPriority(assignment)}`}
238
+ </div>
239
+ {!isConfirm && (
240
+ <div style={{ marginLeft: 'auto' }}>
217
241
  <IconButton onClick={() => clickGo(assignment)}>
218
242
  <ArrowForwardIosOutlinedIcon />
219
243
  </IconButton>
220
- </ListItemSecondaryAction>
221
- </ListItem>
222
- ))}
223
- </List>
224
- </CardContent>
225
- {assignmentCount > 3 && (
226
- <Box display='flex' justifyContent='center'>
227
- {bShowMore ? (
228
- <Button color='primary' onClick={_showMore}>
229
- Show more
230
- </Button>
231
- ) : (
232
- <Button onClick={_showLess}>Show less</Button>
233
- )}
234
- </Box>
235
- )}
236
- </Card>
244
+ </div>
245
+ )}
246
+ </div>
247
+ </>
248
+ ))}
249
+ </List>
250
+ </>
251
+ );
252
+
253
+ return (
254
+ <React.Fragment>
255
+ {type === CONSTS.WORKLIST && (
256
+ <Card className={classes.root}>
257
+ {showTodoList && (
258
+ <CardHeader
259
+ title={
260
+ <Badge badgeContent={assignmentCount} color='primary'>
261
+ <Typography variant='h6'>{headerText}&nbsp;&nbsp;&nbsp;</Typography>
262
+ </Badge>
263
+ }
264
+ avatar={<Avatar className={classes.avatar}>{currentUserInitials}</Avatar>}
265
+ ></CardHeader>
266
+ )}
267
+ <CardContent>
268
+ <List>
269
+ {assignments.map(assignment => (
270
+ <ListItem
271
+ key={getAssignmentId(assignment)}
272
+ dense
273
+ divider
274
+ onClick={() => clickGo(assignment)}
275
+ >
276
+ <ListItemText
277
+ primary={getAssignmentName(assignment)}
278
+ secondary={getListItemComponent(assignment)}
279
+ />
280
+ <ListItemSecondaryAction>
281
+ <IconButton onClick={() => clickGo(assignment)}>
282
+ <ArrowForwardIosOutlinedIcon />
283
+ </IconButton>
284
+ </ListItemSecondaryAction>
285
+ </ListItem>
286
+ ))}
287
+ </List>
288
+ </CardContent>
289
+ </Card>
290
+ )}
291
+
292
+ {type === CONSTS.TODO && !isConfirm && (
293
+ <Card className={classes.todoWrapper}>{toDoContent}</Card>
294
+ )}
295
+ {type === CONSTS.TODO && isConfirm && <Fragment>{toDoContent}</Fragment>}
296
+
297
+ {assignmentCount > 3 && (
298
+ <Box display='flex' justifyContent='center'>
299
+ {bShowMore ? (
300
+ <Button color='primary' onClick={_showMore}>
301
+ Show more
302
+ </Button>
303
+ ) : (
304
+ <Button onClick={_showLess}>Show less</Button>
305
+ )}
306
+ </Box>
307
+ )}
237
308
 
238
309
  <Snackbar
239
310
  open={showSnackbar}
@@ -265,8 +336,9 @@ ToDo.propTypes = {
265
336
  type: PropTypes.string,
266
337
  // pageMessages: PropTypes.arrayOf(PropTypes.any),
267
338
  // eslint-disable-next-line react/no-unused-prop-types
268
- context: PropTypes.string
339
+ context: PropTypes.string,
269
340
  // hideActionButtons: PropTypes.bool
341
+ isConfirm: PropTypes.bool
270
342
  };
271
343
 
272
344
  ToDo.defaultProps = {
@@ -280,6 +352,7 @@ ToDo.defaultProps = {
280
352
  // target: "",
281
353
  type: 'worklist',
282
354
  // pageMessages: null,
283
- context: ''
355
+ context: '',
284
356
  // hideActionButtons: false
357
+ isConfirm: false
285
358
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.23.19",
3
+ "version": "0.23.21",
4
4
  "description": "React SDK - Code for overriding components",
5
5
  "_filesComment": "During packing, npm ignores everything NOT in the files list",
6
6
  "files": [