Skip to content

Commit

Permalink
UIBULKED-404: fix merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin committed Feb 14, 2024
1 parent 50e9337 commit 73f9b69
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
15 changes: 10 additions & 5 deletions src/components/BulkEditActionMenu/BulkEditActionMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
BULK_VISIBLE_COLUMNS,
FILE_SEARCH_PARAMS,
FILE_TO_LINK,
CRITERIA,
} from '../../constants';
import {
useBulkPermissions,
Expand All @@ -43,8 +44,12 @@ const BulkEditActionMenu = ({
const perms = useBulkPermissions();
const search = new URLSearchParams(location.search);
const capability = search.get('capabilities');
const criteria = search.get('criteria');
const queryRecordType = search.get('queryRecordType');
const step = search.get('step');

const key = criteria === CRITERIA.QUERY ? queryRecordType : capability;

const [columnSearch, setColumnSearch] = useState('');

const {
Expand All @@ -60,10 +65,10 @@ const BulkEditActionMenu = ({

const [fileInfo, setFileInfo] = useState(null);

const hasEditPerm = (hasHoldingsInventoryEdit && capability === CAPABILITIES.HOLDING)
|| (hasItemInventoryEdit && capability === CAPABILITIES.ITEM)
|| (hasUserEditInAppPerm && capability === CAPABILITIES.USER)
|| (hasInstanceInventoryEdit && capability === CAPABILITIES.INSTANCE);
const hasEditPerm = (hasHoldingsInventoryEdit && key === CAPABILITIES.HOLDING)
|| (hasItemInventoryEdit && key === CAPABILITIES.ITEM)
|| (hasUserEditInAppPerm && key === CAPABILITIES.USER)
|| (hasInstanceInventoryEdit && key === CAPABILITIES.INSTANCE);


useFileDownload({
Expand Down Expand Up @@ -96,7 +101,7 @@ const BulkEditActionMenu = ({

const columnsOptions = columns.map(item => ({
...item,
label: item.ignoreTranslation ? item.label : intl.formatMessage({ id: `ui-bulk-edit.columns.${capability}.${item.label}` }),
label: item.ignoreTranslation ? item.label : intl.formatMessage({ id: `ui-bulk-edit.columns.${key}.${item.label}` }),
disabled: isLastUnselectedColumn(item.value) || !countOfRecords,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BulkEditInAppTitle } from './BulkEditInAppTitle/BulkEditInAppTitle';
import { ContentUpdatesForm } from './ContentUpdatesForm/ContentUpdatesForm';
import {
CAPABILITIES,
CRITERIA,
getHoldingsOptions,
getInstanceOptions,
getItemsOptions,
Expand All @@ -29,6 +30,9 @@ export const BulkEditInApp = ({
const intl = useIntl();
const location = useLocation();
const search = new URLSearchParams(location.search);
const criteria = search.get('criteria');
const queryRecordType = search.get('queryRecordType');
const key = criteria === CRITERIA.QUERY ? queryRecordType : capabilities;

const fileUploadedName = search.get('fileName');
const isItemCapability = capabilities === CAPABILITIES.ITEM;
Expand All @@ -44,7 +48,7 @@ export const BulkEditInApp = ({
[CAPABILITIES.INSTANCE]: getInstanceOptions(intl.formatMessage),
};

const options = optionsMap[capabilities];
const options = optionsMap[key];
const showContentUpdatesForm = options && !isItemNotesLoading && !isHoldingsNotesLoading;
const sortedOptions = sortAlphabetically(options, intl.formatMessage({ id:'ui-bulk-edit.options.placeholder' }));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { useLocation } from 'react-router-dom';
import PropTypes from 'prop-types';

import {
Headline,
AccordionStatus,
MessageBanner,
} from '@folio/stripes/components';
import PropTypes from 'prop-types';
import { useLocation } from 'react-router-dom';
import React from 'react';

import css from './Preview.css';
import { PreviewAccordion } from './PreviewAccordion';
import { ErrorsAccordion } from './ErrorsAccordion';
Expand All @@ -15,7 +17,6 @@ import {
useErrorsPreview,
useRecordsPreview
} from '../../../../hooks/api';

import {
CRITERIA,
EDITING_STEPS,
Expand All @@ -30,6 +31,7 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
const search = new URLSearchParams(location.search);
const step = search.get('step');
const capabilities = search.get('capabilities');
const queryRecordType = search.get('queryRecordType');
const criteria = search.get('criteria');

const totalRecords = step === EDITING_STEPS.COMMIT ? bulkDetails?.processedNumOfRecords : bulkDetails?.matchedNumOfRecords;
Expand All @@ -51,6 +53,8 @@ export const Preview = ({ id, title, isInitial, bulkDetails }) => {
id,
step,
capabilities,
criteria,
queryRecordType,
...pagination,
});

Expand Down
4 changes: 4 additions & 0 deletions src/hooks/api/useRecordsPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const useRecordsPreview = ({
capabilities,
limit,
offset,
criteria,
queryRecordType
}) => {
const intl = useIntl();
const { setVisibleColumns } = useContext(RootContext);
Expand All @@ -40,6 +42,8 @@ export const useRecordsPreview = ({
data,
intl,
capabilities,
criteria,
queryRecordType
}), [data]);

// set initial and visible columns
Expand Down
9 changes: 6 additions & 3 deletions src/utils/mappers/mappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {

import {
CAPABILITIES,
CRITERIA,
CUSTOM_ENTITY_COLUMNS,
} from '../../constants';
import {
Expand Down Expand Up @@ -44,7 +45,7 @@ const formatData = ({ capability, column, data }) => {
}
};

export const getMappedTableData = ({ data, capabilities, intl }) => {
export const getMappedTableData = ({ data, capabilities, criteria, queryRecordType, intl }) => {
if (!data) {
return {
contentData: null,
Expand All @@ -53,6 +54,8 @@ export const getMappedTableData = ({ data, capabilities, intl }) => {
};
}

const key = criteria === CRITERIA.QUERY ? queryRecordType : capabilities;

const columns = data.header.map((cell) => ({
label: cell.value,
value: cell.value,
Expand All @@ -63,7 +66,7 @@ export const getMappedTableData = ({ data, capabilities, intl }) => {
}));

const columnMapping = columns.reduce((acc, { value, label, ignoreTranslation }) => {
acc[value] = ignoreTranslation ? value : intl.formatMessage({ id: `ui-bulk-edit.columns.${capabilities}.${label}` });
acc[value] = ignoreTranslation ? value : intl.formatMessage({ id: `ui-bulk-edit.columns.${key}.${label}` });

return acc;
}, {});
Expand All @@ -74,7 +77,7 @@ export const getMappedTableData = ({ data, capabilities, intl }) => {

acc[column.value] = formatData({
column,
capability: capabilities,
capability: key,
data: item,
});

Expand Down

0 comments on commit 73f9b69

Please sign in to comment.