Skip to content

Commit

Permalink
UIOR-1147: add donors info to POL (#1519)
Browse files Browse the repository at this point in the history
* UIOR-1147: add donors info to POL

* test: update unit test

* add visible columns and column width prop values

* fix: use `Donors` instead of `DonorsList` component
  • Loading branch information
alisher-epam authored Nov 9, 2023
1 parent c6c7f79 commit a9f7843
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Preview contains blank page when trying to print an order. Refs UIOR-1173.
* Do not disable account numbers having only one account available. Refs UIOR-1174.
* Populate values from a template after the fields are registered. Refs UIOR-1169.
* Add donor info to POL. Refs UIOR-1147.

## [5.0.0](https://github.com/folio-org/ui-orders/tree/v5.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-orders/compare/v4.0.3...v5.0.0)
Expand Down
12 changes: 12 additions & 0 deletions src/components/POLine/POLineForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { ViewMetaData } from '@folio/stripes/smart-components';
import stripesForm from '@folio/stripes/final-form';
import {
Donors,
FundDistributionFieldsFinal,
handleKeyCommand,
} from '@folio/stripes-acq-components';
Expand Down Expand Up @@ -108,6 +109,7 @@ function POLineForm({
const locations = parentResources?.locations?.records;
const lineId = get(initialValues, 'id');
const saveBtnLabelId = isCreateAnotherChecked ? 'save' : 'saveAndClose';
const donorOrganizationIds = get(initialValues, 'donorOrganizationIds', []);

const templateValue = useMemo(() => getOrderTemplateValue(parentResources, order?.template, {
locations,
Expand Down Expand Up @@ -139,6 +141,7 @@ function POLineForm({
Populate field values for new PO Line from a template if it exist.
First, the values of the fields are set, which, when changed, change other fields.
*/

useEffect(() => {
if (!lineId && templateValue.id) {
const populateFieldsFromTemplate = (fields) => {
Expand Down Expand Up @@ -447,6 +450,15 @@ function POLineForm({
integrationConfigs={integrationConfigs}
/>
</Accordion>
<Accordion
id={ACCORDION_ID.donorsInformation}
label={<FormattedMessage id="ui-orders.line.accordion.donorInformation" />}
>
<Donors
name="donorOrganizationIds"
donorOrganizationIds={donorOrganizationIds}
/>
</Accordion>
{isOngoing(order.orderType) && (
<Accordion
label={<FormattedMessage id="ui-orders.line.accordion.ongoingOrder" />}
Expand Down
1 change: 1 addition & 0 deletions src/components/POLine/POLineForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ describe('POLineForm', () => {
expect(screen.getByText('ui-orders.line.accordion.vendor')).toBeInTheDocument();
expect(screen.getByText('ui-orders.line.accordion.cost')).toBeInTheDocument();
expect(screen.getByText('ui-orders.line.accordion.fund')).toBeInTheDocument();
expect(screen.getByText('ui-orders.line.accordion.donorInformation')).toBeInTheDocument();
expect(screen.getByText(/LocationForm/i)).toBeInTheDocument();
});
});
Expand Down
7 changes: 6 additions & 1 deletion src/components/POLine/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ACCORDION_ID = {
vendor: 'vendor',
linkedInstances: 'linkedInstances',
ongoingOrder: 'ongoingOrder',
donorsInformation: 'donorsInformation',
};

// Mapping between attribute (field) in form and id of accordion
Expand Down Expand Up @@ -59,8 +60,12 @@ export const POL_TEMPLATE_FIELDS_MAP = {
'tags.tagList': 'polTags.tagList',
};

const INITIALLY_CLOSED_ACCORDION_IDS = {
[ACCORDION_ID.donorsInformation]: true,
};

export const INITIAL_SECTIONS = Object.values(ACCORDION_ID).reduce(
(accum, id) => ({ ...accum, [id]: true }), {},
(accum, id) => ({ ...accum, [id]: !INITIALLY_CLOSED_ACCORDION_IDS[id] }), {},
);

export const ACCOUNT_STATUS = {
Expand Down
2 changes: 2 additions & 0 deletions translations/ui-orders/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
"line.accordion.linkedInstance": "Linked instance",
"line.accordion.packageTitles": "Package titles",
"line.accordion.vendor": "Vendor",
"line.accordion.donorInformation": "Donor information",
"line.closedOrderMessage": "Purchase order is closed - {reason}",
"line.paneTitle.details": "PO Line details - {poLineNumber}",
"line.paneTitle.edit": "Edit - {lineNumber}",
Expand Down Expand Up @@ -470,6 +471,7 @@
"paneBlock.openBtn": "Open",
"paneBlock.unopenBtn": "Unopen",
"paneBlock.POLines": "PO lines",
"paneBlock.donorInformation": "Donor information",
"paneBlock.POSummary": "PO summary",
"paneBlock.purchaseOrder": "Purchase order",
"paneBlock.receiveBtn": "Receive",
Expand Down

0 comments on commit a9f7843

Please sign in to comment.