Skip to content
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

UIF-473: add list of donors component #766

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 5.1.0 (IN PROGRESS)

* Add donor info to Fund. Refs UIF-473.

## [5.0.0](https://github.com/folio-org/ui-finance/tree/v5.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-finance/compare/v4.0.4...v5.0.0)

Expand Down
50 changes: 32 additions & 18 deletions src/Funds/FundForm/FundForm.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import React, { useCallback, useMemo, useRef } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage, useIntl } from 'react-intl';
import { Field } from 'react-final-form';
import { useHistory } from 'react-router';
import {
find,
get,
} from 'lodash';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import {
FormattedMessage,
useIntl,
} from 'react-intl';
import { useHistory } from 'react-router';

import stripesFinalForm from '@folio/stripes/final-form';
import { useOkapiKy } from '@folio/stripes/core';
import {
AcqUnitsField,
Donors,
FieldMultiSelectionFinal as FieldMultiSelection,
FieldSelectionFinal as FieldSelection,
FormFooter,
FUNDS_API,
handleKeyCommand,
OptimisticLockingBanner,
validateRequired,
} from '@folio/stripes-acq-components';
import {
Accordion,
AccordionSet,
Expand All @@ -27,19 +39,10 @@ import {
TextArea,
TextField,
} from '@folio/stripes/components';
import { useOkapiKy } from '@folio/stripes/core';
import stripesFinalForm from '@folio/stripes/final-form';
import { ViewMetaData } from '@folio/stripes/smart-components';
import {
AcqUnitsField,
FieldMultiSelectionFinal as FieldMultiSelection,
FieldSelectionFinal as FieldSelection,
FormFooter,
FUNDS_API,
handleKeyCommand,
OptimisticLockingBanner,
validateRequired,
} from '@folio/stripes-acq-components';

import { FieldFundGroups } from '../FundGroups';
import {
CREATE_UNITS_PERM,
FUNDS_ROUTE,
Expand All @@ -53,6 +56,7 @@ import {
FUND_STATUSES_OPTIONS,
SECTIONS_FUND,
} from '../constants';
import { FieldFundGroups } from '../FundGroups';

const parseMultiSelectionValue = (items) => items.map(({ value }) => value);

Expand Down Expand Up @@ -85,6 +89,7 @@ const FundForm = ({
});
const fundId = initialValues.fund.id;
const fundLedgerId = get(formValues, 'fund.ledgerId');
const donorOrganizationIds = get(initialValues, 'fund.donorOrganizationIds', []);

const closeForm = useCallback(() => onCancel(), [onCancel]);

Expand Down Expand Up @@ -279,7 +284,6 @@ const FundForm = ({
validateFields={[]}
/>
</Col>

<Col
data-test-col-ledger
xs={3}
Expand Down Expand Up @@ -410,6 +414,16 @@ const FundForm = ({
</Col>
</Row>
</Accordion>
<Accordion
closedByDefault
id={SECTIONS_FUND.DONOR_INFORMATION}
label={<FormattedMessage id="ui-finance.fund.information.donorInformation" />}
>
<Donors
name="fund.donorOrganizationIds"
donorOrganizationIds={donorOrganizationIds}
/>
</Accordion>
</AccordionSet>
</AccordionStatus>
</Col>
Expand Down
10 changes: 10 additions & 0 deletions src/Funds/FundForm/FundForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import FundForm from './FundForm';
jest.mock('@folio/stripes-acq-components/lib/AcqUnits/AcqUnitsField', () => {
return () => <span>AcqUnitsField</span>;
});
jest.mock('@folio/stripes-acq-components', () => ({
...jest.requireActual('@folio/stripes-acq-components'),
Donors: jest.fn(() => 'Donors'),
}));
jest.mock('@folio/stripes-components/lib/Commander', () => ({
HasCommand: jest.fn(({ children }) => <div>{children}</div>),
expandAllSections: jest.fn(),
Expand Down Expand Up @@ -69,6 +73,12 @@ describe('FundForm component', () => {
expect(getByText('ui-finance.saveAndClose')).toBeDefined();
});

it('should display Donors', () => {
renderFundForm();

expect(screen.getByText('Donors')).toBeInTheDocument();
});

describe('Close form', () => {
it('should close the fund form', async () => {
const { getByText } = renderFundForm();
Expand Down
1 change: 1 addition & 0 deletions src/Funds/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const SECTIONS_FUND = {
PLANNED_BUDGET: 'plannedBudget',
PREVIOUS_BUDGETS: 'previousBudgets',
currentExpenseClasses: 'currentExpenseClasses',
DONOR_INFORMATION: 'donorInformation',
};

export const FUND_STATUSES = {
Expand Down
1 change: 1 addition & 0 deletions translations/ui-finance/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"fund.information.name": "Name",
"fund.information.status": "Status",
"fund.information.title": "Fund information",
"fund.information.donorInformation": "Donor information",
"fund.information.transferFrom": "Transfer from",
"fund.information.transferTo": "Transfer to",
"fund.information.type": "Type",
Expand Down
Loading