Skip to content

Commit

Permalink
Merge pull request #5 from PIH/UHM-8240
Browse files Browse the repository at this point in the history
(fix) UHM-8240 make visit summary left nav always show
  • Loading branch information
chibongho authored Dec 19, 2024
2 parents 4e70519 + 83409b7 commit 90f641e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 11 additions & 2 deletions packages/esm-commons-app/src/ward-app/o2-iframe.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ interface O2IFrame {
* a list of css selectors defining elements to be made un-clickable within the iframe
*/
elementsToDisable?: string[];

/**
* JavaScript code to inject into the iframe to run
*/
customJavaScript?: string;
}

const O2IFrame: React.FC<O2IFrame> = ({ src, elementsToHide, elementsToDisable }) => {
const O2IFrame: React.FC<O2IFrame> = ({ src, elementsToHide, elementsToDisable, customJavaScript = '' }) => {
const iframeRef = useRef<HTMLIFrameElement>();
const [isIframeLoading, setIsIframeLoading] = useState(true);
const [isGoingBack, setIsGoingBack] = useState(false);
Expand All @@ -32,7 +37,7 @@ const O2IFrame: React.FC<O2IFrame> = ({ src, elementsToHide, elementsToDisable }

return `@media screen {
${toHide}
${toDisable}
${toDisable}
}`;
}, [elementsToHide, elementsToDisable]);

Expand All @@ -48,6 +53,10 @@ const O2IFrame: React.FC<O2IFrame> = ({ src, elementsToHide, elementsToDisable }
const styleTag = contentDocument.createElement('style');
styleTag.innerHTML = customCss;
contentDocument.head.appendChild(styleTag);

const scriptTag = contentDocument.createElement('script');
scriptTag.innerHTML = customJavaScript;
contentDocument.body.appendChild(scriptTag);
};

const goBack = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ const O2VisitSummaryWorkspace: React.FC<WardPatientWorkspaceProps> = ({ wardPati
toClass(MATERNAL_ADMISSION_ENCOUNTER_TYPE),
toClass(POSTPARTUM_DAILY_PROGRESS),
];
const customJavaScript = `
jQuery('#formBreadcrumb').show();
jQuery('.simple-form-ui form section').width(300);
jQuery('#nav-buttons').hide();
`;

if (patient && visit) {
const src = `${window.openmrsBase}/pihcore/visit/visit.page?patient=${patient.uuid}&visit=${visit.uuid}`;
return <O2IFrame src={src} elementsToHide={elementsToHide} />;
return <O2IFrame src={src} elementsToHide={elementsToHide} customJavaScript={customJavaScript} />;
} else {
return <div>{t('patientHasNoActiveVisit', 'Patient has no active visit')}</div>;
}
Expand Down

0 comments on commit 90f641e

Please sign in to comment.