Skip to content

Commit

Permalink
UIQM-321 Remove deleted fields before deriving (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis authored Nov 18, 2022
1 parent 6e3954b commit 97ab28c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for ui-quick-marc

## [5.1.3](IN PROGRESS)

* [UIQM-321](https://issues.folio.org/browse/UIQM-321) Deleted fields not processing when deriving a new MARC bibliographic record

## [5.1.2](https://github.com/folio-org/ui-quick-marc/tree/v5.1.2) (2022-08-23)

* [UIQM-266](https://issues.folio.org/browse/UIQM-266) Edit quickMARC: Undoing a delete field is not restored in the same position.
Expand Down
8 changes: 5 additions & 3 deletions src/QuickMarcEditor/QuickMarcCreateWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
checkControlFieldLength,
cleanBytesFields,
parseHttpError,
removeDeletedRecords,
} from './utils';

const propTypes = {
Expand Down Expand Up @@ -50,7 +51,8 @@ const QuickMarcCreateWrapper = ({
const [httpError, setHttpError] = useState(null);

const onSubmit = useCallback(async (formValues) => {
const controlFieldErrorMessage = checkControlFieldLength(formValues);
const formValuesToSave = removeDeletedRecords(formValues);
const controlFieldErrorMessage = checkControlFieldLength(formValuesToSave);

if (controlFieldErrorMessage) {
showCallout({ message: controlFieldErrorMessage, type: 'error' });
Expand All @@ -59,7 +61,7 @@ const QuickMarcCreateWrapper = ({
}

const autopopulatedFormValues = autopopulateSubfieldSection(
removeFieldsForDuplicate(formValues),
removeFieldsForDuplicate(formValuesToSave),
initialValues,
marcType,
);
Expand All @@ -74,7 +76,7 @@ const QuickMarcCreateWrapper = ({

return mutator.quickMarcEditMarcRecord.POST(hydrateMarcRecord(formValuesForCreate))
.then(({ qmRecordId }) => {
const instanceId = formValues.externalId;
const instanceId = formValuesToSave.externalId;

getQuickMarcRecordStatus({
quickMarcRecordStatusGETRequest: mutator.quickMarcRecordStatus.GET,
Expand Down
6 changes: 4 additions & 2 deletions src/QuickMarcEditor/QuickMarcDuplicateWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
checkControlFieldLength,
cleanBytesFields,
parseHttpError,
removeDeletedRecords,
} from './utils';

const propTypes = {
Expand Down Expand Up @@ -51,15 +52,16 @@ const QuickMarcDuplicateWrapper = ({
const [httpError, setHttpError] = useState(null);

const onSubmit = useCallback(async (formValues) => {
const controlFieldErrorMessage = checkControlFieldLength(formValues);
const formValuesToSave = removeDeletedRecords(formValues);
const controlFieldErrorMessage = checkControlFieldLength(formValuesToSave);

if (controlFieldErrorMessage) {
showCallout({ message: controlFieldErrorMessage, type: 'error' });

return null;
}

const clearFormValues = removeFieldsForDuplicate(formValues);
const clearFormValues = removeFieldsForDuplicate(formValuesToSave);
const autopopulatedFormWithIndicators = autopopulateIndicators(clearFormValues);
const autopopulatedFormWithSubfields = autopopulateSubfieldSection(
autopopulatedFormWithIndicators,
Expand Down

0 comments on commit 97ab28c

Please sign in to comment.