From 914862dd72320ad660dbf212f92899fb53c051c9 Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Tue, 21 Nov 2023 16:51:29 +0500 Subject: [PATCH] UIORGS-398: modify summary display in organization view mode (#575) * UIORGS-398: modify summary display in organization view mode * tests: add test case for improving test coverage * refactor: update boolean check for accordion visibility * update changelog file * update todo comment --- CHANGELOG.md | 1 + .../OrganizationDetails.js | 89 ++++++++++++------- .../OrganizationDetails.test.js | 13 +++ .../OrganizationSummary.js | 77 +++++++--------- src/Organizations/constants.js | 2 + translations/ui-organizations/en.json | 1 + 6 files changed, 108 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24aef053..04f7ee24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Settings for banking information. Refs UIORGS-391. * Implement organization's banking information form. Refs UIORGS-390. * Implement organization's banking information details view. Refs UIORGS-389. +* Modify summary display in organization view mode. Refs UIORGS-398. ## [5.0.0](https://github.com/folio-org/ui-organizations/tree/v5.0.0) (2023-10-12) [Full Changelog](https://github.com/folio-org/ui-organizations/compare/v4.0.0...v5.0.0) diff --git a/src/Organizations/OrganizationDetails/OrganizationDetails.js b/src/Organizations/OrganizationDetails/OrganizationDetails.js index 82f67910..0c9f37b4 100644 --- a/src/Organizations/OrganizationDetails/OrganizationDetails.js +++ b/src/Organizations/OrganizationDetails/OrganizationDetails.js @@ -62,6 +62,21 @@ import { OrganizationInterfacesContainer } from './OrganizationInterfaces'; import { OrganizationSummary } from './OrganizationSummary'; import { OrganizationVendorInfo } from './OrganizationVendorInfo'; +const { + accountsSection, + agreements, + bankingInformationSection, + contactInformationSection, + contactPeopleSection, + donorContacts, + integrationDetailsSection, + interfacesSection, + notesSection, + summarySection, + vendorInformationSection, + vendorTermsSection, +} = ORGANIZATION_SECTIONS; + const OrganizationDetails = ({ onClose, onEdit, @@ -77,17 +92,17 @@ const OrganizationDetails = ({ const stripes = useStripes(); const [isRemoveModalOpened, toggleRemoveModal] = useModalToggle(); const initialAccordionStatus = { - [ORGANIZATION_SECTIONS.summarySection]: true, - [ORGANIZATION_SECTIONS.contactInformationSection]: false, - [ORGANIZATION_SECTIONS.contactPeopleSection]: true, - [ORGANIZATION_SECTIONS.interfacesSection]: false, - [ORGANIZATION_SECTIONS.vendorInformationSection]: false, - [ORGANIZATION_SECTIONS.vendorTermsSection]: false, - [ORGANIZATION_SECTIONS.integrationDetailsSection]: false, - [ORGANIZATION_SECTIONS.accountsSection]: false, - [ORGANIZATION_SECTIONS.bankingInformationSection]: false, - [ORGANIZATION_SECTIONS.notesSection]: false, - [ORGANIZATION_SECTIONS.agreements]: false, + [summarySection]: true, + [contactInformationSection]: false, + [contactPeopleSection]: true, + [interfacesSection]: false, + [vendorInformationSection]: false, + [vendorTermsSection]: false, + [integrationDetailsSection]: false, + [accountsSection]: false, + [bankingInformationSection]: false, + [notesSection]: false, + [agreements]: false, }; const [isTagsOpened, toggleTagsPane] = useModalToggle(); const paneTitleRef = useRef(); @@ -95,6 +110,7 @@ const OrganizationDetails = ({ const history = useHistory(); const accordionStatusRef = useRef(); const isDetailsPaneInFocus = location.state?.isDetailsPaneInFocus; + const isDonorVisible = organization?.isVendor && organization?.isDonor; const { restrictions, isLoading: isRestrictionsLoading } = useAcqRestrictions( organization.id, organization.acqUnitIds, ); @@ -263,8 +279,8 @@ const OrganizationDetails = ({ + { + isDonorVisible && ( + + {/* + TODO: add Privileged donor information component https://issues.folio.org/browse/UIORGS-397 + */} + + ) + } + { organization.isVendor && ( <> diff --git a/src/Organizations/OrganizationDetails/OrganizationDetails.test.js b/src/Organizations/OrganizationDetails/OrganizationDetails.test.js index 50f6b9e7..b5990634 100644 --- a/src/Organizations/OrganizationDetails/OrganizationDetails.test.js +++ b/src/Organizations/OrganizationDetails/OrganizationDetails.test.js @@ -127,6 +127,19 @@ describe('OrganizationDetails', () => { expect(screen.getByText('OrganizationAccounts')).toBeDefined(); }); + it('should display Donor Contacts accordion when both vendor and donor have been checked', () => { + renderOrganizationDetails({ + ...defaultProps, + organization: { + name: 'Amazon', + isVendor: true, + isDonor: true, + }, + }); + + expect(screen.getByText('ui-organizations.donorContacts')).toBeDefined(); + }); + it('should display warning message if vendor has not unique account numbers', () => { renderOrganizationDetails({ ...defaultProps, diff --git a/src/Organizations/OrganizationDetails/OrganizationSummary/OrganizationSummary.js b/src/Organizations/OrganizationDetails/OrganizationSummary/OrganizationSummary.js index ae5cb36a..ee57a036 100644 --- a/src/Organizations/OrganizationDetails/OrganizationSummary/OrganizationSummary.js +++ b/src/Organizations/OrganizationDetails/OrganizationSummary/OrganizationSummary.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import { FormattedMessage } from 'react-intl'; import PropTypes from 'prop-types'; @@ -6,7 +6,6 @@ import { Checkbox, Col, KeyValue, - MultiColumnList, NoValue, Row, } from '@folio/stripes/components'; @@ -18,12 +17,6 @@ import { import { ORGANIZATION_SECTIONS } from '../../constants'; -const aliasesColumnMapping = { - value: , - description: , -}; -const aliasesVisibleColumns = ['value', 'description']; - const OrganizationSummary = ({ acqUnitIds, aliases, @@ -39,6 +32,7 @@ const OrganizationSummary = ({ organizationTypes, }) => { const defaultLanguageValue = LANG_LABEL_BY_CODE[language] || language; + const alternativeNames = useMemo(() => aliases.map(({ value }) => value).join(', '), [aliases]); return ( <> @@ -54,7 +48,7 @@ const OrganizationSummary = ({ - + } @@ -62,14 +56,14 @@ const OrganizationSummary = ({ /> - + } value={code} /> - + } @@ -77,7 +71,7 @@ const OrganizationSummary = ({ /> - + } > @@ -85,7 +79,7 @@ const OrganizationSummary = ({ - + } @@ -93,25 +87,7 @@ const OrganizationSummary = ({ /> - - } - vertical - /> - - - - } - vertical - /> - - - + } @@ -119,31 +95,42 @@ const OrganizationSummary = ({ /> - + - + } value={description || } /> - - - + + } + vertical + /> + + + + } + vertical + /> + + + } - > - - + value={alternativeNames || } + /> diff --git a/src/Organizations/constants.js b/src/Organizations/constants.js index 717e9b55..1b6b2beb 100644 --- a/src/Organizations/constants.js +++ b/src/Organizations/constants.js @@ -12,6 +12,7 @@ export const ORGANIZATION_SECTIONS = { notesSection: 'notesSection', integrationDetailsSection: 'integrationDetailsSection', agreements: 'linkedAgreements', + donorContacts: 'donorContacts', }; export const ORGANIZATION_SECTION_LABELS = { @@ -25,6 +26,7 @@ export const ORGANIZATION_SECTION_LABELS = { [ORGANIZATION_SECTIONS.accountsSection]: , [ORGANIZATION_SECTIONS.integrationDetailsSection]: , [ORGANIZATION_SECTIONS.agreements]: , + [ORGANIZATION_SECTIONS.donorContacts]: , }; export const CREATE_UNITS_PERM = 'organizations.acquisitions-units-assignments.assign'; diff --git a/translations/ui-organizations/en.json b/translations/ui-organizations/en.json index 66596301..23bd186a 100644 --- a/translations/ui-organizations/en.json +++ b/translations/ui-organizations/en.json @@ -97,6 +97,7 @@ "contactPeople": "Contact people", "agreements": "Agreements", "vendorInformation": "Vendor information", + "donorContacts": "Donor contacts", "ediInformation": "EDI information", "interface": "Interface", "accounts": "Accounts",