Skip to content

Commit

Permalink
#106 Fix for metadata field "publication"
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 31, 2020
1 parent 082ce36 commit db7b7b3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
12 changes: 1 addition & 11 deletions src/components/DocumentMetadata/DocumentMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FieldArray } from 'formik';
import {
Button, Col, Form, InputGroup, Row,
} from 'react-bootstrap';
import { publicationFieldName } from '../../utils/metadataUtil';

const DocumentMetadata = ({
resourceType,
Expand All @@ -13,17 +14,6 @@ const DocumentMetadata = ({
errors,
touched,
}) => {
const publicationFieldName = (type) => {
switch (type) {
case 'Book Section': return 'Book title';
case 'Journal Article': return 'Journal title';
case 'Newspaper Article': return 'Newspaper title';
case 'Magazine Article': return 'Magazine title';
case 'Web Page': return 'Website title';
default: return 'Publication title';
}
};

const contributorTypes = ['Author', 'Editor', 'Translator', 'Contributor'];

const [expandMeta, setExpandMeta] = useState(false);
Expand Down
41 changes: 19 additions & 22 deletions src/components/SecondNavbar/SecondNavbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@ import React, { useState } from 'react';
import {
Nav, Navbar, Breadcrumb, Container, Modal, Table,
} from 'react-bootstrap';
import {
InfoSquare,
} from 'react-bootstrap-icons';

import { InfoSquare } from 'react-bootstrap-icons';
import FilterPopover from '../FilterPopover';
import { publicationFieldName } from '../../utils/metadataUtil';

const SecondNavbar = ({
session,
type,
document,
docView,
}) => {
const metaData = {
const metadataFields = {
title: 'Title',
resourceType: 'Resource Type',
resourceType: 'Type',
contributors: 'Contributors',
bookTitle: 'Book Title',
publication: 'Publication',
publication: document ? publicationFieldName(document.resourceType) : 'Publication',
series: 'Series',
seriesNumber: 'Series Number',
seriesNumber: 'Series number',
volume: 'Volume',
issue: 'Issue',
pageNumbers: 'Page Numbers',
pageNumbers: 'Page numbers',
edition: 'Edition',
publisher: 'Publisher',
publicationDate: 'Publication Date',
publicationDate: 'Publication date',
location: 'Location',
rightsStatus: 'Rights Status',
rightsStatus: 'Rights status',
url: 'URL',
accessed: 'Accessed',
notes: 'Notes',
Expand Down Expand Up @@ -106,7 +103,7 @@ const SecondNavbar = ({
<Modal.Body>
<Table bordered size="sm">
<tbody>
{Object.keys(metaData).map((key) => {
{Object.keys(metadataFields).map((key) => {
let str = '';
if (document[key] !== undefined) {
if (Array.isArray(document[key])) {
Expand All @@ -120,15 +117,15 @@ const SecondNavbar = ({
} else {
str = document[key];
}
}
return (
<tr>
<td className="table-meta-data-name">
<strong>{metaData[key]}</strong>
</td>
<td>{str}</td>
</tr>
);
return (
<tr>
<td className="table-meta-data-name">
<strong>{metadataFields[key]}</strong>
</td>
<td>{str}</td>
</tr>
);
} return '';
})}
</tbody>
</Table>
Expand Down
14 changes: 14 additions & 0 deletions src/utils/metadataUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable import/prefer-default-export */

const publicationFieldName = (type) => {
switch (type) {
case 'Book Section': return 'Book title';
case 'Journal Article': return 'Journal title';
case 'Newspaper Article': return 'Newspaper title';
case 'Magazine Article': return 'Magazine title';
case 'Web Page': return 'Website title';
default: return 'Publication title';
}
};

export { publicationFieldName };

0 comments on commit db7b7b3

Please sign in to comment.