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

UIOR-1078: Allow Editing of "Renewal Date" and "Subscription to" on o… #1508

Merged
merged 6 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* When order line contains bad product IDs - the save & close does not work. Refs UIOR-1141.
* Upgrade `ui-plugin-find-po-line` and `ui-plugin-find-organization` plugins to `5` version. Refs UIOR-1154.
* POL - Display only active account numbers in dropdown list. Refs UIOR-1142.
* Allow Editing of "Renewal Date" and "Subscription to" on open purchase order line. Refs UIOR-1078.

## [4.0.2](https://github.com/folio-org/ui-orders/tree/v4.0.2) (2023-03-17)
[Full Changelog](https://github.com/folio-org/ui-orders/compare/v4.0.1...v4.0.2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ACCORDION_ID } from '../constants';
import {
isWorkflowStatusIsPending,
isWorkflowStatusClosed,
isWorkflowStatusOpen,
} from '../util';

const OngoingInfoForm = ({ hiddenFields = {} }) => {
Expand All @@ -34,6 +35,7 @@ const OngoingInfoForm = ({ hiddenFields = {} }) => {
const isSubscription = !!ongoingFormValues?.isSubscription;
const isClosedNonInteractive = values.workflowStatus && isWorkflowStatusClosed(values);
const isNonPendingNonInteractive = values.workflowStatus && !isWorkflowStatusIsPending(values);
const isOpenNonInteractive = values.workflowStatus && !isWorkflowStatusOpen(values);

if (isClosedNonInteractive && disabled) return null;

Expand All @@ -51,7 +53,7 @@ const OngoingInfoForm = ({ hiddenFields = {} }) => {
<VisibilityControl name="hiddenFields.ongoing.isSubscription">
<FieldRenewalSubscription
disabled={disabled}
isNonInteractive={isNonPendingNonInteractive}
isNonInteractive={isNonPendingNonInteractive && isOpenNonInteractive}
/>
</VisibilityControl>
</Col>
Expand Down Expand Up @@ -80,7 +82,7 @@ const OngoingInfoForm = ({ hiddenFields = {} }) => {
<VisibilityControl name="hiddenFields.ongoing.renewalDate">
<FieldRenewalDate
disabled={!isSubscription}
isNonInteractive={isClosedNonInteractive}
isNonInteractive={isClosedNonInteractive && isOpenNonInteractive}
/>
</VisibilityControl>
</Col>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Form } from 'react-final-form';
import { Form, useFormState } from 'react-final-form';

import { render, screen } from '@folio/jest-config-stripes/testing-library/react';

Expand Down Expand Up @@ -37,4 +37,18 @@ describe('OngoingInfoForm', () => {
expect(screen.getByText('ui-orders.renewals.reviewDate')).toBeInTheDocument();
expect(screen.getByText('ui-orders.renewals.notes')).toBeInTheDocument();
});

it('should subscription and renewalDate fields to be editable when workFlowStatus is Open', () => {
useFormState.mockClear().mockReturnValueOnce({
values: {
workflowStatus: 'Open',
orderType: 'Ongoing',
},
});

renderOngoingInfoForm();

expect(screen.getByText('ui-orders.renewals.subscription')).toBeEnabled();
expect(screen.getByText('ui-orders.renewals.renewalDate')).toBeEnabled();
});
});