-
Notifications
You must be signed in to change notification settings - Fork 18
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
Changes from 1 commit
206be77
e939a79
575f064
f7e643a
5f33597
23f0456
8e76340
e9024df
e5cebd6
685ebae
e1a9baa
9e202b8
391442e
657d272
3592bab
beec654
65fbd3e
d2728a4
0bf7177
2702209
00644eb
2f1cab6
a1320ae
1eb29eb
8381957
29c9b5c
ea9eccf
b0a16b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Added call number generator button to Holdings form, tweaks to settings
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -115,6 +117,9 @@ class HoldingsForm extends React.Component { | |
}), | ||
goTo: PropTypes.func.isRequired, | ||
httpError: PropTypes.object, | ||
configs: PropTypes.shape({ | ||
callNumberGeneratorSettingHoldings: PropTypes.string | ||
}) | ||
}; | ||
|
||
static defaultProps = { | ||
|
@@ -189,6 +194,8 @@ class HoldingsForm extends React.Component { | |
|
||
render() { | ||
const { | ||
configs, | ||
form: { change }, | ||
onCancel, | ||
initialValues, | ||
instance, | ||
|
@@ -225,6 +232,10 @@ class HoldingsForm extends React.Component { | |
}), | ||
) : []; | ||
|
||
const { | ||
callNumberGeneratorSettingHoldings, | ||
} = configs; | ||
|
||
const holdingsTypeOptions = referenceTables.holdingsTypes ? referenceTables.holdingsTypes.map( | ||
it => ({ | ||
label: it.name, | ||
|
@@ -538,15 +549,37 @@ 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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So currently |
||
<Field | ||
label={<FormattedMessage id="ui-inventory.callNumber" />} | ||
name="callNumber" | ||
id="additem_callnumber" | ||
component={TextArea} | ||
rows={1} | ||
fullWidth | ||
disabled={this.isFieldBlocked('callNumber') || callNumberGeneratorSettingHoldings === 'useGenerator'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move |
||
/> | ||
</Row> | ||
<Row> | ||
{( | ||
callNumberGeneratorSettingHoldings === 'useGenerator' || | ||
callNumberGeneratorSettingHoldings === 'useBoth' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And |
||
) && | ||
<Col xs={12}> | ||
<NumberGeneratorModalButton | ||
buttonLabel={<FormattedMessage id="ui-inventory.numberGenerator.generateCallNumber" />} | ||
callback={(generated) => change('callNumber', generated)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this to a separate func |
||
fullWidth | ||
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 | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,5 @@ | ||||||
import { FormattedMessage } from 'react-intl'; | ||||||
import { Layout, MessageBanner } from '@folio/stripes-components'; | ||||||
import { Layout } from '@folio/stripes-components'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { NumberGeneratorModalButton } from '@folio/service-interaction'; | ||||||
|
||||||
// Moving this to a separate utility method so we can declutter this work | ||||||
|
@@ -8,27 +8,27 @@ import { NumberGeneratorModalButton } from '@folio/service-interaction'; | |||||
// `useForm` and `useConfigurationQuery` to get these parameters. | ||||||
const getNumberGeneratorModals = (configs, change) => { | ||||||
const { | ||||||
accessionNumberGeneratorSetting, | ||||||
barcodeGeneratorSetting, | ||||||
callNumberGeneratorSetting, | ||||||
useAccessionNumberForCallNumber | ||||||
accessionNumberGeneratorSettingItems, | ||||||
barcodeGeneratorSettingItems, | ||||||
callNumberGeneratorSettingItems, | ||||||
useAccessionNumberForCallNumberItems | ||||||
} = configs; | ||||||
|
||||||
const accessionNumberGeneratorActive = accessionNumberGeneratorSetting === 'useGenerator' || | ||||||
accessionNumberGeneratorSetting === 'useBoth'; | ||||||
const accessionNumberGeneratorActive = accessionNumberGeneratorSettingItems === 'useGenerator' || | ||||||
accessionNumberGeneratorSettingItems === 'useBoth'; | ||||||
|
||||||
const barcodeGeneratorActive = barcodeGeneratorSetting === 'useGenerator' || | ||||||
barcodeGeneratorSetting === 'useBoth'; | ||||||
const barcodeGeneratorActive = barcodeGeneratorSettingItems === 'useGenerator' || | ||||||
barcodeGeneratorSettingItems === 'useBoth'; | ||||||
|
||||||
const callNumberGeneratorActive = callNumberGeneratorSetting === 'useGenerator' || | ||||||
callNumberGeneratorSetting === 'useBoth'; | ||||||
const callNumberGeneratorActive = callNumberGeneratorSettingItems === 'useGenerator' || | ||||||
callNumberGeneratorSettingItems === 'useBoth'; | ||||||
|
||||||
const disableAccessionNumberField = accessionNumberGeneratorSetting === 'useGenerator'; | ||||||
const disableBarcodeField = barcodeGeneratorSetting === 'useGenerator'; | ||||||
const disableCallNumberField = callNumberGeneratorSetting === 'useGenerator'; | ||||||
const disableAccessionNumberField = accessionNumberGeneratorSettingItems === 'useGenerator'; | ||||||
const disableBarcodeField = barcodeGeneratorSettingItems === 'useGenerator'; | ||||||
const disableCallNumberField = callNumberGeneratorSettingItems === 'useGenerator'; | ||||||
|
||||||
// This is to ensure that if the field somehow _did_ get set when it's not supposed to, we ignore it | ||||||
const useJointModal = useAccessionNumberForCallNumber && accessionNumberGeneratorActive && callNumberGeneratorActive; | ||||||
const useJointModal = useAccessionNumberForCallNumberItems && accessionNumberGeneratorActive && callNumberGeneratorActive; | ||||||
|
||||||
// Don't worry about calling logic in here, do that in renderAccession... and renderCall... | ||||||
const renderJointNumberGenerator = () => ( | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, cover this component with unit tests |
There was a problem hiding this comment.
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.