From ee430f2b4116a898e52b9aa2aafa842171d44375 Mon Sep 17 00:00:00 2001 From: Oleksandr Hladchenko1 Date: Fri, 6 Dec 2024 12:05:27 +0100 Subject: [PATCH] UIDATIMP-1689: Populate 'Existing records' field when create match profile --- CHANGELOG.md | 1 + src/settings/MatchProfiles/MatchProfiles.js | 51 +++++++++------------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3612692b4..828c3156c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/settings/MatchProfiles/MatchProfiles.js b/src/settings/MatchProfiles/MatchProfiles.js index fc4ba3b1d..5f2c92375 100644 --- a/src/settings/MatchProfiles/MatchProfiles.js +++ b/src/settings/MatchProfiles/MatchProfiles.js @@ -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'; @@ -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) => {