Skip to content

Commit 5a1ae43

Browse files
shreeyash07frozenhelium
authored andcommitted
Add presentation mode in local unit map
1 parent b560773 commit 5a1ae43

File tree

11 files changed

+123
-23
lines changed

11 files changed

+123
-23
lines changed

.changeset/old-mirrors-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Add presentation mode in local units map

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"failedMessage": "Failed to add local unit",
66
"updateMessage": "Local unit updated successfully!",
77
"updateFailedMessage": "Failed to update local unit",
8+
"healthCareDetails": "Health care details",
89
"subtype": "Sub-type",
910
"subtypeDescription": "(e.g. hospital)",
1011
"englishLabel": "English",

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ function LocalUnitsForm(props: Props) {
648648
</Container>
649649
{value.type === TYPE_HEALTH_CARE && (
650650
<Container
651-
heading="Health care details"
651+
heading={strings.healthCareDetails}
652652
withHeaderBorder
653653
contentViewType="vertical"
654654
childrenContainerClassName={styles.healthCareDetailsContent}
@@ -982,22 +982,22 @@ function LocalUnitsForm(props: Props) {
982982
error={healthFormError?.other_profiles}
983983
/>
984984
</LocalUnitInputSection>
985+
<LocalUnitInputSection
986+
title={strings.commentsNS}
987+
numPreferredColumns={1}
988+
>
989+
<TextArea
990+
name="feedback"
991+
value={value.health?.feedback}
992+
onChange={onHealthFieldChange}
993+
readOnly={readOnly}
994+
error={getErrorString(
995+
healthFormError?.feedback,
996+
)}
997+
/>
998+
</LocalUnitInputSection>
985999
</Container>
9861000
)}
987-
<Container
988-
heading={strings.commentsNS}
989-
withHeaderBorder
990-
>
991-
<TextArea
992-
name="feedback"
993-
value={value.health?.feedback}
994-
onChange={onHealthFieldChange}
995-
readOnly={readOnly}
996-
error={getErrorString(
997-
healthFormError?.feedback,
998-
)}
999-
/>
1000-
</Container>
10011001
</Container>
10021002
{!readOnly
10031003
&& isDefined(submitButtonContainerRef)

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const schema: LocalUnitsFormSchema = {
7373
required: true,
7474
},
7575
date_of_data: { required: true },
76+
source_loc: {},
7677
source_en: {},
7778
address_en: {
7879
validations: [lengthSmallerThanCondition(200)],
@@ -153,11 +154,12 @@ const schema: LocalUnitsFormSchema = {
153154
},
154155
hospital_type: {},
155156
specialized_medical_beyond_primary_level: { required: true },
157+
primary_health_care_center: {},
156158
other_services: {
157159
validations: [lengthSmallerThanCondition(200)],
158160
},
159161
blood_services: { required: true },
160-
professional_training_facilities: { forceValue: [] },
162+
professional_training_facilities: { defaultValue: [] },
161163
general_medical_services: { required: true },
162164
speciality: {
163165
validations: [lengthSmallerThanCondition(200)],

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"localUnitLocalUnitType": "Local Unit Type",
1111
"localUnitHealthFacilityType": "Health Facility Type",
1212
"localUnitLegendHealthCareTitle": "Health Care Local Units",
13+
"presentationModeButton":"Presentation Mode",
1314
"localUnitDetailEmail": "Email"
1415
}
1516
}

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import react, { useMemo } from 'react';
22
import { useOutletContext } from 'react-router-dom';
33
import {
4+
ArtboardLineIcon,
45
LocationIcon,
56
MailIcon,
67
} from '@ifrc-go/icons';
78
import {
9+
Button,
810
Container,
911
LegendItem,
1012
List,
@@ -99,7 +101,16 @@ function emailKeySelector(email: string) {
99101
return email;
100102
}
101103

102-
function LocalUnitsMap() {
104+
interface Props {
105+
onPresentationModeButtonClick?: () => void;
106+
presentationMode?: boolean;
107+
}
108+
109+
function LocalUnitsMap(props: Props) {
110+
const {
111+
onPresentationModeButtonClick,
112+
presentationMode = false,
113+
} = props;
103114
const { countryResponse } = useOutletContext<CountryOutletContext>();
104115

105116
const {
@@ -347,7 +358,7 @@ function LocalUnitsMap() {
347358
className={styles.localUnitsMap}
348359
contentViewType="vertical"
349360
withGridViewInFilter
350-
filters={(
361+
filters={!presentationMode && (
351362
<Filters
352363
value={rawFilter}
353364
setFieldValue={setFilterField}
@@ -468,6 +479,17 @@ function LocalUnitsMap() {
468479
</MapPopup>
469480
)}
470481
</BaseMap>
482+
{onPresentationModeButtonClick && !presentationMode && (
483+
<Button
484+
className={styles.presentationModeButton}
485+
name={undefined}
486+
icons={<ArtboardLineIcon />}
487+
onClick={onPresentationModeButtonClick}
488+
variant="secondary"
489+
>
490+
{strings.presentationModeButton}
491+
</Button>
492+
)}
471493
{hasContactDetails && (
472494
<Container
473495
className={styles.contactDetail}

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/styles.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
.map-container-with-contact-details {
33
position: relative;
44

5+
.presentation-mode-button {
6+
position: absolute;
7+
top: var(--go-ui-spacing-md);
8+
left: var(--go-ui-spacing-md);
9+
}
10+
511
.map-container {
612
height: 45rem;
713
}

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ function LocalUnitsTableActions(props: Props) {
9898
type="button"
9999
name={localUnitId}
100100
onClick={setShowLocalUnitViewModalTrue}
101+
disabled={!hasValidatePermission}
101102
>
102103
{strings.localUnitsView}
103104
</DropdownMenuItem>
104105
<DropdownMenuItem
105106
type="button"
106107
name={localUnitId}
107108
onClick={setShowLocalUnitEditModalTrue}
109+
disabled={!hasValidatePermission}
108110
>
109111
{strings.localUnitsEdit}
110112
</DropdownMenuItem>

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"localUnitDetailType": "Type",
77
"localUnitsMapView": "Map view",
88
"localUnitsListView": "List view",
9-
"addLocalUnitLabel": "Add a Local Unit"
9+
"addLocalUnitLabel": "Add a Local Unit",
10+
"closePresentationLabel": "Close"
1011
}
1112
}

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/index.tsx

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import {
22
useCallback,
3+
useEffect,
4+
useRef,
35
useState,
46
} from 'react';
57
import { useOutletContext } from 'react-router-dom';
8+
import { CloseLineIcon } from '@ifrc-go/icons';
69
import {
710
Button,
811
Container,
12+
IconButton,
913
Tab,
1014
TabList,
1115
TabPanel,
@@ -15,7 +19,11 @@ import {
1519
useBooleanState,
1620
useTranslation,
1721
} from '@ifrc-go/ui/hooks';
18-
import { _cs } from '@togglecorp/fujs';
22+
import {
23+
_cs,
24+
isDefined,
25+
isNotDefined,
26+
} from '@togglecorp/fujs';
1927

2028
import useAuth from '#hooks/domain/useAuth';
2129
import usePermissions from '#hooks/domain/usePermissions';
@@ -41,15 +49,36 @@ function NationalSocietyLocalUnits(props: Props) {
4149
const { isAuthenticated } = useAuth();
4250
const { countryResponse } = useOutletContext<CountryOutletContext>();
4351
const { isSuperUser, isCountryAdmin } = usePermissions();
52+
const containerRef = useRef<HTMLDivElement>(null);
4453

4554
// NOTE: key is used to refresh the page when local unit data is updated
4655
const [localUnitUpdateKey, setLocalUnitUpdateKey] = useState(0);
56+
const [
57+
presentationMode,
58+
setFullScreenMode,
59+
] = useState(false);
4760

4861
const [showAddEditModal, {
4962
setTrue: setShowAddEditModalTrue,
5063
setFalse: setShowAddEditModalFalse,
5164
}] = useBooleanState(false);
5265

66+
const handleFullScreenChange = useCallback(() => {
67+
setFullScreenMode(isDefined(document.fullscreenElement));
68+
}, [setFullScreenMode]);
69+
70+
const handleFullScreenToggleClick = useCallback(() => {
71+
if (isNotDefined(containerRef.current)) {
72+
return;
73+
}
74+
const { current: viewerContainer } = containerRef;
75+
if (!presentationMode && isDefined(viewerContainer?.requestFullscreen)) {
76+
viewerContainer?.requestFullscreen();
77+
} else if (presentationMode && isDefined(document.exitFullscreen)) {
78+
document.exitFullscreen();
79+
}
80+
}, [presentationMode]);
81+
5382
const handleLocalUnitFormModalClose = useCallback(
5483
() => {
5584
setShowAddEditModalFalse();
@@ -62,6 +91,14 @@ function NationalSocietyLocalUnits(props: Props) {
6291

6392
const hasAddLocalUnitPermission = isCountryAdmin(countryResponse?.id) || isSuperUser;
6493

94+
useEffect(() => {
95+
document.addEventListener('fullscreenchange', handleFullScreenChange);
96+
97+
return (() => {
98+
document.removeEventListener('fullscreenchange', handleFullScreenChange);
99+
});
100+
}, [handleFullScreenChange]);
101+
65102
return (
66103
<Tabs
67104
onChange={setActiveTab}
@@ -91,9 +128,27 @@ function NationalSocietyLocalUnits(props: Props) {
91128
)}
92129
>
93130
<TabPanel name="map">
94-
<LocalUnitsMap
95-
key={localUnitUpdateKey}
96-
/>
131+
<Container
132+
className={_cs(presentationMode && styles.presentationMode)}
133+
containerRef={containerRef}
134+
actions={presentationMode && (
135+
<IconButton
136+
name={undefined}
137+
onClick={handleFullScreenToggleClick}
138+
title={strings.closePresentationLabel}
139+
variant="secondary"
140+
ariaLabel={strings.closePresentationLabel}
141+
>
142+
<CloseLineIcon />
143+
</IconButton>
144+
)}
145+
>
146+
<LocalUnitsMap
147+
key={localUnitUpdateKey}
148+
onPresentationModeButtonClick={handleFullScreenToggleClick}
149+
presentationMode={presentationMode}
150+
/>
151+
</Container>
97152
</TabPanel>
98153
<TabPanel name="table">
99154
<LocalUnitsTable

0 commit comments

Comments
 (0)