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

UIIN-2546/UIIN-2548/UIIN-2549/UIIN-2556/UIIN-2557 Number generator implementation #2408

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
206be77
feat: Number Generator (Settings)
EthanFreestone Mar 3, 2023
e939a79
feat: Wired up settings to ItemForm
EthanFreestone Mar 10, 2023
575f064
feat: ItemForm
EthanFreestone Mar 10, 2023
f7e643a
refactor: Tweaks
EthanFreestone Mar 23, 2023
5f33597
chore: Translation
EthanFreestone Mar 23, 2023
23f0456
feat: Safety
EthanFreestone Mar 23, 2023
8e76340
style: Grey out disabled radio buttons
EthanFreestone Mar 23, 2023
e9024df
chore: Slight tweaks
EthanFreestone Apr 21, 2023
e5cebd6
feat: Styling tweaks
EthanFreestone May 11, 2023
685ebae
style: Padding
EthanFreestone May 11, 2023
e1a9baa
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Jun 20, 2023
9e202b8
build: OptionalOkapiInterfaces
EthanFreestone Jun 20, 2023
391442e
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Aug 7, 2023
657d272
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Aug 21, 2023
3592bab
feat: Holdings
EthanFreestone Sep 1, 2023
beec654
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Sep 1, 2023
65fbd3e
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Sep 13, 2023
d2728a4
chore: Button UX
EthanFreestone Sep 29, 2023
0bf7177
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Sep 29, 2023
2702209
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Oct 23, 2023
00644eb
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Dec 8, 2023
2f1cab6
refactor: Settings order
EthanFreestone Mar 1, 2024
a1320ae
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Mar 1, 2024
1eb29eb
chore: Linting and test fixes
EthanFreestone Mar 1, 2024
8381957
test: More tests and mocks to try and push PR through
EthanFreestone Mar 1, 2024
29c9b5c
Merge branch 'master' of github.com:folio-org/ui-inventory into feat/…
EthanFreestone Mar 7, 2024
ea9eccf
build: Change service interaction dependency to ^3.0.0
EthanFreestone Mar 28, 2024
b0a16b6
chore: Removed "Learn more" button
EthanFreestone Jun 18, 2024
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
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"orders.holding-summary": "1.0",
"order-lines": "2.0 3.0",
"organizations.organizations": "1.0",
"servint": "2.0 3.0",
"pieces": "3.0",
"titles": "1.2"
},
Expand Down Expand Up @@ -484,6 +485,14 @@
],
"visible": true
},
{
"permissionName": "ui-inventory.settings.numberGenerator.manage",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the new permission to translations as well

"displayName": "Settings (Inventory): Manage number generator options",
"subPermissions": [
"settings.users.enabled"
],
"visible": true
},
{
"permissionName": "ui-inventory.instance.view",
"displayName": "Inventory: View instances, holdings, and items",
Expand Down Expand Up @@ -868,6 +877,7 @@
"@babel/preset-react": "^7.9.0",
"@folio/eslint-config-stripes": "^7.0.0",
"@folio/jest-config-stripes": "^2.0.0",
"@folio/service-interaction": "^3.0.0",
"@folio/stripes": "^9.0.0",
"@folio/stripes-cli": "^3.0.0",
"@folio/stripes-components": "^12.0.0",
Expand Down Expand Up @@ -915,6 +925,7 @@
"use-session-storage-state": "^18.2.0"
},
"peerDependencies": {
"@folio/service-interaction": "^3.0.0",
"@folio/stripes": "^9.0.0",
"@folio/stripes-marc-components": "^1.0.0",
"react": "^18.2.0",
Expand Down
5 changes: 4 additions & 1 deletion src/Holding/CreateHolding/CreateHolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { LoadingView } from '@folio/stripes/components';

import { useInstance } from '../../common/hooks';
import { useCallout } from '../../hooks';
import { useCallout, useConfigurationQuery } from '../../hooks';
import HoldingsForm from '../../edit/holdings/HoldingsForm';
import { switchAffiliation } from '../../utils';

Expand All @@ -26,6 +26,8 @@ const CreateHolding = ({
mutator,
}) => {
const callout = useCallout();
const { configs } = useConfigurationQuery('number_generator');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move number_generator to constants, please, I see this is used in several places.


const { instance, isLoading: isInstanceLoading } = useInstance(instanceId);
const sourceId = referenceData.holdingsSourcesByName?.FOLIO?.id;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;
Expand Down Expand Up @@ -65,6 +67,7 @@ const CreateHolding = ({

return (
<HoldingsForm
configs={configs}
form={instance.id}
id={instance.id}
initialValues={initialValues}
Expand Down
1 change: 1 addition & 0 deletions src/Holding/CreateHolding/CreateHolding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CreateHolding from './CreateHolding';
jest.mock('../../hooks', () => ({
...jest.requireActual('../../hooks'),
useCallout: () => ({ sendCallout: jest.fn() }),
useConfigurationQuery: () => ({ configs: {} })
}));

jest.mock('../../common/hooks', () => ({
Expand Down
6 changes: 5 additions & 1 deletion src/Holding/EditHolding/EditHolding.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '../../common/hooks';
import {
useCallout,
useConfigurationQuery,
useHoldingItemsQuery,
useHoldingMutation,
} from '../../hooks';
Expand All @@ -31,13 +32,16 @@ const EditHolding = ({
referenceTables,
}) => {
const callout = useCallout();
const { configs } = useConfigurationQuery('number_generator');

const {
search,
state: {
backPathname: locationState,
tenantFrom,
} = {},
} = location;

const stripes = useStripes();
const [httpError, setHttpError] = useState();
const { instance, isLoading: isInstanceLoading } = useInstanceQuery(instanceId);
Expand All @@ -46,7 +50,6 @@ const EditHolding = ({
searchParams: { limit: 1 },
});


const isMARCRecord = useMemo(() => (
referenceTables?.holdingsSources?.find(source => source.id === holding?.sourceId)?.name === 'MARC'
), [holding]);
Expand Down Expand Up @@ -95,6 +98,7 @@ const EditHolding = ({
return (
<>
<HoldingsForm
configs={configs}
httpError={httpError}
location={location}
initialValues={holding}
Expand Down
1 change: 1 addition & 0 deletions src/Holding/EditHolding/EditHolding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jest.mock('../../edit/holdings/HoldingsForm', () => jest.fn().mockReturnValue('H
jest.mock('../../hooks', () => ({
...jest.requireActual('../../hooks'),
useCallout: () => jest.fn().mockReturnValue({ sendCallout: jest.fn() }),
useConfigurationQuery: () => ({ configs: {} }),
useHoldingItemsQuery: jest.fn().mockReturnValue({ totalRecords: 1, isLoading: false }),
useHoldingMutation: jest.fn().mockReturnValue({ mutateHolding: jest.fn() }),
}));
Expand Down
4 changes: 3 additions & 1 deletion src/Item/CreateItem/CreateItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
useHolding,
} from '../../common';
import ItemForm from '../../edit/items/ItemForm';
import useCallout from '../../hooks/useCallout';
import { useItemMutation } from '../hooks';
import { useCallout, useConfigurationQuery } from '../../hooks';
import { switchAffiliation } from '../../utils';

const CreateItem = ({
Expand All @@ -38,6 +38,7 @@ const CreateItem = ({
const { isLoading: isHoldingLoading, holding } = useHolding(holdingId, { tenantId: tenantTo });
const callout = useCallout();
const stripes = useStripes();
const { configs } = useConfigurationQuery('number_generator');

const initialValues = useMemo(() => ({
status: { name: 'Available' },
Expand Down Expand Up @@ -79,6 +80,7 @@ const CreateItem = ({

return (
<ItemForm
configs={configs}
form={`itemform_${holding.id}`}
id={holding.id}
key={holding.id}
Expand Down
8 changes: 7 additions & 1 deletion src/Item/CreateItem/CreateItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
import CreateItem from './CreateItem';

jest.mock('../../edit/items/ItemForm', () => jest.fn().mockReturnValue('ItemForm'));
jest.mock('../../hooks/useCallout', () => jest.fn().mockReturnValue({ sendCallout: jest.fn() }));

jest.mock('../../hooks', () => ({
...jest.requireActual('../../hooks'),
useCallout: () => jest.fn().mockReturnValue({ sendCallout: jest.fn() }),
useConfigurationQuery: () => ({ configs: {} }),
}));

jest.mock('../../common/hooks', () => ({
...jest.requireActual('../../common/hooks'),
useInstanceQuery: jest.fn().mockReturnValue({ instance: {}, isLoading: false }),
Expand Down
4 changes: 3 additions & 1 deletion src/Item/EditItem/EditItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import {
useHolding,
} from '../../common';
import ItemForm from '../../edit/items/ItemForm';
import useCallout from '../../hooks/useCallout';
import { parseHttpError, switchAffiliation } from '../../utils';
import {
useItem,
useItemMutation,
useBoundWithsMutation,
} from '../hooks';
import { useCallout, useConfigurationQuery } from '../../hooks';

const EditItem = ({
referenceData,
Expand All @@ -39,6 +39,7 @@ const EditItem = ({
const { isLoading: isItemLoading, item } = useItem(itemId);
const callout = useCallout();
const stripes = useStripes();
const { configs } = useConfigurationQuery('number_generator');

const goBack = useCallback(() => {
history.push({
Expand Down Expand Up @@ -114,6 +115,7 @@ const EditItem = ({
return (
<>
<ItemForm
configs={configs}
httpError={httpError}
form={`itemform_${holding.id}`}
id={holding.id}
Expand Down
7 changes: 6 additions & 1 deletion src/Item/EditItem/EditItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import EditItem from './EditItem';
import ItemForm from '../../edit/items/ItemForm';

jest.mock('../../edit/items/ItemForm', () => jest.fn().mockReturnValue('ItemForm'));
jest.mock('../../hooks/useCallout', () => jest.fn().mockReturnValue({ sendCallout: jest.fn() }));
jest.mock('../../hooks', () => ({
...jest.requireActual('../../hooks'),
useCallout: () => jest.fn().mockReturnValue({ sendCallout: jest.fn() }),
useConfigurationQuery: () => ({ configs: {} }),
}));

jest.mock('../../common/hooks', () => ({
...jest.requireActual('../../common/hooks'),
useInstanceQuery: jest.fn().mockReturnValue({ instance: {}, isLoading: false }),
Expand Down
50 changes: 41 additions & 9 deletions src/edit/holdings/HoldingsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { ViewMetaData } from '@folio/stripes/smart-components';

import stripesFinalForm from '@folio/stripes/final-form';

import { NumberGeneratorModalButton } from '@folio/service-interaction';

import OptimisticLockingBanner from '../../components/OptimisticLockingBanner';
import ElectronicAccessFields from '../electronicAccessFields';
import { handleKeyCommand, validateOptionalField } from '../../utils';
Expand Down Expand Up @@ -115,6 +117,9 @@ class HoldingsForm extends React.Component {
}),
goTo: PropTypes.func.isRequired,
httpError: PropTypes.object,
configs: PropTypes.shape({
callNumberGeneratorSettingHoldings: PropTypes.string
})
};

static defaultProps = {
Expand Down Expand Up @@ -189,6 +194,8 @@ class HoldingsForm extends React.Component {

render() {
const {
configs,
form: { change },
onCancel,
initialValues,
instance,
Expand Down Expand Up @@ -225,6 +232,10 @@ class HoldingsForm extends React.Component {
}),
) : [];

const {
callNumberGeneratorSettingHoldings,
} = configs;

const holdingsTypeOptions = referenceTables.holdingsTypes ? referenceTables.holdingsTypes.map(
it => ({
label: it.name,
Expand Down Expand Up @@ -538,15 +549,36 @@ class HoldingsForm extends React.Component {
/>
</Col>
<Col sm={2}>
<Field
label={<FormattedMessage id="ui-inventory.callNumber" />}
name="callNumber"
id="additem_callnumber"
component={TextArea}
rows={1}
fullWidth
disabled={this.isFieldBlocked('callNumber')}
/>
<Row>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So currently Row is a child for Col and then there is another nested Col, is that how it was intended?

<Field
label={<FormattedMessage id="ui-inventory.callNumber" />}
name="callNumber"
id="additem_callnumber"
component={TextArea}
rows={1}
fullWidth
disabled={this.isFieldBlocked('callNumber') || callNumberGeneratorSettingHoldings === 'useGenerator'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move useGenerator string to constants, please

/>
</Row>
<Row>
{(
callNumberGeneratorSettingHoldings === 'useGenerator' ||
callNumberGeneratorSettingHoldings === 'useBoth'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And useBoth also

) &&
<Col xs={12}>
<NumberGeneratorModalButton
buttonLabel={<FormattedMessage id="ui-inventory.numberGenerator.generateCallNumber" />}
callback={(generated) => change('callNumber', generated)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to a separate func

id="inventoryCallNumber"
generateButtonLabel={<FormattedMessage id="ui-inventory.numberGenerator.generateCallNumber" />}
generator="inventory_callNumber"
modalProps={{
label: <FormattedMessage id="ui-inventory.numberGenerator.callNumberGenerator" />
}}
/>
</Col>
}
</Row>
</Col>
<Col sm={2}>
<Field
Expand Down
5 changes: 5 additions & 0 deletions src/edit/holdings/HoldingsForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { DataContext } from '../../contexts';

import HoldingsForm from './HoldingsForm';

jest.mock('@folio/service-interaction', () => ({
NumberGeneratorModalButton: () => <div>NumberGeneratorModalButton</div>
}));

jest.mock('../common', () => ({
LocationSelectionWithCheck: () => <div>LocationSelection</div>,
}));
Expand Down Expand Up @@ -76,6 +80,7 @@ const HoldingsFormSetup = (props = {}) => (
>
<HoldingsForm
initialValues={mockInitialValues}
configs={{}}
onSubmit={mockOnSubmit}
onCancel={mockOnCancel}
instance={mockInstance}
Expand Down
20 changes: 20 additions & 0 deletions src/edit/items/ItemForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import { LocationSelectionWithCheck } from '../common';
import AdministrativeNoteFields from '../administrativeNoteFields';
import styles from './ItemForm.css';
import { RemoteStorageWarning } from './RemoteStorageWarning';
import getNumberGeneratorModals from './getNumberGeneratorModals';

import {
BoundWithTitlesFields,
CirculationNotesFields,
Expand Down Expand Up @@ -197,6 +199,8 @@ class ItemForm extends React.Component {

render() {
const {
configs,
form: { change },
onCancel,
initialValues,
instance,
Expand Down Expand Up @@ -312,6 +316,15 @@ class ItemForm extends React.Component {
},
];

const {
disableAccessionNumberField,
disableBarcodeField,
disableCallNumberField,
renderAccessionNumberGenerator,
renderBarcodeGenerator,
renderCallNumberGenerator
} = getNumberGeneratorModals(configs, change);

return (
<form
data-test-item-page-type={initialValues.id ? 'edit' : 'create'}
Expand Down Expand Up @@ -437,6 +450,7 @@ class ItemForm extends React.Component {
</Col>
<Col sm={2}>
<Field
disabled={disableBarcodeField}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableBarcodeField name looks like this is a function rather, then bool, rename it to disabledBarcodeField, please

label={<FormattedMessage id="ui-inventory.barcode" />}
name="barcode"
id="additem_barcode"
Expand All @@ -445,15 +459,18 @@ class ItemForm extends React.Component {
autoFocus
fullWidth
/>
{renderBarcodeGenerator()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose one way to render the Field - using component props, or rendering children, currently, you have a component prop equal to TextField and children.

</Col>
<Col sm={2}>
<Field
disabled={disableAccessionNumberField}
label={<FormattedMessage id="ui-inventory.accessionNumber" />}
name="accessionNumber"
id="additem_accessionnumber"
component={TextField}
fullWidth
/>
{renderAccessionNumberGenerator()}
</Col>
<Col sm={2}>
<Field
Expand Down Expand Up @@ -547,13 +564,15 @@ class ItemForm extends React.Component {
</Col>
<Col sm={2}>
<Field
disabled={disableCallNumberField}
label={<FormattedMessage id="ui-inventory.callNumber" />}
name="itemLevelCallNumber"
id="additem_callnumber"
component={TextArea}
rows={1}
fullWidth
/>
{renderCallNumberGenerator()}
</Col>
<Col sm={2}>
<Field
Expand Down Expand Up @@ -852,6 +871,7 @@ class ItemForm extends React.Component {
}

ItemForm.propTypes = {
configs: PropTypes.object,
onClose: PropTypes.func, // eslint-disable-line react/no-unused-prop-types
newItem: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
handleSubmit: PropTypes.func.isRequired,
Expand Down
Loading
Loading