@uxland/primary-shell 3.5.1 → 3.5.2

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.
@@ -19,6 +19,7 @@ export declare class PrimariaShell extends PrimariaShell_base {
19
19
  message: string;
20
20
  };
21
21
  _toggleSidebar(): void;
22
+ private subscriptions;
22
23
  _subscribeEvents(): void;
23
24
  _unsubscribeEvents(): void;
24
25
  }
@@ -37,4 +37,4 @@ export interface ConfirmResult<T = any> {
37
37
  }
38
38
  export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
39
39
  export type NotifyPosition = "bottom" | "center" | "top";
40
- export type NotifyType = "danger" | "warning" | "info" | "success" | "error";
40
+ export type NotifyType = "warning" | "info" | "success" | "error";
@@ -17,6 +17,8 @@ export declare class ActivityHistory extends ActivityHistory_base {
17
17
  _toggleFilters(): void;
18
18
  _maximize(): void;
19
19
  _minimize(): void;
20
+ _subscribeEvents(): void;
21
+ _unsubscribeEvents(): void;
20
22
  searchQuery: string;
21
23
  _handleSearchChange(event: any): void;
22
24
  _handleSelectDate(date: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxland/primary-shell",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
4
4
  "description": "Primaria Shell",
5
5
  "author": "UXLand <dev@uxland.es>",
6
6
  "homepage": "https://github.com/uxland/harmonix/tree/app#readme",
@@ -8,6 +8,7 @@ import { template } from "./template";
8
8
  import { shellViews } from "./constants";
9
9
  import { shellEvents } from "../../../events";
10
10
  import { activateDefaultView } from "../../../handle-views";
11
+ import { BrokerDisposableHandler } from "harmonix/core/dist";
11
12
 
12
13
  //@ts-ignore
13
14
  @customElement("primaria-shell")
@@ -68,14 +69,20 @@ export class PrimariaShell extends PrimariaRegionHost(LitElement) {
68
69
  this.sidebarExpanded = !this.sidebarExpanded;
69
70
  }
70
71
 
72
+ private subscriptions: BrokerDisposableHandler[] = [];
73
+
71
74
  _subscribeEvents() {
72
- shellApi.broker.subscribe(shellEvents.appCrashed, (error: { message: string }) => {
73
- this.viewSelected = shellViews.error;
74
- this.error = error;
75
- });
75
+ const subscription = shellApi.broker.subscribe(
76
+ shellEvents.appCrashed,
77
+ (error: { message: string }) => {
78
+ this.viewSelected = shellViews.error;
79
+ this.error = error;
80
+ },
81
+ );
82
+ this.subscriptions.push(subscription);
76
83
  }
77
84
 
78
85
  _unsubscribeEvents() {
79
- //TODO unsubscribe when broker accept unsuscribe
86
+ this.subscriptions.forEach((s) => s.dispose());
80
87
  }
81
88
  }
@@ -33,28 +33,28 @@
33
33
  visibility: visible; /* Show the snackbar */
34
34
  }
35
35
  &.success {
36
- background-color: #00893d;
36
+ background-color: var(--color-green-500);
37
37
  color: white;
38
38
  box-shadow:
39
39
  rgb(67 160 71 / 30%) 0px 0px 2px,
40
40
  rgb(67 160 71 / 22%) 0px 0px 5px;
41
41
  }
42
- &.danger {
43
- background-color: red;
42
+ &.error {
43
+ background-color: var(--color-red-500);
44
44
  color: white;
45
45
  box-shadow:
46
46
  rgb(229 57 53 / 30%) 0px 0px 2px,
47
47
  rgb(229 57 53 / 22%) 0px 0px 5px;
48
48
  }
49
49
  &.warning {
50
- background-color: orange;
51
- color: white;
50
+ background-color: var(--color-yellow-500);
51
+ color: black;
52
52
  box-shadow:
53
53
  rgb(251 140 0 / 30%) 0px 0px 2px,
54
54
  rgb(251 140 0 / 22%) 0px 0px 5px;
55
55
  }
56
56
  &.info {
57
- background-color: blue;
57
+ background-color: var(--color-primary-500);
58
58
  color: white;
59
59
  box-shadow:
60
60
  rgb(14 80 138 / 30%) 0px 0px 2px,
@@ -8,10 +8,10 @@ function getIcon(type: NotifyType | undefined) {
8
8
  if (!type) return;
9
9
 
10
10
  const types = new Map<NotifyType, string>([
11
- ["danger", "cancel"],
11
+ ["error", "error"],
12
12
  ["info", "info"],
13
13
  ["warning", "warning"],
14
- ["success", "done"],
14
+ ["success", "check_circle"],
15
15
  ]);
16
16
 
17
17
  return types.get(type) as string;
@@ -43,4 +43,4 @@ export interface ConfirmResult<T = any> {
43
43
 
44
44
  export type NotifyOrder = "first" | "second" | "third" | "fourth" | "fifth";
45
45
  export type NotifyPosition = "bottom" | "center" | "top";
46
- export type NotifyType = "danger" | "warning" | "info" | "success" | "error";
46
+ export type NotifyType = "warning" | "info" | "success" | "error";
@@ -6,6 +6,7 @@ import { shellApi } from "../../../api/api";
6
6
  import { shellEvents } from "../../../events";
7
7
  import { PrimariaNavItemConfig } from "../typings";
8
8
  import { regionView } from "@uxland/regions";
9
+ import { BrokerDisposableHandler } from "harmonix/core/dist";
9
10
 
10
11
  @customElement("primaria-nav-item")
11
12
  export class PrimariaNavItem extends regionView(LitElement) {
@@ -18,11 +19,15 @@ export class PrimariaNavItem extends regionView(LitElement) {
18
19
  this.config = config;
19
20
  }
20
21
 
22
+ private subscriptions: BrokerDisposableHandler[] = [];
23
+
21
24
  connectedCallback(): void {
22
25
  super.connectedCallback();
23
- shellApi.broker.subscribe(shellEvents.mainViewChanged, (payload: { viewId: string }) => {
24
- this.isActive = payload.viewId === this.view?.id;
25
- });
26
+ this._subscribeEvents();
27
+ }
28
+
29
+ disconnectedCallback(): void {
30
+ this._unsubscribeEvents();
26
31
  }
27
32
 
28
33
  firstUpdated(_changedProps: PropertyValues<PrimariaNavItem>) {
@@ -42,6 +47,20 @@ export class PrimariaNavItem extends regionView(LitElement) {
42
47
  observer.observe(parentElement as HTMLElement);
43
48
  }
44
49
 
50
+ _subscribeEvents() {
51
+ const subscription = shellApi.broker.subscribe(
52
+ shellEvents.mainViewChanged,
53
+ (payload: { viewId: string }) => {
54
+ this.isActive = payload.viewId === this.view?.id;
55
+ },
56
+ );
57
+ this.subscriptions.push(subscription);
58
+ }
59
+
60
+ _unsubscribeEvents() {
61
+ this.subscriptions.forEach((s) => s.dispose());
62
+ }
63
+
45
64
  render() {
46
65
  return html`${template(this)}`;
47
66
  }
@@ -129,8 +129,20 @@ const createDynamicRequestHandler = (handler: messageHandler) =>
129
129
  const createDynamicEventHandler = (handler: messageHandler) =>
130
130
  createDynamicMessageHandler(handler, "EventHandler");
131
131
 
132
+ const usedSuffixes = new Set();
133
+
134
+ function generateUniqueRandomSuffix() {
135
+ let suffix;
136
+ do {
137
+ suffix = Math.floor(Math.random() * 10000);
138
+ } while (usedSuffixes.has(suffix));
139
+
140
+ usedSuffixes.add(suffix);
141
+ return suffix;
142
+ }
143
+
132
144
  const createDynamicMessageHandler = (handler: messageHandler, classPrefix: string) => {
133
- const className = `${classPrefix}_${Math.floor(Math.random() * 10000)}`; // Generate a random class name
145
+ const className = `${classPrefix}_${generateUniqueRandomSuffix()}`; // Generate a random class name
134
146
  return new Function(
135
147
  "handler",
136
148
  `return class ${className}{
@@ -16,7 +16,7 @@ import { IActivityHistoryGroup } from "../../../domain/model";
16
16
  @customElement("activity-history-timeline")
17
17
  export class ActivityHistoryTimeline extends PrimariaRegionHost(LitElement) {
18
18
  render() {
19
- return html`${template(this)}${console.log(this.historyGroups)}`;
19
+ return html`${template(this)}`;
20
20
  }
21
21
 
22
22
  static styles = css`
@@ -31,16 +31,12 @@ export class ActivityHistory extends PrimariaRegionHost(LitElement) {
31
31
 
32
32
  connectedCallback() {
33
33
  super.connectedCallback();
34
- this.subscriptions.push(
35
- this.api.broker.subscribe(shellEvents.openClinicalMonitoringRequested, () => {
36
- this.maximized = false;
37
- }),
38
- );
34
+ this._subscribeEvents();
39
35
  }
40
36
 
41
37
  disconnectedCallback() {
42
38
  super.disconnectedCallback();
43
- this.subscriptions.forEach((s) => s.dispose());
39
+ this._unsubscribeEvents();
44
40
  }
45
41
 
46
42
  @property({ type: Boolean })
@@ -73,6 +69,20 @@ export class ActivityHistory extends PrimariaRegionHost(LitElement) {
73
69
  this.maximized = false;
74
70
  }
75
71
 
72
+ _subscribeEvents() {
73
+ const subscription = this.api.broker.subscribe(
74
+ shellEvents.openClinicalMonitoringRequested,
75
+ () => {
76
+ this.maximized = false;
77
+ },
78
+ );
79
+ this.subscriptions.push(subscription);
80
+ }
81
+
82
+ _unsubscribeEvents() {
83
+ this.subscriptions.forEach((s) => s.dispose());
84
+ }
85
+
76
86
  @property()
77
87
  searchQuery = "";
78
88
  _handleSearchChange(event) {
@@ -16,7 +16,7 @@ export const template = (props: ActivityHistory) =>
16
16
  <div class="title">${translate("activityHistory")}</div>
17
17
  <dss-search-bar dropdownStyle=${"display: none"} @onSearchChange=${props._handleSearchChange} icon="search" inputsize="md" threshold="2" recentsearchestext="" emptydropdowntext="">
18
18
  <label slot="label" for="searchbar1" aria-hidden="false"></label>
19
- <input slot="input" id="searchbar1" type="text" @input=${(e) => props._handleSearchChange({ detail: [e.target.value] })}>
19
+ <input slot="input" id="searchbar1" type="text" value=${props.searchQuery} @input=${(e) => props._handleSearchChange({ detail: [e.target.value] })}>
20
20
  </dss-search-bar>
21
21
  <dss-datepicker dropdownFixed inputsize="md" class="date-picker" @onValueChange=${(event) => props._handleSelectDate(event.detail)}>
22
22
  <label slot="label" for="myDatepicker">${translate("goToDate")}</label>
@@ -65,7 +65,7 @@ export const headerMaximizedTemplate = (props: ActivityHistory) => html`
65
65
  <div class="title">${translate("activityHistory")}</div>
66
66
  <dss-search-bar dropdownStyle=${"display: none"} @onSearchChange=${props._handleSearchChange} icon="search" inputsize="md" threshold="3" recentsearchestext="" emptydropdowntext="Sense resultats per">
67
67
  <label slot="label" for="searchbar1" aria-hidden="false"></label>
68
- <input slot="input" id="searchbar1" type="text" @input=${(e) => props._handleSearchChange({ detail: [e.target.value] })}>
68
+ <input slot="input" id="searchbar1" type="text" value=${props.searchQuery} @input=${(e) => props._handleSearchChange({ detail: [e.target.value] })}>
69
69
  </dss-search-bar>
70
70
  <dss-datepicker dropdownFixed inputsize="md" class="date-picker" @onValueChange=${(event) => props._handleSelectDate(event.detail)}>
71
71
  <label slot="label" for="myDatepicker">${translate("goToDate")}</label>