@genesislcap/pbc-notify-ui 1.0.64 → 14.309.0

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.
Files changed (132) hide show
  1. package/api-extractor.json +4 -0
  2. package/dist/dts/components/foundation-inbox/components/inbox-subscription/inbox-subscription.d.ts.map +1 -1
  3. package/dist/dts/components/foundation-inbox/inbox.utils.d.ts.map +1 -1
  4. package/dist/dts/components/foundation-notification-dashboard/components/rules/columns.d.ts.map +1 -1
  5. package/dist/dts/components/foundation-notification-dashboard/components/templates/columns.d.ts.map +1 -1
  6. package/dist/dts/components/foundation-notification-dashboard/notification-dashboard.utils.d.ts.map +1 -1
  7. package/dist/dts/tsdoc-metadata.json +11 -0
  8. package/dist/dts/utils/gridConfig.d.ts.map +1 -1
  9. package/dist/dts/utils/humanize.d.ts.map +1 -1
  10. package/dist/dts/utils/toBoolean.d.ts.map +1 -1
  11. package/dist/dts/utils/updateArray.d.ts.map +1 -1
  12. package/dist/esm/index.federated.js +0 -1
  13. package/dist/pbc-notify-ui.api.json +889 -0
  14. package/dist/pbc-notify-ui.d.ts +252 -0
  15. package/dist/tsconfig.tsbuildinfo +1 -0
  16. package/docs/api/index.md +30 -0
  17. package/docs/api/pbc-notify-ui.foundationinbox.connectedcallback.md +18 -0
  18. package/docs/api/pbc-notify-ui.foundationinbox.disconnectedcallback.md +18 -0
  19. package/docs/api/pbc-notify-ui.foundationinbox.md +66 -0
  20. package/docs/api/pbc-notify-ui.foundationinboxcounter.connectedcallback.md +15 -0
  21. package/docs/api/pbc-notify-ui.foundationinboxcounter.disconnectedcallback.md +15 -0
  22. package/docs/api/pbc-notify-ui.foundationinboxcounter.inboxservice.md +11 -0
  23. package/docs/api/pbc-notify-ui.foundationinboxcounter.md +116 -0
  24. package/docs/api/pbc-notify-ui.foundationinboxcounter.value.md +11 -0
  25. package/docs/api/pbc-notify-ui.foundationinboxflyout.close.md +15 -0
  26. package/docs/api/pbc-notify-ui.foundationinboxflyout.connectedcallback.md +15 -0
  27. package/docs/api/pbc-notify-ui.foundationinboxflyout.disconnectedcallback.md +15 -0
  28. package/docs/api/pbc-notify-ui.foundationinboxflyout.flyout.md +11 -0
  29. package/docs/api/pbc-notify-ui.foundationinboxflyout.flyoutclosed.md +11 -0
  30. package/docs/api/pbc-notify-ui.foundationinboxflyout.loadremotes.md +15 -0
  31. package/docs/api/pbc-notify-ui.foundationinboxflyout.md +169 -0
  32. package/docs/api/pbc-notify-ui.foundationinboxflyout.open.md +15 -0
  33. package/docs/api/pbc-notify-ui.foundationinboxflyout.ready.md +11 -0
  34. package/docs/api/pbc-notify-ui.foundationnotificationdashboard.auth.md +11 -0
  35. package/docs/api/pbc-notify-ui.foundationnotificationdashboard.connectedcallback.md +15 -0
  36. package/docs/api/pbc-notify-ui.foundationnotificationdashboard.haspermissions.md +11 -0
  37. package/docs/api/pbc-notify-ui.foundationnotificationdashboard.md +122 -0
  38. package/docs/api/pbc-notify-ui.foundationnotificationdashboard.ready.md +11 -0
  39. package/docs/api/pbc-notify-ui.md +60 -0
  40. package/docs/api-report.md.api.md +76 -0
  41. package/license.txt +46 -0
  42. package/package.json +26 -39
  43. package/src/components/components.ts +54 -0
  44. package/src/components/foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter.styles.ts +30 -0
  45. package/src/components/foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter.template.ts +16 -0
  46. package/src/components/foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter.ts +33 -0
  47. package/src/components/foundation-inbox/components/foundation-inbox-flyout/foundation-inbox-flyout.styles.ts +18 -0
  48. package/src/components/foundation-inbox/components/foundation-inbox-flyout/foundation-inbox-flyout.template.ts +22 -0
  49. package/src/components/foundation-inbox/components/foundation-inbox-flyout/foundation-inbox-flyout.ts +43 -0
  50. package/src/components/foundation-inbox/components/inbox-subscription/inbox-subscription.styles.ts +37 -0
  51. package/src/components/foundation-inbox/components/inbox-subscription/inbox-subscription.template.ts +50 -0
  52. package/src/components/foundation-inbox/components/inbox-subscription/inbox-subscription.ts +81 -0
  53. package/src/components/foundation-inbox/components/inbox-subscription/rule-parameter/rule-parameter.styles.ts +25 -0
  54. package/src/components/foundation-inbox/components/inbox-subscription/rule-parameter/rule-parameter.template.ts +96 -0
  55. package/src/components/foundation-inbox/components/inbox-subscription/rule-parameter/rule-parameter.ts +55 -0
  56. package/src/components/foundation-inbox/inbox-base/inbox-base.ts +320 -0
  57. package/src/components/foundation-inbox/inbox.styles.ts +309 -0
  58. package/src/components/foundation-inbox/inbox.template.ts +317 -0
  59. package/src/components/foundation-inbox/inbox.ts +26 -0
  60. package/src/components/foundation-inbox/inbox.types.ts +84 -0
  61. package/src/components/foundation-inbox/inbox.utils.ts +33 -0
  62. package/src/components/foundation-notification-dashboard/components/notify-audit/notify-audit-management.ts +96 -0
  63. package/src/components/foundation-notification-dashboard/components/routes/route-management.ts +56 -0
  64. package/src/components/foundation-notification-dashboard/components/routes/tabs/email-distribution-route-management.ts +58 -0
  65. package/src/components/foundation-notification-dashboard/components/routes/tabs/email-user-route-management.ts +68 -0
  66. package/src/components/foundation-notification-dashboard/components/routes/tabs/log-route-management.ts +43 -0
  67. package/src/components/foundation-notification-dashboard/components/routes/tabs/ms-teams-route-management.ts +48 -0
  68. package/src/components/foundation-notification-dashboard/components/routes/tabs/screen-route-management.ts +73 -0
  69. package/src/components/foundation-notification-dashboard/components/rules/columns.ts +48 -0
  70. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.template.ts +139 -0
  71. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.ts +255 -0
  72. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder.types.ts +4 -0
  73. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.template.ts +159 -0
  74. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.ts +202 -0
  75. package/src/components/foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog.types.ts +28 -0
  76. package/src/components/foundation-notification-dashboard/components/rules/rule-management.ts +72 -0
  77. package/src/components/foundation-notification-dashboard/components/templates/columns.ts +48 -0
  78. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/parameter-builder/parameter-builder.styles.ts +59 -0
  79. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/parameter-builder/parameter-builder.template.ts +95 -0
  80. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/parameter-builder/parameter-builder.ts +124 -0
  81. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.template.ts +107 -0
  82. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder.ts +185 -0
  83. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.template.ts +139 -0
  84. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.ts +246 -0
  85. package/src/components/foundation-notification-dashboard/components/templates/template-dialog/template-dialog.types.ts +38 -0
  86. package/src/components/foundation-notification-dashboard/components/templates/template-management.ts +72 -0
  87. package/src/components/foundation-notification-dashboard/index.ts +1 -0
  88. package/src/components/foundation-notification-dashboard/notification-dashboard.styles.ts +21 -0
  89. package/src/components/foundation-notification-dashboard/notification-dashboard.tabs.ts +35 -0
  90. package/src/components/foundation-notification-dashboard/notification-dashboard.template.ts +58 -0
  91. package/src/components/foundation-notification-dashboard/notification-dashboard.ts +40 -0
  92. package/src/components/foundation-notification-dashboard/notification-dashboard.utils.ts +295 -0
  93. package/src/components/foundation-notification-dashboard/styles/condition-builder.styles.ts +66 -0
  94. package/src/components/foundation-notification-dashboard/styles/dynamic-rule.styles.ts +159 -0
  95. package/src/components/foundation-notification-dashboard/styles/management.styles.ts +21 -0
  96. package/src/components/foundation-notification-dashboard/types/expression-type.ts +13 -0
  97. package/src/components/foundation-notification-dashboard/types/logical-operator.ts +18 -0
  98. package/src/components/foundation-notification-dashboard/types/param-source-type.ts +11 -0
  99. package/src/components/foundation-notification-dashboard/types/param-type.ts +13 -0
  100. package/src/components/foundation-notification-dashboard/types/right-criteria.ts +6 -0
  101. package/src/components/foundation-notification-dashboard/types/rule-execution-strategy.ts +6 -0
  102. package/src/components/foundation-notification-dashboard/types/severity.ts +13 -0
  103. package/src/globals.d.ts +7 -0
  104. package/src/index.federated.ts +1 -0
  105. package/src/index.ts +4 -0
  106. package/src/notify.types.ts +143 -0
  107. package/src/sandbox.ts +83 -0
  108. package/src/services/alert.service.ts +36 -0
  109. package/src/services/inbox.service.ts +85 -0
  110. package/src/services/notify.service.ts +21 -0
  111. package/src/services/rule.service.ts +129 -0
  112. package/src/services/system.service.ts +43 -0
  113. package/src/services/template.service.ts +71 -0
  114. package/src/styles/scrollbar.styles.ts +15 -0
  115. package/src/utils/eventDetail.ts +5 -0
  116. package/src/utils/gridConfig.ts +14 -0
  117. package/src/utils/humanize.ts +14 -0
  118. package/src/utils/icons.ts +15 -0
  119. package/src/utils/index.ts +6 -0
  120. package/src/utils/logger.ts +3 -0
  121. package/src/utils/notifyPermissions.ts +6 -0
  122. package/src/utils/toBoolean.ts +7 -0
  123. package/src/utils/updateArray.ts +33 -0
  124. package/temp/api-report.md.api.md +76 -0
  125. package/tsconfig.json +11 -0
  126. package/.husky/commit-msg +0 -3
  127. package/.husky/pre-commit +0 -4
  128. package/README.md +0 -31
  129. package/commitlint.config.js +0 -25
  130. package/index.html +0 -28
  131. package/scripts/commitlint.js +0 -24
  132. package/sonar-project.properties +0 -5
@@ -0,0 +1,68 @@
1
+ import { customElement, GenesisElement, html } from '@genesislcap/web-core';
2
+ import { managementGridStyles } from '../../../styles/management.styles';
3
+
4
+ const EMAIL_USER_ROUTE_COLUMNS = [
5
+ {
6
+ field: 'NOTIFY_ROUTE_ID',
7
+ headerName: 'Notify Route Id',
8
+ flex: 1,
9
+ },
10
+ {
11
+ field: 'TOPIC_MATCH',
12
+ headerName: 'Topic Match',
13
+ flex: 1,
14
+ },
15
+ {
16
+ field: 'GATEWAY_ID',
17
+ headerName: 'Gateway Id',
18
+ flex: 1,
19
+ },
20
+ {
21
+ field: 'ROUTE_ENABLED',
22
+ headerName: 'Route Enabled',
23
+ flex: 1,
24
+ },
25
+ {
26
+ field: 'ENTITY_ID',
27
+ headerName: 'Entity Id',
28
+ flex: 1,
29
+ },
30
+ {
31
+ field: 'ENTITY_ID_TYPE',
32
+ headerName: 'Entity Id Type',
33
+ flex: 1,
34
+ },
35
+ {
36
+ field: 'RIGHT_CODE',
37
+ headerName: 'Right Code',
38
+ flex: 1,
39
+ },
40
+ {
41
+ field: 'AUTH_CACHE_NAME',
42
+ headerName: 'Auth Cache Name',
43
+ flex: 1,
44
+ },
45
+ {
46
+ field: 'EXCLUDE_SENDER',
47
+ headerName: 'Exclude Sender',
48
+ flex: 1,
49
+ },
50
+ ];
51
+
52
+ @customElement({
53
+ name: 'email-user-route-management',
54
+ template: html<EmailUserRouteManagement>`
55
+ <div class="grid">
56
+ <entity-management
57
+ design-system-prefix="rapid"
58
+ resourceName="ALL_EMAIL_USER_ROUTES"
59
+ createEvent="EVENT_EMAIL_USER_ROUTE_CREATE"
60
+ updateEvent="EVENT_EMAIL_USER_ROUTE_UPDATE"
61
+ deleteEvent="EVENT_EMAIL_USER_ROUTE_DELETE"
62
+ :columns=${() => [...EMAIL_USER_ROUTE_COLUMNS]}
63
+ ></entity-management>
64
+ </div>
65
+ `,
66
+ styles: managementGridStyles,
67
+ })
68
+ export class EmailUserRouteManagement extends GenesisElement {}
@@ -0,0 +1,43 @@
1
+ import { customElement, GenesisElement, html } from '@genesislcap/web-core';
2
+ import { managementGridStyles } from '../../../styles/management.styles';
3
+
4
+ const LOG_ROUTE_MANAGEMENT_COLUMNS = [
5
+ {
6
+ field: 'NOTIFY_ROUTE_ID',
7
+ headerName: 'Notify Route Id',
8
+ flex: 1,
9
+ },
10
+ {
11
+ field: 'TOPIC_MATCH',
12
+ headerName: 'Topic Match',
13
+ flex: 1,
14
+ },
15
+ {
16
+ field: 'GATEWAY_ID',
17
+ headerName: 'Gateway Id',
18
+ flex: 1,
19
+ },
20
+ {
21
+ field: 'ROUTE_ENABLED',
22
+ headerName: 'Route Enabled',
23
+ flex: 1,
24
+ },
25
+ ];
26
+
27
+ @customElement({
28
+ name: 'log-route-management',
29
+ template: html<LogRouteManagement>`
30
+ <div class="grid">
31
+ <entity-management
32
+ design-system-prefix="rapid"
33
+ resourceName="ALL_LOG_ROUTES"
34
+ createEvent="EVENT_LOG_ROUTE_CREATE"
35
+ updateEvent="EVENT_LOG_ROUTE_UPDATE"
36
+ deleteEvent="EVENT_LOG_ROUTE_DELETE"
37
+ :columns=${() => [...LOG_ROUTE_MANAGEMENT_COLUMNS]}
38
+ ></entity-management>
39
+ </div>
40
+ `,
41
+ styles: managementGridStyles,
42
+ })
43
+ export class LogRouteManagement extends GenesisElement {}
@@ -0,0 +1,48 @@
1
+ import { customElement, GenesisElement, html } from '@genesislcap/web-core';
2
+ import { managementGridStyles } from '../../../styles/management.styles';
3
+
4
+ const MS_TEAMS_ROUTE_MANAGEMENT_COLUMNS = [
5
+ {
6
+ field: 'NOTIFY_ROUTE_ID',
7
+ headerName: 'Notify Route Id',
8
+ flex: 1,
9
+ },
10
+ {
11
+ field: 'TOPIC_MATCH',
12
+ headerName: 'Topic Match',
13
+ flex: 1,
14
+ },
15
+ {
16
+ field: 'GATEWAY_ID',
17
+ headerName: 'Gateway Id',
18
+ flex: 1,
19
+ },
20
+ {
21
+ field: 'ROUTE_ENABLED',
22
+ headerName: 'Route Enabled',
23
+ flex: 1,
24
+ },
25
+ {
26
+ field: 'URL',
27
+ headerName: 'Url',
28
+ flex: 1,
29
+ },
30
+ ];
31
+
32
+ @customElement({
33
+ name: 'ms-teams-route-management',
34
+ template: html<MSTeamsRouteManagement>`
35
+ <div class="grid">
36
+ <entity-management
37
+ design-system-prefix="rapid"
38
+ resourceName="ALL_MS_TEAMS_ROUTES"
39
+ createEvent="EVENT_MS_TEAMS_ROUTE_CREATE"
40
+ updateEvent="EVENT_MS_TEAMS_ROUTE_UPDATE"
41
+ deleteEvent="EVENT_MS_TEAMS_ROUTE_DELETE"
42
+ :columns=${() => [...MS_TEAMS_ROUTE_MANAGEMENT_COLUMNS]}
43
+ ></entity-management>
44
+ </div>
45
+ `,
46
+ styles: managementGridStyles,
47
+ })
48
+ export class MSTeamsRouteManagement extends GenesisElement {}
@@ -0,0 +1,73 @@
1
+ import { UiSchema } from '@genesislcap/foundation-forms';
2
+ import { customElement, GenesisElement, html } from '@genesislcap/web-core';
3
+ import { managementGridStyles } from '../../../styles/management.styles';
4
+
5
+ const SCREEN_ROUTE_MANAGEMENT_COLUMNS = [
6
+ {
7
+ field: 'NOTIFY_ROUTE_ID',
8
+ headerName: 'Notify Route Id',
9
+ flex: 1,
10
+ },
11
+ {
12
+ field: 'TOPIC_MATCH',
13
+ headerName: 'Topic Match',
14
+ flex: 1,
15
+ },
16
+ {
17
+ field: 'GATEWAY_ID',
18
+ headerName: 'Gateway Id',
19
+ flex: 1,
20
+ },
21
+ {
22
+ field: 'ROUTE_ENABLED',
23
+ headerName: 'Route Enabled',
24
+ flex: 1,
25
+ },
26
+ {
27
+ field: 'ENTITY_ID',
28
+ headerName: 'Entity Id',
29
+ flex: 1,
30
+ },
31
+ {
32
+ field: 'ENTITY_ID_TYPE',
33
+ headerName: 'Entity Id Type',
34
+ flex: 1,
35
+ },
36
+ {
37
+ field: 'EXCLUDE_SENDER',
38
+ headerName: 'Exclude Sender',
39
+ flex: 1,
40
+ },
41
+ ];
42
+
43
+ const SCREEN_ROUTE_MANAGEMENT_UI_SCHEMA: UiSchema = {
44
+ type: 'VerticalLayout',
45
+ elements: [
46
+ { type: 'Control', scope: '#/properties/ENTITY_ID', label: 'ENTITY ID' },
47
+ { type: 'Control', scope: '#/properties/ENTITY_ID_TYPE', label: 'ENTITY ID TYPE' },
48
+ { type: 'Control', scope: '#/properties/EXCLUDE_SENDER', label: 'EXCLUDE SENDER' },
49
+ { type: 'Control', scope: '#/properties/GATEWAY_ID', label: 'GATEWAY ID' },
50
+ { type: 'Control', scope: '#/properties/ROUTE_ENABLED', label: 'ROUTE ENABLED' },
51
+ { type: 'Control', scope: '#/properties/TOPIC_MATCH', label: 'TOPIC MATCH' },
52
+ ],
53
+ };
54
+
55
+ @customElement({
56
+ name: 'screen-route-management',
57
+ template: html<ScreenRouteManagement>`
58
+ <div class="grid">
59
+ <entity-management
60
+ design-system-prefix="rapid"
61
+ resourceName="ALL_SCREEN_ROUTES"
62
+ createEvent="EVENT_SCREEN_NOTIFY_ROUTE_CREATE"
63
+ updateEvent="EVENT_SCREEN_NOTIFY_ROUTE_UPDATE"
64
+ deleteEvent="EVENT_SCREEN_NOTIFY_ROUTE_DELETE"
65
+ :columns=${() => [...SCREEN_ROUTE_MANAGEMENT_COLUMNS]}
66
+ :createFormUiSchema=${(x) => SCREEN_ROUTE_MANAGEMENT_UI_SCHEMA}
67
+ :updateFormUiSchema=${(x) => SCREEN_ROUTE_MANAGEMENT_UI_SCHEMA}
68
+ ></entity-management>
69
+ </div>
70
+ `,
71
+ styles: managementGridStyles,
72
+ })
73
+ export class ScreenRouteManagement extends GenesisElement {}
@@ -0,0 +1,48 @@
1
+ import { buttonCellRenderer } from '@genesislcap/foundation-entity-management';
2
+ import { deleteIcon, editIcon } from '../../../../utils';
3
+ import type { RuleManagement } from './rule-management';
4
+
5
+ export const RULE_MANAGEMENT_COLUMNS = (context: RuleManagement) => [
6
+ {
7
+ field: 'NAME',
8
+ headerName: 'Name',
9
+ flex: 1,
10
+ },
11
+ {
12
+ field: 'DESCRIPTION',
13
+ headerName: 'Description',
14
+ flex: 1,
15
+ },
16
+ {
17
+ field: 'USER_NAME',
18
+ headerName: 'Username',
19
+ flex: 1,
20
+ },
21
+ {
22
+ field: 'RULE_TABLE',
23
+ headerName: 'Table',
24
+ flex: 1,
25
+ },
26
+ {
27
+ field: 'RULE_STATUS',
28
+ headerName: 'Status',
29
+ flex: 1,
30
+ },
31
+ {
32
+ field: 'RULE_EXPRESSION',
33
+ headerName: 'Expression',
34
+ flex: 1,
35
+ },
36
+ {
37
+ field: 'RESULT_EXPRESSION',
38
+ headerName: 'Result',
39
+ flex: 1,
40
+ },
41
+ {
42
+ field: 'RULE_EXECUTION_STRATEGY',
43
+ headerName: 'Execution Strategy',
44
+ flex: 1,
45
+ },
46
+ buttonCellRenderer('Edit', (e) => context.editRule(e), editIcon),
47
+ buttonCellRenderer('Delete', (e) => context.deleteRule(e), deleteIcon),
48
+ ];
@@ -0,0 +1,139 @@
1
+ import { FieldTypeEnum } from '@genesislcap/foundation-comms';
2
+ import { sync } from '@genesislcap/foundation-utils';
3
+ import { classNames, html, repeat, when, whenElse } from '@genesislcap/web-core';
4
+ import { LogicalOperator, nullAndBlankLogicalOperatorValues } from '../../../../../../notify.types';
5
+ import type { RuleConditionBuilder } from './rule-condition-builder';
6
+ import { RightCriteria } from './rule-condition-builder.types';
7
+
8
+ export const RuleConditionBuilderTemplate = html<RuleConditionBuilder>`
9
+ <div class="condition-builder">
10
+ <rapid-select
11
+ :value=${sync((x) => x.leftValue)}
12
+ :initialValue=${sync((x) => x.leftValue)}
13
+ title=${(x) => (x.leftValue ? JSON.parse(x.leftValue).FIELD_NAME : '')}
14
+ class="left-value"
15
+ >
16
+ ${repeat(
17
+ (x) => x.getAllFields(),
18
+ html`
19
+ <rapid-option value=${(x) => JSON.stringify(x)} title=${(x) => x.FIELD_NAME}>
20
+ ${(x) => x.FIELD_NAME}
21
+ </rapid-option>
22
+ `,
23
+ )}
24
+ </rapid-select>
25
+
26
+ <rapid-select
27
+ class="logical-operator${(x) =>
28
+ classNames([
29
+ '-null-and-blank',
30
+ nullAndBlankLogicalOperatorValues.includes(LogicalOperator[x.logicalOperator]),
31
+ ])}"
32
+ :value=${sync((x) => x.logicalOperator)}
33
+ title=${(x) => x.logicalOperator}
34
+ >
35
+ ${repeat(
36
+ (x) => x.getLogicalOperators(),
37
+ html`
38
+ <rapid-option value=${(x) => x.operator} title=${(x) => x}>
39
+ ${(x) => x.label}
40
+ </rapid-option>
41
+ `,
42
+ )}
43
+ </rapid-select>
44
+
45
+ ${when(
46
+ (x) => !nullAndBlankLogicalOperatorValues.includes(LogicalOperator[x.logicalOperator]),
47
+ html`
48
+ <rapid-select
49
+ class="right-criteria"
50
+ :value=${sync((x) => x.rightCriteria)}
51
+ title=${(x) => x.rightCriteria}
52
+ >
53
+ ${repeat(
54
+ (x) => x.getRightCriteria(),
55
+ html`
56
+ <rapid-option value=${(x) => x} title=${(x) => x}>${(x) => x}</rapid-option>
57
+ `,
58
+ )}
59
+ </rapid-select>
60
+
61
+ ${when(
62
+ (x) => x.rightCriteria === RightCriteria.VALUE,
63
+ html`
64
+ ${whenElse(
65
+ (x) => JSON.parse(x.leftValue ?? '{}').FIELD_TYPE === FieldTypeEnum.BOOLEAN,
66
+ html`
67
+ <rapid-select class="right-criteria-select" :value=${sync((x) => x.rightValueText)}>
68
+ <rapid-option value="true">true</rapid-option>
69
+ <rapid-option value="false">false</rapid-option>
70
+ </rapid-select>
71
+ `,
72
+ html`
73
+ ${whenElse(
74
+ (x) => JSON.parse(x.leftValue ?? '{}').FIELD_TYPE === FieldTypeEnum.DATE,
75
+ html`
76
+ <rapid-text-field
77
+ class="right-criteria-text"
78
+ :value=${sync((x) => x.rightValueText)}
79
+ type="date"
80
+ ></rapid-text-field>
81
+ `,
82
+ html`
83
+ ${whenElse(
84
+ (x) => JSON.parse(x.leftValue ?? '{}').FIELD_TYPE === FieldTypeEnum.DATETIME,
85
+ html`
86
+ <rapid-text-field
87
+ class="right-criteria-text"
88
+ :value=${sync((x) => x.rightValueText)}
89
+ type="datetime-local"
90
+ ></rapid-text-field>
91
+ `,
92
+ html`
93
+ <rapid-text-field
94
+ class="right-criteria-text"
95
+ :value=${sync((x) => x.rightValueText)}
96
+ placeholder="Value"
97
+ autocomplete="off"
98
+ ></rapid-text-field>
99
+ `,
100
+ )}
101
+ `,
102
+ )}
103
+ `,
104
+ )}
105
+ `,
106
+ )}
107
+ ${when(
108
+ (x) => x.rightCriteria === RightCriteria.FIELD,
109
+ html`
110
+ <rapid-select
111
+ class="right-criteria-select"
112
+ :value=${sync((x) => x.rightValueSelect)}
113
+ title=${(x) => x.rightValueSelect}
114
+ >
115
+ ${repeat(
116
+ (x) => x.getApplicableFields(),
117
+ html`
118
+ <rapid-option value=${(x) => x.FIELD_NAME} title=${(x) => x.FIELD_NAME}>
119
+ ${(x) => x.FIELD_NAME}
120
+ </rapid-option>
121
+ `,
122
+ )}
123
+ </rapid-select>
124
+ `,
125
+ )}
126
+ `,
127
+ )}
128
+
129
+ <rapid-button appearance="icon" class="delete" @click=${(x) => x.deleteCondition()}>
130
+ <rapid-icon
131
+ style="opacity: 0.5"
132
+ variant="regular"
133
+ name="trash-alt"
134
+ size="lg"
135
+ part="icon"
136
+ ></rapid-icon>
137
+ </rapid-button>
138
+ </div>
139
+ `;
@@ -0,0 +1,255 @@
1
+ import { FieldTypeEnum } from '@genesislcap/foundation-comms';
2
+ import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
3
+ import dayjs from 'dayjs';
4
+ import {
5
+ ConditionBuilderEntity,
6
+ DateLogicalOperators,
7
+ LogicalOperator,
8
+ LogicalOperators,
9
+ nullAndBlankLogicalOperatorValues,
10
+ } from '../../../../../../notify.types';
11
+ import { Field } from '../../../../../../services/system.service';
12
+ import { logger } from '../../../../../../utils';
13
+ import { ConditionBuilderStyles } from '../../../../styles/condition-builder.styles';
14
+ import { RuleConditionBuilderTemplate } from './rule-condition-builder.template';
15
+ import { RightCriteria } from './rule-condition-builder.types';
16
+
17
+ @customElement({
18
+ name: 'rule-condition-builder',
19
+ template: RuleConditionBuilderTemplate,
20
+ styles: ConditionBuilderStyles,
21
+ })
22
+ export class RuleConditionBuilder extends GenesisElement {
23
+ @observable condition: ConditionBuilderEntity;
24
+ @observable fields: Field[] = [];
25
+
26
+ @observable leftValue: string = null;
27
+ @observable leftValueItems: Array<any> = [];
28
+
29
+ @observable logicalOperator: string = null;
30
+
31
+ @observable rightCriteria: string = RightCriteria.VALUE;
32
+ @observable rightValueText: string = null;
33
+ @observable rightValueSelect: string = null;
34
+
35
+ deleteCondition() {
36
+ this.$emit('delete', this.condition as ConditionBuilderEntity);
37
+ }
38
+
39
+ async conditionChanged() {
40
+ if (this.fields) {
41
+ this.leftValueItems = this.fields;
42
+ }
43
+
44
+ const rightValue = this.condition.RIGHT_VALUE;
45
+ this.assignLeftValue();
46
+ this.logicalOperator = this.condition.LOGICAL_OPERATOR;
47
+ this.rightCriteria = this.condition.RIGHT_CRITERIA;
48
+ this.condition.RIGHT_VALUE = rightValue;
49
+ this.assignRightValue();
50
+
51
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
52
+ }
53
+
54
+ fieldsChanged() {
55
+ if (!Array.isArray(this.fields) || !this.fields.length) {
56
+ return;
57
+ }
58
+
59
+ this.leftValueItems = this.fields;
60
+ this.leftValue = JSON.stringify(this.leftValueItems[0]);
61
+ }
62
+
63
+ private assignLeftValue() {
64
+ if (!this.condition.LEFT_VALUE) {
65
+ // Add (fresh new; assign the 1st element)
66
+ this.leftValue = JSON.stringify(this.leftValueItems[0]);
67
+ } else if (typeof this.condition.LEFT_VALUE !== 'string') {
68
+ // Add (value changed)
69
+ this.leftValue = JSON.stringify(this.condition.LEFT_VALUE);
70
+ } else {
71
+ // Edit
72
+ this.leftValue = JSON.stringify(
73
+ this.leftValueItems.find((item) => item.FIELD_NAME === this.condition.LEFT_VALUE),
74
+ );
75
+ }
76
+
77
+ this.condition.LEFT_VALUE = JSON.parse(this.leftValue ?? '{}');
78
+ }
79
+
80
+ assignRightValue() {
81
+ if (this.condition.RIGHT_CRITERIA === RightCriteria.VALUE) {
82
+ switch (this.condition.LEFT_VALUE.FIELD_TYPE) {
83
+ case 'DATE':
84
+ this.rightValueText = this.convertLongForDatePicker(Number(this.condition.RIGHT_VALUE));
85
+ break;
86
+ case 'DATETIME':
87
+ this.rightValueText = this.convertLongForDatePicker(
88
+ Number(this.condition.RIGHT_VALUE),
89
+ true,
90
+ );
91
+ break;
92
+ default:
93
+ this.rightValueText = this.condition.RIGHT_VALUE;
94
+ }
95
+ return;
96
+ } else if (this.condition.RIGHT_CRITERIA === RightCriteria.FIELD) {
97
+ this.rightValueSelect = this.condition.RIGHT_VALUE;
98
+ return;
99
+ }
100
+
101
+ this.rightValueSelect = null;
102
+ }
103
+
104
+ getRightCriteria(): Array<any> {
105
+ return Object.values(RightCriteria);
106
+ }
107
+
108
+ getLogicalOperators(): Array<any> {
109
+ const leftFieldType = JSON.parse(this.leftValue ?? '{}').FIELD_TYPE;
110
+
111
+ if (leftFieldType === FieldTypeEnum.DATE || leftFieldType === FieldTypeEnum.DATETIME) {
112
+ return Object.values(DateLogicalOperators);
113
+ } else {
114
+ return LogicalOperators;
115
+ }
116
+ }
117
+
118
+ leftValueChanged() {
119
+ if (!this.condition) {
120
+ return;
121
+ }
122
+
123
+ this.getLogicalOperators();
124
+
125
+ this.condition.LEFT_VALUE = JSON.parse(this.leftValue ?? '{}');
126
+
127
+ if (this.condition.LEFT_VALUE.FIELD_TYPE === FieldTypeEnum.BOOLEAN) {
128
+ this.rightValueText = 'true';
129
+ } else {
130
+ this.clearRightValueText();
131
+ }
132
+
133
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
134
+ }
135
+
136
+ logicalOperatorChanged() {
137
+ if (!this.condition) {
138
+ return;
139
+ }
140
+
141
+ if (nullAndBlankLogicalOperatorValues.includes(LogicalOperator[this.logicalOperator])) {
142
+ this.rightCriteria = RightCriteria.VALUE;
143
+ this.clearRightValueText();
144
+ }
145
+
146
+ this.condition.LOGICAL_OPERATOR = this.logicalOperator;
147
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
148
+ }
149
+
150
+ rightCriteriaChanged() {
151
+ if (!this.condition) {
152
+ return;
153
+ }
154
+
155
+ this.condition.RIGHT_CRITERIA = this.rightCriteria;
156
+
157
+ switch (this.rightCriteria) {
158
+ case RightCriteria.VALUE:
159
+ if (this.condition.LEFT_VALUE.FIELD_TYPE === FieldTypeEnum.BOOLEAN) {
160
+ this.rightValueText = 'true';
161
+ } else {
162
+ this.clearRightValueText();
163
+ }
164
+ break;
165
+ case RightCriteria.FIELD:
166
+ this.clearRightValueSelect();
167
+ break;
168
+ default:
169
+ logger.error(`Unknown RightCriteria: ${this.rightCriteria}`);
170
+ break;
171
+ }
172
+
173
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
174
+ }
175
+
176
+ private clearRightValueText() {
177
+ this.rightValueText = '';
178
+ }
179
+
180
+ private clearRightValueSelect() {
181
+ this.rightValueSelect = this.fields[0].FIELD_NAME;
182
+ }
183
+
184
+ rightValueTextChanged() {
185
+ if (!this.condition) {
186
+ return;
187
+ }
188
+
189
+ switch (this.condition.LEFT_VALUE.FIELD_TYPE) {
190
+ case FieldTypeEnum.DATETIME:
191
+ case FieldTypeEnum.DATE:
192
+ this.condition.RIGHT_VALUE = `${this.convertDateTime(this.rightValueText)}`;
193
+ break;
194
+ default:
195
+ this.condition.RIGHT_VALUE = this.rightValueText;
196
+ break;
197
+ }
198
+
199
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
200
+ }
201
+
202
+ rightValueSelectChanged() {
203
+ if (!this.condition) {
204
+ return;
205
+ }
206
+
207
+ this.condition.RIGHT_VALUE = this.rightValueSelect;
208
+ this.$emit('edit', this.condition as ConditionBuilderEntity);
209
+ }
210
+
211
+ convertDateTime(dateTimeStr: string) {
212
+ if (!dateTimeStr || dateTimeStr == '') return;
213
+ const unixTimestampMillis = dayjs.utc(dateTimeStr).valueOf();
214
+ return unixTimestampMillis;
215
+ }
216
+
217
+ convertLongForDatePicker(value: number, time: boolean = false) {
218
+ return time ? dayjs(value).format('YYYY-MM-DDTHH:mm') : dayjs(value).format('YYYY-MM-DD');
219
+ }
220
+
221
+ getAllFields() {
222
+ return this.fields.filter((field) => field.FIELD_NAME != 'TIMESTAMP');
223
+ }
224
+
225
+ getApplicableFields() {
226
+ const leftFieldType = JSON.parse(this.leftValue ?? '{}').FIELD_TYPE;
227
+ const leftFieldName = JSON.parse(this.leftValue ?? '{}').FIELD_NAME;
228
+
229
+ // Prevent comparing the field to itself
230
+ const applicableFields = this.getAllFields().filter(
231
+ (field) => field.FIELD_NAME != leftFieldName,
232
+ );
233
+
234
+ switch (leftFieldType) {
235
+ case FieldTypeEnum.DATE:
236
+ case FieldTypeEnum.DATETIME:
237
+ return applicableFields.filter(
238
+ (field) =>
239
+ field.FIELD_TYPE === FieldTypeEnum.DATE || field.FIELD_TYPE === FieldTypeEnum.DATETIME,
240
+ );
241
+ case FieldTypeEnum.BOOLEAN:
242
+ return applicableFields.filter((field) => field.FIELD_TYPE === FieldTypeEnum.BOOLEAN);
243
+ case FieldTypeEnum.NUMBER:
244
+ return applicableFields.filter((field) => field.FIELD_TYPE === FieldTypeEnum.NUMBER);
245
+ default:
246
+ return applicableFields.filter(
247
+ (field) =>
248
+ field.FIELD_TYPE !== FieldTypeEnum.DATE &&
249
+ field.FIELD_TYPE !== FieldTypeEnum.DATETIME &&
250
+ field.FIELD_TYPE !== FieldTypeEnum.BOOLEAN &&
251
+ field.FIELD_TYPE !== FieldTypeEnum.NUMBER,
252
+ );
253
+ }
254
+ }
255
+ }