Skip to content

Commit

Permalink
UIORGS-356 Show in version history record view, which fields have bee…
Browse files Browse the repository at this point in the history
…n edited
  • Loading branch information
usavkov-epam committed Nov 25, 2024
1 parent 9a29cc4 commit 40a886b
Show file tree
Hide file tree
Showing 39 changed files with 1,576 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 6.0.0 (IN PROGRESS)

* *BREAKING* Display all versions in change log in fourth pane. Refs UIORGS-355.
* Show in version history record view, which fields have been edited. Refs UIORGS-356.
* Adapt organization metadata fields to version history mechanism. Refs UIORGS-359.

## [5.2.0](https://github.com/folio-org/ui-organizations/tree/v5.2.0) (2024-10-31)
[Full Changelog](https://github.com/folio-org/ui-organizations/compare/v5.1.1...v5.2.0)
Expand Down
1 change: 1 addition & 0 deletions src/ContactPeople/ContactPerson/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default } from './ContactPerson';
export { default as ContactPersonSection } from './ContactPersonSection';
17 changes: 14 additions & 3 deletions src/Organizations/OrganizationVersion/OrganizationVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {
} from '../../common/constants';
import { HIDDEN_FIELDS_FOR_ORGANIZATION_VERSION_HISTORY } from '../constants';
import { getOrganizationFieldsLabelMap } from './getOrganizationFieldsLabelMap';
import { useOrganizationVersions } from './hooks';
import {
useOrganizationVersions,
useSelectedOrganizationVersion,
} from './hooks';
import { OrganizationVersionView } from './OrganizationVersionView';

const OrganizationVersion = ({
history,
Expand Down Expand Up @@ -62,8 +66,15 @@ const OrganizationVersion = ({
},
});

const {
isLoading: isOrganizationVersionLoading,
selectedVersion,
} = useSelectedOrganizationVersion({ versionId, versions, snapshotPath });

const isVersionLoading = (
isOrganizationLoading || isHistoryLoading
isOrganizationLoading
|| isHistoryLoading
|| isOrganizationVersionLoading
);

const labelsMap = useMemo(() => getOrganizationFieldsLabelMap(), []);
Expand All @@ -84,7 +95,7 @@ const OrganizationVersion = ({
tags={get(organization, 'tags.tagList', [])}
versionId={versionId}
>
{/* TODO: https://folio-org.atlassian.net/browse/UIORGS-356 */}
<OrganizationVersionView version={selectedVersion} />
</VersionView>

<VersionHistoryPane
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import PropTypes from 'prop-types';
import { useRef } from 'react';

import {
Accordion,
AccordionSet,
AccordionStatus,
checkScope,
Col,
collapseAllSections,
ExpandAllButton,
expandAllSections,
HasCommand,
Row,
} from '@folio/stripes/components';

import {
ORGANIZATION_SECTION_LABELS,
ORGANIZATION_SECTIONS,
} from '../../constants';
import {
OrganizationAccountsVersionView,
OrganizationContactInfoVersionView,
OrganizationContactPeopleVersionView,
OrganizationInterfacesVersionView,
OrganizationSummaryVersionView,
OrganizationVendorInfoVersionView,
OrganizationVendorTermsVersionView,
} from '../components';

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.agreements]: false,
};

export const OrganizationVersionView = ({ version }) => {
const accordionStatusRef = useRef();

const shortcuts = [
{
name: 'expandAllSections',
handler: (e) => expandAllSections(e, accordionStatusRef),
},
{
name: 'collapseAllSections',
handler: (e) => collapseAllSections(e, accordionStatusRef),
},
];

console.log('version', version);

Check warning on line 57 in src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement

Check warning on line 57 in src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js

View workflow job for this annotation

GitHub Actions / github-actions-ci

Unexpected console statement

return (
<HasCommand
commands={shortcuts}
isWithinScope={checkScope}
scope={document.body}
>
<AccordionStatus ref={accordionStatusRef}>
<Row end="xs">
<Col xs={12}>
<ExpandAllButton />
</Col>
</Row>

<AccordionSet initialStatus={initialAccordionStatus}>
<Accordion
id={ORGANIZATION_SECTIONS.summarySection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.summarySection]}
>
<OrganizationSummaryVersionView version={version} />
</Accordion>

<Accordion
id={ORGANIZATION_SECTIONS.contactInformationSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.contactInformationSection]}
>
<OrganizationContactInfoVersionView
version={version}
/>
</Accordion>

<Accordion
id={ORGANIZATION_SECTIONS.contactPeopleSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.contactPeopleSection]}
>
<OrganizationContactPeopleVersionView
name="contacts"
version={version}
/>
</Accordion>

<Accordion
id={ORGANIZATION_SECTIONS.interfacesSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.interfacesSection]}
>
<OrganizationInterfacesVersionView
name="interfaces"
version={version}
/>
</Accordion>

{
version?.isVendor && (
<>
<Accordion
id={ORGANIZATION_SECTIONS.vendorInformationSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.vendorInformationSection]}
>
<OrganizationVendorInfoVersionView version={version} />
</Accordion>

<Accordion
id={ORGANIZATION_SECTIONS.vendorTermsSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.vendorTermsSection]}
>
<OrganizationVendorTermsVersionView
name="agreements"
version={version}
/>
</Accordion>

<Accordion
id={ORGANIZATION_SECTIONS.accountsSection}
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.accountsSection]}
>
<OrganizationAccountsVersionView
name="accounts"
version={version}
/>
</Accordion>
</>
)
}
</AccordionSet>
</AccordionStatus>
</HasCommand>
);
};

OrganizationVersionView.propTypes = {
version: PropTypes.object,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { OrganizationVersionView } from './OrganizationVersionView';
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import {
Col,
Row,
} from '@folio/stripes/components';
import {
PAYMENT_METHOD_LABELS,
VersionKeyValue,
} from '@folio/stripes-acq-components';

import css from '../../../OrganizationDetails/OrganizationAccounts/OrganizationAccount/OrganizationAccount.css';

export const OrganizationAccountsVersionView = ({ name, version }) => {
if (!version?.accounts?.length) {
return (
<p>
<FormattedMessage id="ui-organizations.accounts.noAccountsAvail" />
</p>
);
}

return (
<>
{version?.accounts?.map((account, indx) => {
return (
<Row className={css.organizationAccount}>
<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].name`}
label={<FormattedMessage id="ui-organizations.accounts.name" />}
value={account?.name}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].accountNo`}
label={<FormattedMessage id="ui-organizations.accounts.accountNumber" />}
value={account?.accountNo}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].description`}
label={<FormattedMessage id="ui-organizations.accounts.description" />}
value={account?.description}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].appSystemNo`}
label={<FormattedMessage id="ui-organizations.accounts.payable" />}
value={account?.appSystemNo}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].paymentMethod`}
label={<FormattedMessage id="ui-organizations.accounts.paymentMethod" />}
value={PAYMENT_METHOD_LABELS[account?.paymentMethod]}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].contactInfo`}
label={<FormattedMessage id="ui-organizations.accounts.account.contactInfo" />}
value={account?.contactInfo}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].libraryCode`}
label={<FormattedMessage id="ui-organizations.accounts.libraryCode" />}
value={account?.libraryCode}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].libraryEdiCode`}
label={<FormattedMessage id="ui-organizations.accounts.libraryEDICode" />}
value={account?.libraryEdiCode}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].notes`}
label={<FormattedMessage id="ui-organizations.accounts.notes" />}
value={account?.notes}
/>
</Col>

<Col xs={3}>
<VersionKeyValue
name={`${name}[${indx}].acqUnitIds`}
label={<FormattedMessage id="stripes-acq-components.label.acqUnits" />}
value={account?.acqUnits}
multiple
/>
</Col>
</Row>
);
})}
</>
);
};

OrganizationAccountsVersionView.propTypes = {
name: PropTypes.string.isRequired,
version: PropTypes.object,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { OrganizationAccountsVersionView } from './OrganizationAccountsVersionView';
Loading

0 comments on commit 40a886b

Please sign in to comment.