@uxland/primary-shell 5.1.0 → 5.1.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.
Files changed (35) hide show
  1. package/dist/index.js +22412 -22134
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.umd.cjs +229 -174
  4. package/dist/index.umd.cjs.map +1 -1
  5. package/dist/primary/shell/src/UI/components/clinical-monitoring/clinical-monitoring.d.ts +3 -0
  6. package/dist/primary/shell/src/UI/components/pdf-visor/pdf-selector/pdf-selector.d.ts +12 -0
  7. package/dist/primary/shell/src/UI/components/pdf-visor/pdf-selector/template.d.ts +3 -0
  8. package/dist/primary/shell/src/UI/components/pdf-visor/pdf-visor.d.ts +22 -0
  9. package/dist/primary/shell/src/UI/components/pdf-visor/utils.d.ts +1 -0
  10. package/dist/primary/shell/src/UI/components/poc-events-ecap/poc-events-ecap.d.ts +2 -0
  11. package/dist/primary/shell/src/api/api.d.ts +2 -0
  12. package/dist/primary/shell/src/api/pdf-viewer-manager/events.d.ts +5 -0
  13. package/dist/primary/shell/src/api/pdf-viewer-manager/pdf-viewer-manager.d.ts +27 -0
  14. package/dist/primary/shell/src/constants.d.ts +1 -0
  15. package/dist/primary/shell/src/locales.d.ts +10 -0
  16. package/package.json +1 -1
  17. package/src/UI/components/clinical-monitoring/clinical-monitoring.ts +32 -0
  18. package/src/UI/components/clinical-monitoring/styles.css +0 -3
  19. package/src/UI/components/index.ts +1 -0
  20. package/src/UI/components/pdf-visor/pdf-selector/pdf-selector.ts +40 -0
  21. package/src/UI/components/pdf-visor/pdf-selector/styles.css +24 -0
  22. package/src/UI/components/pdf-visor/pdf-selector/template.ts +37 -0
  23. package/src/UI/components/pdf-visor/pdf-visor.ts +124 -0
  24. package/src/UI/components/pdf-visor/styles.css +29 -0
  25. package/src/UI/components/pdf-visor/utils.ts +16 -0
  26. package/src/UI/components/poc-events-ecap/poc-events-ecap.ts +37 -7
  27. package/src/api/api.ts +7 -1
  28. package/src/api/pdf-viewer-manager/events.ts +5 -0
  29. package/src/api/pdf-viewer-manager/pdf-viewer-manager.ts +97 -0
  30. package/src/constants.ts +1 -0
  31. package/src/features/exit/handler.ts +2 -2
  32. package/src/handle-plugins.ts +1 -1
  33. package/src/handle-views.ts +12 -7
  34. package/src/internal-plugins/activity-history/activity-history-item/list/UI/main-view/activity-history-main.ts +1 -1
  35. package/src/locales.ts +10 -0
@@ -0,0 +1,97 @@
1
+ import { translate } from "../../locales";
2
+ import { PrimariaNavItem } from "../../UI/shared-components/primaria-nav-item/primaria-nav-item";
3
+ import { PrimariaBroker } from "../broker/primaria-broker";
4
+ import { PrimariaNotificationService } from "../notification-service/notification-service";
5
+ import { shellRegions } from "../region-manager/regions";
6
+ import { pdfViwerEvents } from "./events";
7
+ import { pdfViewerId } from "../../constants";
8
+ import { PrimariaRegionManager } from "../region-manager/region-manager";
9
+ import { generateId } from "@primaria/plugins-core";
10
+
11
+ export interface IPdfDocument {
12
+ pdfName: string;
13
+ id: string;
14
+ data: PdfData;
15
+ }
16
+
17
+ export interface PdfData {
18
+ url?: string;
19
+ b64?: string;
20
+ }
21
+
22
+ export class PdfViewerManager {
23
+ constructor(
24
+ private broker: PrimariaBroker,
25
+ private notificationService: PrimariaNotificationService,
26
+ private regionManager: PrimariaRegionManager,
27
+ ) {}
28
+
29
+ private pdfs: IPdfDocument[] = [];
30
+ private activePdf: IPdfDocument | null = null;
31
+ private hasBeenActivated = false;
32
+
33
+ add(pdfName: string, data: PdfData) {
34
+ const id = generateId();
35
+ const pdf: IPdfDocument = { id, pdfName, data };
36
+
37
+ if (!data.url && !data.b64) {
38
+ this.notificationService.error(translate("pdfManager.missingData"));
39
+ return;
40
+ }
41
+ if (data.url && data.b64) {
42
+ this.notificationService.error(translate("pdfManager.duplicatedSource"));
43
+ return;
44
+ }
45
+ if (!this.hasBeenActivated) {
46
+ this.registerNavButton();
47
+ this.hasBeenActivated = true;
48
+ }
49
+ if (this.pdfs.some((p) => p.pdfName === pdf.pdfName)) {
50
+ this.notificationService.warning(translate("pdfManager.alreadyUploaded"));
51
+ } else {
52
+ this.pdfs.push(pdf as IPdfDocument);
53
+ this.broker.publish(pdfViwerEvents.added, pdf);
54
+
55
+ this.notificationService.success(translate("pdfManager.uploaded"));
56
+ }
57
+ }
58
+
59
+ delete(pdfId: string) {
60
+ this.pdfs = this.pdfs.filter((pdf) => pdf.id !== pdfId);
61
+
62
+ if (this.activePdf?.id === pdfId) {
63
+ this.activePdf = null;
64
+ }
65
+
66
+ this.broker.publish(pdfViwerEvents.deleted, { id: pdfId });
67
+ }
68
+
69
+ getPdfs(): IPdfDocument[] {
70
+ return this.pdfs;
71
+ }
72
+
73
+ private registerNavButton() {
74
+ this.regionManager.registerView(shellRegions.navigationMenu, {
75
+ id: pdfViewerId,
76
+ factory: () => {
77
+ const menuItem = new PrimariaNavItem({
78
+ icon: "picture_as_pdf",
79
+ label: translate("pdfManager.navButtonLabel"),
80
+ callbackFn: () => {
81
+ this.regionManager.activateMainView(pdfViewerId);
82
+ },
83
+ });
84
+ return Promise.resolve(menuItem);
85
+ },
86
+ });
87
+ }
88
+ }
89
+
90
+ const pdfViewerManager = (broker, interactionManager, regionManager) =>
91
+ new PdfViewerManager(broker, interactionManager, regionManager);
92
+
93
+ export const createPdfViewerManager = (
94
+ broker: PrimariaBroker,
95
+ notificationService: PrimariaNotificationService,
96
+ regionManager: PrimariaRegionManager,
97
+ ) => pdfViewerManager(broker, notificationService, regionManager);
package/src/constants.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export const primariaShellId = "primaria-shell";
2
2
  export const clinicalMonitoringId = "clinical-monitoring";
3
3
  export const pocTestEventsId = "poc-events-ecap";
4
+ export const pdfViewerId = "pdf-viewer";
@@ -17,17 +17,17 @@ export class ExitShellHandler {
17
17
  const { confirmed } = await this.askForClose(busyTasks);
18
18
  if (!confirmed) return;
19
19
  }
20
- disposeShell();
21
20
 
22
21
  // Per si un plugin tarda molt en fer dispose, màxim deixarem 5 segons, per no interrompre el tancar infinitament
23
22
  await Promise.race([
24
23
  disposePlugins(), // S'intenta executar un dispose normal
25
24
  this.timeout(5000), // Si passen 5s, es segueix amb l'execució
26
25
  ]);
27
-
26
+ disposeShell();
28
27
  raiseCloseEvent();
29
28
  } catch (error) {
30
29
  this.api.notificationService.error(error.message);
30
+ raiseCloseEvent();
31
31
  }
32
32
  }
33
33
 
@@ -26,7 +26,7 @@ export const bootstrapPlugins = async (plugins: PluginDefinition[]) => {
26
26
  };
27
27
 
28
28
  export const disposePlugins = async () => {
29
- return Promise.all(bootstrappedPlugins.map((plugin: BootstrappedPlugin) => plugin.dispose()));
29
+ return Promise.all(bootstrappedPlugins.map((plugin: BootstrappedPlugin) => plugin?.dispose()));
30
30
  };
31
31
 
32
32
  export type Plugin = PluginType<PrimariaApi>;
@@ -1,9 +1,10 @@
1
1
  import { shellApi } from "./api/api";
2
2
  import { shellRegions } from "./api/region-manager/regions";
3
- import { clinicalMonitoringId, pocTestEventsId } from "./constants";
3
+ import { clinicalMonitoringId, pdfViewerId, pocTestEventsId } from "./constants";
4
4
  import { shellEvents } from "./events";
5
5
  import { ExitShell } from "./features/exit/request";
6
6
  import { ClinicalMonitoring } from "./UI/components/clinical-monitoring/clinical-monitoring";
7
+ import { PdfVisor } from "./UI/components/pdf-visor/pdf-visor";
7
8
  import { PocEventsEcap } from "./UI/components/poc-events-ecap/poc-events-ecap";
8
9
  import { PrimariaNavItem } from "./UI/shared-components/primaria-nav-item/primaria-nav-item";
9
10
  import { PrimariaNavTreeMenu } from "./UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu";
@@ -30,9 +31,7 @@ const registerUpperNavMenuViews = () => {
30
31
  });
31
32
  return Promise.resolve(menuItem);
32
33
  },
33
- options: {
34
- sortHint: "000100",
35
- },
34
+ sortHint: "000100",
36
35
  });
37
36
  shellApi.regionManager.registerView(shellRegions.navigationMenu, {
38
37
  id: "communication",
@@ -290,9 +289,7 @@ const registerMainViews = () => {
290
289
  const mainItem = new ClinicalMonitoring();
291
290
  return Promise.resolve(mainItem as unknown as HTMLElement);
292
291
  },
293
- options: {
294
- isDefault: true,
295
- },
292
+ isDefault: true,
296
293
  });
297
294
  shellApi.regionManager.registerMainView({
298
295
  id: pocTestEventsId,
@@ -301,6 +298,14 @@ const registerMainViews = () => {
301
298
  return Promise.resolve(mainItem as unknown as HTMLElement);
302
299
  },
303
300
  });
301
+
302
+ shellApi.regionManager.registerMainView({
303
+ id: pdfViewerId,
304
+ factory: () => {
305
+ const mainItem = new PdfVisor();
306
+ return Promise.resolve(mainItem as unknown as HTMLElement);
307
+ },
308
+ });
304
309
  };
305
310
 
306
311
  export const registerInternalViews = () => {
@@ -36,7 +36,7 @@ export class ActivityHistoryMain extends PrimariaRegionHost(LitElement) {
36
36
  this._unsubscribeEvents();
37
37
  }
38
38
 
39
- @property({ type: Boolean })
39
+ @property({ type: Boolean, reflect: true })
40
40
  maximized = false;
41
41
 
42
42
  @lazyInject(TYPES.primaryApi)
package/src/locales.ts CHANGED
@@ -53,6 +53,16 @@ export const locales = {
53
53
  busyManager: {
54
54
  title: "Tasques pendents a desar:",
55
55
  },
56
+ pdfManager: {
57
+ uploaded: "Document disponible al visor de resultats",
58
+ alreadyUploaded: "Ja s'ha carregat un document amb aquest nom",
59
+ navButtonLabel: "Visor PDF",
60
+ missingData: "Es necesita un document o URL per enviar al visor de resultats",
61
+ duplicatedSource: "Només pots envar un document o URL a la vegada",
62
+ },
63
+ pdfVisor: {
64
+ noPdfSelected: "No hi ha cap PDF seleccionat",
65
+ },
56
66
  },
57
67
  },
58
68
  };