-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Relationships UI improvements #278
Changes from 7 commits
5fdeb87
6bd1e3d
50cfb55
e46c40a
ff9b9dd
e6c30a2
6647233
de8a41c
f4aaf51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,27 +17,35 @@ import { | |
} from '@carbon/react'; | ||
import { Add } from '@carbon/react/icons'; | ||
import { EmptyDataIllustration, ErrorState, CardHeader, usePaginationInfo } from '@openmrs/esm-patient-common-lib'; | ||
import { ConfigurableLink, isDesktop, navigate, useConfig, useLayoutType, usePagination } from '@openmrs/esm-framework'; | ||
import { | ||
ConfigurableLink, | ||
isDesktop, | ||
launchWorkspace, | ||
useConfig, | ||
useLayoutType, | ||
usePagination, | ||
} from '@openmrs/esm-framework'; | ||
import { useRelationships } from './relationships.resource'; | ||
import ConceptObservations from './concept-obs.component'; | ||
import type { ConfigObject } from '../config-schema'; | ||
import styles from './family-history.scss'; | ||
|
||
interface FamilyHistoryProps { | ||
encounterTypeUuid?: string; | ||
formEntrySub?: any; | ||
patientUuid: string; | ||
} | ||
|
||
const FamilyHistory: React.FC<FamilyHistoryProps> = ({ patientUuid }) => { | ||
const { t } = useTranslation(); | ||
const config = useConfig<ConfigObject>(); | ||
const { concepts, familyRelationshipsTypeList } = config; | ||
const layout = useLayoutType(); | ||
const { concepts } = config; | ||
const [pageSize, setPageSize] = useState(10); | ||
const { relationships, error, isLoading, isValidating } = useRelationships(patientUuid); | ||
const headerTitle = t('familyHistory', 'Family history'); | ||
const { results, totalPages, currentPage, goTo } = usePagination(relationships, pageSize); | ||
const familyRelationshipTypeUUIDs = new Set(familyRelationshipsTypeList.map((type) => type.uuid)); | ||
const familyRelationships = relationships.filter((r) => familyRelationshipTypeUUIDs.has(r.relationshipTypeUUID)); | ||
|
||
const headerTitle = t('familyContacts', 'Family contacts'); | ||
const { results, totalPages, currentPage, goTo } = usePagination(familyRelationships, pageSize); | ||
const { pageSizes } = usePaginationInfo(pageSize, totalPages, currentPage, results.length); | ||
|
||
const headers = [ | ||
|
@@ -68,7 +76,10 @@ const FamilyHistory: React.FC<FamilyHistoryProps> = ({ patientUuid }) => { | |
]; | ||
|
||
const handleAddHistory = () => { | ||
navigate({ to: `\${openmrsSpaBase}/patient/${patientUuid}/edit` }); | ||
launchWorkspace('family-relationship-form', { | ||
workspaceTitle: 'Family Relationship Form', | ||
rootPersonUuid: patientUuid, | ||
}); | ||
}; | ||
|
||
const tableRows = | ||
|
@@ -95,15 +106,26 @@ const FamilyHistory: React.FC<FamilyHistoryProps> = ({ patientUuid }) => { | |
}; | ||
}) ?? []; | ||
|
||
if (isLoading) { | ||
return <DataTableSkeleton rowCount={5} />; | ||
if (isLoading || isValidating) { | ||
return ( | ||
<DataTableSkeleton | ||
headers={headers} | ||
aria-label="patient bills table" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this miss placed label? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this is misplaced let me fix this. |
||
showToolbar={false} | ||
showHeader={false} | ||
rowCount={3} | ||
zebra | ||
columnCount={3} | ||
className={styles.dataTableSkeleton} | ||
/> | ||
); | ||
} | ||
|
||
if (error) { | ||
return <ErrorState headerTitle={headerTitle} error={error} />; | ||
} | ||
|
||
if (relationships.length === 0) { | ||
if (familyRelationships.length === 0) { | ||
return ( | ||
<Layer> | ||
<Tile className={styles.tile}> | ||
|
@@ -113,7 +135,7 @@ const FamilyHistory: React.FC<FamilyHistoryProps> = ({ patientUuid }) => { | |
<EmptyDataIllustration /> | ||
<p className={styles.content}>There is no family history data to display for this patient.</p> | ||
<Button onClick={handleAddHistory} renderIcon={Add} kind="ghost"> | ||
{t('recordHistory', 'Record History')} | ||
{t('addRelationship', 'Add relationship')} | ||
</Button> | ||
</Tile> | ||
</Layer> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
@use '@carbon/styles/scss/spacing'; | ||
@use '@carbon/styles/scss/type'; | ||
@use '@carbon/layout'; | ||
@import '~@openmrs/esm-styleguide/src/vars'; | ||
amosmachora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.heading { | ||
@include type.type-style('heading-compact-01'); | ||
margin: spacing.$spacing-05 0 spacing.$spacing-05; | ||
} | ||
|
||
.warningContainer { | ||
background-color: $carbon--red-50; | ||
padding: spacing.$spacing-04; | ||
margin: spacing.$spacing-03 0 spacing.$spacing-03; | ||
display: flex; | ||
justify-content: space-between; | ||
.warning { | ||
@include type.type-style('heading-compact-01'); | ||
color: $ui-05; | ||
} | ||
} | ||
|
||
.datePickerInput span, | ||
.datePickerInput div, | ||
.datePickerInput input, | ||
.datePickerInput { | ||
width: 100% !important; | ||
} | ||
.form { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
padding-bottom: 20px; | ||
} | ||
|
||
.buttonSet { | ||
margin-top: auto; | ||
display: flex; | ||
} | ||
|
||
.button { | ||
height: spacing.$spacing-10; | ||
display: flex; | ||
align-content: flex-start; | ||
align-items: center; | ||
max-width: 50%; | ||
min-width: 50%; | ||
width: 50%; | ||
} | ||
|
||
.grid { | ||
Comment on lines
+35
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to localize the naming to avoid style overrides. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay got it |
||
margin: 0 spacing.$spacing-05; | ||
padding: 0rem; | ||
} | ||
.textbox { | ||
margin-bottom: spacing.$spacing-08; | ||
} | ||
|
||
.caseFormTitle { | ||
@include type.type-style('heading-02'); | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
margin: spacing.$spacing-05; | ||
margin-bottom: spacing.$spacing-07; | ||
row-gap: 1.5rem; | ||
position: relative; | ||
|
||
&::after { | ||
content: ''; | ||
display: block; | ||
width: 2rem; | ||
border-bottom: 0.375rem solid var(--brand-03); | ||
position: absolute; | ||
bottom: -0.75rem; | ||
left: 0; | ||
} | ||
|
||
& > span { | ||
@include type.type-style('body-01'); | ||
} | ||
} | ||
|
||
.sectionHeader { | ||
@include type.type-style('heading-02'); | ||
margin-top: spacing.$spacing-05; | ||
} | ||
|
||
:global(.omrs-breakpoint-lt-desktop) { | ||
.form { | ||
height: var(--tablet-workspace-window-height); | ||
} | ||
|
||
.buttonSet { | ||
padding: spacing.$spacing-06 spacing.$spacing-05; | ||
background-color: $ui-02; | ||
justify-content: flex-end; | ||
gap: spacing.$spacing-05; | ||
padding: 0; | ||
margin-top: auto; | ||
display: flex; | ||
justify-content: end; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. The config looks good