From c5ec9e146a0ee9371171ce9e6b621b96e44c50f0 Mon Sep 17 00:00:00 2001 From: insane-22 Date: Tue, 2 Jan 2024 01:04:31 +0530 Subject: [PATCH 1/3] BB-766 --- src/client/unified-form/validators/cover-tab.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/client/unified-form/validators/cover-tab.ts b/src/client/unified-form/validators/cover-tab.ts index 6f636ae67e..09d7a73526 100644 --- a/src/client/unified-form/validators/cover-tab.ts +++ b/src/client/unified-form/validators/cover-tab.ts @@ -23,9 +23,9 @@ export function validateISBN(isbn) { * @param {Array} identifierTypes - the list of identifier types * @returns {boolean} - true if form state valid, false if invalid */ -export function validateCoverTab(data:any, identifierTypes:any[]) { +export function validateCoverTab(data:any, identifierTypes:(any[]|null)) { return validateNameSection(get(data, 'nameSection')) && - validateIdentifiers(get(data, 'identifierEditor', {}), identifierTypes) && + (identifierTypes ? validateIdentifiers(get(data, 'identifierEditor', {}), identifierTypes) : true) && validateAuthorCreditSection(get(data, 'authorCreditEditor')) && validateISBN(get(data, 'ISBN')); } @@ -40,13 +40,11 @@ export function isCoverTabEmpty(data:any) { const nameSection = get(data, 'nameSection', {}); const authorCreditEditor = get(data, 'authorCreditEditor', {}); const ISBN = get(data, 'ISBN', {}); - const identifierEditor = get(data, 'identifierEditor', {}); return nameSection.name?.length === 0 && nameSection.sortName?.length === 0 && !nameSection.language && nameSection.disambiguation?.length === 0 && size(authorCreditEditor) === 1 && !authorCreditEditor.n0?.author && - size(identifierEditor) === 0 && !ISBN.type; } From 0ab5a0df8e555d3ee31488cedb2a017f82fe6ced Mon Sep 17 00:00:00 2001 From: insane-22 Date: Sat, 13 Jan 2024 11:13:39 +0530 Subject: [PATCH 2/3] Revert "BB-766" Issue identified incorrectly, reverting previous commit This reverts commit c5ec9e146a0ee9371171ce9e6b621b96e44c50f0. --- src/client/unified-form/validators/cover-tab.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/unified-form/validators/cover-tab.ts b/src/client/unified-form/validators/cover-tab.ts index 09d7a73526..6f636ae67e 100644 --- a/src/client/unified-form/validators/cover-tab.ts +++ b/src/client/unified-form/validators/cover-tab.ts @@ -23,9 +23,9 @@ export function validateISBN(isbn) { * @param {Array} identifierTypes - the list of identifier types * @returns {boolean} - true if form state valid, false if invalid */ -export function validateCoverTab(data:any, identifierTypes:(any[]|null)) { +export function validateCoverTab(data:any, identifierTypes:any[]) { return validateNameSection(get(data, 'nameSection')) && - (identifierTypes ? validateIdentifiers(get(data, 'identifierEditor', {}), identifierTypes) : true) && + validateIdentifiers(get(data, 'identifierEditor', {}), identifierTypes) && validateAuthorCreditSection(get(data, 'authorCreditEditor')) && validateISBN(get(data, 'ISBN')); } @@ -40,11 +40,13 @@ export function isCoverTabEmpty(data:any) { const nameSection = get(data, 'nameSection', {}); const authorCreditEditor = get(data, 'authorCreditEditor', {}); const ISBN = get(data, 'ISBN', {}); + const identifierEditor = get(data, 'identifierEditor', {}); return nameSection.name?.length === 0 && nameSection.sortName?.length === 0 && !nameSection.language && nameSection.disambiguation?.length === 0 && size(authorCreditEditor) === 1 && !authorCreditEditor.n0?.author && + size(identifierEditor) === 0 && !ISBN.type; } From 70d3644ac68e1bc4a749e9d64483d589b562e3f9 Mon Sep 17 00:00:00 2001 From: insane-22 Date: Tue, 16 Jan 2024 22:53:08 +0530 Subject: [PATCH 3/3] empty identifiers and aliases logic updated --- src/client/entity-editor/alias-editor/reducer.js | 2 +- src/client/entity-editor/identifier-editor/reducer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/entity-editor/alias-editor/reducer.js b/src/client/entity-editor/alias-editor/reducer.js index 3fc723a5cf..dc0d18eb71 100644 --- a/src/client/entity-editor/alias-editor/reducer.js +++ b/src/client/entity-editor/alias-editor/reducer.js @@ -50,7 +50,7 @@ function reducer( return state.delete(payload); case REMOVE_EMPTY_ALIASES: return state.filterNot(alias => - alias.get('name') === '' && alias.get('language') === null && alias.get('sortName') === ''); + alias.get('name') === ''); // no default } return state; diff --git a/src/client/entity-editor/identifier-editor/reducer.ts b/src/client/entity-editor/identifier-editor/reducer.ts index 9e5749ac98..0c07ccba23 100644 --- a/src/client/entity-editor/identifier-editor/reducer.ts +++ b/src/client/entity-editor/identifier-editor/reducer.ts @@ -58,7 +58,7 @@ function reducer( return state.delete(payload); case REMOVE_EMPTY_IDENTIFIERS: return state.filterNot(identifier => - identifier.get('value') === '' && identifier.get('type') === null); + identifier.get('value') === ''); case ADD_OTHER_ISBN: { const {rowId, value, type: typeId} = payload; // search if given identifier already exists