@uxland/primary-shell 8.3.4 → 8.3.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/README.md +18 -1
- package/dist/{component-Dv2Cw4dX.js → component-B4xPOzaR.js} +2 -2
- package/dist/{component-Dv2Cw4dX.js.map → component-B4xPOzaR.js.map} +1 -1
- package/dist/{index-CCC4rQo1.js → index-DsKLmCZe.js} +388 -388
- package/dist/index-DsKLmCZe.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{plugin-D3sg1ev9.js → plugin-CRWxCmf1.js} +1058 -1055
- package/dist/plugin-CRWxCmf1.js.map +1 -0
- package/dist/primary/shell/src/api/import-data-manager/import-data-manager-impl.d.ts +3 -2
- package/dist/primary/shell/src/api/import-data-manager/import-data-manager.d.ts +6 -4
- package/package.json +6 -14
- package/dist/index-CCC4rQo1.js.map +0 -1
- package/dist/plugin-D3sg1ev9.js.map +0 -1
- package/src/UI/bootstrapper.ts +0 -14
- package/src/UI/components/bootstrapper.ts +0 -25
- package/src/UI/components/clinical-pathways-action-menu/clinical-pathways-action-menu.ts +0 -13
- package/src/UI/components/communication-action-menu/communication-action-menu.ts +0 -13
- package/src/UI/components/error-view/component.ts +0 -17
- package/src/UI/components/error-view/styles.css +0 -27
- package/src/UI/components/error-view/template.ts +0 -12
- package/src/UI/components/nav-divider/nav-divider.ts +0 -41
- package/src/UI/components/nav-divider/styles.css +0 -21
- package/src/UI/components/nav-divider/template.ts +0 -8
- package/src/UI/components/petitioner-action-menu/petitioner-action-menu.ts +0 -13
- package/src/UI/components/primaria-accordion/primaria-accordion.ts +0 -45
- package/src/UI/components/primaria-shell/constants.ts +0 -4
- package/src/UI/components/primaria-shell/primaria-shell.ts +0 -105
- package/src/UI/components/primaria-shell/shell-header/header-divider/header-divider.ts +0 -13
- package/src/UI/components/primaria-shell/shell-header/header-divider/styles.css +0 -5
- package/src/UI/components/primaria-shell/shell-header/header-divider/template.ts +0 -8
- package/src/UI/components/primaria-shell/shell-header/shell-header.ts +0 -71
- package/src/UI/components/primaria-shell/shell-header/styles.css +0 -45
- package/src/UI/components/primaria-shell/shell-header/template.ts +0 -37
- package/src/UI/components/primaria-shell/styles.css +0 -185
- package/src/UI/components/primaria-shell/template.ts +0 -72
- package/src/UI/components/sidenav-action-menu/sidenav-action-menu.ts +0 -62
- package/src/UI/components/sidenav-action-menu/styles.css +0 -25
- package/src/UI/components/sidenav-action-menu/template.ts +0 -24
- package/src/UI/fonts/fonts.css +0 -48
- package/src/UI/fonts/open-sans-v40-latin-300.woff2 +0 -0
- package/src/UI/fonts/open-sans-v40-latin-500.woff2 +0 -0
- package/src/UI/fonts/open-sans-v40-latin-600.woff2 +0 -0
- package/src/UI/fonts/open-sans-v40-latin-700.woff2 +0 -0
- package/src/UI/fonts/open-sans-v40-latin-800.woff2 +0 -0
- package/src/UI/fonts/open-sans-v40-latin-regular.woff2 +0 -0
- package/src/UI/images/Gencat_Logotip.svg +0 -70
- package/src/UI/images/Salut_Logotip.svg +0 -8
- package/src/UI/index.ts +0 -1
- package/src/UI/internal-views/administrative-nav-menu.ts +0 -302
- package/src/UI/internal-views/common-nav-menu.ts +0 -94
- package/src/UI/internal-views/doctor-nav-menu.ts +0 -297
- package/src/UI/internal-views/doctor-quick-action-menu.ts +0 -16
- package/src/UI/internal-views/handle-views.ts +0 -24
- package/src/UI/shared-components/bootstrapper.ts +0 -18
- package/src/UI/shared-components/index.ts +0 -1
- package/src/UI/shared-components/primaria-character-limit-badge/primaria-character-limit-badge.ts +0 -27
- package/src/UI/shared-components/primaria-character-limit-badge/styles.css +0 -8
- package/src/UI/shared-components/primaria-content-switcher/primaria-content-switcher.ts +0 -78
- package/src/UI/shared-components/primaria-nav-item/primaria-nav-item.ts +0 -71
- package/src/UI/shared-components/primaria-nav-item/styles.css +0 -25
- package/src/UI/shared-components/primaria-nav-item/template.ts +0 -27
- package/src/UI/shared-components/primaria-nav-tree-menu/primaria-nav-tree-menu.ts +0 -41
- package/src/UI/shared-components/primaria-nav-tree-menu/styles.css +0 -11
- package/src/UI/shared-components/primaria-nav-tree-menu/template.ts +0 -46
- package/src/UI/shared-components/primaria-region/index.ts +0 -1
- package/src/UI/shared-components/primaria-region/primaria-region.ts +0 -199
- package/src/UI/shared-components/primaria-text-editor/primaria-rich-text-editor.ts +0 -261
- package/src/UI/shared-components/primaria-text-editor/styles.css +0 -966
- package/src/UI/shared-components/primaria-text-editor/template.ts +0 -8
- package/src/UI/shared-components/primaria-text-editor/utils.ts +0 -39
- package/src/UI/shared-components/quick-action-item/quick-action-item.ts +0 -21
- package/src/UI/shared-components/quick-action-item/template.ts +0 -8
- package/src/UI/shared-components/typings.ts +0 -19
- package/src/api/activity-monitor/activity-monitor.test.ts +0 -67
- package/src/api/activity-monitor/activity-monitor.ts +0 -26
- package/src/api/api.test.ts +0 -37
- package/src/api/api.ts +0 -119
- package/src/api/broker/broker-events.ts +0 -39
- package/src/api/broker/broker-requests.ts +0 -20
- package/src/api/broker/factory.test.ts +0 -378
- package/src/api/broker/factory.ts +0 -151
- package/src/api/broker/primaria-broker.ts +0 -20
- package/src/api/context-manager/context-manager.test.ts +0 -86
- package/src/api/context-manager/context-manager.ts +0 -42
- package/src/api/ecap-event-manager/ecap-event-manager.test.ts +0 -100
- package/src/api/ecap-event-manager/ecap-event-manager.ts +0 -58
- package/src/api/ecap-event-manager/typings.ts +0 -6
- package/src/api/exit-guard-manager/exit-guard-manager.test.ts +0 -75
- package/src/api/exit-guard-manager/exit-guard-manager.ts +0 -31
- package/src/api/global-state/global-state.test.ts +0 -45
- package/src/api/global-state/global-state.ts +0 -38
- package/src/api/http-client/http-client.test.ts +0 -196
- package/src/api/http-client/http-client.ts +0 -97
- package/src/api/import-data-manager/component/component.ts +0 -29
- package/src/api/import-data-manager/component/styles.css +0 -79
- package/src/api/import-data-manager/component/template.ts +0 -49
- package/src/api/import-data-manager/import-data-manager-impl.test.ts +0 -364
- package/src/api/import-data-manager/import-data-manager-impl.ts +0 -121
- package/src/api/import-data-manager/import-data-manager.ts +0 -42
- package/src/api/import-data-manager/index.ts +0 -2
- package/src/api/interaction-service/confirmation-message.tsx +0 -5
- package/src/api/interaction-service/index.ts +0 -1
- package/src/api/interaction-service/interaction-service-impl.tsx +0 -260
- package/src/api/interaction-service/interaction-service.ts +0 -52
- package/src/api/interaction-service/modal-styles.css +0 -97
- package/src/api/localization/localization.test.ts +0 -61
- package/src/api/localization/localization.ts +0 -58
- package/src/api/notification-service/notification-service-impl.test.ts +0 -84
- package/src/api/notification-service/notification-service.ts +0 -6
- package/src/api/notification-service/notification.service-impl.ts +0 -67
- package/src/api/pdf-viewer-manager/constants.ts +0 -1
- package/src/api/pdf-viewer-manager/events.ts +0 -5
- package/src/api/pdf-viewer-manager/handle-views.ts +0 -32
- package/src/api/pdf-viewer-manager/pdf-viewer-manager.test.ts +0 -126
- package/src/api/pdf-viewer-manager/pdf-viewer-manager.ts +0 -96
- package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/pdf-selector.ts +0 -39
- package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/styles.css +0 -45
- package/src/api/pdf-viewer-manager/pdf-visor/pdf-selector/template.ts +0 -32
- package/src/api/pdf-viewer-manager/pdf-visor/pdf-visor.ts +0 -122
- package/src/api/pdf-viewer-manager/pdf-visor/styles.css +0 -29
- package/src/api/pdf-viewer-manager/pdf-visor/utils.ts +0 -16
- package/src/api/quick-action-busy-manager/quick-action-busy-manager.test.ts +0 -61
- package/src/api/quick-action-busy-manager/quick-action-busy-manager.ts +0 -45
- package/src/api/region-manager/region-manager.test.ts +0 -239
- package/src/api/region-manager/region-manager.ts +0 -263
- package/src/api/region-manager/regions.ts +0 -30
- package/src/api/region-manager/remove-view-idempotency.test.ts +0 -98
- package/src/api/session-refresh-timer/session-refresh-timer.test.ts +0 -102
- package/src/api/session-refresh-timer/session-refresh-timer.ts +0 -75
- package/src/api/token-manager/token-manager.test.ts +0 -146
- package/src/api/token-manager/token-manager.ts +0 -70
- package/src/api/user-manager/user-manager.ts +0 -79
- package/src/bootstrapper.ts +0 -41
- package/src/constants.ts +0 -1
- package/src/disposer.ts +0 -19
- package/src/features/bootstrapper.ts +0 -21
- package/src/features/exit/bootstrapper.ts +0 -17
- package/src/features/exit/handler.test.ts +0 -187
- package/src/features/exit/handler.ts +0 -58
- package/src/features/exit/request.ts +0 -10
- package/src/features/get-patient-cip/action.ts +0 -5
- package/src/features/get-user-info/backend-adapter.ts +0 -48
- package/src/features/get-user-info/bootstrapper.ts +0 -20
- package/src/features/get-user-info/handler.test.ts +0 -66
- package/src/features/get-user-info/handler.ts +0 -23
- package/src/features/get-user-info/model.ts +0 -10
- package/src/features/get-user-info/pds-token.ts +0 -28
- package/src/features/get-user-info/request.ts +0 -4
- package/src/features/get-visi-id/action.ts +0 -11
- package/src/features/navigate-to-ecap/navigate-to-ecap.ts +0 -21
- package/src/features/utils.ts +0 -27
- package/src/handle-plugins.ts +0 -82
- package/src/index.ts +0 -101
- package/src/infrastructure/ioc/container.ts +0 -14
- package/src/infrastructure/ioc/types.ts +0 -5
- package/src/locales.ts +0 -70
- package/src/types/custom.d.ts +0 -30
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { PrimariaNotificationService } from "./notification-service";
|
|
2
|
-
|
|
3
|
-
// Workaround DSS V3: dss-toast-manager shows again a toast that is on its way out whenever another one closes.
|
|
4
|
-
// The toasts go in an own container, without the manager.
|
|
5
|
-
const CONTAINER_ID = "primaria-toast-container";
|
|
6
|
-
|
|
7
|
-
export class PrimariaNotificationServiceImpl extends PrimariaNotificationService {
|
|
8
|
-
private getOrCreateContainer(): HTMLElement {
|
|
9
|
-
let container = document.getElementById(CONTAINER_ID);
|
|
10
|
-
if (!container) {
|
|
11
|
-
container = document.createElement("div");
|
|
12
|
-
container.id = CONTAINER_ID;
|
|
13
|
-
container.style.cssText =
|
|
14
|
-
"position:fixed;bottom:var(--dss-spacing-xxs,8px);left:var(--dss-spacing-xxs,8px);display:flex;flex-direction:column-reverse;gap:var(--dss-spacing-xs,4px);z-index:999;pointer-events:none;";
|
|
15
|
-
document.body.appendChild(container);
|
|
16
|
-
}
|
|
17
|
-
return container;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private removeContainerIfEmpty(container: HTMLElement): void {
|
|
21
|
-
if (container.childElementCount === 0) {
|
|
22
|
-
container.remove();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private notify(message: string, state: "info" | "warning" | "error" | "success", duration = 5000): void {
|
|
27
|
-
const container = this.getOrCreateContainer();
|
|
28
|
-
|
|
29
|
-
const toast = document.createElement("dss-toast");
|
|
30
|
-
toast.setAttribute("isshow", "true");
|
|
31
|
-
toast.setAttribute("state", state);
|
|
32
|
-
toast.setAttribute("position", "bottom-left");
|
|
33
|
-
toast.setAttribute("text", message);
|
|
34
|
-
toast.setAttribute("hasicon", "true");
|
|
35
|
-
toast.setAttribute("duration", duration.toString());
|
|
36
|
-
toast.style.position = "relative";
|
|
37
|
-
toast.style.bottom = "auto";
|
|
38
|
-
toast.style.left = "auto";
|
|
39
|
-
toast.style.pointerEvents = "auto";
|
|
40
|
-
|
|
41
|
-
container.appendChild(toast);
|
|
42
|
-
|
|
43
|
-
setTimeout(() => {
|
|
44
|
-
toast.setAttribute("isshow", "false");
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
toast.remove();
|
|
47
|
-
this.removeContainerIfEmpty(container);
|
|
48
|
-
}, 300);
|
|
49
|
-
}, duration);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
info(message: string, duration?: number): void {
|
|
53
|
-
this.notify(message, "info", duration);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
warning(message: string, duration?: number): void {
|
|
57
|
-
this.notify(message, "warning", duration);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
error(message: string, duration?: number): void {
|
|
61
|
-
this.notify(message, "error", duration);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
success(message: string, duration?: number): void {
|
|
65
|
-
this.notify(message, "success", duration);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const pdfViewerId = "pdf-viewer";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { pdfViewerId } from "./constants";
|
|
2
|
-
import { translate } from "../../locales";
|
|
3
|
-
import { PrimariaNavItem } from "../../UI/shared-components/primaria-nav-item/primaria-nav-item";
|
|
4
|
-
import { shellApi } from "../api";
|
|
5
|
-
import { PdfVisor } from "./pdf-visor/pdf-visor";
|
|
6
|
-
|
|
7
|
-
export const registerPdfViewerNavItem = () => {
|
|
8
|
-
shellApi.regionManager.registerView(shellApi.regionManager.regions.shell.navigationMenu, {
|
|
9
|
-
id: pdfViewerId,
|
|
10
|
-
sortHint: "0110",
|
|
11
|
-
factory: () => {
|
|
12
|
-
const menuItem = new PrimariaNavItem({
|
|
13
|
-
icon: "picture_as_pdf",
|
|
14
|
-
label: translate("pdfManager.navButtonLabel"),
|
|
15
|
-
callbackFn: () => {
|
|
16
|
-
shellApi.regionManager.activateMainView(pdfViewerId);
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
return Promise.resolve(menuItem);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const registerPDFVisorMainView = () => {
|
|
25
|
-
shellApi.regionManager.registerMainView({
|
|
26
|
-
id: pdfViewerId,
|
|
27
|
-
factory: () => {
|
|
28
|
-
const mainItem = new PdfVisor();
|
|
29
|
-
return Promise.resolve(mainItem as unknown as HTMLElement);
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { createPdfViewerManager } from "./pdf-viewer-manager";
|
|
3
|
-
import { pdfViwerEvents } from "./events";
|
|
4
|
-
import { registerPdfViewerNavItem } from "./handle-views";
|
|
5
|
-
|
|
6
|
-
vi.mock("@primaria/plugins-core", () => ({
|
|
7
|
-
generateId: () => "generated-id",
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
vi.mock("./handle-views", () => ({
|
|
11
|
-
registerPdfViewerNavItem: vi.fn(),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
vi.mock("../../locales", () => ({
|
|
15
|
-
translate: (key: string) => key,
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
describe("PdfViewerManager", () => {
|
|
19
|
-
let manager: ReturnType<typeof createPdfViewerManager>;
|
|
20
|
-
let broker: any;
|
|
21
|
-
let notificationService: any;
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
broker = {
|
|
25
|
-
publish: vi.fn(),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
notificationService = {
|
|
29
|
-
error: vi.fn(),
|
|
30
|
-
warning: vi.fn(),
|
|
31
|
-
success: vi.fn(),
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
vi.clearAllMocks();
|
|
35
|
-
|
|
36
|
-
manager = createPdfViewerManager(broker, notificationService);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should show error if neither url nor b64 is provided", () => {
|
|
40
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00" });
|
|
41
|
-
expect(notificationService.error).toHaveBeenCalledWith("pdfManager.missingData");
|
|
42
|
-
expect(manager.getPdfs()).toHaveLength(0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should show error if both url and b64 are provided", () => {
|
|
46
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "url", b64: "b64" });
|
|
47
|
-
expect(notificationService.error).toHaveBeenCalledWith("pdfManager.duplicatedSource");
|
|
48
|
-
expect(manager.getPdfs()).toHaveLength(0);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("should add a valid pdf and publish event", () => {
|
|
52
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "https://test.com/doc1.pdf" });
|
|
53
|
-
|
|
54
|
-
expect(manager.getPdfs()).toHaveLength(1);
|
|
55
|
-
expect(broker.publish).toHaveBeenCalledWith(pdfViwerEvents.added, {
|
|
56
|
-
id: "doc-1",
|
|
57
|
-
pdfName: "Doc1",
|
|
58
|
-
data: { id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "https://test.com/doc1.pdf" },
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should show success notification when adding a valid pdf", () => {
|
|
63
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "https://test.com/doc1.pdf" });
|
|
64
|
-
|
|
65
|
-
expect(notificationService.success).toHaveBeenCalledWith("pdfManager.tooltipMessage");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("should warn if pdf with same name already exists", () => {
|
|
69
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", b64: "xxx" });
|
|
70
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", b64: "xxx" });
|
|
71
|
-
|
|
72
|
-
expect(notificationService.warning).toHaveBeenCalledWith("pdfManager.alreadyUploaded");
|
|
73
|
-
expect(manager.getPdfs()).toHaveLength(1); // solo el primero
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("should not show success notification when pdf with same name already exists", () => {
|
|
77
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", b64: "xxx" });
|
|
78
|
-
vi.clearAllMocks();
|
|
79
|
-
|
|
80
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", b64: "xxx" });
|
|
81
|
-
|
|
82
|
-
expect(notificationService.warning).toHaveBeenCalledWith("pdfManager.alreadyUploaded");
|
|
83
|
-
expect(notificationService.success).not.toHaveBeenCalled();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should not show success notification when pdf data is invalid", () => {
|
|
87
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00" });
|
|
88
|
-
|
|
89
|
-
expect(notificationService.error).toHaveBeenCalledWith("pdfManager.missingData");
|
|
90
|
-
expect(notificationService.success).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should not call registerNavButton when adding PDFs", () => {
|
|
94
|
-
// registerPdfViewerNavItem is now called from UI/internal-views, not from the manager
|
|
95
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "u" });
|
|
96
|
-
manager.add({ id: "doc-2", name: "Doc2", date: "2024-01-15 - 10:00", url: "u2" });
|
|
97
|
-
|
|
98
|
-
expect(registerPdfViewerNavItem).not.toHaveBeenCalled();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should delete a pdf and publish deletion event", () => {
|
|
102
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "u" });
|
|
103
|
-
const pdfs = manager.getPdfs();
|
|
104
|
-
expect(pdfs.length).toBeGreaterThan(0);
|
|
105
|
-
const id = pdfs[0]!.id;
|
|
106
|
-
|
|
107
|
-
manager.delete(id);
|
|
108
|
-
|
|
109
|
-
expect(manager.getPdfs()).toHaveLength(0);
|
|
110
|
-
expect(broker.publish).toHaveBeenCalledWith(pdfViwerEvents.deleted, { id });
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should clear activePdf if deleted", () => {
|
|
114
|
-
manager.add({ id: "doc-1", name: "Doc1", date: "2024-01-15 - 10:00", url: "u" });
|
|
115
|
-
const pdfs = manager.getPdfs();
|
|
116
|
-
expect(pdfs.length).toBeGreaterThan(0);
|
|
117
|
-
const id = pdfs[0]!.id;
|
|
118
|
-
|
|
119
|
-
// simula que esté activo
|
|
120
|
-
(manager as any).activePdf = { id } as any;
|
|
121
|
-
|
|
122
|
-
manager.delete(id);
|
|
123
|
-
|
|
124
|
-
expect((manager as any).activePdf).toBeNull();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { customElement } from "lit/decorators.js";
|
|
2
|
-
import { translate } from "../../locales";
|
|
3
|
-
import { PrimariaBroker } from "../broker/primaria-broker";
|
|
4
|
-
import { PrimariaNotificationService } from "../notification-service/notification-service";
|
|
5
|
-
import { pdfViwerEvents } from "./events";
|
|
6
|
-
import { PdfSelector } from "./pdf-visor/pdf-selector/pdf-selector";
|
|
7
|
-
import { PdfVisor } from "./pdf-visor/pdf-visor";
|
|
8
|
-
import { pdfViewerId } from "./constants";
|
|
9
|
-
|
|
10
|
-
export interface PdfData {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
date: string;
|
|
14
|
-
url?: string;
|
|
15
|
-
b64?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface IPdfDocument {
|
|
19
|
-
id: string;
|
|
20
|
-
pdfName: string;
|
|
21
|
-
data: PdfData;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface PdfViewerOptions {
|
|
25
|
-
autoNavigate?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class PdfViewerManager {
|
|
29
|
-
constructor(
|
|
30
|
-
private broker: PrimariaBroker,
|
|
31
|
-
private notificationService: PrimariaNotificationService,
|
|
32
|
-
) {
|
|
33
|
-
if (!customElements.get("pdf-visor")) {
|
|
34
|
-
customElement("pdf-visor")(PdfVisor);
|
|
35
|
-
}
|
|
36
|
-
if (!customElements.get("pdf-selector")) {
|
|
37
|
-
customElement("pdf-selector")(PdfSelector);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private pdfs: IPdfDocument[] = [];
|
|
42
|
-
private activePdf: IPdfDocument | null = null;
|
|
43
|
-
|
|
44
|
-
add(data: PdfData, options?: PdfViewerOptions) {
|
|
45
|
-
const pdf: IPdfDocument = {
|
|
46
|
-
id: data.id,
|
|
47
|
-
pdfName: data.name,
|
|
48
|
-
data
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
if (!data.url && !data.b64) {
|
|
52
|
-
this.notificationService.error(translate("pdfManager.missingData"));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (data.url && data.b64) {
|
|
56
|
-
this.notificationService.error(translate("pdfManager.duplicatedSource"));
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (this.pdfs.some((p) => p.id === pdf.id)) {
|
|
60
|
-
this.notificationService.warning(translate("pdfManager.alreadyUploaded"));
|
|
61
|
-
} else {
|
|
62
|
-
this.pdfs.push(pdf as IPdfDocument);
|
|
63
|
-
this.broker.publish(pdfViwerEvents.added, pdf);
|
|
64
|
-
|
|
65
|
-
if (options?.autoNavigate) {
|
|
66
|
-
// Navigate automatically to PDF viewer
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
import("../api").then(({ shellApi }) => {
|
|
69
|
-
shellApi.regionManager.activateMainView(pdfViewerId);
|
|
70
|
-
});
|
|
71
|
-
}, 150);
|
|
72
|
-
} else {
|
|
73
|
-
this.notificationService.success(translate("pdfManager.tooltipMessage"));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return pdf;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
delete(pdfId: string) {
|
|
81
|
-
this.pdfs = this.pdfs.filter((pdf) => pdf.id !== pdfId);
|
|
82
|
-
|
|
83
|
-
if (this.activePdf?.id === pdfId) {
|
|
84
|
-
this.activePdf = null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.broker.publish(pdfViwerEvents.deleted, { id: pdfId });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getPdfs(): IPdfDocument[] {
|
|
91
|
-
return this.pdfs;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export const createPdfViewerManager = (broker: PrimariaBroker, notificationService: PrimariaNotificationService) =>
|
|
96
|
-
new PdfViewerManager(broker, notificationService);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { LitElement, css, unsafeCSS } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
import { IPdfDocument } from "../../../../../src/api/pdf-viewer-manager/pdf-viewer-manager";
|
|
4
|
-
import { createUrlFromBase64 } from "../utils";
|
|
5
|
-
import styles from "./styles.css?inline";
|
|
6
|
-
import { template } from "./template";
|
|
7
|
-
|
|
8
|
-
export class PdfSelector extends LitElement {
|
|
9
|
-
render() {
|
|
10
|
-
return template(this);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static styles = css`
|
|
14
|
-
${unsafeCSS(styles)}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
@property({ type: Array })
|
|
18
|
-
pdfList: IPdfDocument[];
|
|
19
|
-
|
|
20
|
-
@property({ type: Array })
|
|
21
|
-
activePdfs: IPdfDocument[] = [];
|
|
22
|
-
|
|
23
|
-
removePdf(id: string) {
|
|
24
|
-
this.dispatchEvent(
|
|
25
|
-
new CustomEvent("pdf-removed", { detail: id, bubbles: true, composed: true }),
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
setActivePdf(id: string) {
|
|
30
|
-
this.dispatchEvent(
|
|
31
|
-
new CustomEvent("active-pdf-changed", { detail: id, bubbles: true, composed: true }),
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
openInNewWindow(pdf: IPdfDocument) {
|
|
36
|
-
const url = pdf.data.url ? pdf.data.url : createUrlFromBase64(pdf.data.b64 as string);
|
|
37
|
-
url && window.open(url);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
width: 250px;
|
|
3
|
-
gap: 8px
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.pdf-item{
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: flex-start;
|
|
9
|
-
padding: 8px;
|
|
10
|
-
gap:8px;
|
|
11
|
-
color:black;
|
|
12
|
-
border-bottom: 1px solid var(--color-neutral-100);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.container{
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
flex: 1;
|
|
19
|
-
position: relative;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.close-button{
|
|
23
|
-
position: absolute;
|
|
24
|
-
top: 0;
|
|
25
|
-
right: 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.data{
|
|
29
|
-
display: flex;
|
|
30
|
-
flex-direction: column;
|
|
31
|
-
gap: 4px;
|
|
32
|
-
padding-right: 40px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.pdf-name{
|
|
36
|
-
font-weight: 500;
|
|
37
|
-
font-size: 14px;
|
|
38
|
-
line-height: 1.4;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.pdf-date{
|
|
42
|
-
font-size: 12px;
|
|
43
|
-
color: var(--color-neutral-500);
|
|
44
|
-
line-height: 1.3;
|
|
45
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { html } from "lit";
|
|
2
|
-
import { PdfSelector } from "./pdf-selector";
|
|
3
|
-
import { IPdfDocument } from "primary/shell/src/api/pdf-viewer-manager/pdf-viewer-manager";
|
|
4
|
-
import { repeat } from "lit/directives/repeat.js";
|
|
5
|
-
|
|
6
|
-
export const template = (props: PdfSelector) => {
|
|
7
|
-
const pdfitem = (pdf: IPdfDocument) => {
|
|
8
|
-
return html`
|
|
9
|
-
<div class="pdf-item">
|
|
10
|
-
<dss-checkbox
|
|
11
|
-
hideLabel
|
|
12
|
-
label=${pdf.data.name || "Sense nom"}
|
|
13
|
-
?checked=${props.activePdfs.some((p) => p.id === pdf.id)}
|
|
14
|
-
@change=${() => props.setActivePdf(pdf.id)}
|
|
15
|
-
></dss-checkbox>
|
|
16
|
-
<div class="container">
|
|
17
|
-
<dss-icon-button class="close-button" size="md" variant="error" icon="close" @click=${() => props.removePdf(pdf.id)}></dss-icon-button>
|
|
18
|
-
<div class="data">
|
|
19
|
-
<div class="pdf-name">${pdf.data.name || "Sense nom"}</div>
|
|
20
|
-
<div class="pdf-date">${pdf.data.date || " "}</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
`;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
return html`
|
|
28
|
-
<div>
|
|
29
|
-
${repeat(props.pdfList, (pdf: IPdfDocument) => pdfitem(pdf))}
|
|
30
|
-
</div>
|
|
31
|
-
`;
|
|
32
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { css, html, LitElement, unsafeCSS } from "lit";
|
|
2
|
-
import { property } from "lit/decorators.js";
|
|
3
|
-
import { pdfViwerEvents } from "../../../../src/api/pdf-viewer-manager/events";
|
|
4
|
-
import { lazyInject } from "../../../../src/infrastructure/ioc/container";
|
|
5
|
-
import { TYPES } from "../../../../src/infrastructure/ioc/types";
|
|
6
|
-
import { translate } from "../../../../src/locales";
|
|
7
|
-
import { PrimariaApi } from "../../../api/api";
|
|
8
|
-
import { BrokerDisposableHandler } from "../../../api/broker/primaria-broker";
|
|
9
|
-
import { IPdfDocument } from "../../../api/pdf-viewer-manager/pdf-viewer-manager";
|
|
10
|
-
import styles from "./styles.css?inline";
|
|
11
|
-
import { createUrlFromBase64 } from "./utils";
|
|
12
|
-
|
|
13
|
-
export class PdfVisor extends LitElement {
|
|
14
|
-
static styles = css`${unsafeCSS(styles)}`;
|
|
15
|
-
|
|
16
|
-
@lazyInject(TYPES.primaryApi)
|
|
17
|
-
api: PrimariaApi;
|
|
18
|
-
|
|
19
|
-
@property({ type: Array })
|
|
20
|
-
pdfList: IPdfDocument[] = [];
|
|
21
|
-
|
|
22
|
-
@property({ type: Array })
|
|
23
|
-
activePdfs: IPdfDocument[] = [];
|
|
24
|
-
|
|
25
|
-
private subscriptions: BrokerDisposableHandler[] = [];
|
|
26
|
-
|
|
27
|
-
async connectedCallback() {
|
|
28
|
-
super.connectedCallback();
|
|
29
|
-
this._initializePdfState();
|
|
30
|
-
this._subscribeEvents();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
disconnectedCallback(): void {
|
|
34
|
-
super.disconnectedCallback();
|
|
35
|
-
this._unsubscribeEvents();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private _initializePdfState() {
|
|
39
|
-
const initialPdfs = this.api.pdfViewerManager.getPdfs?.() || [];
|
|
40
|
-
this.pdfList = [...initialPdfs];
|
|
41
|
-
|
|
42
|
-
if (initialPdfs.length === 1) {
|
|
43
|
-
this.activePdfs = [initialPdfs[0] as IPdfDocument];
|
|
44
|
-
} else if (initialPdfs.length >= 2) {
|
|
45
|
-
this.activePdfs = initialPdfs.slice(-2);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
private _getPdfSrc(pdf: IPdfDocument): string {
|
|
50
|
-
const src = pdf.data.url || (pdf.data.b64 ? createUrlFromBase64(pdf.data.b64) : "") || "";
|
|
51
|
-
if (!src) return "";
|
|
52
|
-
|
|
53
|
-
const separator = src.includes("#") ? "&" : "#";
|
|
54
|
-
return `${src}${separator}navpanes=0`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private _subscribeEvents() {
|
|
58
|
-
const subscriptions = [
|
|
59
|
-
this.api.broker.subscribe(pdfViwerEvents.added, (pdf: IPdfDocument) => this._onPdfAdded(pdf)),
|
|
60
|
-
this.api.broker.subscribe(pdfViwerEvents.deleted, ({ id }) => this._onPdfDeleted({ id })),
|
|
61
|
-
];
|
|
62
|
-
subscriptions.forEach((s) => this.subscriptions.push(s));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
private _unsubscribeEvents() {
|
|
66
|
-
this.subscriptions.forEach((s) => s.dispose());
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private _onPdfAdded(pdf: IPdfDocument) {
|
|
70
|
-
this.pdfList = [...this.pdfList, pdf];
|
|
71
|
-
this._updateActivePdfs(pdf.id);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
private _onPdfDeleted({ id }) {
|
|
75
|
-
this.pdfList = this.pdfList.filter((pdf) => pdf.id !== id);
|
|
76
|
-
this.activePdfs = this.activePdfs.filter((pdf) => pdf.id !== id);
|
|
77
|
-
this.requestUpdate();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private _removePdf(id: string) {
|
|
81
|
-
this.api.pdfViewerManager.delete(id);
|
|
82
|
-
this.activePdfs = this.activePdfs.filter((pdf) => pdf.id !== id);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private _updateActivePdfs(id: string) {
|
|
86
|
-
const isAlreadyActive = this.activePdfs.some((pdf) => pdf.id === id);
|
|
87
|
-
if (isAlreadyActive) {
|
|
88
|
-
this.activePdfs = this.activePdfs.filter((pdf) => pdf.id !== id);
|
|
89
|
-
} else {
|
|
90
|
-
const newPdf = this.pdfList.find((pdf) => pdf.id === id);
|
|
91
|
-
if (!newPdf) return;
|
|
92
|
-
if (this.activePdfs.length === 2) {
|
|
93
|
-
this.activePdfs = [this.activePdfs[1] as IPdfDocument, newPdf];
|
|
94
|
-
} else {
|
|
95
|
-
this.activePdfs = [...this.activePdfs, newPdf];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
this.requestUpdate();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
render() {
|
|
102
|
-
return html`
|
|
103
|
-
<div class="pdf-container">
|
|
104
|
-
${
|
|
105
|
-
this.activePdfs.length > 0
|
|
106
|
-
? this.activePdfs.map((pdf) => html`<iframe height="100%" src=${this._getPdfSrc(pdf)} frameborder="0"></iframe>`)
|
|
107
|
-
: html`
|
|
108
|
-
<div class="no-pdf">
|
|
109
|
-
<p>${translate("pdfVisor.noPdfSelected")}</p>
|
|
110
|
-
</div>
|
|
111
|
-
`
|
|
112
|
-
}
|
|
113
|
-
</div>
|
|
114
|
-
<pdf-selector
|
|
115
|
-
.pdfList=${this.pdfList}
|
|
116
|
-
.activePdfs=${this.activePdfs}
|
|
117
|
-
@pdf-removed=${(e: CustomEvent) => this._removePdf(e.detail)}
|
|
118
|
-
@active-pdf-changed=${(e: CustomEvent) => this._updateActivePdfs(e.detail)}
|
|
119
|
-
></pdf-selector>
|
|
120
|
-
`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
min-height: 1px;
|
|
3
|
-
height: 100%;
|
|
4
|
-
width: 100%;
|
|
5
|
-
display: flex;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
iframe {
|
|
9
|
-
border: none;
|
|
10
|
-
flex:1;
|
|
11
|
-
height: 100%;
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.pdf-container {
|
|
16
|
-
display: flex;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
align-items: center;
|
|
19
|
-
height: 100%;
|
|
20
|
-
flex: 1;
|
|
21
|
-
border: 1px solid #ccc;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.no-pdf {
|
|
25
|
-
text-align: center;
|
|
26
|
-
color: #666;
|
|
27
|
-
font-size: 1.2rem;
|
|
28
|
-
font-weight: bold;
|
|
29
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
function base64ToBlob(base64, type = "application/octet-stream") {
|
|
2
|
-
const binStr = window.atob(base64);
|
|
3
|
-
const len = binStr.length;
|
|
4
|
-
const arr = new Uint8Array(len);
|
|
5
|
-
for (let i = 0; i < len; i++) {
|
|
6
|
-
arr[i] = binStr.charCodeAt(i);
|
|
7
|
-
}
|
|
8
|
-
return new Blob([arr], { type: type });
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const createUrlFromBase64 = (b64: string, type?: string) => {
|
|
12
|
-
if (b64) {
|
|
13
|
-
const blob = base64ToBlob(b64, type || "application/pdf");
|
|
14
|
-
return URL.createObjectURL(blob);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { QuickActionBusyManagerImpl } from "./quick-action-busy-manager";
|
|
3
|
-
import { BROKER_EVENTS } from "../broker/broker-events";
|
|
4
|
-
|
|
5
|
-
describe("QuickActionBusyManagerImpl", () => {
|
|
6
|
-
let brokerMock: any;
|
|
7
|
-
let manager: QuickActionBusyManagerImpl;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
brokerMock = {
|
|
11
|
-
publish: vi.fn(),
|
|
12
|
-
};
|
|
13
|
-
manager = new QuickActionBusyManagerImpl(brokerMock);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
describe("addTask", () => {
|
|
17
|
-
it("should add a task and emit event", () => {
|
|
18
|
-
const task = { taskId: "qa1" };
|
|
19
|
-
manager.addTask(task);
|
|
20
|
-
expect(brokerMock.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.quickActionBusyChanged, {
|
|
21
|
-
busy: true,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should not add duplicate task with same taskId", () => {
|
|
26
|
-
const task = { taskId: "qa1" };
|
|
27
|
-
manager.addTask(task);
|
|
28
|
-
manager.addTask(task);
|
|
29
|
-
|
|
30
|
-
// Should only emit once for the first addition
|
|
31
|
-
expect(brokerMock.publish).toHaveBeenCalledTimes(1);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("removeTask", () => {
|
|
36
|
-
it("should remove a task and emit event", () => {
|
|
37
|
-
const task = { taskId: "qa1" };
|
|
38
|
-
manager.addTask(task);
|
|
39
|
-
manager.removeTask("qa1");
|
|
40
|
-
expect(brokerMock.publish).toHaveBeenCalledWith(BROKER_EVENTS.shell.quickActionBusyChanged, {
|
|
41
|
-
busy: false,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should do nothing and not emit event if task does not exist", () => {
|
|
46
|
-
manager.removeTask("non-existent");
|
|
47
|
-
expect(brokerMock.publish).not.toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe("isBusy", () => {
|
|
52
|
-
it("should return false when no tasks exist", () => {
|
|
53
|
-
expect(manager.isBusy()).toBe(false);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("should return true when tasks exist", () => {
|
|
57
|
-
manager.addTask({ taskId: "qa1" });
|
|
58
|
-
expect(manager.isBusy()).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|