From b9e469a50037500fcded9c6c7d05f2c8ba6f4849 Mon Sep 17 00:00:00 2001 From: shreeyash07 Date: Wed, 28 Aug 2024 10:19:40 +0545 Subject: [PATCH 1/3] Remove ellipsizeHeading from map pop up heading --- .../NationalSocietyLocalUnits/LocalUnitsMap/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx index 954b719ea..6acc6a4c2 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx @@ -423,7 +423,6 @@ function LocalUnitsMap(props: Props) { errored={isDefined(localUnitDetailError)} errorMessage={localUnitDetailError?.value.messageForNotification} compactMessage - ellipsizeHeading > Date: Thu, 29 Aug 2024 17:16:51 +0545 Subject: [PATCH 2/3] Add edit button in local unit view modal --- .../LocalUnitValidateButton/index.tsx | 5 ++++- .../LocalUnitValidateButton/styles.module.css | 9 +++++++++ .../LocalUnitsFormModal/LocalUnitsForm/i18n.json | 3 ++- .../LocalUnitsFormModal/LocalUnitsForm/index.tsx | 10 ++++++++++ .../LocalUnitsFormModal/index.tsx | 13 +++++++++++-- .../LocalUnitsTable/LocalUnitTableActions/index.tsx | 2 +- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/index.tsx index fb1c97ed2..507d4af73 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/index.tsx @@ -3,6 +3,7 @@ import { CheckboxCircleLineIcon } from '@ifrc-go/icons'; import { ConfirmButton } from '@ifrc-go/ui'; import { useTranslation } from '@ifrc-go/ui/hooks'; import { resolveToString } from '@ifrc-go/ui/utils'; +import { _cs } from '@togglecorp/fujs'; import usePermissions from '#hooks/domain/usePermissions'; import useAlert from '#hooks/useAlert'; @@ -95,7 +96,9 @@ function LocalUnitValidateButton(props: Props) { return ( void; + onEditButtonClick?: () => void; localUnitId?: number; actionsContainerRef?: RefObject; headingDescriptionRef?: RefObject; @@ -118,6 +119,7 @@ function LocalUnitsForm(props: Props) { const { readOnly = false, onSuccess, + onEditButtonClick, localUnitId, actionsContainerRef, headingDescriptionRef, @@ -387,6 +389,14 @@ function LocalUnitsForm(props: Props) { onActionSuccess={onSuccess} disabled={!pristine} /> + {readOnly && ( + + )} void; } @@ -20,7 +21,7 @@ function LocalUnitsFormModal(props: Props) { const { onClose, localUnitId, - readOnly, + viewMode = false, } = props; const strings = useTranslation(i18n); @@ -28,11 +29,18 @@ function LocalUnitsFormModal(props: Props) { const headingDescriptionRef = useRef(null); const headerDescriptionRef = useRef(null); + const [readOnly, setReadOnly] = useState(viewMode); + const handleSuccess = useCallback( () => { onClose(true); }, [onClose], ); + const handleEditButtonClick = useCallback( + () => { setReadOnly(false); }, + [], + ); + return ( )} From 4192da190dd0250063b12761b760613d629a0055 Mon Sep 17 00:00:00 2001 From: shreeyash07 Date: Fri, 30 Aug 2024 11:25:49 +0545 Subject: [PATCH 3/3] Add local unit modal in map popup --- .changeset/six-hounds-film.md | 9 ++++ .../LocalUnitValidateButton/styles.module.css | 2 +- .../LocalUnitsForm/index.tsx | 33 +++++++------ .../LocalUnitsFormModal/index.tsx | 26 ++++++----- .../LocalUnitsMap/index.tsx | 46 ++++++++++++++++++- .../LocalUnitTableActions/index.tsx | 45 ++++++++++++------ 6 files changed, 115 insertions(+), 46 deletions(-) create mode 100644 .changeset/six-hounds-film.md diff --git a/.changeset/six-hounds-film.md b/.changeset/six-hounds-film.md new file mode 100644 index 000000000..e405b99f7 --- /dev/null +++ b/.changeset/six-hounds-film.md @@ -0,0 +1,9 @@ +--- +"go-web-app": patch +--- + +- Local Units popup, view/edit mode improvements in [#1178](https://github.com/IFRCGo/go-web-app/issues/1178) + - Remove ellipsize heading option in local units map popup + - Local units title on popup are now clickable that opens up a modal to show details + - Added an Edit button to the View Mode for users with edit permissions + - Users will now see a **disabled grey button** when the content is already validated diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/styles.module.css b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/styles.module.css index 9bf2a8579..32f3f51f1 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/styles.module.css +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitValidateButton/styles.module.css @@ -5,8 +5,8 @@ } .local-unit-validated-button { - background-color: var(--go-ui-color-gray-40); border: none; + background-color: var(--go-ui-color-gray-40); .icon { font-size: var(--go-ui-height-icon-multiplier); diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx index 86647a57f..72f254872 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx @@ -110,7 +110,7 @@ interface Props { onSuccess?: () => void; onEditButtonClick?: () => void; localUnitId?: number; - actionsContainerRef?: RefObject; + actionsContainerRef: RefObject; headingDescriptionRef?: RefObject; headerDescriptionRef: RefObject; } @@ -316,14 +316,21 @@ function LocalUnitsForm(props: Props) { return (
- {!readOnly - && isDefined(actionsContainerRef) - && isDefined(actionsContainerRef.current) - && ( - - {submitButton} - - )} + {readOnly && isDefined(actionsContainerRef.current) && ( + + + + )} + {!readOnly && isDefined(actionsContainerRef.current) && ( + + {submitButton} + + )} {isDefined(headingDescriptionRef) && isDefined(headingDescriptionRef.current) && (
@@ -389,14 +396,6 @@ function LocalUnitsForm(props: Props) { onActionSuccess={onSuccess} disabled={!pristine} /> - {readOnly && ( - - )} >; onClose: (requestDone?: boolean) => void; } @@ -21,7 +22,8 @@ function LocalUnitsFormModal(props: Props) { const { onClose, localUnitId, - viewMode = false, + readOnly, + setReadOnly, } = props; const strings = useTranslation(i18n); @@ -29,16 +31,20 @@ function LocalUnitsFormModal(props: Props) { const headingDescriptionRef = useRef(null); const headerDescriptionRef = useRef(null); - const [readOnly, setReadOnly] = useState(viewMode); - const handleSuccess = useCallback( - () => { onClose(true); }, + () => { + onClose(true); + }, [onClose], ); const handleEditButtonClick = useCallback( - () => { setReadOnly(false); }, - [], + () => { + if (isDefined(setReadOnly)) { + setReadOnly(false); + } + }, + [setReadOnly], ); return ( @@ -49,9 +55,7 @@ function LocalUnitsFormModal(props: Props) { size="pageWidth" withHeaderBorder headingLevel={2} - actions={!readOnly && ( -
- )} + actions={
} headingContainerClassName={styles.headingContainer} headingDescription={
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx index 6acc6a4c2..eb58cc495 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx @@ -16,7 +16,10 @@ import { List, TextOutput, } from '@ifrc-go/ui'; -import { useTranslation } from '@ifrc-go/ui/hooks'; +import { + useBooleanState, + useTranslation, +} from '@ifrc-go/ui/hooks'; import { numericIdSelector, stringNameSelector, @@ -65,6 +68,7 @@ import { VALIDATED, } from '../common'; import type { FilterValue } from '../Filters'; +import LocalUnitsFormModal from '../LocalUnitsFormModal'; import { TYPE_HEALTH_CARE } from '../LocalUnitsFormModal/LocalUnitsForm/schema'; import i18n from './i18n.json'; @@ -132,6 +136,12 @@ function LocalUnitsMap(props: Props) { } = props; const { countryResponse } = useOutletContext(); + const [showLocalUnitModal, { + setTrue: setShowLocalUnitViewModalTrue, + setFalse: setShowLocalUnitViewModalFalse, + }] = useBooleanState(false); + const [readOnlyLocalUnitModal, setReadOnlyLocalUnitModal] = useState(true); + const urlQuery = useMemo>( () => ({ limit: MAX_PAGE_LIMIT, @@ -305,6 +315,22 @@ function LocalUnitsMap(props: Props) { [setClickedPointProperties], ); + const handleLocalUnitHeadingClick = useCallback( + () => { + setReadOnlyLocalUnitModal(true); + setShowLocalUnitViewModalTrue(); + }, + [setShowLocalUnitViewModalTrue], + ); + + const handleLocalUnitsFormModalClose = useCallback( + () => { + setShowLocalUnitViewModalFalse(); + setReadOnlyLocalUnitModal(true); + }, + [setShowLocalUnitViewModalFalse], + ); + const emailRendererParams = useCallback( (_: string, email: string): LinkProps => ({ className: styles.email, @@ -417,7 +443,15 @@ function LocalUnitsMap(props: Props) { popupClassName={styles.mapPopup} coordinates={clickedPointProperties.lngLat} onCloseButtonClick={handlePointClose} - heading={localUnitName} + heading={( + + )} contentViewType="vertical" pending={localUnitDetailPending} errored={isDefined(localUnitDetailError)} @@ -543,6 +577,14 @@ function LocalUnitsMap(props: Props) { iconElementClassName={styles.legendIcon} /> )} + {(showLocalUnitModal && ( + + ))} ); } diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx index 0e2ddd3e0..5782af847 100644 --- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx +++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx @@ -1,4 +1,7 @@ -import { useCallback } from 'react'; +import { + useCallback, + useState, +} from 'react'; import { TableActions } from '@ifrc-go/ui'; import { useBooleanState, @@ -39,26 +42,37 @@ function LocalUnitsTableActions(props: Props) { const hasValidatePermission = !isGuestUser && (isSuperUser || isCountryAdmin(countryId)); - const [showLocalUnitViewModal, { - setTrue: setShowLocalUnitViewModalTrue, - setFalse: setShowLocalUnitViewModalFalse, - }] = useBooleanState(false); + const [readOnlyLocalUnitModal, setReadOnlyLocalUnitModal] = useState(false); - const [showLocalUnitEditModal, { - setTrue: setShowLocalUnitEditModalTrue, - setFalse: setShowLocalUnitEditModalFalse, + const [showLocalUnitModal, { + setTrue: setShowLocalUnitModalTrue, + setFalse: setShowLocalUnitModalFalse, }] = useBooleanState(false); const handleLocalUnitsFormModalClose = useCallback( (shouldUpdate?: boolean) => { - setShowLocalUnitEditModalFalse(); - setShowLocalUnitViewModalFalse(); + setShowLocalUnitModalFalse(); if (shouldUpdate) { onActionSuccess(); } }, - [setShowLocalUnitViewModalFalse, setShowLocalUnitEditModalFalse, onActionSuccess], + [setShowLocalUnitModalFalse, onActionSuccess], + ); + + const handleViewLocalUnitClick = useCallback( + () => { + setReadOnlyLocalUnitModal(true); + setShowLocalUnitModalTrue(); + }, + [setShowLocalUnitModalTrue], + ); + const handleEditLocalUnitClick = useCallback( + () => { + setReadOnlyLocalUnitModal(false); + setShowLocalUnitModalTrue(); + }, + [setShowLocalUnitModalTrue], ); return ( @@ -70,7 +84,7 @@ function LocalUnitsTableActions(props: Props) { {strings.localUnitsView} @@ -78,7 +92,7 @@ function LocalUnitsTableActions(props: Props) { {strings.localUnitsEdit} @@ -101,11 +115,12 @@ function LocalUnitsTableActions(props: Props) { localUnitId={localUnitId} /> - {(showLocalUnitViewModal || showLocalUnitEditModal) && ( + {showLocalUnitModal && ( )}