@pega/custom-dx-components 0.24.5 → 0.24.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.24.5",
3
+ "version": "0.24.6",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -17,10 +17,84 @@ const meta: Meta<typeof {{COMPONENT_CLASS_NAME}}> = {
17
17
  export default meta;
18
18
  type Story = StoryObj<typeof {{COMPONENT_CLASS_NAME}}>;
19
19
 
20
+ if (!window.PCore) {
21
+ window.PCore = {};
22
+ }
23
+
24
+ const worklistData = {
25
+ data: [
26
+ {
27
+ pxProcessName: 'Loan',
28
+ pxRefObjectInsName: ' A-8002',
29
+ pyAssignmentStatus: 'New',
30
+ pxTaskLabel: 'Details'
31
+ },
32
+ {
33
+ pxProcessName: 'Loan',
34
+ pxRefObjectInsName: ' A-7001',
35
+ pyAssignmentStatus: 'Open',
36
+ pxTaskLabel: 'Info'
37
+ },
38
+ {
39
+ pxProcessName: 'Loan',
40
+ pxRefObjectInsName: ' A-9000',
41
+ pyAssignmentStatus: 'Open',
42
+ pxTaskLabel: 'Amount'
43
+ }
44
+ ]
45
+ };
46
+
47
+ window.PCore.getDataPageUtils = () => {
48
+ return {
49
+ getDataAsync: () => {
50
+ return new Promise(resolve => {
51
+ resolve(worklistData);
52
+ });
53
+ }
54
+ };
55
+ };
56
+
57
+
58
+
20
59
  export const Base{{COMPONENT_CLASS_NAME}}: Story = args => {
21
60
 
22
61
  const props = {
23
- image: configProps.image
62
+ image: configProps.image,
63
+ getPConnect: () => {
64
+ return {
65
+ getValue: value => {
66
+ return value;
67
+ },
68
+ getContextName: () => {
69
+ return 'app/primary_1';
70
+ },
71
+ getLocalizedValue: value => {
72
+ return value;
73
+ },
74
+ getActionsApi: () => {
75
+ return {
76
+ updateFieldValue: () => {
77
+ /* nothing */
78
+ },
79
+ triggerFieldChange: () => {
80
+ /* nothing */
81
+ }
82
+ };
83
+ },
84
+ ignoreSuggestion: () => {
85
+ /* nothing */
86
+ },
87
+ acceptSuggestion: () => {
88
+ /* nothing */
89
+ },
90
+ setInheritedProps: () => {
91
+ /* nothing */
92
+ },
93
+ resolveConfigProps: () => {
94
+ /* nothing */
95
+ }
96
+ };
97
+ }
24
98
  };
25
99
 
26
100
  return (
@@ -1,4 +1,5 @@
1
- import { withConfiguration } from '@pega/cosmos-react-core';
1
+ import { useEffect, useState } from 'react';
2
+ import { withConfiguration, Table } from '@pega/cosmos-react-core';
2
3
  import { AppAnnouncement as PegaAppAnnouncement } from '@pega/cosmos-react-work';
3
4
  import type { PConnFieldProps } from './PConnProps';
4
5
 
@@ -14,14 +15,13 @@ interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
14
15
  image: string;
15
16
  }
16
17
 
17
-
18
- // Duplicated runtime code from Constellation Design System Component
19
-
20
18
  // props passed in combination of props from property panel (config.json) and run time props from Constellation
21
19
  // any default values in config.pros should be set in defaultProps at bottom of this file
22
20
  function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
23
21
 
24
- const { header, description, datasource = [], whatsnewlink, image } = props;
22
+ const { header, description, datasource = [], whatsnewlink, image, getPConnect } = props;
23
+ const [worklist, setWorklist] = useState([]);
24
+ const PConnect = getPConnect();
25
25
  let details = [];
26
26
  // @ts-ignore
27
27
  if (datasource && datasource.source) {
@@ -30,6 +30,48 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
30
30
  return item.name;
31
31
  });
32
32
  }
33
+
34
+ // setting up columns for the work list table
35
+ const columns = [
36
+ { renderer: 'caseType', label: PConnect.getLocalizedValue('Case type', '', '') },
37
+ { renderer: 'insKey', label: PConnect.getLocalizedValue('Key', '', '') },
38
+ { renderer: 'status', label: PConnect.getLocalizedValue('Status', '', '') },
39
+ { renderer: 'stage', label: PConnect.getLocalizedValue('Stage', '', '') }
40
+ ];
41
+
42
+ // going to get data for worklist to put into a table
43
+ // data comes from calling a PCore function to get
44
+ // get data from a data page and a PConnect function
45
+ // to get getContextName
46
+ useEffect(() => {
47
+ const dataViewName = 'D_pyMyWorkList';
48
+ const context = PConnect.getContextName();
49
+
50
+ PCore.getDataPageUtils()
51
+ .getDataAsync(dataViewName, context)
52
+ // @ts-ignore
53
+ .then((response: any) => {
54
+ // table requires an index or will get setExtraStackFrame error
55
+ setWorklist(
56
+ response.data.map((entry: any, index: number) => {
57
+ // mapping the data into the column names
58
+ // MUST have an id/index or will get a setExtraStackFrame error
59
+ // put a key in the table
60
+ return {
61
+ caseType: entry.pxProcessName,
62
+ insKey: entry.pxRefObjectInsName,
63
+ status: entry.pyAssignmentStatus,
64
+ stage: entry.pxTaskLabel,
65
+ id: index
66
+ };
67
+ })
68
+ );
69
+ })
70
+ .catch((error: any) => {
71
+ console.log(error);
72
+ });
73
+ }, [PConnect]);
74
+
33
75
  return (
34
76
  <Styled{{COMPONENT_CLASS_NAME}}Wrapper>
35
77
  <PegaAppAnnouncement
@@ -39,6 +81,12 @@ function {{COMPONENT_CLASS_NAME}}(props: {{COMPONENT_CLASS_NAME}}Props) {
39
81
  whatsNewLink={whatsnewlink}
40
82
  image={image.replace(/ /g, '+')}
41
83
  />
84
+ <br></br>
85
+ <Table
86
+ title={PConnect.getLocalizedValue('Work list', '', '')}
87
+ columns={columns}
88
+ data={worklist}
89
+ />
42
90
  </Styled{{COMPONENT_CLASS_NAME}}Wrapper>
43
91
  );
44
92
 
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@pega/configs": "^0.6.0",
72
- "@pega/custom-dx-components": "0.24.5",
72
+ "@pega/custom-dx-components": "0.24.6",
73
73
  "@pega/pcore-pconnect-typedefs": "~2.1.1",
74
74
  "@storybook/addon-actions": "^7.6.7",
75
75
  "@storybook/addon-essentials": "^7.6.7",
@@ -17,10 +17,84 @@ const meta: Meta<typeof PegaDxilMyPageWidget> = {
17
17
  export default meta;
18
18
  type Story = StoryObj<typeof PegaDxilMyPageWidget>;
19
19
 
20
+ if (!window.PCore) {
21
+ window.PCore = {};
22
+ }
23
+
24
+ const worklistData = {
25
+ data: [
26
+ {
27
+ pxProcessName: 'Loan',
28
+ pxRefObjectInsName: ' A-8002',
29
+ pyAssignmentStatus: 'New',
30
+ pxTaskLabel: 'Details'
31
+ },
32
+ {
33
+ pxProcessName: 'Loan',
34
+ pxRefObjectInsName: ' A-7001',
35
+ pyAssignmentStatus: 'Open',
36
+ pxTaskLabel: 'Info'
37
+ },
38
+ {
39
+ pxProcessName: 'Loan',
40
+ pxRefObjectInsName: ' A-9000',
41
+ pyAssignmentStatus: 'Open',
42
+ pxTaskLabel: 'Amount'
43
+ }
44
+ ]
45
+ };
46
+
47
+ window.PCore.getDataPageUtils = () => {
48
+ return {
49
+ getDataAsync: () => {
50
+ return new Promise(resolve => {
51
+ resolve(worklistData);
52
+ });
53
+ }
54
+ };
55
+ };
56
+
57
+
58
+
20
59
  export const BasePegaDxilMyPageWidget: Story = args => {
21
60
 
22
61
  const props = {
23
- image: configProps.image
62
+ image: configProps.image,
63
+ getPConnect: () => {
64
+ return {
65
+ getValue: value => {
66
+ return value;
67
+ },
68
+ getContextName: () => {
69
+ return 'app/primary_1';
70
+ },
71
+ getLocalizedValue: value => {
72
+ return value;
73
+ },
74
+ getActionsApi: () => {
75
+ return {
76
+ updateFieldValue: () => {
77
+ /* nothing */
78
+ },
79
+ triggerFieldChange: () => {
80
+ /* nothing */
81
+ }
82
+ };
83
+ },
84
+ ignoreSuggestion: () => {
85
+ /* nothing */
86
+ },
87
+ acceptSuggestion: () => {
88
+ /* nothing */
89
+ },
90
+ setInheritedProps: () => {
91
+ /* nothing */
92
+ },
93
+ resolveConfigProps: () => {
94
+ /* nothing */
95
+ }
96
+ };
97
+ }
24
98
  };
25
99
 
26
100
  return (
@@ -1,4 +1,5 @@
1
- import { withConfiguration } from '@pega/cosmos-react-core';
1
+ import { useEffect, useState } from 'react';
2
+ import { withConfiguration, Table } from '@pega/cosmos-react-core';
2
3
  import { AppAnnouncement as PegaAppAnnouncement } from '@pega/cosmos-react-work';
3
4
  import type { PConnFieldProps } from './PConnProps';
4
5
 
@@ -14,14 +15,13 @@ interface PegaDxilMyPageWidgetProps extends PConnFieldProps {
14
15
  image: string;
15
16
  }
16
17
 
17
-
18
- // Duplicated runtime code from Constellation Design System Component
19
-
20
18
  // props passed in combination of props from property panel (config.json) and run time props from Constellation
21
19
  // any default values in config.pros should be set in defaultProps at bottom of this file
22
20
  function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
23
21
 
24
- const { header, description, datasource = [], whatsnewlink, image } = props;
22
+ const { header, description, datasource = [], whatsnewlink, image, getPConnect } = props;
23
+ const [worklist, setWorklist] = useState([]);
24
+ const PConnect = getPConnect();
25
25
  let details = [];
26
26
  // @ts-ignore
27
27
  if (datasource && datasource.source) {
@@ -30,6 +30,48 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
30
30
  return item.name;
31
31
  });
32
32
  }
33
+
34
+ // setting up columns for the work list table
35
+ const columns = [
36
+ { renderer: 'caseType', label: PConnect.getLocalizedValue('Case type', '', '') },
37
+ { renderer: 'insKey', label: PConnect.getLocalizedValue('Key', '', '') },
38
+ { renderer: 'status', label: PConnect.getLocalizedValue('Status', '', '') },
39
+ { renderer: 'stage', label: PConnect.getLocalizedValue('Stage', '', '') }
40
+ ];
41
+
42
+ // going to get data for worklist to put into a table
43
+ // data comes from calling a PCore function to get
44
+ // get data from a data page and a PConnect function
45
+ // to get getContextName
46
+ useEffect(() => {
47
+ const dataViewName = 'D_pyMyWorkList';
48
+ const context = PConnect.getContextName();
49
+
50
+ PCore.getDataPageUtils()
51
+ .getDataAsync(dataViewName, context)
52
+ // @ts-ignore
53
+ .then((response: any) => {
54
+ // table requires an index or will get setExtraStackFrame error
55
+ setWorklist(
56
+ response.data.map((entry: any, index: number) => {
57
+ // mapping the data into the column names
58
+ // MUST have an id/index or will get a setExtraStackFrame error
59
+ // put a key in the table
60
+ return {
61
+ caseType: entry.pxProcessName,
62
+ insKey: entry.pxRefObjectInsName,
63
+ status: entry.pyAssignmentStatus,
64
+ stage: entry.pxTaskLabel,
65
+ id: index
66
+ };
67
+ })
68
+ );
69
+ })
70
+ .catch((error: any) => {
71
+ console.log(error);
72
+ });
73
+ }, [PConnect]);
74
+
33
75
  return (
34
76
  <StyledPegaDxilMyPageWidgetWrapper>
35
77
  <PegaAppAnnouncement
@@ -39,6 +81,12 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
39
81
  whatsNewLink={whatsnewlink}
40
82
  image={image.replace(/ /g, '+')}
41
83
  />
84
+ <br></br>
85
+ <Table
86
+ title={PConnect.getLocalizedValue('Work list', '', '')}
87
+ columns={columns}
88
+ data={worklist}
89
+ />
42
90
  </StyledPegaDxilMyPageWidgetWrapper>
43
91
  );
44
92
 
@@ -17,10 +17,84 @@ const meta: Meta<typeof PegaDxilMyPageWidget> = {
17
17
  export default meta;
18
18
  type Story = StoryObj<typeof PegaDxilMyPageWidget>;
19
19
 
20
+ if (!window.PCore) {
21
+ window.PCore = {};
22
+ }
23
+
24
+ const worklistData = {
25
+ data: [
26
+ {
27
+ pxProcessName: 'Loan',
28
+ pxRefObjectInsName: ' A-8002',
29
+ pyAssignmentStatus: 'New',
30
+ pxTaskLabel: 'Details'
31
+ },
32
+ {
33
+ pxProcessName: 'Loan',
34
+ pxRefObjectInsName: ' A-7001',
35
+ pyAssignmentStatus: 'Open',
36
+ pxTaskLabel: 'Info'
37
+ },
38
+ {
39
+ pxProcessName: 'Loan',
40
+ pxRefObjectInsName: ' A-9000',
41
+ pyAssignmentStatus: 'Open',
42
+ pxTaskLabel: 'Amount'
43
+ }
44
+ ]
45
+ };
46
+
47
+ window.PCore.getDataPageUtils = () => {
48
+ return {
49
+ getDataAsync: () => {
50
+ return new Promise(resolve => {
51
+ resolve(worklistData);
52
+ });
53
+ }
54
+ };
55
+ };
56
+
57
+
58
+
20
59
  export const BasePegaDxilMyPageWidget: Story = args => {
21
60
 
22
61
  const props = {
23
- image: configProps.image
62
+ image: configProps.image,
63
+ getPConnect: () => {
64
+ return {
65
+ getValue: value => {
66
+ return value;
67
+ },
68
+ getContextName: () => {
69
+ return 'app/primary_1';
70
+ },
71
+ getLocalizedValue: value => {
72
+ return value;
73
+ },
74
+ getActionsApi: () => {
75
+ return {
76
+ updateFieldValue: () => {
77
+ /* nothing */
78
+ },
79
+ triggerFieldChange: () => {
80
+ /* nothing */
81
+ }
82
+ };
83
+ },
84
+ ignoreSuggestion: () => {
85
+ /* nothing */
86
+ },
87
+ acceptSuggestion: () => {
88
+ /* nothing */
89
+ },
90
+ setInheritedProps: () => {
91
+ /* nothing */
92
+ },
93
+ resolveConfigProps: () => {
94
+ /* nothing */
95
+ }
96
+ };
97
+ }
24
98
  };
25
99
 
26
100
  return (
@@ -1,4 +1,5 @@
1
- import { withConfiguration } from '@pega/cosmos-react-core';
1
+ import { useEffect, useState } from 'react';
2
+ import { withConfiguration, Table } from '@pega/cosmos-react-core';
2
3
  import { AppAnnouncement as PegaAppAnnouncement } from '@pega/cosmos-react-work';
3
4
  import type { PConnFieldProps } from './PConnProps';
4
5
 
@@ -14,14 +15,13 @@ interface PegaDxilMyPageWidgetProps extends PConnFieldProps {
14
15
  image: string;
15
16
  }
16
17
 
17
-
18
- // Duplicated runtime code from Constellation Design System Component
19
-
20
18
  // props passed in combination of props from property panel (config.json) and run time props from Constellation
21
19
  // any default values in config.pros should be set in defaultProps at bottom of this file
22
20
  function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
23
21
 
24
- const { header, description, datasource = [], whatsnewlink, image } = props;
22
+ const { header, description, datasource = [], whatsnewlink, image, getPConnect } = props;
23
+ const [worklist, setWorklist] = useState([]);
24
+ const PConnect = getPConnect();
25
25
  let details = [];
26
26
  // @ts-ignore
27
27
  if (datasource && datasource.source) {
@@ -30,6 +30,48 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
30
30
  return item.name;
31
31
  });
32
32
  }
33
+
34
+ // setting up columns for the work list table
35
+ const columns = [
36
+ { renderer: 'caseType', label: PConnect.getLocalizedValue('Case type', '', '') },
37
+ { renderer: 'insKey', label: PConnect.getLocalizedValue('Key', '', '') },
38
+ { renderer: 'status', label: PConnect.getLocalizedValue('Status', '', '') },
39
+ { renderer: 'stage', label: PConnect.getLocalizedValue('Stage', '', '') }
40
+ ];
41
+
42
+ // going to get data for worklist to put into a table
43
+ // data comes from calling a PCore function to get
44
+ // get data from a data page and a PConnect function
45
+ // to get getContextName
46
+ useEffect(() => {
47
+ const dataViewName = 'D_pyMyWorkList';
48
+ const context = PConnect.getContextName();
49
+
50
+ PCore.getDataPageUtils()
51
+ .getDataAsync(dataViewName, context)
52
+ // @ts-ignore
53
+ .then((response: any) => {
54
+ // table requires an index or will get setExtraStackFrame error
55
+ setWorklist(
56
+ response.data.map((entry: any, index: number) => {
57
+ // mapping the data into the column names
58
+ // MUST have an id/index or will get a setExtraStackFrame error
59
+ // put a key in the table
60
+ return {
61
+ caseType: entry.pxProcessName,
62
+ insKey: entry.pxRefObjectInsName,
63
+ status: entry.pyAssignmentStatus,
64
+ stage: entry.pxTaskLabel,
65
+ id: index
66
+ };
67
+ })
68
+ );
69
+ })
70
+ .catch((error: any) => {
71
+ console.log(error);
72
+ });
73
+ }, [PConnect]);
74
+
33
75
  return (
34
76
  <StyledPegaDxilMyPageWidgetWrapper>
35
77
  <PegaAppAnnouncement
@@ -39,6 +81,12 @@ function PegaDxilMyPageWidget(props: PegaDxilMyPageWidgetProps) {
39
81
  whatsNewLink={whatsnewlink}
40
82
  image={image.replace(/ /g, '+')}
41
83
  />
84
+ <br></br>
85
+ <Table
86
+ title={PConnect.getLocalizedValue('Work list', '', '')}
87
+ columns={columns}
88
+ data={worklist}
89
+ />
42
90
  </StyledPegaDxilMyPageWidgetWrapper>
43
91
  );
44
92