From b40057af0bea3dce7812077e94042b11922a7f5f Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:14:41 +0530 Subject: [PATCH 01/29] bug(Edition & Edition-Group): fixes Unset Author Credit leads to bugs --- .../components/pages/entities/edition-group.js | 4 ++-- src/client/components/pages/entities/edition.js | 4 ++-- .../author-credit-editor/actions.ts | 12 ++++++++++++ .../author-credit-section.tsx | 16 ++++++++++++---- .../edition-group-section/reducer.ts | 4 +++- .../entity-editor/edition-section/reducer.ts | 4 +++- 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index a8be344c1e..17d45507fd 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -79,7 +79,7 @@ EditionGroupAttributes.propTypes = { }; -function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { +function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract} , authorCreditEnable) { const [showCBReviewModal, setShowCBReviewModal] = React.useState(false); const handleModalToggle = useCallback(() => { setShowCBReviewModal(!showCBReviewModal); @@ -101,7 +101,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac /> ); } - else if (!entity.deleted) { + else if (!entity.deleted && !authorCreditEnable) { authorCreditSection = (
Author Credit unset; please  diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index afbd5fe354..7930bfbce3 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -107,7 +107,7 @@ EditionAttributes.propTypes = { }; -function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { +function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}, authorCreditEnable) { // relationshipTypeId = 10 refers the relation ( is contained by ) const relationshipTypeId = 10; const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId); @@ -122,7 +122,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { /> ); } - else if (!entity.deleted) { + else if (!entity.deleted && !authorCreditEnable) { authorCreditSection = (
Author Credit unset; please  diff --git a/src/client/entity-editor/author-credit-editor/actions.ts b/src/client/entity-editor/author-credit-editor/actions.ts index 52e5eabf30..e352855a45 100644 --- a/src/client/entity-editor/author-credit-editor/actions.ts +++ b/src/client/entity-editor/author-credit-editor/actions.ts @@ -30,6 +30,7 @@ export const UPDATE_AUTHOR_CREDIT = 'UPDATE_AUTHOR_CREDIT'; export const CLEAR_AUTHOR_CREDIT = 'CLEAR_AUTHOR_CREDIT'; export const RESET_AUTHOR_CREDIT = 'RESET_AUTHOR_CREDIT'; export const TOGGLE_AUTHOR_CREDIT = 'TOGGLE_AUTHOR_CREDIT'; +export const INIT_AUTHOR_CREDIT = 'INIT_AUTHOR_CREDIT'; export type Action = { type: string, @@ -224,3 +225,14 @@ export function toggleAuthorCredit(): Action { type: TOGGLE_AUTHOR_CREDIT }; } + +/** + * Produces an action indicating that the AC checkbox should be initialized with true. + * + * @returns {Action} The resulting INIT_AUTHOR_CREDIT action. + */ +export function initAuthorCredit(): Action { + return { + type: INIT_AUTHOR_CREDIT + }; +} diff --git a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx index b1a6fcca73..2e9e5717b3 100644 --- a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx +++ b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx @@ -24,8 +24,9 @@ import {Action, removeEmptyCreditRows, resetAuthorCredit, showAuthorCreditEditor, - toggleAuthorCredit - , updateCreditAuthorValue} from './actions'; + toggleAuthorCredit, + initAuthorCredit, + updateCreditAuthorValue} from './actions'; import {Button, Col, Form, FormLabel, InputGroup, OverlayTrigger, Row, Tooltip} from 'react-bootstrap'; import {get as _get, map as _map, values as _values, camelCase} from 'lodash'; @@ -62,6 +63,7 @@ type StateProps = { }; type DispatchProps = { + initCheckBoxState: ()=> unknown, onAuthorChange: (Author) => unknown, toggleAuthorCreditEnable: (newValue:boolean) => unknown, onClearHandler:(arg) => unknown, @@ -73,9 +75,12 @@ type Props = OwnProps & StateProps & DispatchProps; function AuthorCreditSection({ authorCreditEditor: immutableAuthorCreditEditor, onEditAuthorCredit, onEditorClose, - showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable, + showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable,initCheckBoxState, onClearHandler, isUnifiedForm, isLeftAlign, ...rest }: Props) { + React.useEffect(() => { + initCheckBoxState(); + }, []); const authorCreditEditor = convertMapToObject(immutableAuthorCreditEditor); let editor; if (showEditor) { @@ -91,7 +96,7 @@ function AuthorCreditSection({ const authorCreditPreview = _map(authorCreditEditor, (credit) => `${credit.name}${credit.joinPhrase}`).join(''); const authorCreditRows = _values(authorCreditEditor); - const isValid = validateAuthorCreditSection(authorCreditRows, authorCreditEnable); + const isValid = validateAuthorCreditSection(authorCreditRows, authorCreditEnable) || !authorCreditEnable; const editButton = ( // eslint-disable-next-line react/jsx-no-bind @@ -247,6 +252,9 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { dispatch(removeEmptyCreditRows()); dispatch(hideAuthorCreditEditor()); }, + initCheckBoxState: ()=>{ + dispatch(initAuthorCredit()); + }, toggleAuthorCreditEnable: (newValue) => { if (newValue) { dispatch(resetAuthorCredit()); diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index 64c3184351..5d411bc4fc 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -21,7 +21,7 @@ import * as Immutable from 'immutable'; import { Action, UPDATE_TYPE } from './actions'; -import {HIDE_AUTHOR_CREDIT_EDITOR, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; +import {HIDE_AUTHOR_CREDIT_EDITOR, INIT_AUTHOR_CREDIT, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; type State = Immutable.Map; @@ -43,6 +43,8 @@ function reducer( return state.set('authorCreditEditorVisible', false); case TOGGLE_AUTHOR_CREDIT: return state.set('authorCreditEnable', !state.get('authorCreditEnable')); + case INIT_AUTHOR_CREDIT: + return state.set('authorCreditEnable', true); // no default } return state; diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index 49878790d0..b3df4a6f86 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -39,7 +39,7 @@ import { UPDATE_WEIGHT, UPDATE_WIDTH } from './actions'; -import {HIDE_AUTHOR_CREDIT_EDITOR, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; +import {HIDE_AUTHOR_CREDIT_EDITOR, INIT_AUTHOR_CREDIT, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; type State = Immutable.Map; @@ -101,6 +101,8 @@ function reducer( return state.set('matchingNameEditionGroups', payload); case TOGGLE_AUTHOR_CREDIT: return state.set('authorCreditEnable', !state.get('authorCreditEnable')); + case INIT_AUTHOR_CREDIT: + return state.set('authorCreditEnable', true); // no default } return state; From 00666329da5d3fb0707e8bc90bd969e4e9eedb6c Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:47:55 +0530 Subject: [PATCH 02/29] fixed linting errors --- src/client/components/pages/entities/edition-group.js | 2 +- .../author-credit-editor/author-credit-section.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index 17d45507fd..c601459250 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -79,7 +79,7 @@ EditionGroupAttributes.propTypes = { }; -function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract} , authorCreditEnable) { +function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}, authorCreditEnable) { const [showCBReviewModal, setShowCBReviewModal] = React.useState(false); const handleModalToggle = useCallback(() => { setShowCBReviewModal(!showCBReviewModal); diff --git a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx index 2e9e5717b3..14390e6a63 100644 --- a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx +++ b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx @@ -21,11 +21,11 @@ import {Action, addAuthorCreditRow, clearAuthorCredit, hideAuthorCreditEditor, + initAuthorCredit, removeEmptyCreditRows, resetAuthorCredit, showAuthorCreditEditor, toggleAuthorCredit, - initAuthorCredit, updateCreditAuthorValue} from './actions'; import {Button, Col, Form, FormLabel, InputGroup, OverlayTrigger, Row, Tooltip} from 'react-bootstrap'; @@ -75,7 +75,7 @@ type Props = OwnProps & StateProps & DispatchProps; function AuthorCreditSection({ authorCreditEditor: immutableAuthorCreditEditor, onEditAuthorCredit, onEditorClose, - showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable,initCheckBoxState, + showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable, initCheckBoxState, onClearHandler, isUnifiedForm, isLeftAlign, ...rest }: Props) { React.useEffect(() => { @@ -237,6 +237,9 @@ function mapStateToProps(rootState, {type}): StateProps { function mapDispatchToProps(dispatch: Dispatch): DispatchProps { return { + initCheckBoxState: () => { + dispatch(initAuthorCredit()); + }, onAuthorChange: (value) => { dispatch(updateCreditAuthorValue(-1, value)); }, @@ -252,9 +255,6 @@ function mapDispatchToProps(dispatch: Dispatch): DispatchProps { dispatch(removeEmptyCreditRows()); dispatch(hideAuthorCreditEditor()); }, - initCheckBoxState: ()=>{ - dispatch(initAuthorCredit()); - }, toggleAuthorCreditEnable: (newValue) => { if (newValue) { dispatch(resetAuthorCredit()); From dabbd3699cd39e006d3d505a401a5d995a0fd4d0 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:27:37 +0530 Subject: [PATCH 03/29] better solution --- .../entity-editor/author-credit-editor/actions.ts | 11 ----------- .../author-credit-editor/author-credit-section.tsx | 12 ++---------- .../entity-editor/edition-group-section/reducer.ts | 4 +--- src/client/entity-editor/edition-section/reducer.ts | 4 +--- src/server/routes/entity/edition-group.ts | 1 + src/server/routes/entity/edition.ts | 1 - 6 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/client/entity-editor/author-credit-editor/actions.ts b/src/client/entity-editor/author-credit-editor/actions.ts index e352855a45..6f17c4d172 100644 --- a/src/client/entity-editor/author-credit-editor/actions.ts +++ b/src/client/entity-editor/author-credit-editor/actions.ts @@ -30,7 +30,6 @@ export const UPDATE_AUTHOR_CREDIT = 'UPDATE_AUTHOR_CREDIT'; export const CLEAR_AUTHOR_CREDIT = 'CLEAR_AUTHOR_CREDIT'; export const RESET_AUTHOR_CREDIT = 'RESET_AUTHOR_CREDIT'; export const TOGGLE_AUTHOR_CREDIT = 'TOGGLE_AUTHOR_CREDIT'; -export const INIT_AUTHOR_CREDIT = 'INIT_AUTHOR_CREDIT'; export type Action = { type: string, @@ -226,13 +225,3 @@ export function toggleAuthorCredit(): Action { }; } -/** - * Produces an action indicating that the AC checkbox should be initialized with true. - * - * @returns {Action} The resulting INIT_AUTHOR_CREDIT action. - */ -export function initAuthorCredit(): Action { - return { - type: INIT_AUTHOR_CREDIT - }; -} diff --git a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx index 14390e6a63..477d8f2482 100644 --- a/src/client/entity-editor/author-credit-editor/author-credit-section.tsx +++ b/src/client/entity-editor/author-credit-editor/author-credit-section.tsx @@ -21,7 +21,6 @@ import {Action, addAuthorCreditRow, clearAuthorCredit, hideAuthorCreditEditor, - initAuthorCredit, removeEmptyCreditRows, resetAuthorCredit, showAuthorCreditEditor, @@ -63,7 +62,6 @@ type StateProps = { }; type DispatchProps = { - initCheckBoxState: ()=> unknown, onAuthorChange: (Author) => unknown, toggleAuthorCreditEnable: (newValue:boolean) => unknown, onClearHandler:(arg) => unknown, @@ -75,12 +73,9 @@ type Props = OwnProps & StateProps & DispatchProps; function AuthorCreditSection({ authorCreditEditor: immutableAuthorCreditEditor, onEditAuthorCredit, onEditorClose, - showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable, initCheckBoxState, + showEditor, onAuthorChange, isEditable, authorCreditEnable, toggleAuthorCreditEnable, onClearHandler, isUnifiedForm, isLeftAlign, ...rest }: Props) { - React.useEffect(() => { - initCheckBoxState(); - }, []); const authorCreditEditor = convertMapToObject(immutableAuthorCreditEditor); let editor; if (showEditor) { @@ -96,7 +91,7 @@ function AuthorCreditSection({ const authorCreditPreview = _map(authorCreditEditor, (credit) => `${credit.name}${credit.joinPhrase}`).join(''); const authorCreditRows = _values(authorCreditEditor); - const isValid = validateAuthorCreditSection(authorCreditRows, authorCreditEnable) || !authorCreditEnable; + const isValid = validateAuthorCreditSection(authorCreditRows, authorCreditEnable); const editButton = ( // eslint-disable-next-line react/jsx-no-bind @@ -237,9 +232,6 @@ function mapStateToProps(rootState, {type}): StateProps { function mapDispatchToProps(dispatch: Dispatch): DispatchProps { return { - initCheckBoxState: () => { - dispatch(initAuthorCredit()); - }, onAuthorChange: (value) => { dispatch(updateCreditAuthorValue(-1, value)); }, diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index 5d411bc4fc..64c3184351 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -21,7 +21,7 @@ import * as Immutable from 'immutable'; import { Action, UPDATE_TYPE } from './actions'; -import {HIDE_AUTHOR_CREDIT_EDITOR, INIT_AUTHOR_CREDIT, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; +import {HIDE_AUTHOR_CREDIT_EDITOR, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; type State = Immutable.Map; @@ -43,8 +43,6 @@ function reducer( return state.set('authorCreditEditorVisible', false); case TOGGLE_AUTHOR_CREDIT: return state.set('authorCreditEnable', !state.get('authorCreditEnable')); - case INIT_AUTHOR_CREDIT: - return state.set('authorCreditEnable', true); // no default } return state; diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index b3df4a6f86..49878790d0 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -39,7 +39,7 @@ import { UPDATE_WEIGHT, UPDATE_WIDTH } from './actions'; -import {HIDE_AUTHOR_CREDIT_EDITOR, INIT_AUTHOR_CREDIT, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; +import {HIDE_AUTHOR_CREDIT_EDITOR, SHOW_AUTHOR_CREDIT_EDITOR, TOGGLE_AUTHOR_CREDIT} from '../author-credit-editor/actions'; type State = Immutable.Map; @@ -101,8 +101,6 @@ function reducer( return state.set('matchingNameEditionGroups', payload); case TOGGLE_AUTHOR_CREDIT: return state.set('authorCreditEnable', !state.get('authorCreditEnable')); - case INIT_AUTHOR_CREDIT: - return state.set('authorCreditEnable', true); // no default } return state; diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index 59b4b2ab4a..12b7e2f191 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -279,6 +279,7 @@ export function editionGroupToFormState(editionGroup) { ); const editionGroupSection = { + authorCreditEnable: true, type: editionGroup.editionGroupType && editionGroup.editionGroupType.id }; diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index 3239810f48..71f6175b49 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -204,7 +204,6 @@ router.get( let relationshipTypeId; let initialRelationshipIndex = 0; - initialState.editionSection = initialState.editionSection ?? {}; if (props.author) { initialState.authorCreditEditor = { a0: { From c70134448548496647bae676bad86c5ac971cc1c Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Fri, 2 Feb 2024 03:14:02 +0530 Subject: [PATCH 04/29] removed some previous unecessary changes --- src/client/components/pages/entities/edition-group.js | 4 ++-- src/client/components/pages/entities/edition.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index c601459250..a8be344c1e 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -79,7 +79,7 @@ EditionGroupAttributes.propTypes = { }; -function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}, authorCreditEnable) { +function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { const [showCBReviewModal, setShowCBReviewModal] = React.useState(false); const handleModalToggle = useCallback(() => { setShowCBReviewModal(!showCBReviewModal); @@ -101,7 +101,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac /> ); } - else if (!entity.deleted && !authorCreditEnable) { + else if (!entity.deleted) { authorCreditSection = (
Author Credit unset; please  diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index 7930bfbce3..afbd5fe354 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -107,7 +107,7 @@ EditionAttributes.propTypes = { }; -function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}, authorCreditEnable) { +function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { // relationshipTypeId = 10 refers the relation ( is contained by ) const relationshipTypeId = 10; const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId); @@ -122,7 +122,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}, a /> ); } - else if (!entity.deleted && !authorCreditEnable) { + else if (!entity.deleted) { authorCreditSection = (
Author Credit unset; please  From fd60e88b88cc1aabb24c74f2a7e00ff39e24b626 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Thu, 8 Feb 2024 02:48:47 +0530 Subject: [PATCH 05/29] saving the credit section state in database also made schema changes --- .../2024-08-23-credit-section/up.sql | 93 +++++++++++++++++++ sql/scripts/create_triggers.sql | 8 +- .../edition-group-section/reducer.ts | 7 +- .../entity-editor/edition-section/reducer.ts | 5 +- src/server/routes/entity/edition-group.ts | 3 +- src/server/routes/entity/edition.ts | 3 +- 6 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 sql/migrations/2024-08-23-credit-section/up.sql diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql new file mode 100644 index 0000000000..223bbd2f3d --- /dev/null +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -0,0 +1,93 @@ +----------------------------------------------------------------------- +-- Rename entities Creator -> Author and Publication -> Edition Group -- +------------------------------------------------------------------------ + + +---------------------- ****** NOTICE ****** ---------------------- +-- Don't forget to run the create_trigger.sql script afterwards -- +------------------------------------------------------------------ + +BEGIN TRANSACTION; + +-- Adding credit_section column in edition_data and edition_group_data table +ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; +ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; + +-- Drop the existing view if it exists +DROP VIEW IF EXISTS + bookbrainz.edition, + bookbrainz.edition_group; + +-- Recreate the view with the new definition +-- Adding credit_section column in edition view and edition_group view +CREATE VIEW bookbrainz.edition AS +SELECT e.bbid, + edd.id AS data_id, + edr.id AS revision_id, + edr.id = edh.master_revision_id AS master, + edd.annotation_id, + edd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + edd.edition_group_bbid, + edd.author_credit_id, + edd.width, + edd.height, + edd.depth, + edd.weight, + edd.pages, + edd.format_id, + edd.status_id, + edd.alias_set_id, + edd.identifier_set_id, + edd.relationship_set_id, + edd.language_set_id, + edd.release_event_set_id, + edd.publisher_set_id, + edd.credit_section, + e.type + FROM bookbrainz.edition_revision edr + LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid + LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id + LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id + WHERE e.type = 'Edition'::entity_type; + +CREATE VIEW bookbrainz.edition_group AS +SELECT e.bbid, + egd.id AS data_id, + pcr.id AS revision_id, + pcr.id = egh.master_revision_id AS master, + egd.annotation_id, + egd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + egd.type_id, + egtype.label AS edition_group_type, + egd.author_credit_id, + egd.alias_set_id, + egd.identifier_set_id, + egd.relationship_set_id, + egd.credit_section, + e.type + FROM bookbrainz.edition_group_revision pcr + LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid + LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id + LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id + LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id + WHERE e.type = 'EditionGroup'::entity_type; + +---------------------- ****** NOTICE ****** ---------------------- +-- Don't forget to run the create_trigger.sql script afterwards -- +------------------------------------------------------------------ + +COMMIT TRANSACTION; \ No newline at end of file diff --git a/sql/scripts/create_triggers.sql b/sql/scripts/create_triggers.sql index 9d0af01345..5c8c0b0285 100644 --- a/sql/scripts/create_triggers.sql +++ b/sql/scripts/create_triggers.sql @@ -60,14 +60,14 @@ CREATE OR REPLACE FUNCTION bookbrainz.process_edition() RETURNS TRIGGER alias_set_id, identifier_set_id, relationship_set_id, annotation_id, disambiguation_id, edition_group_bbid, author_credit_id, publisher_set_id, release_event_set_id, language_set_id, width, - height, depth, weight, pages, format_id, status_id + height, depth, weight, pages, format_id, status_id, credit_section ) VALUES ( NEW.alias_set_id, NEW.identifier_set_id, NEW.relationship_set_id, NEW.annotation_id, NEW.disambiguation_id, NEW.edition_group_bbid, NEW.author_credit_id, NEW.publisher_set_id, NEW.release_event_set_id, NEW.language_set_id, NEW.width, NEW.height, NEW.depth, NEW.weight, NEW.pages, NEW.format_id, - NEW.status_id + NEW.status_id, NEW.credit_section ) RETURNING bookbrainz.edition_data.id INTO edition_data_id; INSERT INTO bookbrainz.edition_revision VALUES(NEW.revision_id, NEW.bbid, edition_data_id); @@ -218,10 +218,10 @@ CREATE OR REPLACE FUNCTION bookbrainz.process_edition_group() RETURNS TRIGGER IF (TG_OP <> 'DELETE') THEN INSERT INTO bookbrainz.edition_group_data( alias_set_id, identifier_set_id, relationship_set_id, annotation_id, - disambiguation_id, type_id, author_credit_id + disambiguation_id, type_id, author_credit_id, credit_section ) VALUES ( NEW.alias_set_id, NEW.identifier_set_id, NEW.relationship_set_id, - NEW.annotation_id, NEW.disambiguation_id, NEW.type_id, NEW.author_credit_id + NEW.annotation_id, NEW.disambiguation_id, NEW.type_id, NEW.author_credit_id, NEW.credit_section ) RETURNING bookbrainz.edition_group_data.id INTO edition_group_data_id; INSERT INTO bookbrainz.edition_group_revision VALUES(NEW.revision_id, NEW.bbid, edition_group_data_id); diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index 64c3184351..3e50c6ed0d 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -29,6 +29,7 @@ type State = Immutable.Map; function reducer( state: State = Immutable.Map({ authorCreditEnable: true, + creditSection: true, type: null }), action: Action @@ -41,8 +42,10 @@ function reducer( return state.set('authorCreditEditorVisible', true); case HIDE_AUTHOR_CREDIT_EDITOR: return state.set('authorCreditEditorVisible', false); - case TOGGLE_AUTHOR_CREDIT: - return state.set('authorCreditEnable', !state.get('authorCreditEnable')); + case TOGGLE_AUTHOR_CREDIT: + return state + .set('authorCreditEnable', !state.get('authorCreditEnable')) + .set('creditSection', !state.get('creditSection')); // no default } return state; diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index 49878790d0..48a0e2b84a 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -48,6 +48,7 @@ function reducer( state: State = Immutable.Map({ authorCreditEditorVisible: false, authorCreditEnable: true, + creditSection: true, format: null, languages: Immutable.List([]), matchingNameEditionGroups: [], @@ -100,7 +101,9 @@ function reducer( } return state.set('matchingNameEditionGroups', payload); case TOGGLE_AUTHOR_CREDIT: - return state.set('authorCreditEnable', !state.get('authorCreditEnable')); + return state + .set('authorCreditEnable', !state.get('authorCreditEnable')) + .set('creditSection', !state.get('creditSection')); // no default } return state; diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index 12b7e2f191..b53b52590f 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -79,6 +79,7 @@ export function transformNewForm(data) { aliases, annotation: data.annotationSection.content, authorCredit, + creditSection: data.editionGroupSection.creditSection, disambiguation: data.nameSection.disambiguation, identifiers, note: data.submissionSection.note, @@ -88,7 +89,7 @@ export function transformNewForm(data) { } const createOrEditHandler = makeEntityCreateOrEditHandler( - 'editionGroup', transformNewForm, 'typeId' + 'editionGroup', transformNewForm, ['typeId','creditSection'] ); const mergeHandler = makeEntityCreateOrEditHandler( diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index 71f6175b49..40e83680a3 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -54,7 +54,7 @@ type AuthorCreditEditorT ={ const additionalEditionProps = [ 'editionGroupBbid', 'width', 'height', 'depth', 'weight', 'pages', - 'formatId', 'statusId' + 'formatId', 'statusId', 'creditSection' ]; type PassportRequest = express.Request & { @@ -99,6 +99,7 @@ export function transformNewForm(data) { aliases, annotation: data.annotationSection.content, authorCredit, + creditSection: data.editionSection.creditSection, depth: data.editionSection.depth && parseInt(data.editionSection.depth, 10), disambiguation: data.nameSection.disambiguation, From d175cea1375265278a9f7e45214be08c3edfe855 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Thu, 8 Feb 2024 02:55:07 +0530 Subject: [PATCH 06/29] linting error fix --- src/client/entity-editor/edition-group-section/reducer.ts | 4 ++-- src/client/entity-editor/edition-section/reducer.ts | 4 ++-- src/server/routes/entity/edition-group.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index 3e50c6ed0d..c579679e58 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -42,8 +42,8 @@ function reducer( return state.set('authorCreditEditorVisible', true); case HIDE_AUTHOR_CREDIT_EDITOR: return state.set('authorCreditEditorVisible', false); - case TOGGLE_AUTHOR_CREDIT: - return state + case TOGGLE_AUTHOR_CREDIT: + return state .set('authorCreditEnable', !state.get('authorCreditEnable')) .set('creditSection', !state.get('creditSection')); // no default diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index 48a0e2b84a..348e098df4 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -102,8 +102,8 @@ function reducer( return state.set('matchingNameEditionGroups', payload); case TOGGLE_AUTHOR_CREDIT: return state - .set('authorCreditEnable', !state.get('authorCreditEnable')) - .set('creditSection', !state.get('creditSection')); + .set('authorCreditEnable', !state.get('authorCreditEnable')) + .set('creditSection', !state.get('creditSection')); // no default } return state; diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index b53b52590f..212073beda 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -89,7 +89,7 @@ export function transformNewForm(data) { } const createOrEditHandler = makeEntityCreateOrEditHandler( - 'editionGroup', transformNewForm, ['typeId','creditSection'] + 'editionGroup', transformNewForm, ['typeId', 'creditSection'] ); const mergeHandler = makeEntityCreateOrEditHandler( From f5c53203b2f694b18f6eceb4643dc655a27d1133 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:22:10 +0530 Subject: [PATCH 07/29] fix(Auhtor-Credit-section) : used saved state of credit section in frontend to set or unset warning on entity page and enable or disable credit state whenever edit page loads --- sql/migrations/2024-08-23-credit-section/up.sql | 4 +++- src/client/components/pages/entities/edition-group.js | 3 ++- src/client/components/pages/entities/edition.js | 3 ++- src/server/routes/entity/edition-group.ts | 10 +++++++--- src/server/routes/entity/edition.ts | 10 +++++++--- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 223bbd2f3d..9fcf208283 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -9,9 +9,11 @@ BEGIN TRANSACTION; --- Adding credit_section column in edition_data and edition_group_data table +-- Adding credit_section column in edition_data and edition_group_data table and intitalizing it with true ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; +UPDATE edition_data SET credit_section = true; +UPDATE edition_group_data SET credit_section = true; -- Drop the existing view if it exists DROP VIEW IF EXISTS diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index a8be344c1e..63a4126616 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -92,6 +92,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac }, [reviewsRef]); const urlPrefix = getEntityUrl(entity); + const hasAuthorCredits = entity.creditSection; let authorCreditSection; if (entity.authorCredit) { @@ -101,7 +102,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac /> ); } - else if (!entity.deleted) { + else if (!entity.deleted && hasAuthorCredits === true) { authorCreditSection = (
Author Credit unset; please  diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index afbd5fe354..580e92be63 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -113,6 +113,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId); const worksContainedByEditionWithAuthors = addAuthorsDataToWorks(entity.authorsData, worksContainedByEdition); const urlPrefix = getEntityUrl(entity); + const hasAuthorCredits = entity.creditSection; let authorCreditSection; if (entity.authorCredit) { @@ -122,7 +123,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { /> ); } - else if (!entity.deleted) { + else if (!entity.deleted && hasAuthorCredits === true) { authorCreditSection = (
Author Credit unset; please  diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index 212073beda..1ba6e78461 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -280,7 +280,8 @@ export function editionGroupToFormState(editionGroup) { ); const editionGroupSection = { - authorCreditEnable: true, + authorCreditEnable: editionGroup.creditSection, + creditSection: editionGroup.creditSection, type: editionGroup.editionGroupType && editionGroup.editionGroupType.id }; @@ -315,11 +316,14 @@ export function editionGroupToFormState(editionGroup) { }) ) : []; - const authorCreditEditor: AuthorCreditEditorT = {}; + let authorCreditEditor: AuthorCreditEditorT = {}; for (const credit of credits) { authorCreditEditor[credit.position] = credit; } - if (_.isEmpty(authorCreditEditor)) { + if (!editionGroup.creditSection) { + authorCreditEditor = {}; + } + if (_.isEmpty(authorCreditEditor) && editionGroup.creditSection) { authorCreditEditor.n0 = { author: null, joinPhrase: '', diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index 40e83680a3..d74e04a253 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -437,11 +437,14 @@ export function editionToFormState(edition) { }) ) : []; - const authorCreditEditor: AuthorCreditEditorT = {}; + let authorCreditEditor: AuthorCreditEditorT = {}; for (const credit of credits) { authorCreditEditor[credit.position] = credit; } - if (_.isEmpty(authorCreditEditor)) { + if (!edition.creditSection) { + authorCreditEditor = {}; + } + if (_.isEmpty(authorCreditEditor) && edition.creditSection) { authorCreditEditor.n0 = { author: null, joinPhrase: '', @@ -476,7 +479,8 @@ export function editionToFormState(edition) { const editionGroup = utils.entityToOption(edition.editionGroup); const editionSection = { - authorCreditEnable: true, + authorCreditEnable: edition.creditSection, + creditSection: edition.creditSection, depth: edition.depth, editionGroup, // Determines whether the EG can be left blank (an EG will be auto-created) for existing Editions From 3b733964884915ba5fc2fd87ae83176fe10a68bc Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Wed, 14 Feb 2024 03:59:34 +0530 Subject: [PATCH 08/29] made changes in bookbrainz.sql and fix linting error --- sql/schemas/bookbrainz.sql | 98 +++++++++++++------ src/client/entity-editor/entity-editor.tsx | 6 +- test/src/api/routes/test-edition-group.js | 3 +- test/src/api/routes/test-edition.js | 3 +- .../src/server/routes/entity/edition-group.js | 2 + test/src/server/routes/entity/edition.js | 1 + 6 files changed, 79 insertions(+), 34 deletions(-) diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 533a4eccea..3b93bba232 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -352,8 +352,10 @@ CREATE TABLE bookbrainz.edition_data ( weight SMALLINT CHECK (weight >= 0), pages SMALLINT CHECK (pages >= 0), format_id INT, - status_id INT + status_id INT, + credit_section BOOLEAN DEFAULT TRUE ); +UPDATE edition_data SET credit_section = true; ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (format_id) REFERENCES bookbrainz.edition_format (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (edition_group_bbid) REFERENCES bookbrainz.edition_group_header (bbid); @@ -375,8 +377,11 @@ CREATE TABLE bookbrainz.edition_group_data ( annotation_id INT, disambiguation_id INT, author_credit_id INT, - type_id INT + type_id INT, + credit_section BOOLEAN DEFAULT TRUE ); + +UPDATE edition_group_data SET credit_section = true; ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (type_id) REFERENCES bookbrainz.edition_group_type (id); ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_group_revision ADD FOREIGN KEY (data_id) REFERENCES bookbrainz.edition_group_data (id); @@ -867,20 +872,41 @@ CREATE VIEW bookbrainz.author AS WHERE e.type = 'Author'; CREATE VIEW bookbrainz.edition AS - SELECT - e.bbid, edd.id AS data_id, edr.id AS revision_id, (edr.id = edh.master_revision_id) AS master, edd.annotation_id, edd.disambiguation_id, dis.comment disambiguation, - als.default_alias_id, al."name", al.sort_name, edd.edition_group_bbid, edd.author_credit_id, edd.width, edd.height, - edd.depth, edd.weight, edd.pages, edd.format_id, edd.status_id, - edd.alias_set_id, edd.identifier_set_id, edd.relationship_set_id, - edd.language_set_id, edd.release_event_set_id, edd.publisher_set_id, e.type - FROM bookbrainz.edition_revision edr - LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid - LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid - LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id - LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id - LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id - LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id - WHERE e.type = 'Edition'; +SELECT e.bbid, + edd.id AS data_id, + edr.id AS revision_id, + edr.id = edh.master_revision_id AS master, + edd.annotation_id, + edd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + edd.edition_group_bbid, + edd.author_credit_id, + edd.width, + edd.height, + edd.depth, + edd.weight, + edd.pages, + edd.format_id, + edd.status_id, + edd.alias_set_id, + edd.identifier_set_id, + edd.relationship_set_id, + edd.language_set_id, + edd.release_event_set_id, + edd.publisher_set_id, + edd.credit_section, + e.type + FROM bookbrainz.edition_revision edr + LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid + LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id + LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id + WHERE e.type = 'Edition'::entity_type; CREATE VIEW bookbrainz.work AS SELECT @@ -914,19 +940,33 @@ CREATE VIEW bookbrainz.publisher AS WHERE e.type = 'Publisher'; CREATE VIEW bookbrainz.edition_group AS - SELECT - e.bbid, egd.id AS data_id, pcr.id AS revision_id, (pcr.id = egh.master_revision_id) AS master, egd.annotation_id, egd.disambiguation_id, dis.comment disambiguation, - als.default_alias_id, al."name", al.sort_name, egd.type_id, egtype.label as edition_group_type, egd.author_credit_id, egd.alias_set_id, egd.identifier_set_id, - egd.relationship_set_id, e.type - FROM bookbrainz.edition_group_revision pcr - LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid - LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid - LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id - LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id - LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id - LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id - LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id - WHERE e.type = 'EditionGroup'; +SELECT e.bbid, + egd.id AS data_id, + pcr.id AS revision_id, + pcr.id = egh.master_revision_id AS master, + egd.annotation_id, + egd.disambiguation_id, + dis.comment AS disambiguation, + als.default_alias_id, + al.name, + al.sort_name, + egd.type_id, + egtype.label AS edition_group_type, + egd.author_credit_id, + egd.alias_set_id, + egd.identifier_set_id, + egd.relationship_set_id, + egd.credit_section, + e.type + FROM bookbrainz.edition_group_revision pcr + LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid + LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id + LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id + LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id + WHERE e.type = 'EditionGroup'::entity_type; CREATE VIEW bookbrainz.series AS SELECT diff --git a/src/client/entity-editor/entity-editor.tsx b/src/client/entity-editor/entity-editor.tsx index 317b6e32ba..0f0a83366a 100644 --- a/src/client/entity-editor/entity-editor.tsx +++ b/src/client/entity-editor/entity-editor.tsx @@ -84,10 +84,10 @@ const EntityEditor = (props: Props) => { window.onbeforeunload = handleUrlChange; }, [handleUrlChange]); - if(entity){ - entityURL = getEntityUrl(entity); + if (entity) { + entityURL = getEntityUrl(entity); } - + return (
diff --git a/test/src/api/routes/test-edition-group.js b/test/src/api/routes/test-edition-group.js index d9c8c52d44..68b3d4533d 100644 --- a/test/src/api/routes/test-edition-group.js +++ b/test/src/api/routes/test-edition-group.js @@ -54,7 +54,8 @@ describe('GET /EditionGroup', () => { 'bbid', 'defaultAlias', 'disambiguation', - 'editionGroupType' + 'editionGroupType', + 'creditSection' ); }); diff --git a/test/src/api/routes/test-edition.js b/test/src/api/routes/test-edition.js index 25b62bd081..36cbd8c060 100644 --- a/test/src/api/routes/test-edition.js +++ b/test/src/api/routes/test-edition.js @@ -63,7 +63,8 @@ describe('GET /Edition', () => { 'pages', 'status', 'releaseEventDates', - 'weight' + 'weight', + 'creditSection' ); }); diff --git a/test/src/server/routes/entity/edition-group.js b/test/src/server/routes/entity/edition-group.js index 759ef9e757..375e385632 100644 --- a/test/src/server/routes/entity/edition-group.js +++ b/test/src/server/routes/entity/edition-group.js @@ -50,9 +50,11 @@ describe('Edition Group routes with entity editing priv', () => { it('should not throw error while seeding edition group', async () => { const data = { ...seedInitialState, + 'editionGroupSection.creditSection': true, 'editionGroupSection.type': '', 'identifierEditor.t19': 'wikidataid' + }; const res = await agent.post('/edition-group/create').set('Origin', `http://127.0.0.1:${agent.app.address().port}`).send(data); expect(res.ok).to.be.true; diff --git a/test/src/server/routes/entity/edition.js b/test/src/server/routes/entity/edition.js index 2436e0de8c..4e9b605995 100644 --- a/test/src/server/routes/entity/edition.js +++ b/test/src/server/routes/entity/edition.js @@ -49,6 +49,7 @@ describe('Edition routes with entity editing priv', () => { it('should not throw error while seeding edition', async () => { const data = { ...seedInitialState, + 'editionSection.creditSection': 'true', 'editionSection.depth': 'nan', 'editionSection.format': '', 'editionSection.height': '139', From 2b853b30b6f4cabfc8925e517248b4c60238e608 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:04:18 +0530 Subject: [PATCH 09/29] better warning display checks , also used the creditsection state in unified form and added the edition_data.credit_section state in bb.edition_import view --- sql/schemas/bookbrainz.sql | 1 + src/client/components/pages/entities/edition-group.js | 8 +++++++- src/client/components/pages/entities/edition.js | 8 +++++++- src/server/routes/entity/process-unified-form.ts | 2 +- test/src/api/routes/test-edition.js | 3 +-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 3b93bba232..9eabf73695 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -1023,6 +1023,7 @@ CREATE VIEW bookbrainz.edition_import AS edition_data.depth, edition_data.weight, edition_data.pages, + edition_data.credit_section, edition_data.format_id, edition_data.status_id, edition_data.alias_set_id, diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index 63a4126616..ac0d8da239 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -102,7 +102,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac /> ); } - else if (!entity.deleted && hasAuthorCredits === true) { + else if (!entity.deleted && (hasAuthorCredits === true || hasAuthorCredits === null)) { authorCreditSection = (
Author Credit unset; please  @@ -111,6 +111,12 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac You can copy the Author Credit from one of the Editions as well
); } + else if(!entity.deleted && hasAuthorCredits === false){ + authorCreditSection = ( +
+ Author Credits : N/A +
); + } return (
diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index 580e92be63..c592d112f4 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -123,7 +123,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { /> ); } - else if (!entity.deleted && hasAuthorCredits === true) { + else if (!entity.deleted && (hasAuthorCredits === true || hasAuthorCredits === null)) { authorCreditSection = (
Author Credit unset; please  @@ -131,6 +131,12 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { and add its Author(s) if you see this!
); } + else if(!entity.deleted && hasAuthorCredits === false){ + authorCreditSection = ( +
+ Author Credits : N/A +
); + } let editionGroupSection; if (entity.editionGroup) { diff --git a/src/server/routes/entity/process-unified-form.ts b/src/server/routes/entity/process-unified-form.ts index 7b3726904c..856eb093d2 100644 --- a/src/server/routes/entity/process-unified-form.ts +++ b/src/server/routes/entity/process-unified-form.ts @@ -34,7 +34,7 @@ const additionalEntityProps = { ], edition: [ 'editionGroupBbid', 'width', 'height', 'depth', 'weight', 'pages', - 'formatId', 'statusId' + 'formatId', 'statusId', 'creditSection' ], editionGroup: 'typeid', publisher: ['typeId', 'areaId', 'beginDate', 'endDate', 'ended'], diff --git a/test/src/api/routes/test-edition.js b/test/src/api/routes/test-edition.js index 36cbd8c060..25b62bd081 100644 --- a/test/src/api/routes/test-edition.js +++ b/test/src/api/routes/test-edition.js @@ -63,8 +63,7 @@ describe('GET /Edition', () => { 'pages', 'status', 'releaseEventDates', - 'weight', - 'creditSection' + 'weight' ); }); From 0d6962246e20be1b75a10c59a8a939698b49db3d Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:09:31 +0530 Subject: [PATCH 10/29] changes in bb.edition_group_import view --- sql/schemas/bookbrainz.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 9eabf73695..2ead9bbde9 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -1069,6 +1069,7 @@ CREATE VIEW bookbrainz.edition_group_import AS edition_group_data.disambiguation_id, alias_set.default_alias_id, edition_group_data.type_id, + edition_group_data.credit_section, edition_group_data.alias_set_id, edition_group_data.identifier_set_id, import.type From ac12b87ccb8aa295fa8a72b8f98800a619380ea5 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 <97682967+Tarunmeena0901@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:12:28 +0530 Subject: [PATCH 11/29] fix lint error --- src/client/components/pages/entities/edition-group.js | 2 +- src/client/components/pages/entities/edition.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index ac0d8da239..38f391b63c 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -111,7 +111,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac You can copy the Author Credit from one of the Editions as well
); } - else if(!entity.deleted && hasAuthorCredits === false){ + else if (!entity.deleted && hasAuthorCredits === false) { authorCreditSection = (
Author Credits : N/A diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index c592d112f4..8a1d94ec71 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -131,7 +131,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { and add its Author(s) if you see this!
); } - else if(!entity.deleted && hasAuthorCredits === false){ + else if (!entity.deleted && hasAuthorCredits === false) { authorCreditSection = (
Author Credits : N/A From 472dc68d3a756215683177c3ed28547bd910bd5e Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Wed, 6 Mar 2024 02:19:25 +0530 Subject: [PATCH 12/29] minor fix --- sql/migrations/2024-08-23-credit-section/down.sql | 8 ++++++++ sql/migrations/2024-08-23-credit-section/up.sql | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 sql/migrations/2024-08-23-credit-section/down.sql diff --git a/sql/migrations/2024-08-23-credit-section/down.sql b/sql/migrations/2024-08-23-credit-section/down.sql new file mode 100644 index 0000000000..906b8181ad --- /dev/null +++ b/sql/migrations/2024-08-23-credit-section/down.sql @@ -0,0 +1,8 @@ +BEGIN TRANSACTION; + +-- Drop the existing view if it exists +DROP VIEW IF EXISTS + bookbrainz.edition, + bookbrainz.edition_group; + +COMMIT; \ No newline at end of file diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 9fcf208283..5b65a06633 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -15,11 +15,6 @@ ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFA UPDATE edition_data SET credit_section = true; UPDATE edition_group_data SET credit_section = true; --- Drop the existing view if it exists -DROP VIEW IF EXISTS - bookbrainz.edition, - bookbrainz.edition_group; - -- Recreate the view with the new definition -- Adding credit_section column in edition view and edition_group view CREATE VIEW bookbrainz.edition AS From bba6428fc66d37ea7e1d529a1f76228b2cae5a91 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Wed, 6 Mar 2024 19:30:41 +0530 Subject: [PATCH 13/29] fix failing build test --- sql/migrations/2024-08-23-credit-section/up.sql | 4 ++-- sql/schemas/bookbrainz.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 5b65a06633..72c64e3c70 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -12,8 +12,8 @@ BEGIN TRANSACTION; -- Adding credit_section column in edition_data and edition_group_data table and intitalizing it with true ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; -UPDATE edition_data SET credit_section = true; -UPDATE edition_group_data SET credit_section = true; +UPDATE bookbrainz.edition_data SET credit_section = true; +UPDATE bookbrainz.edition_group_data SET credit_section = true; -- Recreate the view with the new definition -- Adding credit_section column in edition view and edition_group view diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 2ead9bbde9..4dccad8459 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -355,7 +355,7 @@ CREATE TABLE bookbrainz.edition_data ( status_id INT, credit_section BOOLEAN DEFAULT TRUE ); -UPDATE edition_data SET credit_section = true; +UPDATE bookbrainz.edition_data SET credit_section = true; ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (format_id) REFERENCES bookbrainz.edition_format (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (edition_group_bbid) REFERENCES bookbrainz.edition_group_header (bbid); @@ -381,7 +381,7 @@ CREATE TABLE bookbrainz.edition_group_data ( credit_section BOOLEAN DEFAULT TRUE ); -UPDATE edition_group_data SET credit_section = true; +UPDATE bookbrainz.edition_group_data SET credit_section = true; ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (type_id) REFERENCES bookbrainz.edition_group_type (id); ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_group_revision ADD FOREIGN KEY (data_id) REFERENCES bookbrainz.edition_group_data (id); From e32636b141240433297fc8759d180a0dce8e99a9 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Wed, 6 Mar 2024 19:52:54 +0530 Subject: [PATCH 14/29] fail build test fix #2 --- sql/migrations/2024-08-23-credit-section/up.sql | 4 ++-- sql/schemas/bookbrainz.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 72c64e3c70..25781a4c1e 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -52,7 +52,7 @@ SELECT e.bbid, LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id - WHERE e.type = 'Edition'::entity_type; + WHERE e.type = 'Edition'; CREATE VIEW bookbrainz.edition_group AS SELECT e.bbid, @@ -81,7 +81,7 @@ SELECT e.bbid, LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id - WHERE e.type = 'EditionGroup'::entity_type; + WHERE e.type = 'EditionGroup'; ---------------------- ****** NOTICE ****** ---------------------- -- Don't forget to run the create_trigger.sql script afterwards -- diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 4dccad8459..42360eebe2 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -906,7 +906,7 @@ SELECT e.bbid, LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id - WHERE e.type = 'Edition'::entity_type; + WHERE e.type = 'Edition'; CREATE VIEW bookbrainz.work AS SELECT @@ -966,7 +966,7 @@ SELECT e.bbid, LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id - WHERE e.type = 'EditionGroup'::entity_type; + WHERE e.type = 'EditionGroup'; CREATE VIEW bookbrainz.series AS SELECT From d35e293ca0aaef30978369a0d44c27e50b9e37df Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Wed, 6 Mar 2024 20:19:59 +0530 Subject: [PATCH 15/29] merge latest changes and also i made changes in test file which i dont think were correct cause mocha test fail so maybe we should leave the test part for another pr ( truth is i am not good at writing test ) --- test/src/api/routes/test-edition-group.js | 3 +-- test/src/server/routes/entity/edition-group.js | 1 - test/src/server/routes/entity/edition.js | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/test/src/api/routes/test-edition-group.js b/test/src/api/routes/test-edition-group.js index 68b3d4533d..d9c8c52d44 100644 --- a/test/src/api/routes/test-edition-group.js +++ b/test/src/api/routes/test-edition-group.js @@ -54,8 +54,7 @@ describe('GET /EditionGroup', () => { 'bbid', 'defaultAlias', 'disambiguation', - 'editionGroupType', - 'creditSection' + 'editionGroupType' ); }); diff --git a/test/src/server/routes/entity/edition-group.js b/test/src/server/routes/entity/edition-group.js index 375e385632..a686811ac0 100644 --- a/test/src/server/routes/entity/edition-group.js +++ b/test/src/server/routes/entity/edition-group.js @@ -50,7 +50,6 @@ describe('Edition Group routes with entity editing priv', () => { it('should not throw error while seeding edition group', async () => { const data = { ...seedInitialState, - 'editionGroupSection.creditSection': true, 'editionGroupSection.type': '', 'identifierEditor.t19': 'wikidataid' diff --git a/test/src/server/routes/entity/edition.js b/test/src/server/routes/entity/edition.js index 4e9b605995..2436e0de8c 100644 --- a/test/src/server/routes/entity/edition.js +++ b/test/src/server/routes/entity/edition.js @@ -49,7 +49,6 @@ describe('Edition routes with entity editing priv', () => { it('should not throw error while seeding edition', async () => { const data = { ...seedInitialState, - 'editionSection.creditSection': 'true', 'editionSection.depth': 'nan', 'editionSection.format': '', 'editionSection.height': '139', From f6c2689a18cec2fd65659fd6cf98e0a6ace2b4fb Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 16:23:30 +0530 Subject: [PATCH 16/29] removed creditSection from redux state and made changes in sql migration files --- .../2024-08-23-credit-section/down.sql | 34 +++++++++++++++++++ .../2024-08-23-credit-section/up.sql | 6 ++-- .../pages/entities/edition-group.js | 8 +---- .../components/pages/entities/edition.js | 8 +---- .../edition-group-section/reducer.ts | 2 -- .../entity-editor/edition-section/reducer.ts | 2 -- src/server/routes/entity/edition-group.ts | 9 ++--- src/server/routes/entity/edition.ts | 7 ++-- src/server/routes/entity/entity.tsx | 8 +++++ 9 files changed, 57 insertions(+), 27 deletions(-) diff --git a/sql/migrations/2024-08-23-credit-section/down.sql b/sql/migrations/2024-08-23-credit-section/down.sql index 906b8181ad..acd67c9c4b 100644 --- a/sql/migrations/2024-08-23-credit-section/down.sql +++ b/sql/migrations/2024-08-23-credit-section/down.sql @@ -1,8 +1,42 @@ BEGIN TRANSACTION; +ALTER TABLE bookbrainz.edition_data DROP COLUMN credit_section; +ALTER TABLE bookbrainz.edition_group_data DROP COLUMN credit_section; + -- Drop the existing view if it exists DROP VIEW IF EXISTS bookbrainz.edition, bookbrainz.edition_group; +CREATE VIEW bookbrainz.edition AS + SELECT + e.bbid, edd.id AS data_id, edr.id AS revision_id, (edr.id = edh.master_revision_id) AS master, edd.annotation_id, edd.disambiguation_id, dis.comment disambiguation, + als.default_alias_id, al."name", al.sort_name, edd.edition_group_bbid, edd.author_credit_id, edd.width, edd.height, + edd.depth, edd.weight, edd.pages, edd.format_id, edd.status_id, + edd.alias_set_id, edd.identifier_set_id, edd.relationship_set_id, + edd.language_set_id, edd.release_event_set_id, edd.publisher_set_id, e.type + FROM bookbrainz.edition_revision edr + LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid + LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id + LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id + WHERE e.type = 'Edition'; + +CREATE VIEW bookbrainz.edition_group AS + SELECT + e.bbid, egd.id AS data_id, pcr.id AS revision_id, (pcr.id = egh.master_revision_id) AS master, egd.annotation_id, egd.disambiguation_id, dis.comment disambiguation, + als.default_alias_id, al."name", al.sort_name, egd.type_id, egtype.label as edition_group_type, egd.author_credit_id, egd.alias_set_id, egd.identifier_set_id, + egd.relationship_set_id, e.type + FROM bookbrainz.edition_group_revision pcr + LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid + LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid + LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id + LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id + LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id + LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id + LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id + WHERE e.type = 'EditionGroup'; + COMMIT; \ No newline at end of file diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 25781a4c1e..18c5b86020 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -12,8 +12,10 @@ BEGIN TRANSACTION; -- Adding credit_section column in edition_data and edition_group_data table and intitalizing it with true ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE; -UPDATE bookbrainz.edition_data SET credit_section = true; -UPDATE bookbrainz.edition_group_data SET credit_section = true; + +DROP VIEW IF EXISTS + bookbrainz.edition, + bookbrainz.edition_group; -- Recreate the view with the new definition -- Adding credit_section column in edition view and edition_group view diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index 38f391b63c..8aba17d40d 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -92,7 +92,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac }, [reviewsRef]); const urlPrefix = getEntityUrl(entity); - const hasAuthorCredits = entity.creditSection; + const hasAuthorCredits = entity.authorCreditEnable; let authorCreditSection; if (entity.authorCredit) { @@ -111,12 +111,6 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac You can copy the Author Credit from one of the Editions as well
); } - else if (!entity.deleted && hasAuthorCredits === false) { - authorCreditSection = ( -
- Author Credits : N/A -
); - } return (
diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index 8a1d94ec71..dd394714b2 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -113,7 +113,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId); const worksContainedByEditionWithAuthors = addAuthorsDataToWorks(entity.authorsData, worksContainedByEdition); const urlPrefix = getEntityUrl(entity); - const hasAuthorCredits = entity.creditSection; + const hasAuthorCredits = entity.authorCreditEnable; let authorCreditSection; if (entity.authorCredit) { @@ -131,12 +131,6 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { and add its Author(s) if you see this!
); } - else if (!entity.deleted && hasAuthorCredits === false) { - authorCreditSection = ( -
- Author Credits : N/A -
); - } let editionGroupSection; if (entity.editionGroup) { diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index c579679e58..8a6347c436 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -29,7 +29,6 @@ type State = Immutable.Map; function reducer( state: State = Immutable.Map({ authorCreditEnable: true, - creditSection: true, type: null }), action: Action @@ -45,7 +44,6 @@ function reducer( case TOGGLE_AUTHOR_CREDIT: return state .set('authorCreditEnable', !state.get('authorCreditEnable')) - .set('creditSection', !state.get('creditSection')); // no default } return state; diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index 348e098df4..e4b62c6e81 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -48,7 +48,6 @@ function reducer( state: State = Immutable.Map({ authorCreditEditorVisible: false, authorCreditEnable: true, - creditSection: true, format: null, languages: Immutable.List([]), matchingNameEditionGroups: [], @@ -103,7 +102,6 @@ function reducer( case TOGGLE_AUTHOR_CREDIT: return state .set('authorCreditEnable', !state.get('authorCreditEnable')) - .set('creditSection', !state.get('creditSection')); // no default } return state; diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index 1ba6e78461..c699c92a7a 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -62,9 +62,9 @@ export function transformNewForm(data) { const relationships = entityRoutes.constructRelationships( data.relationshipSection ); - + const authorCreditEnable = _.get(data, ['editionGroupSection', 'authorCreditEnable'], true); let authorCredit = {}; - if (!_.get(data, ['editionGroupSection', 'authorCreditEnable'], true)) { + if (!authorCreditEnable) { authorCredit = null; } else if (!_.isNil(data.authorCredit)) { @@ -79,7 +79,7 @@ export function transformNewForm(data) { aliases, annotation: data.annotationSection.content, authorCredit, - creditSection: data.editionGroupSection.creditSection, + creditSection: authorCreditEnable, disambiguation: data.nameSection.disambiguation, identifiers, note: data.submissionSection.note, @@ -279,9 +279,10 @@ export function editionGroupToFormState(editionGroup) { (identifier) => { identifierEditor[identifier.id] = identifier; } ); + + const editionGroupSection = { authorCreditEnable: editionGroup.creditSection, - creditSection: editionGroup.creditSection, type: editionGroup.editionGroupType && editionGroup.editionGroupType.id }; diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index d74e04a253..258cdebc9f 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -84,7 +84,9 @@ export function transformNewForm(data) { data.editionSection.languages, (language) => language.value ); let authorCredit = {}; - if (!_.get(data, ['editionSection', 'authorCreditEnable'], true)) { + const authorCreditEnable = _.get(data, ['editionSection', 'authorCreditEnable'], true); + + if (authorCreditEnable) { authorCredit = null; } else if (!_.isNil(data.authorCredit)) { @@ -99,7 +101,7 @@ export function transformNewForm(data) { aliases, annotation: data.annotationSection.content, authorCredit, - creditSection: data.editionSection.creditSection, + creditSection: authorCreditEnable, depth: data.editionSection.depth && parseInt(data.editionSection.depth, 10), disambiguation: data.nameSection.disambiguation, @@ -480,7 +482,6 @@ export function editionToFormState(edition) { const editionSection = { authorCreditEnable: edition.creditSection, - creditSection: edition.creditSection, depth: edition.depth, editionGroup, // Determines whether the EG can be left blank (an EG will be auto-created) for existing Editions diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index 21ebee34ca..ab5daca6a5 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -699,6 +699,14 @@ async function processAuthorCredit( body: ProcessAuthorCreditBody, transacting: Transaction ): Promise { + + const authorCreditEnabled = _.get(currentEntity, ['creditSection']); + if (!authorCreditEnabled) { + return { + authorCreditId: null + }; + } + const authorCreditID = _.get(currentEntity, ['authorCredit', 'id']); const oldAuthorCredit = await ( From 013ef9cd31fdb52a13250c75c576706e47ab2885 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 16:26:23 +0530 Subject: [PATCH 17/29] lint error fix --- src/client/entity-editor/edition-group-section/reducer.ts | 3 +-- src/client/entity-editor/edition-section/reducer.ts | 3 +-- src/server/routes/entity/edition-group.ts | 2 -- src/server/routes/entity/entity.tsx | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/client/entity-editor/edition-group-section/reducer.ts b/src/client/entity-editor/edition-group-section/reducer.ts index 8a6347c436..64c3184351 100644 --- a/src/client/entity-editor/edition-group-section/reducer.ts +++ b/src/client/entity-editor/edition-group-section/reducer.ts @@ -42,8 +42,7 @@ function reducer( case HIDE_AUTHOR_CREDIT_EDITOR: return state.set('authorCreditEditorVisible', false); case TOGGLE_AUTHOR_CREDIT: - return state - .set('authorCreditEnable', !state.get('authorCreditEnable')) + return state.set('authorCreditEnable', !state.get('authorCreditEnable')); // no default } return state; diff --git a/src/client/entity-editor/edition-section/reducer.ts b/src/client/entity-editor/edition-section/reducer.ts index e4b62c6e81..49878790d0 100644 --- a/src/client/entity-editor/edition-section/reducer.ts +++ b/src/client/entity-editor/edition-section/reducer.ts @@ -100,8 +100,7 @@ function reducer( } return state.set('matchingNameEditionGroups', payload); case TOGGLE_AUTHOR_CREDIT: - return state - .set('authorCreditEnable', !state.get('authorCreditEnable')) + return state.set('authorCreditEnable', !state.get('authorCreditEnable')); // no default } return state; diff --git a/src/server/routes/entity/edition-group.ts b/src/server/routes/entity/edition-group.ts index c699c92a7a..6b2d6da5f7 100644 --- a/src/server/routes/entity/edition-group.ts +++ b/src/server/routes/entity/edition-group.ts @@ -279,8 +279,6 @@ export function editionGroupToFormState(editionGroup) { (identifier) => { identifierEditor[identifier.id] = identifier; } ); - - const editionGroupSection = { authorCreditEnable: editionGroup.creditSection, type: editionGroup.editionGroupType && editionGroup.editionGroupType.id diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index ab5daca6a5..e2dbecf4b8 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -698,7 +698,7 @@ async function processAuthorCredit( currentEntity: Record | null | undefined, body: ProcessAuthorCreditBody, transacting: Transaction -): Promise { +): Promise{ const authorCreditEnabled = _.get(currentEntity, ['creditSection']); if (!authorCreditEnabled) { From 3851777c44a9065f85687e946aa04ccbb4904654 Mon Sep 17 00:00:00 2001 From: "Ta.run" <97682967+Tarunmeena0901@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:27:20 +0530 Subject: [PATCH 18/29] better comments in sql migrations Co-authored-by: Monkey Do --- sql/migrations/2024-08-23-credit-section/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-08-23-credit-section/up.sql index 18c5b86020..4834320997 100644 --- a/sql/migrations/2024-08-23-credit-section/up.sql +++ b/sql/migrations/2024-08-23-credit-section/up.sql @@ -1,5 +1,5 @@ ----------------------------------------------------------------------- --- Rename entities Creator -> Author and Publication -> Edition Group -- +-- Adds a credit_section boolean column to edition_data and edition_group_data to make author credits optional -- ------------------------------------------------------------------------ From 194d55024a69a47fc73e9452162542e9f4908b90 Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 16:51:14 +0530 Subject: [PATCH 19/29] minor error fix --- src/server/routes/entity/process-unified-form.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/routes/entity/process-unified-form.ts b/src/server/routes/entity/process-unified-form.ts index 0c78eec5d7..6711815683 100644 --- a/src/server/routes/entity/process-unified-form.ts +++ b/src/server/routes/entity/process-unified-form.ts @@ -36,7 +36,7 @@ const additionalEntityProps = { 'editionGroupBbid', 'width', 'height', 'depth', 'weight', 'pages', 'formatId', 'statusId', 'creditSection' ], - editionGroup: 'typeid', + editionGroup: ['typeid','creditSection'], publisher: ['typeId', 'areaId', 'beginDate', 'endDate', 'ended'], series: ['entityType', 'orderingTypeId'], work: 'typeId' From c7d250a6376fb53eedfd69ba0b580d36d876424d Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 17:04:18 +0530 Subject: [PATCH 20/29] build error fix --- src/server/routes/entity/entity.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index e2dbecf4b8..5c0466360a 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -700,12 +700,13 @@ async function processAuthorCredit( transacting: Transaction ): Promise{ - const authorCreditEnabled = _.get(currentEntity, ['creditSection']); - if (!authorCreditEnabled) { - return { - authorCreditId: null - }; - } + console.log("22 CURRENT ENTITY:", JSON.stringify(currentEntity,null,2)); + // const authorCreditEnabled = _.get(currentEntity, ['creditSection']); + // if (!authorCreditEnabled) { + // return { + // authorCreditId: null + // }; + // } const authorCreditID = _.get(currentEntity, ['authorCredit', 'id']); From 157943adfcc4ab987f5ebae88bf8dd58eb20f31f Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 17:10:04 +0530 Subject: [PATCH 21/29] reverting some changes --- src/server/routes/entity/entity.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index 5c0466360a..c6d35f2e68 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -701,12 +701,12 @@ async function processAuthorCredit( ): Promise{ console.log("22 CURRENT ENTITY:", JSON.stringify(currentEntity,null,2)); - // const authorCreditEnabled = _.get(currentEntity, ['creditSection']); - // if (!authorCreditEnabled) { - // return { - // authorCreditId: null - // }; - // } + const authorCreditEnabled = _.get(currentEntity, ['creditSection']); + if (!authorCreditEnabled) { + return { + authorCreditId: null + }; + } const authorCreditID = _.get(currentEntity, ['authorCredit', 'id']); From 887e6f1b781e67d74411cccec6ef9ef7049d361d Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 17:22:08 +0530 Subject: [PATCH 22/29] minor error fix --- src/client/components/pages/entities/edition-group.js | 2 +- src/client/components/pages/entities/edition.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/components/pages/entities/edition-group.js b/src/client/components/pages/entities/edition-group.js index 8aba17d40d..2951c1b1a3 100644 --- a/src/client/components/pages/entities/edition-group.js +++ b/src/client/components/pages/entities/edition-group.js @@ -92,7 +92,7 @@ function EditionGroupDisplayPage({entity, identifierTypes, user, wikipediaExtrac }, [reviewsRef]); const urlPrefix = getEntityUrl(entity); - const hasAuthorCredits = entity.authorCreditEnable; + const hasAuthorCredits = entity.creditSection; let authorCreditSection; if (entity.authorCredit) { diff --git a/src/client/components/pages/entities/edition.js b/src/client/components/pages/entities/edition.js index dd394714b2..2d6de5cfd2 100644 --- a/src/client/components/pages/entities/edition.js +++ b/src/client/components/pages/entities/edition.js @@ -113,7 +113,7 @@ function EditionDisplayPage({entity, identifierTypes, user, wikipediaExtract}) { const worksContainedByEdition = getRelationshipTargetByTypeId(entity, relationshipTypeId); const worksContainedByEditionWithAuthors = addAuthorsDataToWorks(entity.authorsData, worksContainedByEdition); const urlPrefix = getEntityUrl(entity); - const hasAuthorCredits = entity.authorCreditEnable; + const hasAuthorCredits = entity.creditSection; let authorCreditSection; if (entity.authorCredit) { From 869f02f309fad24f625fca55425d52a7295dd72b Mon Sep 17 00:00:00 2001 From: Tarunmeena0901 Date: Mon, 3 Jun 2024 18:00:20 +0530 Subject: [PATCH 23/29] build error fix --- src/server/routes/entity/edition.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index 258cdebc9f..a500be60a2 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -83,10 +83,11 @@ export function transformNewForm(data) { const languages = _.map( data.editionSection.languages, (language) => language.value ); + let authorCredit = {}; const authorCreditEnable = _.get(data, ['editionSection', 'authorCreditEnable'], true); - if (authorCreditEnable) { + if (!authorCreditEnable) { authorCredit = null; } else if (!_.isNil(data.authorCredit)) { From 5b11d0545c885796b8495a761587b260ecf418b9 Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Mon, 3 Jun 2024 18:31:48 +0200 Subject: [PATCH 24/29] Update bookbrainz-data package version Required for the new author credit related columns and model functions --- package.json | 4 +- yarn.lock | 189 ++++++++++++++++++++++++++------------------------- 2 files changed, 98 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index b11c0f2fb5..21cea66d26 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ }, "browserslist": "> 0.25%, not dead", "overrides": { - "react-select-fast-filter-options":{ + "react-select-fast-filter-options": { "react-select": "$react-select" } }, @@ -41,7 +41,7 @@ "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.1.11", "array-move": "^3.0.1", - "bookbrainz-data": "^5.0.0", + "bookbrainz-data": "5.1.1", "chart.js": "^2.9.4", "chartjs-adapter-date-fns": "^1.0.0", "classnames": "^2.3.2", diff --git a/yarn.lock b/yarn.lock index 5f4ef0ac51..e01546568b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2760,10 +2760,10 @@ body-parser@1.20.2: type-is "~1.6.18" unpipe "1.0.0" -bookbrainz-data@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bookbrainz-data/-/bookbrainz-data-5.0.0.tgz#02ef3ef8483300fed33d1e3bc64b21466fdb62e5" - integrity sha512-CqpJHYrQGeQjxhjJBbzdSpl6FEvrINc05yAb23ClDsLEEgDvWMPoB85+FElCtR+KcvqA44oMmq95ez3nHVvX0g== +bookbrainz-data@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/bookbrainz-data/-/bookbrainz-data-5.1.1.tgz#600158905b6f1f27ceba96311bf2c238c98fb45e" + integrity sha512-REP1BpCc93lAqrGRPO5+l27ggNkpLbyxf2m41znlbFeR63GtAkAv2udqxqSRqLKTmQSftWWGes9McT0hmDplXw== dependencies: "@metabrainz/bookshelf" "^1.4.0" bookshelf-virtuals-plugin "^1.0.0" @@ -2852,11 +2852,6 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer-writer@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-2.0.0.tgz#ce7eb81a38f7829db09c873f2fbb792c0c98ec04" - integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw== - bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" @@ -3215,11 +3210,6 @@ commander@^7.0.0, commander@^7.2.0: resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== -commander@^9.1.0: - version "9.5.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" - integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== - commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" @@ -3359,7 +3349,7 @@ cosmiconfig@^6.0.0: create-error@~0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/create-error/-/create-error-0.3.1.tgz#69810245a629e654432bf04377360003a5351a23" - integrity sha1-aYECRaYp5lRDK/BDdzYAA6U1GiM= + integrity sha512-n/Q4aSCtYuuDneEW5Q+nd0IIZwbwmX/oF6wKcDUhXGJNwhmp2WHEoWKz7X+/H7rBtjimInW7f0ceouxU0SmuzQ== cross-env@^7.0.3: version "7.0.3" @@ -3999,9 +3989,9 @@ es6-weak-map@^2.0.3: es6-symbol "^3.1.1" escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + version "3.1.2" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" + integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== escape-goat@^2.0.0: version "2.1.1" @@ -4686,10 +4676,10 @@ fsevents@^2.3.2, fsevents@~2.3.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +function-bind@^1.1.1, function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== function.prototype.name@^1.1.2, function.prototype.name@^1.1.3, function.prototype.name@^1.1.5: version "1.1.5" @@ -4973,11 +4963,16 @@ has-yarn@^2.1.0: integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + version "1.0.4" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.4.tgz#2eb2860e000011dae4f1406a86fe80e530fb2ec6" + integrity sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ== + +hasown@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== dependencies: - function-bind "^1.1.1" + function-bind "^1.1.2" he@1.2.0: version "1.2.0" @@ -5163,9 +5158,9 @@ imurmurhash@^0.1.4: integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= inflection@^1.12.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.13.1.tgz#c5cadd80888a90cf84c2e96e340d7edc85d5f0cb" - integrity sha512-dldYtl2WlN0QDkIDtg8+xFwOS2Tbmp12t1cHa5/YClU6ZQjTFm7B66UcVbh9NQB+HvT5BAd2t5+yKsBkw5pcqA== + version "1.13.4" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.13.4.tgz#65aa696c4e2da6225b148d7a154c449366633a32" + integrity sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw== inflight@^1.0.4: version "1.0.6" @@ -5180,7 +5175,7 @@ influx@^5.9.3: resolved "https://registry.yarnpkg.com/influx/-/influx-5.9.3.tgz#81f92b55c8354275653393eae0c0c697b6568e76" integrity sha512-QQU9CgwnaEV6zMrK8+vhVItsdoKFqDioXJrjJhRQaff9utvT3N0jcrQJT9qnxFLktqgJ5ngbDY68Zh4eo4uD/w== -inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -5273,7 +5268,14 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.2.0, is-core-module@^2.8.1, is-core-module@^2.9.0: +is-core-module@^2.13.0, is-core-module@^2.9.0: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== + dependencies: + hasown "^2.0.0" + +is-core-module@^2.2.0, is-core-module@^2.8.1: version "2.11.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== @@ -5808,12 +5810,12 @@ klona@^2.0.4: integrity sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ== knex@^2.4.2: - version "2.4.2" - resolved "https://registry.yarnpkg.com/knex/-/knex-2.4.2.tgz#a34a289d38406dc19a0447a78eeaf2d16ebedd61" - integrity sha512-tMI1M7a+xwHhPxjbl/H9K1kHX+VncEYcvCx5K00M16bWvpYPKAZd6QrCu68PtHAdIZNQPWZn0GVhqVBEthGWCg== + version "2.5.1" + resolved "https://registry.yarnpkg.com/knex/-/knex-2.5.1.tgz#a6c6b449866cf4229f070c17411f23871ba52ef9" + integrity sha512-z78DgGKUr4SE/6cm7ku+jHvFT0X97aERh/f0MUKAKgFnwCYBEW4TFBqtHWFYiJFid7fMrtpZ/gxJthvz5mEByA== dependencies: colorette "2.0.19" - commander "^9.1.0" + commander "^10.0.0" debug "4.3.4" escalade "^3.1.1" esm "^3.2.25" @@ -5821,7 +5823,7 @@ knex@^2.4.2: getopts "2.3.0" interpret "^2.2.0" lodash "^4.17.21" - pg-connection-string "2.5.0" + pg-connection-string "2.6.1" rechoir "^0.8.0" resolve-from "^5.0.0" tarn "^3.0.2" @@ -6271,11 +6273,16 @@ mocha@^9.1.3: yargs-parser "20.2.4" yargs-unparser "2.0.0" -moment@^2.10.2, moment@^2.29.1: +moment@^2.10.2: version "2.29.4" resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== +moment@^2.29.1: + version "2.30.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" + integrity sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how== + moo@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/moo/-/moo-0.5.1.tgz#7aae7f384b9b09f620b6abf6f74ebbcd1b65dbc4" @@ -6655,11 +6662,6 @@ package-json@^6.3.0: registry-url "^5.0.0" semver "^6.2.0" -packet-reader@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-1.0.0.tgz#9238e5480dedabacfe1fe3f2771063f164157d74" - integrity sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ== - parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -6802,25 +6804,35 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -pg-connection-string@2.5.0, pg-connection-string@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.5.0.tgz#538cadd0f7e603fc09a12590f3b8a452c2c0cf34" - integrity sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ== +pg-cloudflare@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz#e6d5833015b170e23ae819e8c5d7eaedb472ca98" + integrity sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q== + +pg-connection-string@2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb" + integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg== + +pg-connection-string@^2.6.4: + version "2.6.4" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.4.tgz#f543862adfa49fa4e14bc8a8892d2a84d754246d" + integrity sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA== pg-int8@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw== -pg-pool@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.4.1.tgz#0e71ce2c67b442a5e862a9c182172c37eda71e9c" - integrity sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ== +pg-pool@^3.6.2: + version "3.6.2" + resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.6.2.tgz#3a592370b8ae3f02a7c8130d245bc02fa2c5f3f2" + integrity sha512-Htjbg8BlwXqSBQ9V8Vjtc+vzf/6fVUuak/3/XXKA9oxZprwW3IMDQTGHP+KDmVL7rtd+R1QjbnCFPuTHm3G4hg== -pg-protocol@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0" - integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ== +pg-protocol@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.1.tgz#21333e6d83b01faaebfe7a33a7ad6bfd9ed38cb3" + integrity sha512-jPIlvgoD63hrEuihvIg+tJhoGjUsLPn6poJY9N5CnlPd91c2T18T/9zBtLxZSb1EhYxBRoZJtzScCaWlYLtktg== pg-types@^2.1.0: version "2.2.0" @@ -6834,24 +6846,24 @@ pg-types@^2.1.0: postgres-interval "^1.1.0" pg@^8.6.0: - version "8.7.1" - resolved "https://registry.yarnpkg.com/pg/-/pg-8.7.1.tgz#9ea9d1ec225980c36f94e181d009ab9f4ce4c471" - integrity sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA== - dependencies: - buffer-writer "2.0.0" - packet-reader "1.0.0" - pg-connection-string "^2.5.0" - pg-pool "^3.4.1" - pg-protocol "^1.5.0" + version "8.11.5" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.11.5.tgz#e722b0a5f1ed92931c31758ebec3ddf878dd4128" + integrity sha512-jqgNHSKL5cbDjFlHyYsCXmQDrfIX/3RsNwYqpd4N0Kt8niLuNoRNH+aazv6cOd43gPh9Y4DjQCtb+X0MH0Hvnw== + dependencies: + pg-connection-string "^2.6.4" + pg-pool "^3.6.2" + pg-protocol "^1.6.1" pg-types "^2.1.0" pgpass "1.x" + optionalDependencies: + pg-cloudflare "^1.1.1" pgpass@1.x: - version "1.0.4" - resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.4.tgz#85eb93a83800b20f8057a2b029bf05abaf94ea9c" - integrity sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w== + version "1.0.5" + resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d" + integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug== dependencies: - split2 "^3.1.1" + split2 "^4.1.0" picocolors@^1.0.0: version "1.0.0" @@ -6967,7 +6979,7 @@ postgres-array@~2.0.0: postgres-bytea@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35" - integrity sha1-AntTPAqokOJtFy1Hz5zOzFIazTU= + integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w== postgres-date@~1.0.4: version "1.0.7" @@ -7399,15 +7411,6 @@ readable-stream@^2.0.0, readable-stream@^2.3.5: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.0.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -7628,7 +7631,7 @@ resolve-url-loader@^5.0.0: postcss "^8.2.14" source-map "0.6.1" -resolve@^1.10.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.9.0: +resolve@^1.10.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.22.0, resolve@^1.9.0: version "1.22.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== @@ -7637,6 +7640,15 @@ resolve@^1.10.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.20.0, resolve@^1.2 path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +resolve@^1.20.0: + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + resolve@^2.0.0-next.3: version "2.0.0-next.3" resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.3.tgz#d41016293d4a8586a39ca5d9b5f15cbea1f55e46" @@ -7713,7 +7725,7 @@ safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@5.2.1, safe-buffer@^5.1.0, safe-buffer@~5.2.0: +safe-buffer@5.2.1, safe-buffer@^5.1.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -7987,12 +7999,10 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -split2@^3.1.1: - version "3.2.2" - resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" - integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== - dependencies: - readable-stream "^3.0.0" +split2@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4" + integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== sprintf-js@~1.0.2: version "1.0.3" @@ -8084,13 +8094,6 @@ string.prototype.trimstart@^1.0.5: define-properties "^1.1.4" es-abstract "^1.19.5" -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" @@ -8583,7 +8586,7 @@ url-parse@^1.5.3: querystringify "^2.1.1" requires-port "^1.0.0" -util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: +util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= From c8d1097400ac1066884c01be8f1435d949a5152b Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Mon, 3 Jun 2024 18:59:03 +0200 Subject: [PATCH 25/29] Linting Remove console log, + formatting --- src/server/routes/entity/edition.ts | 2 +- src/server/routes/entity/entity.tsx | 4 +--- src/server/routes/entity/process-unified-form.ts | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/server/routes/entity/edition.ts b/src/server/routes/entity/edition.ts index a500be60a2..0de14ece70 100644 --- a/src/server/routes/entity/edition.ts +++ b/src/server/routes/entity/edition.ts @@ -86,7 +86,7 @@ export function transformNewForm(data) { let authorCredit = {}; const authorCreditEnable = _.get(data, ['editionSection', 'authorCreditEnable'], true); - + if (!authorCreditEnable) { authorCredit = null; } diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index c6d35f2e68..120afcde0b 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -698,9 +698,7 @@ async function processAuthorCredit( currentEntity: Record | null | undefined, body: ProcessAuthorCreditBody, transacting: Transaction -): Promise{ - - console.log("22 CURRENT ENTITY:", JSON.stringify(currentEntity,null,2)); +): Promise { const authorCreditEnabled = _.get(currentEntity, ['creditSection']); if (!authorCreditEnabled) { return { diff --git a/src/server/routes/entity/process-unified-form.ts b/src/server/routes/entity/process-unified-form.ts index 6711815683..ca9d048543 100644 --- a/src/server/routes/entity/process-unified-form.ts +++ b/src/server/routes/entity/process-unified-form.ts @@ -36,7 +36,7 @@ const additionalEntityProps = { 'editionGroupBbid', 'width', 'height', 'depth', 'weight', 'pages', 'formatId', 'statusId', 'creditSection' ], - editionGroup: ['typeid','creditSection'], + editionGroup: ['typeid', 'creditSection'], publisher: ['typeId', 'areaId', 'beginDate', 'endDate', 'ended'], series: ['entityType', 'orderingTypeId'], work: 'typeId' From 0bfbe8f73d7524c2d6d7246ae12121c845af20e5 Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Tue, 4 Jun 2024 11:59:15 +0200 Subject: [PATCH 26/29] Remove SQL column setting Not required, and unwanted --- sql/schemas/bookbrainz.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/schemas/bookbrainz.sql b/sql/schemas/bookbrainz.sql index 42360eebe2..5bb1af2aa6 100644 --- a/sql/schemas/bookbrainz.sql +++ b/sql/schemas/bookbrainz.sql @@ -355,7 +355,6 @@ CREATE TABLE bookbrainz.edition_data ( status_id INT, credit_section BOOLEAN DEFAULT TRUE ); -UPDATE bookbrainz.edition_data SET credit_section = true; ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (format_id) REFERENCES bookbrainz.edition_format (id); ALTER TABLE bookbrainz.edition_data ADD FOREIGN KEY (edition_group_bbid) REFERENCES bookbrainz.edition_group_header (bbid); @@ -381,7 +380,6 @@ CREATE TABLE bookbrainz.edition_group_data ( credit_section BOOLEAN DEFAULT TRUE ); -UPDATE bookbrainz.edition_group_data SET credit_section = true; ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (type_id) REFERENCES bookbrainz.edition_group_type (id); ALTER TABLE bookbrainz.edition_group_data ADD FOREIGN KEY (author_credit_id) REFERENCES bookbrainz.author_credit (id); ALTER TABLE bookbrainz.edition_group_revision ADD FOREIGN KEY (data_id) REFERENCES bookbrainz.edition_group_data (id); From 0535cc1db69e783584595fcbc8d30f1ce898fd4f Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 21 Jun 2024 18:17:58 +0200 Subject: [PATCH 27/29] Fix Author Credit creation processAuthorCredit was using the old entity to determine if it should save an author credit, which meant that an edition without AC was never allowed to have an AC. Also refactored processEditionSets to await promises directly instead of using makePromiseFromObject --- src/server/routes/entity/entity.tsx | 55 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/server/routes/entity/entity.tsx b/src/server/routes/entity/entity.tsx index 9d45f7ec42..95ec6df0a1 100644 --- a/src/server/routes/entity/entity.tsx +++ b/src/server/routes/entity/entity.tsx @@ -689,32 +689,33 @@ export async function processMergeOperation(orm, transacting, session, mainEntit } type ProcessAuthorCreditBody = { - authorCredit: Array + authorCredit: Array; + creditSection: boolean; }; type ProcessAuthorCreditResult = {authorCreditId: number}; async function processAuthorCredit( orm: any, currentEntity: Record | null | undefined, - body: ProcessAuthorCreditBody, + newEntityBody: ProcessAuthorCreditBody, transacting: Transaction ): Promise { - const authorCreditEnabled = _.get(currentEntity, ['creditSection']); + const authorCreditEnabled = newEntityBody.creditSection !== false; if (!authorCreditEnabled) { return { authorCreditId: null }; } - const authorCreditID = _.get(currentEntity, ['authorCredit', 'id']); + const existingAuthorCreditID = _.get(currentEntity, ['authorCredit', 'id']); const oldAuthorCredit = await ( - authorCreditID && - orm.AuthorCredit.forge({id: authorCreditID}) + existingAuthorCreditID && + orm.AuthorCredit.forge({id: existingAuthorCreditID}) .fetch({transacting, withRelated: ['names']}) ); - const names = _.get(body, 'authorCredit') || []; + const names = _.get(newEntityBody, 'authorCredit') || []; const newAuthorCredit = await orm.func.authorCredit.updateAuthorCredit( orm, transacting, oldAuthorCredit, names.map((name) => ({ @@ -752,14 +753,14 @@ async function processEditionSets( ); const languages = _.get(body, 'languages') || []; - const newLanguageSetIDPromise = orm.func.language.updateLanguageSet( + + const newLanguageSet = await orm.func.language.updateLanguageSet( orm, transacting, oldLanguageSet, languages.map((languageID) => ({id: languageID})) - ) - .then((set) => set && set.get('id')); + ); + const newLanguageSetID = newLanguageSet && newLanguageSet.get('id'); const publisherSetID = _.get(currentEntity, ['publisherSet', 'id']); - const oldPublisherSet = await ( publisherSetID && orm.PublisherSet.forge({id: publisherSetID}) @@ -767,12 +768,12 @@ async function processEditionSets( ); const publishers = _.get(body, 'publishers') || []; - const newPublisherSetIDPromise = orm.func.publisher.updatePublisherSet( + + const newPublisherSet = await orm.func.publisher.updatePublisherSet( orm, transacting, oldPublisherSet, publishers.map((publisherBBID) => ({bbid: publisherBBID})) - ) - .then((set) => set && set.get('id')); - + ); + const newPublisherSetID = newPublisherSet && newPublisherSet.get('id'); const releaseEventSetID = _.get(currentEntity, ['releaseEventSet', 'id']); const oldReleaseEventSet = await ( @@ -795,20 +796,20 @@ async function processEditionSets( } } - const newReleaseEventSetIDPromise = - orm.func.releaseEvent.updateReleaseEventSet( + const newReleaseEventSet = + await orm.func.releaseEvent.updateReleaseEventSet( orm, transacting, oldReleaseEventSet, releaseEvents - ) - .then((set) => set && set.get('id')); - - const authorCreditIDPromise = processAuthorCredit(orm, currentEntity, body, transacting).then(acResult => acResult.authorCreditId); + ); + const newReleaseEventSetID = newReleaseEventSet && newReleaseEventSet.get('id'); + const newAuthorCredit = await processAuthorCredit(orm, currentEntity, body, transacting); + const newAuthorCreditID = newAuthorCredit.authorCreditId; - return commonUtils.makePromiseFromObject({ - authorCreditId: authorCreditIDPromise, - languageSetId: newLanguageSetIDPromise, - publisherSetId: newPublisherSetIDPromise, - releaseEventSetId: newReleaseEventSetIDPromise - }); + return { + authorCreditId: newAuthorCreditID, + languageSetId: newLanguageSetID, + publisherSetId: newPublisherSetID, + releaseEventSetId: newReleaseEventSetID + }; } type ProcessWorkSetsResult = {languageSetId: number[]}; From 96a28a28f9dfbe57089cf3c42b55928ec474a22c Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 21 Jun 2024 18:37:55 +0200 Subject: [PATCH 28/29] Rename migration folder The date was copied from another folder but not changed --- .../down.sql | 0 .../up.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename sql/migrations/{2024-08-23-credit-section => 2024-02-07-credit-section}/down.sql (100%) rename sql/migrations/{2024-08-23-credit-section => 2024-02-07-credit-section}/up.sql (100%) diff --git a/sql/migrations/2024-08-23-credit-section/down.sql b/sql/migrations/2024-02-07-credit-section/down.sql similarity index 100% rename from sql/migrations/2024-08-23-credit-section/down.sql rename to sql/migrations/2024-02-07-credit-section/down.sql diff --git a/sql/migrations/2024-08-23-credit-section/up.sql b/sql/migrations/2024-02-07-credit-section/up.sql similarity index 100% rename from sql/migrations/2024-08-23-credit-section/up.sql rename to sql/migrations/2024-02-07-credit-section/up.sql From ccc1c2bbdfb7a0ededb60a9bea3e29aa379d7b8b Mon Sep 17 00:00:00 2001 From: Monkey Do Date: Fri, 21 Jun 2024 19:20:47 +0200 Subject: [PATCH 29/29] Fix revision diff display when removing author credits --- src/server/helpers/diffFormatters/authorCredit.ts | 4 ++-- src/server/helpers/diffFormatters/set.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/server/helpers/diffFormatters/authorCredit.ts b/src/server/helpers/diffFormatters/authorCredit.ts index b7bf4bd10c..7556b4c96c 100644 --- a/src/server/helpers/diffFormatters/authorCredit.ts +++ b/src/server/helpers/diffFormatters/authorCredit.ts @@ -35,7 +35,7 @@ function authorCreditNameForDisplay(authorCreditName: AuthorCreditNameT) { } function authorCreditNamesForDisplay(rhs: {names: AuthorCreditNameT[]}) { - return rhs.names.sort((a, b) => a.position - b.position) + return rhs?.names?.sort((a, b) => a.position - b.position) .map(authorCreditNameForDisplay); } @@ -45,7 +45,7 @@ function formatNewAuthorCredit(change) { function formatAuthorCreditAddOrDelete(change) { return set.formatItemAddOrDelete( - change, `Author Credit ${change.item?.rhs?.position + 1}`, authorCreditNameForDisplay + change, `Author Credit ${change.item?.rhs?.position + 1 || 'removed'}`, authorCreditNamesForDisplay ); } diff --git a/src/server/helpers/diffFormatters/set.js b/src/server/helpers/diffFormatters/set.js index 7e13213932..01d56e1467 100644 --- a/src/server/helpers/diffFormatters/set.js +++ b/src/server/helpers/diffFormatters/set.js @@ -31,7 +31,7 @@ export function formatNewSet(change, label, itemProp, transformerFunc) { export function formatItemAddOrDelete(change, label, transformerFunc) { return [ - base.formatChange(change.item, label, transformerFunc) + base.formatChange(change, label, transformerFunc) ]; } @@ -55,11 +55,11 @@ export function format( return newSetFormatter(change); } - const itemAddDeleteModify = - change.path.length > 1 && change.path[0] === setProp && - change.path[1] === itemProp; + const itemAddDeleteModify = (change.kind === 'D' && change.path[0] === setProp) || + (change.path.length > 1 && change.path[0] === setProp && + change.path[1] === itemProp); if (itemAddDeleteModify) { - if (change.kind === 'A') { + if (change.kind === 'A' || change.kind === 'D') { // Item added to or deleted from set return addDeleteFormatter(change); }