diff --git a/src/client/components/pages/entities/work-table.js b/src/client/components/pages/entities/work-table.js index 01c95bf4c9..db239635f6 100644 --- a/src/client/components/pages/entities/work-table.js +++ b/src/client/components/pages/entities/work-table.js @@ -64,7 +64,19 @@ function WorkTableRow({showAddedAtColumn, work, showCheckboxes, selectedEntities {name} {disambiguation} - {authorData && {authorData.length ? renderAuthors(authorData) : '?'}} + {authorData && + + {authorData.length ? renderAuthors(authorData) : + + ? + + } + + } {languages} {workType} {showAddedAtColumn ? {addedAt} : null} diff --git a/src/server/routes/entity/author.js b/src/server/routes/entity/author.js index 330f8b1b26..6ae7bbb065 100644 --- a/src/server/routes/entity/author.js +++ b/src/server/routes/entity/author.js @@ -24,12 +24,14 @@ import * as search from '../../../common/helpers/search'; import * as utils from '../../helpers/utils'; import { + addInitialRelationship, entityEditorMarkup, generateEntityProps, makeEntityCreateOrEditHandler } from '../../helpers/entityRouteUtils'; import {ConflictError} from '../../../common/helpers/error'; +import {RelationshipTypes} from '../../../client/entity-editor/relationship-editor/types'; import _ from 'lodash'; import {escapeProps} from '../../helpers/props'; import express from 'express'; @@ -98,11 +100,25 @@ router.get( middleware.loadGenders, middleware.loadLanguages, middleware.loadAuthorTypes, middleware.loadRelationshipTypes, async (req, res) => { + const {Work} = req.app.locals.orm; + let relationshipTypeId; + let initialRelationshipIndex = 0; const markupProps = generateEntityProps( 'author', req, res, { genderOptions: res.locals.genders } ); + if (req.query.work) { + const data = await Work.forge({bbid: req.query.work}).fetch({require: false, withRelated: 'defaultAlias'}); + markupProps.work = data && utils.entityToOption(data.toJSON()); + } + + if (markupProps.work) { + // add initial relationship with relationshipTypeId = 8 ( is written by ) + relationshipTypeId = RelationshipTypes.AuthorWroteWork; + addInitialRelationship(markupProps, relationshipTypeId, initialRelationshipIndex++, markupProps.work); + } + const nameSection = { disambiguation: '', exactMatches: null,