@uxland/primary-shell 7.49.2 → 7.50.1
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/dist/{component-ftY27Sve.js → component-BI9HXATX.js} +2 -2
- package/dist/{component-ftY27Sve.js.map → component-BI9HXATX.js.map} +1 -1
- package/dist/{index-BjHmySvD.js → index-D9hfKjLi.js} +28 -5
- package/dist/index-D9hfKjLi.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/index.umd.cjs.map +1 -1
- package/dist/{plugin-DS8LOzZZ.js → plugin-BPpYe_wT.js} +183 -154
- package/dist/{plugin-DS8LOzZZ.js.map → plugin-BPpYe_wT.js.map} +1 -1
- package/dist/primary/shell/src/api/region-manager/region-manager.d.ts +6 -0
- package/dist/primary/shell/src/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/api/region-manager/region-manager.test.ts +53 -0
- package/src/api/region-manager/region-manager.ts +33 -0
- package/src/index.ts +14 -1
- package/dist/index-BjHmySvD.js.map +0 -1
|
@@ -2,6 +2,11 @@ import { HarmonixRegionManager, HarmonixViewDefinition, IRegionManager } from '@
|
|
|
2
2
|
import { PluginInfo } from '../../handle-plugins';
|
|
3
3
|
import { PrimariaBroker } from '../broker/primaria-broker';
|
|
4
4
|
import { activityHistoryRegions, administrativeManagementRegions, clinicalMonitoringRegions, shellRegions } from './regions';
|
|
5
|
+
/** Una vista de la region main, amb el plugin que l'ha registrada. */
|
|
6
|
+
export interface RegisteredMainView {
|
|
7
|
+
pluginId: string;
|
|
8
|
+
viewId: string;
|
|
9
|
+
}
|
|
5
10
|
export interface PrimariaRegionManager extends HarmonixRegionManager {
|
|
6
11
|
regions: {
|
|
7
12
|
shell: typeof shellRegions;
|
|
@@ -15,6 +20,7 @@ export interface PrimariaRegionManager extends HarmonixRegionManager {
|
|
|
15
20
|
activateMainView(viewId: string): Promise<void>;
|
|
16
21
|
activatePluginView(regionName: string, pluginId: string, viewId: string): Promise<void>;
|
|
17
22
|
getCurrentMainViewActive(): string | undefined;
|
|
23
|
+
getRegisteredMainViews(): RegisteredMainView[];
|
|
18
24
|
_removeAllViews(): Promise<void>;
|
|
19
25
|
_destroy(): Promise<void>;
|
|
20
26
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export * from './bootstrapper';
|
|
2
2
|
export * from './disposer';
|
|
3
3
|
export * from './api/region-manager/regions';
|
|
4
|
+
export type { RegisteredMainView } from './api/region-manager/region-manager';
|
|
4
5
|
export * from './handle-plugins';
|
|
5
6
|
export type { PrimariaApi } from './api/api';
|
|
6
7
|
export { PrimariaRegionHost, shellApi } from './api/api';
|
|
7
8
|
export type { TokenManager, InternalTokenManager } from './api/token-manager/token-manager';
|
|
8
9
|
export * from './api/broker/primaria-broker';
|
|
9
10
|
export type { PrimariaContextManager, EcapContext } from './api/context-manager/context-manager';
|
|
11
|
+
export type { PrimariaImportDataManager, ImportParams, ImportParamsDiagnostic, } from './api/import-data-manager/import-data-manager';
|
|
10
12
|
export * from './UI/index';
|
|
11
13
|
export { PrimariaNavItem } from './UI/shared-components/primaria-nav-item/primaria-nav-item';
|
|
12
14
|
export { QuickActionItem } from './UI/shared-components/quick-action-item/quick-action-item';
|
package/package.json
CHANGED
|
@@ -125,6 +125,59 @@ describe("RegionManagerProxy", () => {
|
|
|
125
125
|
expect(result).toBe("view1");
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
describe("getRegisteredMainViews", () => {
|
|
129
|
+
// `id: undefined` vol dir una definicio que no en declara, no una amb l'id a undefined.
|
|
130
|
+
const registeredView = (key: string, id?: string) => ({
|
|
131
|
+
key,
|
|
132
|
+
view: id === undefined ? { factory: mockView.factory } : { ...mockView, id },
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("desglossa la clau del registry en pluginId i viewId", () => {
|
|
136
|
+
regionManager.getRegisteredViews.mockReturnValue([
|
|
137
|
+
registeredView("appointments::main", "main"),
|
|
138
|
+
registeredView("activity-history::timeline", "timeline"),
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
expect(proxy.getRegisteredMainViews()).toEqual([
|
|
142
|
+
{ pluginId: "appointments", viewId: "main" },
|
|
143
|
+
{ pluginId: "activity-history", viewId: "timeline" },
|
|
144
|
+
]);
|
|
145
|
+
expect(regionManager.getRegisteredViews).toHaveBeenCalledWith(proxy.regions.shell.main);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* El registry s'omple en registrar la vista; `getRegion(main).currentViews` només té
|
|
150
|
+
* les vistes afegides a un host ja muntat, i `getRegion` retorna `undefined` mentre la
|
|
151
|
+
* regio no hi es. Per aixo el metode no ha de dependre de la regio.
|
|
152
|
+
*/
|
|
153
|
+
it("no depen que la regio main estigui muntada", () => {
|
|
154
|
+
regionManager.getRegion.mockReturnValue(undefined);
|
|
155
|
+
regionManager.getRegisteredViews.mockReturnValue([registeredView("appointments::main", "main")]);
|
|
156
|
+
|
|
157
|
+
expect(proxy.getRegisteredMainViews()).toEqual([{ pluginId: "appointments", viewId: "main" }]);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("retorna una llista buida quan no hi ha res registrat", () => {
|
|
161
|
+
regionManager.getRegisteredViews.mockReturnValue([]);
|
|
162
|
+
|
|
163
|
+
expect(proxy.getRegisteredMainViews()).toEqual([]);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Les vistes dels plugins de tercers (econsulta, allergies...) es poden registrar
|
|
167
|
+
// directament contra el regionManager, sense el prefix que hi posa aquest proxy.
|
|
168
|
+
it("deixa el pluginId buit si la clau no porta prefix de plugin", () => {
|
|
169
|
+
regionManager.getRegisteredViews.mockReturnValue([registeredView("legacy-view", "legacy-view")]);
|
|
170
|
+
|
|
171
|
+
expect(proxy.getRegisteredMainViews()).toEqual([{ pluginId: "", viewId: "legacy-view" }]);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("cau a la clau quan la definicio no declara id", () => {
|
|
175
|
+
regionManager.getRegisteredViews.mockReturnValue([registeredView("appointments::main", undefined)]);
|
|
176
|
+
|
|
177
|
+
expect(proxy.getRegisteredMainViews()).toEqual([{ pluginId: "appointments", viewId: "main" }]);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
128
181
|
it("_destroy should call regionManager.destroy", () => {
|
|
129
182
|
proxy._destroy();
|
|
130
183
|
expect(regionManager.destroy).toHaveBeenCalled();
|
|
@@ -5,6 +5,12 @@ import { BROKER_EVENTS } from "../broker/broker-events";
|
|
|
5
5
|
import { PrimariaBroker } from "../broker/primaria-broker";
|
|
6
6
|
import { activityHistoryRegions, administrativeManagementRegions, clinicalMonitoringRegions, shellRegions } from "./regions";
|
|
7
7
|
|
|
8
|
+
/** Una vista de la region main, amb el plugin que l'ha registrada. */
|
|
9
|
+
export interface RegisteredMainView {
|
|
10
|
+
pluginId: string;
|
|
11
|
+
viewId: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
export interface PrimariaRegionManager extends HarmonixRegionManager {
|
|
9
15
|
regions: {
|
|
10
16
|
shell: typeof shellRegions;
|
|
@@ -18,6 +24,7 @@ export interface PrimariaRegionManager extends HarmonixRegionManager {
|
|
|
18
24
|
activateMainView(viewId: string): Promise<void>;
|
|
19
25
|
activatePluginView(regionName: string, pluginId: string, viewId: string): Promise<void>;
|
|
20
26
|
getCurrentMainViewActive(): string | undefined;
|
|
27
|
+
getRegisteredMainViews(): RegisteredMainView[];
|
|
21
28
|
_removeAllViews(): Promise<void>;
|
|
22
29
|
_destroy(): Promise<void>;
|
|
23
30
|
}
|
|
@@ -168,6 +175,32 @@ class RegionManagerProxy implements PrimariaRegionManager {
|
|
|
168
175
|
return mainView?.id;
|
|
169
176
|
}
|
|
170
177
|
|
|
178
|
+
/**
|
|
179
|
+
* Totes les vistes registrades a la region main, amb el plugin que les ha registrat.
|
|
180
|
+
*
|
|
181
|
+
* Va pel registry del regionManager i no per `getRegion(main).currentViews`, i és a
|
|
182
|
+
* propòsit: el registry s'omple en registrar la vista, mentre que `currentViews` només
|
|
183
|
+
* té les que s'han afegit a un host de regió ja muntat —i `getRegion` retorna
|
|
184
|
+
* `undefined` si la regió encara no hi és—, així que cridar-ho des de l'`initialize()`
|
|
185
|
+
* d'un plugin donaria una llista incompleta o petaria.
|
|
186
|
+
*
|
|
187
|
+
* Les claus del registry són `pluginId::viewId`. El `viewId` es llegeix de la
|
|
188
|
+
* definició, que és qui en manda; de la clau només se'n treu el prefix del plugin, que
|
|
189
|
+
* pot no ser-hi si la vista l'ha registrada un plugin de tercers directament contra el
|
|
190
|
+
* regionManager, sense passar per aquest proxy.
|
|
191
|
+
*/
|
|
192
|
+
getRegisteredMainViews(): RegisteredMainView[] {
|
|
193
|
+
return this.regionManager.getRegisteredViews(this.regions.shell.main).map(({ key, view }) => {
|
|
194
|
+
const separatorIndex = key.indexOf("::");
|
|
195
|
+
const hasPluginPrefix = separatorIndex !== -1;
|
|
196
|
+
|
|
197
|
+
return {
|
|
198
|
+
pluginId: hasPluginPrefix ? key.slice(0, separatorIndex) : "",
|
|
199
|
+
viewId: (view as HarmonixViewDefinition).id ?? (hasPluginPrefix ? key.slice(separatorIndex + 2) : key),
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
171
204
|
/**
|
|
172
205
|
* Activates a view if it is marked as default and the region currently has no active views.
|
|
173
206
|
*
|
package/src/index.ts
CHANGED
|
@@ -5,12 +5,15 @@ import fontsCSS from "./UI/fonts/fonts.css?inline";
|
|
|
5
5
|
// Inject CSS automatically
|
|
6
6
|
if (typeof document !== "undefined") {
|
|
7
7
|
const style = document.createElement("style");
|
|
8
|
-
style.textContent = fontsCSS
|
|
8
|
+
style.textContent = `${fontsCSS}\n${dssCSS}`;
|
|
9
9
|
document.head.appendChild(style);
|
|
10
10
|
}
|
|
11
11
|
export * from "./bootstrapper";
|
|
12
12
|
export * from "./disposer";
|
|
13
13
|
export * from "./api/region-manager/regions";
|
|
14
|
+
// Tipus de retorn de `regionManager.getRegisteredMainViews()`. El regionManager
|
|
15
|
+
// arriba als plugins tipat via `PrimariaApi`; això només és per poder-lo anomenar.
|
|
16
|
+
export type { RegisteredMainView } from "./api/region-manager/region-manager";
|
|
14
17
|
export * from "./handle-plugins";
|
|
15
18
|
// Superfície pública explícita: `primariaApiFactory`, `activityMonitor` i
|
|
16
19
|
// `sessionRefreshTimer` són singletons interns del shell i no s'exposen.
|
|
@@ -23,6 +26,16 @@ export { PrimariaRegionHost, shellApi } from "./api/api";
|
|
|
23
26
|
export type { TokenManager, InternalTokenManager } from "./api/token-manager/token-manager";
|
|
24
27
|
export * from "./api/broker/primaria-broker";
|
|
25
28
|
export type { PrimariaContextManager, EcapContext } from "./api/context-manager/context-manager";
|
|
29
|
+
// Contractes de l'importador de dades estructurades. Una iniciativa que crida
|
|
30
|
+
// `importDataManager.import(...)` necessita `ImportParams` per tipar-ho, i la que
|
|
31
|
+
// s'injecta dins del modal la rep de `getCurrentImportParams()`. La implementació
|
|
32
|
+
// (`ImportDataManagerImpl`) es queda dins: els plugins reben el mànager per la
|
|
33
|
+
// `PrimariaApi`, no l'instancien.
|
|
34
|
+
export type {
|
|
35
|
+
PrimariaImportDataManager,
|
|
36
|
+
ImportParams,
|
|
37
|
+
ImportParamsDiagnostic,
|
|
38
|
+
} from "./api/import-data-manager/import-data-manager";
|
|
26
39
|
export * from "./UI/index";
|
|
27
40
|
export { PrimariaNavItem } from "./UI/shared-components/primaria-nav-item/primaria-nav-item";
|
|
28
41
|
export { QuickActionItem } from "./UI/shared-components/quick-action-item/quick-action-item";
|