Skip to content

Commit

Permalink
UIDATIMP-1689: Populate 'Existing records' field when create match pr…
Browse files Browse the repository at this point in the history
…ofile
  • Loading branch information
OleksandrHladchenko1 committed Dec 6, 2024
1 parent 9ae7e0b commit ee430f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Allow central tenant to create action profile for Orders and Invoices. (UIDATIMP-1679)
* Allow central tenant to create filed mapping profile for Orders and Invoices. (UIDATIMP-1685)
* Replace `_/proxy/tenants/${tenant}/modules` with `stripes.discovery.modules` object. (UIDATIMP-1686)
* Populate "Existing records" field when create match profile. (UIDATIMP-1689)

## [8.0.2](https://github.com/folio-org/ui-data-import/tree/v8.0.2) (2024-11-21)

Expand Down
51 changes: 22 additions & 29 deletions src/settings/MatchProfiles/MatchProfiles.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import {
isEqual,
isEmpty,
} from 'lodash';

import { stripesConnect } from '@folio/stripes/core';
import { makeQueryFunction } from '@folio/stripes/smart-components';
Expand Down Expand Up @@ -297,34 +293,31 @@ export class MatchProfiles extends Component {
identifierTypes: [],
};

async componentDidUpdate(prevProps) {
if (!isEqual(prevProps.stripes.discovery.modules, this.props.stripes.discovery.modules)
&& !isEmpty(this.props.stripes.discovery.modules)) {
const {
stripes,
stripes: { okapi },
stripes: { discovery: { modules } },
} = this.props;
async componentDidMount() {
const {
stripes,
stripes: { okapi },
stripes: { discovery: { modules } },
} = this.props;

const inventoryModuleVersion = getModuleVersion(modules, 'Inventory Storage Module');
const ordersModuleVersion = getModuleVersion(modules, 'Orders Business Logic Module');
const invoiceModuleVersion = getModuleVersion(modules, 'Invoice business logic module');
const inventoryModuleVersion = getModuleVersion(modules, 'Inventory Storage Module');
const ordersModuleVersion = getModuleVersion(modules, 'Orders Business Logic Module');
const invoiceModuleVersion = getModuleVersion(modules, 'Invoice business logic module');

const requestsToInstance = INSTANCE_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToHoldings = HOLDINGS_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToItem = ITEM_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToInvoice = INVOICE_RESOURCE_PATHS.map(path => fetchJsonSchema(path, invoiceModuleVersion, okapi));
const requestToAcquisitionsData = ACQ_DATA_RESOURCE_PATHS.map(path => fetchJsonSchema(path, ordersModuleVersion, okapi));
const requestsToInstance = INSTANCE_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToHoldings = HOLDINGS_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToItem = ITEM_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToInvoice = INVOICE_RESOURCE_PATHS.map(path => fetchJsonSchema(path, invoiceModuleVersion, okapi));
const requestToAcquisitionsData = ACQ_DATA_RESOURCE_PATHS.map(path => fetchJsonSchema(path, ordersModuleVersion, okapi));

await handleAllRequests(requestsToInstance, 'INSTANCE', this.addToState);
await handleAllRequests(requestsToHoldings, 'HOLDINGS', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'HOLDINGS', this.addToState);
await handleAllRequests(requestsToItem, 'ITEM', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'INSTANCE', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'ITEM', this.addToState);
await handleAllRequests(requestsToInvoice, 'INVOICE', this.addToState);
await getIdentifierTypes(stripes).then(identifierTypes => this.setState({ identifierTypes }));
}
await handleAllRequests(requestsToInstance, 'INSTANCE', this.addToState);
await handleAllRequests(requestsToHoldings, 'HOLDINGS', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'HOLDINGS', this.addToState);
await handleAllRequests(requestsToItem, 'ITEM', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'INSTANCE', this.addToState);
await handleAllRequests(requestToAcquisitionsData, 'ITEM', this.addToState);
await handleAllRequests(requestsToInvoice, 'INVOICE', this.addToState);
await getIdentifierTypes(stripes).then(identifierTypes => this.setState({ identifierTypes }));
}

addToState = (properties, stateKey) => {
Expand Down

0 comments on commit ee430f2

Please sign in to comment.