Skip to content

Commit

Permalink
Merge branch 'master' into UIREQMED-51
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-blazhko authored Nov 26, 2024
2 parents 2ccc297 + cd0df03 commit 30d67e6
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Add circulation-storage.staff-slips.collection.get for get staff-slips on Send item in transit. Refs UIREQMED-55.
* Add Decline Action for Mediated request with status of New - Awaiting confirmation. Refs UIREQMED-42.
* Fix DOMPurify import. Refs UIREQMED-56.
* Hide proxy functionality. Refs UIREQMED-59.
* Add functionality for managing missing data related to item, instance, requester. Refs UIREQMED-51.

## [1.1.0](https://github.com/folio-org/ui-requests-mediated/tree/v1.1.0) (2024-10-30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
import {
getTotalCount,
modifyRecordsToExport,
isProxyFunctionalityAvailable,
} from '../../utils';

export const getActionMenu = ({
Expand Down Expand Up @@ -146,7 +147,11 @@ export const getActionMenu = ({
const queryString = queryParams.join(' and ');
const records = await getRecords(queryString);
const recordsToCSV = buildRecords(records);
const columns = getColumnHeaders(REPORT_HEADERS);
const columnHeaders = [
...REPORT_HEADERS,
...(isProxyFunctionalityAvailable() ? ['proxy.name', 'proxy.barcode'] : []),
];
const columns = getColumnHeaders(columnHeaders);

exportToCsv(recordsToCSV, {
onlyFields: columns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
getDeliveryInformation,
getResourceTypeId,
getRequestInformation,
isProxyFunctionalityAvailable,
} from '../../../../utils';

import css from './RequestForm.css';
Expand Down Expand Up @@ -198,7 +199,7 @@ class RequestForm extends React.Component {
});
}

if (request.proxy) {
if (isProxyFunctionalityAvailable() && request.proxy) {
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PROXY_USER_ID, request.proxyUserId);
onSetSelectedProxy(request.proxy);
}
Expand Down Expand Up @@ -299,20 +300,28 @@ class RequestForm extends React.Component {
onSetSelectedUser,
onSetSelectedProxy,
} = this.props;
const isProxyAvailable = isProxyFunctionalityAvailable();

this.setState({
isUserLoading: true,
requestTypes: {},
isRequestTypesReceived: false,
isUserPreselected: false,
});
onSetSelectedProxy(EMPTY_RESOURCE_VALUE);

if (isProxyAvailable) {
onSetSelectedProxy(EMPTY_RESOURCE_VALUE);
}

onSetSelectedUser(EMPTY_RESOURCE_VALUE);

form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, DEFAULT_REQUEST_TYPE_VALUE);
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE);
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE);
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PROXY_USER_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE);

if (isProxyAvailable) {
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PROXY_USER_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE);
}

return findResource(RESOURCE_TYPES.USER, value, fieldName)
.then((result) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getRequestInformation,
getFulfillmentPreference,
getDefaultRequestPreferences,
isProxyFunctionalityAvailable,
} from '../../../../utils';

const basicProps = {
Expand Down Expand Up @@ -169,6 +170,7 @@ jest.mock('../../../../utils', () => ({
getRequestInformation: jest.fn((isTlr, instance, item) => {
return isTlr ? instance : item;
}),
isProxyFunctionalityAvailable: jest.fn(),
}));

describe('RequestForm', () => {
Expand Down Expand Up @@ -253,6 +255,7 @@ describe('RequestForm', () => {
};

beforeEach(() => {
isProxyFunctionalityAvailable.mockReturnValue(true);
props.findResource
.mockResolvedValueOnce(foundInstance)
.mockResolvedValueOnce(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
} from '@folio/stripes/core';

import UserForm from '../UserForm';
import { memoizeValidation } from '../../../../utils';
import {
memoizeValidation,
isProxyFunctionalityAvailable,
} from '../../../../utils';
import {
MEDIATED_REQUEST_FORM_FIELD_NAMES,
RESOURCE_KEYS,
Expand Down Expand Up @@ -170,7 +173,10 @@ class RequesterInformation extends Component {
form,
} = this.props;

onSetSelectedProxy(null);
if (isProxyFunctionalityAvailable()) {
onSetSelectedProxy(null);
}

onSetSelectedUser(null);
form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, DEFAULT_REQUEST_TYPE_VALUE);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import {
ENTER_EVENT_KEY,
BASE_SPINNER_PROPS,
} from '../../../../constants';
import { isProxyFunctionalityAvailable } from '../../../../utils';

jest.mock('../../../../utils', () => ({
...jest.requireActual('../../../../utils'),
memoizeValidation: (fn) => () => fn,
isProxyFunctionalityAvailable: jest.fn(),
}));
jest.mock('../UserForm', () => jest.fn(() => <div />));

Expand Down Expand Up @@ -391,6 +393,18 @@ describe('RequesterInformation', () => {
describe('handleBlur', () => {
const onBlur = jest.fn();

it('should reset proxy if proxy functionality is available', () => {
isProxyFunctionalityAvailable.mockReturnValueOnce(true);
renderRequesterInfoWithBarcode(onBlur);

const requesterBarcodeField = screen.getByTestId(testIds.requesterBarcodeField);

fireEvent.click(requesterBarcodeField);
fireEvent.blur(requesterBarcodeField);

expect(basicProps.onSetSelectedProxy).toHaveBeenCalledWith(null);
});

it('should trigger "input.onBlur" if requester barcode is presented', () => {
renderRequesterInfoWithBarcode(onBlur);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import {
getRequesterName,
getProxyInformation,
isProxyFunctionalityAvailable,
} from '../../../../utils';
import UserHighlightBox from '../UserHighlightBox';

Expand All @@ -23,7 +24,7 @@ const UserDetail = ({
const id = user?.id ?? request.requesterId;
const name = getRequesterName(user);
const proxyInformation = getProxyInformation(proxy, request.proxyUserId);
const proxySection = proxyInformation.id ?
const proxySection = (isProxyFunctionalityAvailable() && proxyInformation.id) ?
<UserHighlightBox
title={<FormattedMessage id="ui-requests-mediated.requesterDetails.proxy" />}
name={proxyInformation.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const proxy = {
jest.mock('../../../../utils', () => ({
getRequesterName: jest.fn((user) => user.lastName),
getProxyInformation: jest.fn(() => proxy),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));
jest.mock('../UserHighlightBox', () => jest.fn(({
title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import UserHighlightBox from '../UserHighlightBox';
import {
getProxyInformation,
getRequesterName,
isProxyFunctionalityAvailable,
} from '../../../../utils';

const UserForm = ({
Expand All @@ -31,15 +32,16 @@ const UserForm = ({
const name = getRequesterName(user);
const ConnectedProxyManager = useMemo(() => stripes.connect(ProxyManager), [stripes]);
const proxyInformation = getProxyInformation(proxy, request?.proxyUserId);
const isProxyManagerAvailable = !isEditMode || (!isUserPreselected && isEditPermission);
const isProxyAvailable = isProxyFunctionalityAvailable();
const isProxyManagerAvailable = (!isEditMode || (!isUserPreselected && isEditPermission)) && isProxyAvailable;
const userSection =
<UserHighlightBox
title={<FormattedMessage id="ui-requests-mediated.requesterDetails.requester" />}
name={name}
id={user.id}
barcode={user.barcode}
/>;
const proxySection = proxyInformation.id ?
const proxySection = (isProxyAvailable && proxyInformation.id) ?
<UserHighlightBox
title={<FormattedMessage id="ui-requests-mediated.requesterDetails.proxy" />}
name={proxyInformation.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const labelIds = {
jest.mock('../../../../utils', () => ({
getProxyInformation: jest.fn(() => proxy),
getRequesterName: jest.fn((user) => user.lastName),
isProxyFunctionalityAvailable: jest.fn(() => true),
}));
jest.mock('../UserHighlightBox', () => jest.fn(({
title,
Expand Down
4 changes: 2 additions & 2 deletions src/constants/mediatedRequestsActivities.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export const REPORT_HEADERS = [
'fulfillmentPreference',
'pickupServicePoint.name',
'deliveryAddress',
'proxy.name',
'proxy.barcode',
'patronComments',
];

export const IS_PROXY_AVAILABLE = false;
5 changes: 4 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
REQUEST_PARAMS,
USER_NAMES,
STAFF_SLIPS_TYPE,
IS_PROXY_AVAILABLE,
} from './constants';

export const transformRequestFilterOptions = (formatMessage, source = []) => (
Expand Down Expand Up @@ -337,7 +338,7 @@ export const modifyRecordsToExport = (records) => {
instance.contributorNames = '';
}

if (proxy) {
if (isProxyFunctionalityAvailable() && proxy) {

Check failure on line 341 in src/utils.js

View workflow job for this annotation

GitHub Actions / build-npm

'isProxyFunctionalityAvailable' was used before it was defined

Check failure on line 341 in src/utils.js

View workflow job for this annotation

GitHub Actions / build-npm

'isProxyFunctionalityAvailable' was used before it was defined
proxy.name = getFullNameForCsvRecords(proxy);
}

Expand Down Expand Up @@ -517,3 +518,5 @@ export const convertToSlipData = (source, intl, timeZone, locale) => {

return slipData;
};

export const isProxyFunctionalityAvailable = () => IS_PROXY_AVAILABLE;
7 changes: 2 additions & 5 deletions src/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ import {
buildTemplate,
shouldProcessNode,
buildLocaleDateAndTime,
convertToSlipData, processNode,
convertToSlipData,
processNode,
} from './utils';
import {
FULFILMENT_TYPES,
Expand Down Expand Up @@ -931,10 +932,6 @@ describe('utils', () => {
...records[0].instance,
contributorNames: records[0].instance.contributorNames[0].name,
},
proxy: {
...records[0].proxy,
name: records[0].proxy.lastName,
},
requester: {
...records[0].requester,
name: records[0].requester.lastName,
Expand Down
16 changes: 8 additions & 8 deletions translations/ui-requests-mediated/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"filters.mediatedRequestStatus.accordionTitle": "Mediated request status",
"filters.mediatedRequestLevel.accordionTitle": "Mediated request level",
"filters.mediatedRequestLevel.item": "Item",
"filters.mediatedRequestLevel.title": "Title",
"filters.mediatedRequestLevel.title": "Tytuł",
"form.tlrCheckboxLabel": "Create title level request",
"form.enterButton": "Enter",
"form.cancelButton": "Anuluj",
Expand Down Expand Up @@ -37,7 +37,7 @@
"form.errors.userDoesNotExist": "User with this barcode does not exist",
"itemDetails.barcode": "Item barcode",
"itemDetails.id": "Item id",
"itemDetails.title": "Title",
"itemDetails.title": "Tytuł",
"itemDetails.contributor": "Contributor",
"itemDetails.effectiveLocation": "Effective location",
"itemDetails.callNumber": "Aktualna sygnatura całkowita",
Expand All @@ -52,7 +52,7 @@
"itemsDialog.instanceItems": "Other items in {title}",
"itemsDialog.noItems": "No items found",
"itemsDialog.resultCount": "{count, number} {count, plural, one {Record found} other {Records found}}",
"instanceDetails.title": "Title",
"instanceDetails.title": "Tytuł",
"instanceDetails.contributor": "Contributor",
"instanceDetails.publicationDate": "Publication date",
"instanceDetails.edition": "Edition",
Expand All @@ -64,7 +64,7 @@
"item.status.awaitingDelivery": "Awaiting delivery",
"item.status.awaitingPickup": "Awaiting pickup",
"item.status.checkedOut": "Checked out",
"item.status.claimedReturned": "Claimed returned",
"item.status.claimedReturned": "Zapewniony że zwrócony",
"item.status.declaredLost": "Declared lost",
"item.status.inProcess": "In process",
"item.status.inProcessNonRequestable": "In process (non-requestable)",
Expand All @@ -85,7 +85,7 @@
"item.status.orderClosed": "Order closed",
"item.status.restricted": "Restricted",
"mediatedRequestList.columnName.mediatedRequestDate": "Mediated request date",
"mediatedRequestList.columnName.title": "Title",
"mediatedRequestList.columnName.title": "Tytuł",
"mediatedRequestList.columnName.itemBarcode": "Item barcode",
"mediatedRequestList.columnName.effectiveCallNumber": "Aktualna sygnatura całkowita",
"mediatedRequestList.columnName.mediatedRequestStatus": "Mediated request status",
Expand Down Expand Up @@ -124,7 +124,7 @@
"requesterDetails.pickupServicePoint": "Pickup service point",
"requesterDetails.fulfillmentPreference": "Fulfillment preference",
"mediatedRequestInformation.level.item": "Item",
"mediatedRequestInformation.level.title": "Title",
"mediatedRequestInformation.level.title": "Tytuł",
"mediatedRequestInformation.requestType": "Mediated request type",
"mediatedRequestInformation.status": "Mediated request status",
"mediatedRequestInformation.level": "Mediated request level",
Expand Down Expand Up @@ -156,7 +156,7 @@
"report.status": "Mediated request status",
"report.requestDate": "Mediated request date",
"report.item.barcode": "Item barcode",
"report.instance.title": "Title",
"report.instance.title": "Tytuł",
"report.instance.contributorNames": "Contributor",
"report.item.location.libraryName": "Library",
"report.item.callNumberComponents.prefix": "Effective call number prefix",
Expand Down Expand Up @@ -191,7 +191,7 @@
"confirmItem.errorModal.close": "Close",
"confirmItemList.columnName.arrivalDate": "Arrival date",
"confirmItemList.columnName.inTransitDate": "In transit date",
"confirmItemList.columnName.title": "Title",
"confirmItemList.columnName.title": "Tytuł",
"confirmItemList.columnName.itemBarcode": "Item barcode",
"confirmItemList.columnName.effectiveCallNumber": "Aktualna sygnatura całkowita",
"confirmItemList.columnName.mediatedRequestStatus": "Mediated request status",
Expand Down
2 changes: 1 addition & 1 deletion translations/ui-requests-mediated/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
"form.create.title": "Nova requisição mediada",
"form.edit.title": "Editar requisição mediada",
"form.createRequest.error": "A requisição não foi criada com sucesso",
"declineModal.title": "Confirmar recusa de solicitação mediada",
"declineModal.title": "Confirmar recusa de requisição mediada",
"declineModal.message": "<b>{title}</b> será <b>recusado</b>",
"declineModal.confirm": "Confirmar",
"declineModal.back": "Voltar"
Expand Down

0 comments on commit 30d67e6

Please sign in to comment.