Skip to content

Commit

Permalink
Added custom type text for standard -> CRE (#338)
Browse files Browse the repository at this point in the history
Co-authored-by: Spyros <[email protected]>
  • Loading branch information
john681611 and northdpole authored Aug 3, 2023
1 parent 7f57f0a commit ff9edf4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const DocumentNode: FunctionComponent<DocumentNode> = ({
<div className="document-node__link-type-container" key={type}>
{idx > 0 && <hr style={{borderColor: "transparent", margin: "20px 0"}} />}
<div>
<b>Which {getDocumentTypeText(type, links[0].document.doctype)}</b>:
<b>Which {getDocumentTypeText(type, links[0].document.doctype, node.doctype)}</b>:
{/* Risk here of mixed doctype in here causing odd output */}
</div>
<div>
Expand Down
2 changes: 2 additions & 0 deletions application/frontend/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const TYPE_IS_PART_OF = 'Is Part Of';
export const TYPE_LINKED_TO = 'Linked To';
export const TYPE_LINKED_FROM = 'Linked From';
export const TYPE_CONTAINS = 'Contains';
export const TYPE_RELATED = 'Related';
export const TYPE_SAME = 'SAME';
Expand All @@ -10,6 +11,7 @@ export const DOCUMENT_TYPE_NAMES = {
[TYPE_SAM]: ' has been automatically mapped to',
[TYPE_LINKED_TO]: ' is linked to sources',
[TYPE_IS_PART_OF]: ' is part of CREs',
[TYPE_LINKED_FROM]: 'is linked from CREs',
[TYPE_CONTAINS]: ' contains CREs',
[TYPE_RELATED]: ' is related to CREs',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const StandardSection = () => {
Object.entries(linksByType).map(([type, links]) => (
<div className="cre-page__links" key={type}>
<div className="cre-page__links-header">
<b>Which {getDocumentTypeText(type, links[0].document.doctype)}</b>:
<b>Which {getDocumentTypeText(type, links[0].document.doctype, document.doctype)}</b>:
{/* Risk here of mixed doctype in here causing odd output */}
</div>
{links
Expand Down
6 changes: 3 additions & 3 deletions application/frontend/src/utils/document.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DOCUMENT_TYPES, DOCUMENT_TYPE_NAMES, TYPE_IS_PART_OF, TYPE_LINKED_TO } from '../const';
import { DOCUMENT_TYPES, DOCUMENT_TYPE_NAMES, TYPE_IS_PART_OF, TYPE_LINKED_FROM, TYPE_LINKED_TO } from '../const';
import { Document, LinkedDocument } from '../types';

export const getDocumentDisplayName = (document: Document) => {
Expand Down Expand Up @@ -73,10 +73,10 @@ export const getApiEndpoint = (doc: Document, apiUrl: string): string => {
return `${apiUrl}/id/${doc.id}`;
};

export const getDocumentTypeText = (linkType, docType): string => {
export const getDocumentTypeText = (linkType, docType, parentDocType = ""): string => {
let docText = DOCUMENT_TYPE_NAMES[linkType];
if (linkType === TYPE_LINKED_TO && docType === DOCUMENT_TYPES.TYPE_CRE) {
docText = DOCUMENT_TYPE_NAMES[TYPE_IS_PART_OF];
docText = parentDocType === DOCUMENT_TYPES.TYPE_STANDARD ? DOCUMENT_TYPE_NAMES[TYPE_LINKED_FROM] : DOCUMENT_TYPE_NAMES[TYPE_IS_PART_OF];
}
return docText;
};

0 comments on commit ff9edf4

Please sign in to comment.