@cc-openmrs/cc-esm-active-prescriptions 1.0.30 → 1.0.33

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/477.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_cc_openmrs_cc_esm_active_prescriptions=globalThis.webpackChunk_cc_openmrs_cc_esm_active_prescriptions||[]).push([[477],{4477(n,t,e){e.r(t),e.d(t,{default:()=>p});var c=e(6072),a=e(4504),o=e(4424),i=e(2076),r="active-prescriptions-workspace",s="[active-prescriptions-action-button]";const p=function(n){var t=n.patientUuid,e=n.closeOverflowMenu,p=(0,(0,i.useTranslation)().t)("prescriptionsActionButton","Active prescriptions"),l=(0,c.useCallback)(function(){var n=window.location.pathname,c=function(n){return/\/patient\/[^/]+\/chart(?:\/|$)/.test(n)}(n);if(console.info("".concat(s," click"),{patientUuid:t,hasCloseOverflowMenu:Boolean(e),pathname:n,inPatientChart:c}),t){try{if(c)console.info("".concat(s," launching workspace in current context"),{workspaceName:r,patientUuid:t}),(0,o.launchWorkspace)(r,{patientUuid:t});else{var a="".concat(window.getOpenmrsSpaBase(),"patient/").concat(t,"/chart"),i="patient/".concat(t);console.info("".concat(s," navigating to patient chart and launching workspace"),{workspaceName:r,patientUuid:t,targetUrl:a,contextKey:i}),(0,o.navigateAndLaunchWorkspace)({targetUrl:a,contextKey:i,workspaceName:r,additionalProps:{patientUuid:t}})}console.info("".concat(s," workspace launch dispatched"))}catch(n){return void console.error("".concat(s," workspace launch failed"),n)}e&&(console.info("".concat(s," closing overflow menu")),e())}else console.warn("".concat(s," patientUuid missing; workspace launch aborted"))},[t,e]);return c.createElement(a.XSD,{itemText:p,onClick:l})}}}]);
1
+ "use strict";(globalThis.webpackChunk_cc_openmrs_cc_esm_active_prescriptions=globalThis.webpackChunk_cc_openmrs_cc_esm_active_prescriptions||[]).push([[477],{4477(c,e,o){o.r(e),o.d(e,{default:()=>p});var n=o(6072),t=o(4504),a=o(4424),i=o(2076),s="active-prescriptions-workspace",r="[active-prescriptions-action-button]";const p=function(c){var e=c.patientUuid,o=c.closeMenu,p=(0,(0,i.useTranslation)().t)("prescriptionsActionButton","Active prescriptions"),l=(0,n.useCallback)(function(){if(console.info("".concat(r," click"),{patientUuid:e,hasCloseMenu:Boolean(o),workspaceName:s}),e){try{console.info("".concat(r," launching workspace (v1)"),{workspaceName:s,patientUuid:e}),(0,a.launchWorkspace)(s,{patientUuid:e,openedFrom:"patient-actions-slot"}),console.info("".concat(r," workspace launch dispatched"))}catch(c){return void console.error("".concat(r," workspace launch failed"),c)}o&&(console.info("".concat(r," closing overflow menu")),o())}else console.warn("".concat(r," patientUuid missing; workspace launch aborted"))},[e,o]);return n.createElement(t.XSD,{itemText:p,onClick:l})}}}]);
@@ -337,9 +337,9 @@
337
337
  "initial": false,
338
338
  "entry": false,
339
339
  "recorded": false,
340
- "size": 3099,
340
+ "size": 2105,
341
341
  "sizes": {
342
- "javascript": 3099
342
+ "javascript": 2105
343
343
  },
344
344
  "names": [],
345
345
  "idHints": [],
@@ -353,7 +353,7 @@
353
353
  "auxiliaryFiles": [
354
354
  "477.js.map"
355
355
  ],
356
- "hash": "d03147dd6335beac",
356
+ "hash": "5fe86c5947905ede",
357
357
  "childrenByOrder": {}
358
358
  },
359
359
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"extensions":[{"name":"Red box","component":"redBox","slot":"Boxes"},{"name":"Blue box","component":"blueBox","slot":"Boxes"},{"name":"Brand box","component":"brandBox","slot":"Boxes"},{"name":"prescriptions-action","component":"prescriptionsActionButton","slot":"patient-actions-slot","order":50}],"pages":[{"component":"root","route":"root"}],"workspaces":[{"name":"active-prescriptions-workspace","title":"Active prescriptions","type":"active-prescriptions","component":"root","canHide":true,"width":"wider"}],"version":"1.0.30"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":">=2.2.0"},"extensions":[{"name":"Red box","component":"redBox","slot":"Boxes"},{"name":"Blue box","component":"blueBox","slot":"Boxes"},{"name":"Brand box","component":"brandBox","slot":"Boxes"},{"name":"prescriptions-action","component":"prescriptionsActionButton","slot":"patient-actions-slot","order":50,"meta":{"fullWidth":false}}],"pages":[{"component":"root","route":"root"}],"workspaces":[{"name":"active-prescriptions-workspace","title":"Active prescriptions","type":"active-prescriptions","component":"root","canHide":true,"width":"wider"}],"version":"1.0.33"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-openmrs/cc-esm-active-prescriptions",
3
- "version": "1.0.30",
3
+ "version": "1.0.33",
4
4
  "license": "MPL-2.0",
5
5
  "description": "An OpenMRS seed application for building microfrontends",
6
6
  "browser": "dist/openmrs-esm-template-app.js",
@@ -1,34 +1,33 @@
1
1
  import React, { useCallback } from 'react';
2
2
  import { OverflowMenuItem } from '@carbon/react';
3
- import { launchWorkspace, navigateAndLaunchWorkspace } from '@openmrs/esm-framework';
3
+ import { launchWorkspace } from '@openmrs/esm-framework';
4
4
  import { useTranslation } from 'react-i18next';
5
5
 
6
6
  interface PrescriptionsActionButtonProps {
7
+ /**
8
+ * In patient-chart actions, this is typically provided by the slot context.
9
+ */
7
10
  patientUuid?: string;
8
- closeOverflowMenu?: () => void; // Importante para fechar o menu
11
+
12
+ /**
13
+ * The patient actions overflow menu commonly provides this callback as `closeMenu`.
14
+ * (Using `closeMenu` aligns with core implementations.)
15
+ */
16
+ closeMenu?: () => void;
9
17
  }
10
18
 
11
19
  const workspaceName = 'active-prescriptions-workspace';
12
20
  const logPrefix = '[active-prescriptions-action-button]';
13
21
 
14
- const isPatientChartPath = (pathname: string) => /\/patient\/[^/]+\/chart(?:\/|$)/.test(pathname);
15
-
16
- const PrescriptionsActionButton: React.FC<PrescriptionsActionButtonProps> = ({
17
- patientUuid,
18
- closeOverflowMenu,
19
- }) => {
22
+ const PrescriptionsActionButton: React.FC<PrescriptionsActionButtonProps> = ({ patientUuid, closeMenu }) => {
20
23
  const { t } = useTranslation();
21
24
  const label = t('prescriptionsActionButton', 'Active prescriptions');
22
25
 
23
26
  const handleClick = useCallback(() => {
24
- const pathname = window.location.pathname;
25
- const inPatientChart = isPatientChartPath(pathname);
26
-
27
27
  console.info(`${logPrefix} click`, {
28
28
  patientUuid,
29
- hasCloseOverflowMenu: Boolean(closeOverflowMenu),
30
- pathname,
31
- inPatientChart,
29
+ hasCloseMenu: Boolean(closeMenu),
30
+ workspaceName,
32
31
  });
33
32
 
34
33
  if (!patientUuid) {
@@ -37,43 +36,27 @@ const PrescriptionsActionButton: React.FC<PrescriptionsActionButtonProps> = ({
37
36
  }
38
37
 
39
38
  try {
40
- if (inPatientChart) {
41
- console.info(`${logPrefix} launching workspace in current context`, { workspaceName, patientUuid });
42
- launchWorkspace(workspaceName, {
43
- patientUuid,
44
- });
45
- } else {
46
- const targetUrl = `${window.getOpenmrsSpaBase()}patient/${patientUuid}/chart`;
47
- const contextKey = `patient/${patientUuid}`;
48
-
49
- console.info(`${logPrefix} navigating to patient chart and launching workspace`, {
50
- workspaceName,
51
- patientUuid,
52
- targetUrl,
53
- contextKey,
54
- });
39
+ // IMPORTANT:
40
+ // - Your current @openmrs/esm-framework does NOT export launchWorkspace2 (TS error).
41
+ // - So we use v1: launchWorkspace + routes.json "workspaces" (not "workspaces2").
42
+ console.info(`${logPrefix} launching workspace (v1)`, { workspaceName, patientUuid });
55
43
 
56
- navigateAndLaunchWorkspace({
57
- targetUrl,
58
- contextKey,
59
- workspaceName,
60
- additionalProps: {
61
- patientUuid,
62
- },
63
- });
64
- }
44
+ launchWorkspace(workspaceName, {
45
+ patientUuid,
46
+ openedFrom: 'patient-actions-slot',
47
+ });
65
48
 
66
49
  console.info(`${logPrefix} workspace launch dispatched`);
67
- } catch (error) {
50
+ } catch (error: any) {
68
51
  console.error(`${logPrefix} workspace launch failed`, error);
69
52
  return;
70
53
  }
71
54
 
72
- if (closeOverflowMenu) {
55
+ if (closeMenu) {
73
56
  console.info(`${logPrefix} closing overflow menu`);
74
- closeOverflowMenu();
57
+ closeMenu();
75
58
  }
76
- }, [patientUuid, closeOverflowMenu]);
59
+ }, [patientUuid, closeMenu]);
77
60
 
78
61
  return <OverflowMenuItem itemText={label} onClick={handleClick} />;
79
62
  };
package/src/routes.json CHANGED
@@ -24,7 +24,10 @@
24
24
  "name": "prescriptions-action",
25
25
  "component": "prescriptionsActionButton",
26
26
  "slot": "patient-actions-slot",
27
- "order": 50
27
+ "order": 50,
28
+ "meta": {
29
+ "fullWidth": false
30
+ }
28
31
  }
29
32
  ],
30
33
  "pages": [