@genesislcap/pbc-notify-ui 1.0.64 → 14.308.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,54 @@
1
+ import { foundationLayoutComponents } from '@genesislcap/foundation-layout';
2
+ import * as rapidDesignSystem from '@genesislcap/rapid-design-system';
3
+ import { rapidGridComponents } from '@genesislcap/rapid-grid-pro';
4
+ import { FoundationInboxCounter } from './foundation-inbox/components/foundation-inbox-counter/foundation-inbox-counter';
5
+ import { InboxSubscription } from './foundation-inbox/components/inbox-subscription/inbox-subscription';
6
+ import { RuleParameter } from './foundation-inbox/components/inbox-subscription/rule-parameter/rule-parameter';
7
+ import { NotifyAuditManagement } from './foundation-notification-dashboard/components/notify-audit/notify-audit-management';
8
+ import { RouteManagement } from './foundation-notification-dashboard/components/routes/route-management';
9
+ import { EmailDistributionRouteManagement } from './foundation-notification-dashboard/components/routes/tabs/email-distribution-route-management';
10
+ import { EmailUserRouteManagement } from './foundation-notification-dashboard/components/routes/tabs/email-user-route-management';
11
+ import { LogRouteManagement } from './foundation-notification-dashboard/components/routes/tabs/log-route-management';
12
+ import { MSTeamsRouteManagement } from './foundation-notification-dashboard/components/routes/tabs/ms-teams-route-management';
13
+ import { ScreenRouteManagement } from './foundation-notification-dashboard/components/routes/tabs/screen-route-management';
14
+ import { RuleConditionBuilder } from './foundation-notification-dashboard/components/rules/rule-dialog/rule-condition-builder/rule-condition-builder';
15
+ import { RuleDialog } from './foundation-notification-dashboard/components/rules/rule-dialog/rule-dialog';
16
+ import { RuleManagement } from './foundation-notification-dashboard/components/rules/rule-management';
17
+ import { ParameterBuilder } from './foundation-notification-dashboard/components/templates/template-dialog/parameter-builder/parameter-builder';
18
+ import { TemplateConditionBuilder } from './foundation-notification-dashboard/components/templates/template-dialog/template-condition-builder/template-condition-builder';
19
+ import { TemplateDialog } from './foundation-notification-dashboard/components/templates/template-dialog/template-dialog';
20
+ import { TemplateManagement } from './foundation-notification-dashboard/components/templates/template-management';
21
+
22
+ // Components
23
+
24
+ // #region Inbox
25
+ FoundationInboxCounter;
26
+ InboxSubscription;
27
+ RuleParameter;
28
+ // #endregion Inbox
29
+
30
+ // #region Notification Dashboard
31
+ RuleManagement;
32
+ RuleDialog;
33
+ RuleConditionBuilder;
34
+
35
+ TemplateManagement;
36
+ TemplateDialog;
37
+ ParameterBuilder;
38
+ TemplateConditionBuilder;
39
+
40
+ RouteManagement;
41
+ ScreenRouteManagement;
42
+ EmailDistributionRouteManagement;
43
+ EmailUserRouteManagement;
44
+ LogRouteManagement;
45
+ MSTeamsRouteManagement;
46
+
47
+ NotifyAuditManagement;
48
+ // #endregion Notification Dashboard
49
+
50
+ export async function loadRemotes() {
51
+ rapidDesignSystem
52
+ .provideDesignSystem()
53
+ .register(rapidGridComponents, rapidDesignSystem.baseComponents, foundationLayoutComponents);
54
+ }
@@ -0,0 +1,30 @@
1
+ import { css } from '@genesislcap/web-core';
2
+
3
+ const BACKGROUND_COLOR = '#EF5547';
4
+
5
+ /** Class to use when there are no items */
6
+ export const noItemsClass = 'no-items';
7
+
8
+ export const FoundationInboxCounterStyles = css`
9
+ :host {
10
+ display: inline-block;
11
+ min-width: 16px;
12
+ height: 16px;
13
+ border-radius: 9px;
14
+ text-align: center;
15
+ color: #fff;
16
+ line-height: 16px;
17
+ font-size: 9px;
18
+ font-weight: 700;
19
+ background: ${BACKGROUND_COLOR};
20
+ pointer-events: none;
21
+ }
22
+
23
+ .hidden {
24
+ visibility: hidden;
25
+ }
26
+
27
+ :host(.${noItemsClass}) {
28
+ display: none;
29
+ }
30
+ `;
@@ -0,0 +1,16 @@
1
+ import { classNames, html, when } from '@genesislcap/web-core';
2
+ import type { FoundationInboxCounter } from './foundation-inbox-counter';
3
+ import { noItemsClass } from './foundation-inbox-counter.styles';
4
+
5
+ const MAX_NUMBER_TO_DISPLAY = 99;
6
+
7
+ export const FoundationInboxCounterTemplate = html<FoundationInboxCounter>`
8
+ <template class="${(x) => classNames([noItemsClass, x.value < 1])}">
9
+ ${when(
10
+ (x) => x.value > 0,
11
+ html`
12
+ ${(x) => (x.value > MAX_NUMBER_TO_DISPLAY ? `${MAX_NUMBER_TO_DISPLAY}+` : x.value)}
13
+ `,
14
+ )}
15
+ </template>
16
+ `;
@@ -0,0 +1,33 @@
1
+ import { customElement, GenesisElement, observable } from '@genesislcap/web-core';
2
+ import { FoundationInboxService } from '../../../../services/inbox.service';
3
+ import { AlertStatus } from '../../inbox.types';
4
+ import { FoundationInboxCounterStyles } from './foundation-inbox-counter.styles';
5
+ import { FoundationInboxCounterTemplate } from './foundation-inbox-counter.template';
6
+
7
+ @customElement({
8
+ name: 'foundation-inbox-counter',
9
+ template: FoundationInboxCounterTemplate,
10
+ styles: FoundationInboxCounterStyles,
11
+ })
12
+ export class FoundationInboxCounter extends GenesisElement {
13
+ @observable value: number = 0;
14
+ @FoundationInboxService inboxService: FoundationInboxService;
15
+ private subscriptionHandler: (any) => void;
16
+
17
+ async connectedCallback() {
18
+ super.connectedCallback();
19
+ this.subscriptionHandler = ({ store }) => {
20
+ this.value = (store?.items || []).length;
21
+ };
22
+ this.inboxService.subscribe(
23
+ this.subscriptionHandler,
24
+ false,
25
+ `ALERT_STATUS=='${AlertStatus.NEW}'`,
26
+ );
27
+ }
28
+
29
+ disconnectedCallback() {
30
+ super.disconnectedCallback();
31
+ this.inboxService.unsubscribe(this.subscriptionHandler);
32
+ }
33
+ }
@@ -0,0 +1,18 @@
1
+ import { css } from '@genesislcap/web-core';
2
+ import { FoundationInboxStyles } from '../../inbox.styles';
3
+
4
+ export const FoundationInboxFlyoutStyles = css`
5
+ rapid-flyout::part(flyout) {
6
+ width: 30%;
7
+ min-width: 320px;
8
+ padding: 0;
9
+ }
10
+
11
+ rapid-flyout::part(content) {
12
+ height: 100%;
13
+ display: flex;
14
+ flex-direction: column;
15
+ }
16
+
17
+ ${FoundationInboxStyles}
18
+ `;
@@ -0,0 +1,22 @@
1
+ import { html, ref } from '@genesislcap/web-core';
2
+ import { FoundationInboxTemplate } from '../../inbox.template';
3
+ import type { FoundationInboxFlyout } from './foundation-inbox-flyout';
4
+
5
+ export const FoundationInboxFlyoutTemplate = html<FoundationInboxFlyout>`
6
+ <rapid-flyout
7
+ ${ref('flyout')}
8
+ position="right"
9
+ @closed=${(x) => (x.flyoutClosed = true)}
10
+ :closed=${(x) => x.flyoutClosed}
11
+ displayHeader=${false}
12
+ >
13
+ <div class="inbox-header">
14
+ <div class="inbox-header-title">Alerts Center</div>
15
+ <rapid-button class="inbox-header-close" @click=${(x) => x.close()}>
16
+ <rapid-icon part="icon" name="xmark" size="xl"></rapid-icon>
17
+ </rapid-button>
18
+ </div>
19
+
20
+ ${FoundationInboxTemplate}
21
+ </rapid-flyout>
22
+ `;
@@ -0,0 +1,43 @@
1
+ import type { Flyout } from '@genesislcap/rapid-design-system';
2
+ import { observable, customElement } from '@genesislcap/web-core';
3
+ import { loadRemotes } from '../../../components';
4
+ import { FoundationInboxBase } from '../../inbox-base/inbox-base';
5
+ import { FoundationInboxFlyoutStyles } from './foundation-inbox-flyout.styles';
6
+ import { FoundationInboxFlyoutTemplate } from './foundation-inbox-flyout.template';
7
+
8
+ @customElement({
9
+ name: 'foundation-inbox-flyout',
10
+ template: FoundationInboxFlyoutTemplate,
11
+ styles: FoundationInboxFlyoutStyles,
12
+ })
13
+ export class FoundationInboxFlyout extends FoundationInboxBase {
14
+ @observable ready: boolean = false;
15
+
16
+ flyout: Flyout;
17
+ @observable flyoutClosed: boolean = true;
18
+
19
+ async connectedCallback() {
20
+ super.connectedCallback();
21
+ await this.loadRemotes();
22
+ }
23
+
24
+ disconnectedCallback(): void {
25
+ super.disconnectedCallback();
26
+ }
27
+
28
+ public async open() {
29
+ this.flyoutClosed = false;
30
+ this.rules = await this.ruleService.getRules();
31
+ this.templates = await this.templateService.getRuleTemplates();
32
+ }
33
+
34
+ public close() {
35
+ this.ruleTemplateDetails = null;
36
+ this.flyout.closeFlyout();
37
+ }
38
+
39
+ async loadRemotes() {
40
+ const remoteComponents = await loadRemotes();
41
+ this.ready = true;
42
+ }
43
+ }
@@ -0,0 +1,37 @@
1
+ import { css } from '@genesislcap/web-core';
2
+
3
+ export const InboxSubscriptionStyles = css`
4
+ .inbox-subscription {
5
+ display: flex;
6
+ flex-direction: column;
7
+ }
8
+
9
+ .inbox-subscription-header {
10
+ border-top: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
11
+ border-bottom: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
12
+ padding: calc(var(--design-unit) * 2px);
13
+ }
14
+
15
+ .inbox-subscription-content {
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: calc(var(--design-unit) * 2px);
19
+ overflow: auto;
20
+ max-height: calc(var(--design-unit) * 80px);
21
+ border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
22
+ margin: calc(var(--design-unit) * 2px);
23
+ padding: calc(var(--design-unit) * 2px);
24
+ border-radius: calc(var(--control-corner-radius) * 1px);
25
+ }
26
+
27
+ .inbox-subscription-footer {
28
+ padding: calc(var(--design-unit) * 2px);
29
+ border-top: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
30
+ }
31
+
32
+ rapid-button.subscribe {
33
+ display: flex;
34
+ margin: 0;
35
+ width: 100%;
36
+ }
37
+ `;
@@ -0,0 +1,50 @@
1
+ import { html, repeat, when } from '@genesislcap/web-core';
2
+ import { eventDetail } from '../../../../utils';
3
+ import { RuleParameterEntity } from '../../inbox.types';
4
+ import type { InboxSubscription } from './inbox-subscription';
5
+
6
+ export const InboxSubscriptionTemplate = html<InboxSubscription>`
7
+ <div class="inbox-subscription">
8
+ <div class="inbox-subscription-header">
9
+ Subscribe to
10
+ <span style="font-weight: bold;">${(x) => x.template.RULE_NAME}</span>
11
+ </div>
12
+
13
+ ${when(
14
+ (x) => Object.values(x.template.PARAMETERS).length === 0,
15
+ html`
16
+ <p style="padding-left: 10px;">The selected template doesn't have parameters.</p>
17
+ `,
18
+ )}
19
+ ${when(
20
+ (x) => Object.values(x.template.PARAMETERS).length > 0,
21
+ html`
22
+ <div class="inbox-subscription-content">
23
+ ${repeat(
24
+ // @ts-ignore
25
+ (x) => Object.values(x.template.PARAMETERS),
26
+ html<RuleParameterEntity>`
27
+ <rule-parameter
28
+ :parameter=${(x) => x}
29
+ :isFirstElement=${(x, c) => c.parent.isFirstElement(x)}
30
+ :operator=${(x, c) => c.parent.parametersOperators[x.PARAM_NAME]}
31
+ @parameterEdited=${(x, c) => c.parent.parameterEdit(eventDetail(c))}
32
+ ></rule-parameter>
33
+ `,
34
+ )}
35
+ </div>
36
+ `,
37
+ )}
38
+
39
+ <div class="inbox-subscription-footer">
40
+ <rapid-button
41
+ class="subscribe"
42
+ appearance="primary"
43
+ @click=${(x) => x.subscribeTemplate()}
44
+ ?disabled=${(x) => x.subscribeDisabled}
45
+ >
46
+ Subscribe
47
+ </rapid-button>
48
+ </div>
49
+ </div>
50
+ `;
@@ -0,0 +1,81 @@
1
+ import { attr, customElement, GenesisElement, observable } from '@genesislcap/web-core';
2
+ import { RuleService } from '../../../../services/rule.service';
3
+ import { EXPRESSION_TYPE_PLACEHOLDER } from '../../../foundation-notification-dashboard/types/expression-type';
4
+ import { PARAM_SOURCE_TYPE_DEFINED_GROUP } from '../../../foundation-notification-dashboard/types/param-source-type';
5
+ import { RuleParameterEntity } from '../../inbox.types';
6
+ import { InboxSubscriptionStyles } from './inbox-subscription.styles';
7
+ import { InboxSubscriptionTemplate } from './inbox-subscription.template';
8
+
9
+ @customElement({
10
+ name: 'inbox-subscription',
11
+ template: InboxSubscriptionTemplate,
12
+ styles: InboxSubscriptionStyles,
13
+ })
14
+ export class InboxSubscription extends GenesisElement {
15
+ @attr template;
16
+ private parametersDetails = {};
17
+ @observable parametersOperators = {};
18
+ @observable subscribeDisabled = true;
19
+ @RuleService ruleService: RuleService;
20
+
21
+ connectedCallback() {
22
+ super.connectedCallback();
23
+ }
24
+
25
+ disconnectedCallback() {
26
+ super.disconnectedCallback();
27
+ this.parametersDetails = {};
28
+ this.subscribeDisabled = true;
29
+ }
30
+
31
+ templateChanged() {
32
+ const parameters: RuleParameterEntity = this.template.PARAMETERS;
33
+
34
+ Object.keys(parameters).forEach((key) => {
35
+ const parameter = parameters[key];
36
+
37
+ if (parameter.PARAM_SOURCE_TYPE === PARAM_SOURCE_TYPE_DEFINED_GROUP) {
38
+ // Attribute 1st group value for select fields
39
+ this.parametersDetails[parameter.PARAM_NAME] = parameter.PARAM_SOURCE.split(',')[0];
40
+ }
41
+
42
+ this.parametersDetails[parameter.PARAM_NAME] = '';
43
+ });
44
+
45
+ this.parametersOperators = this.createParametersOperatorMap(
46
+ this.template.RULE_EXPRESSION.CONDITIONS,
47
+ );
48
+
49
+ this.verifySubscribe();
50
+ }
51
+
52
+ parameterEdit(value: any) {
53
+ this.parametersDetails[value.parameter.PARAM_NAME] = value.valueTyped;
54
+ this.verifySubscribe();
55
+ }
56
+
57
+ verifySubscribe() {
58
+ const parameters = Object.values(this.parametersDetails);
59
+ this.subscribeDisabled = parameters.length > 0 ? !parameters.every((x) => x !== '') : false;
60
+ }
61
+
62
+ isFirstElement = (parameter: RuleParameterEntity) =>
63
+ (Object.values(this.template.PARAMETERS) as any).findIndex(
64
+ (p) => p.PARAM_NAME === parameter.PARAM_NAME,
65
+ ) === 0;
66
+
67
+ async subscribeTemplate() {
68
+ await this.ruleService.subscribeRule(this.template.DYNAMIC_RULE_ID, this.parametersDetails);
69
+ this.$emit('templateSubscribed');
70
+ }
71
+
72
+ createParametersOperatorMap = (conditions) => {
73
+ this.parametersOperators = {};
74
+ conditions.forEach((condition) => {
75
+ if (condition.RIGHT.TYPE == EXPRESSION_TYPE_PLACEHOLDER) {
76
+ this.parametersOperators[condition.RIGHT.KEY] = condition.OPERATION;
77
+ }
78
+ });
79
+ return this.parametersOperators;
80
+ };
81
+ }
@@ -0,0 +1,25 @@
1
+ import { css } from '@genesislcap/web-core';
2
+
3
+ export const RuleParameterStyles = css`
4
+ .control {
5
+ display: flex;
6
+ flex-direction: column;
7
+ width: 100%;
8
+ }
9
+
10
+ label {
11
+ margin-bottom: calc(var(--design-unit) * 2px);
12
+ }
13
+
14
+ .input-field {
15
+ display: flex;
16
+ }
17
+
18
+ .input-field::part(root) {
19
+ width: 100%;
20
+ }
21
+
22
+ rapid-select::part(listbox) {
23
+ max-height: 160px;
24
+ }
25
+ `;
@@ -0,0 +1,96 @@
1
+ import { sync } from '@genesislcap/foundation-utils';
2
+ import { html, repeat, when } from '@genesislcap/web-core';
3
+ import { humanize } from '../../../../../utils';
4
+ import {
5
+ PARAM_SOURCE_TYPE_DEFINED_GROUP,
6
+ PARAM_SOURCE_TYPE_REQ_REP,
7
+ PARAM_SOURCE_TYPE_USER_TEXT,
8
+ } from '../../../../foundation-notification-dashboard/types/param-source-type';
9
+ import {
10
+ PARAM_TYPE_BOOLEAN,
11
+ PARAM_TYPE_NUMBER,
12
+ PARAM_TYPE_STRING,
13
+ } from '../../../../foundation-notification-dashboard/types/param-type';
14
+ import type { RuleParameter } from './rule-parameter';
15
+
16
+ export const RuleParameterTemplate = html<RuleParameter>`
17
+ <div class="control">
18
+ <label>
19
+ <span style="font-weight: bold;">${(x) => x.parameter.PARAM_LABEL}</span>
20
+ ${(x, c) => humanize(x.operator).toLowerCase()}
21
+ </label>
22
+
23
+ <!-- USER_TEXT -->
24
+ ${when(
25
+ (x) => x.parameter.PARAM_SOURCE_TYPE === PARAM_SOURCE_TYPE_USER_TEXT,
26
+ html`
27
+ ${when(
28
+ (x) => x.parameter.PARAM_TYPE === PARAM_TYPE_STRING,
29
+ html`
30
+ <rapid-text-field
31
+ autofocus=${(x) => x.isFirstElement}
32
+ class="input-field"
33
+ :value=${sync((x) => x.inputValue)}
34
+ @input=${(x, c) => x.parameterEdit((c.event.target as HTMLInputElement).value)}
35
+ ></rapid-text-field>
36
+ `,
37
+ )}
38
+ ${when(
39
+ (x) => x.parameter.PARAM_TYPE === PARAM_TYPE_NUMBER,
40
+ html`
41
+ <rapid-number-field
42
+ hide-step
43
+ autofocus=${(x) => x.isFirstElement}
44
+ class="input-field"
45
+ :value=${sync((x) => x.inputValue)}
46
+ @input=${(x, c) => x.parameterEdit((c.event.target as HTMLInputElement).value)}
47
+ ></rapid-number-field>
48
+ `,
49
+ )}
50
+
51
+ <!-- TODO: Implement
52
+ ${when(
53
+ (x) => x.parameter.PARAM_TYPE === PARAM_TYPE_BOOLEAN,
54
+ html`
55
+ <rapid-select
56
+ autofocus=${(x) => x.isFirstElement}
57
+ class="input-field"
58
+ :value=${sync((x) => x.inputValue)}
59
+ >
60
+ <rapid-option value="true">true</rapid-option>
61
+ <rapid-option value="false">false</rapid-option>
62
+ </rapid-select>
63
+ `,
64
+ )}
65
+ -->
66
+ `,
67
+ )}
68
+
69
+ <!-- DEFINED_GROUP -->
70
+ ${when(
71
+ (x) => x.parameter.PARAM_SOURCE_TYPE === PARAM_SOURCE_TYPE_DEFINED_GROUP,
72
+ html`
73
+ <rapid-select
74
+ autofocus=${(x) => x.isFirstElement}
75
+ class="input-field"
76
+ :value=${sync((x) => x.inputValue)}
77
+ >
78
+ ${repeat(
79
+ (x) => x.parameter.PARAM_SOURCE.split(','),
80
+ html`
81
+ <rapid-option value=${(x) => x}>${(x) => x}</rapid-option>
82
+ `,
83
+ )}
84
+ </rapid-select>
85
+ `,
86
+ )}
87
+
88
+ <!-- TODO: REQ_REP -->
89
+ ${when(
90
+ (x) => x.parameter.PARAM_SOURCE_TYPE === PARAM_SOURCE_TYPE_REQ_REP,
91
+ html`
92
+ <rapid-select :value=${sync((x) => x.inputValue)}></rapid-select>
93
+ `,
94
+ )}
95
+ </div>
96
+ `;
@@ -0,0 +1,55 @@
1
+ import { attr, customElement, GenesisElement, observable } from '@genesislcap/web-core';
2
+ import {
3
+ PARAM_SOURCE_TYPE_DEFINED_GROUP,
4
+ PARAM_SOURCE_TYPE_USER_TEXT,
5
+ } from '../../../../foundation-notification-dashboard/types/param-source-type';
6
+ import { PARAM_TYPE_BOOLEAN } from '../../../../foundation-notification-dashboard/types/param-type';
7
+ import { RuleParameterEntity } from '../../../inbox.types';
8
+ import { RuleParameterStyles } from './rule-parameter.styles';
9
+ import { RuleParameterTemplate } from './rule-parameter.template';
10
+
11
+ @customElement({
12
+ name: 'rule-parameter',
13
+ template: RuleParameterTemplate,
14
+ styles: RuleParameterStyles,
15
+ })
16
+ export class RuleParameter extends GenesisElement {
17
+ @attr @observable parameter: RuleParameterEntity;
18
+ @attr isFirstElement: boolean = false;
19
+ @attr operator: string = null;
20
+ @observable inputValue: string = '';
21
+
22
+ connectedCallback() {
23
+ super.connectedCallback();
24
+
25
+ switch (this.parameter.PARAM_SOURCE_TYPE) {
26
+ case PARAM_SOURCE_TYPE_DEFINED_GROUP:
27
+ this.inputValue = this.parameter.PARAM_SOURCE.split(',')[0];
28
+ break;
29
+ case PARAM_SOURCE_TYPE_USER_TEXT:
30
+ switch (this.parameter.PARAM_TYPE) {
31
+ case PARAM_TYPE_BOOLEAN:
32
+ this.inputValue = 'true';
33
+ break;
34
+ default:
35
+ this.inputValue = '';
36
+ break;
37
+ }
38
+ break;
39
+ default:
40
+ break;
41
+ }
42
+ }
43
+
44
+ disconnectedCallback() {
45
+ super.disconnectedCallback();
46
+ }
47
+
48
+ parameterEdit(inputValue) {
49
+ this.inputValue = inputValue;
50
+ this.$emit('parameterEdited', {
51
+ parameter: this.parameter,
52
+ valueTyped: inputValue,
53
+ } as any);
54
+ }
55
+ }