Skip to content

Commit

Permalink
Merge pull request #233 from CSCfi/bugfix/dac-title
Browse files Browse the repository at this point in the history
DAC is an acronym treat it as one
  • Loading branch information
blankdots authored Apr 13, 2021
2 parents be0932a + 5195610 commit 54d0dbb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { resetCurrentObject } from "features/wizardCurrentObjectSlice"
import { setObjectType } from "features/wizardObjectTypeSlice"
import { setSubmissionType } from "features/wizardSubmissionTypeSlice"
import schemaAPIService from "services/schemaAPI"
import {formatDisplayObjectType} from "utils"

const useStyles = makeStyles(theme => ({
index: {
Expand Down Expand Up @@ -340,7 +341,7 @@ const WizardObjectIndex = (): React$Element<any> => {
return (
<div className={classes.index}>
{objectsArray.map(objectType => {
const typeCapitalized = objectType[0].toUpperCase() + objectType.substring(1)
const typeCapitalized = formatDisplayObjectType(objectType)
const isCurrentObjectType = objectType === currentObjectType
return (
<Accordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import WizardSavedObjectActions from "./WizardSavedObjectActions"

import { ObjectSubmissionTypes } from "constants/wizardObject"
import type { ObjectInsideFolderWithTags } from "types"
import { getItemPrimaryText } from "utils"
import { getItemPrimaryText, formatDisplayObjectType } from "utils"

const useStyles = makeStyles(theme => ({
objectList: {
Expand Down Expand Up @@ -73,10 +73,6 @@ const WizardSavedObjectsList = ({ submissions }: WizardSavedObjectsListProps): R
submittedItems: submissions.filter(obj => obj.tags.submissionType && obj.tags.submissionType === submissionType),
}))

const displayObjectType = (objectType: string) => {
return `${objectType.charAt(0).toUpperCase()}${objectType.slice(1)}`
}

const displaySubmissionType = (submission: {
submissionType: string,
submittedItems: Array<ObjectInsideFolderWithTags>,
Expand All @@ -97,7 +93,7 @@ const WizardSavedObjectsList = ({ submissions }: WizardSavedObjectsListProps): R
groupedSubmissions.map(group => (
<Box pt={0} key={group.submissionType}>
<CardHeader
title={`Submitted ${displayObjectType(objectType)} ${displaySubmissionType(group)}`}
title={`Submitted ${formatDisplayObjectType(objectType)} ${displaySubmissionType(group)}`}
titleTypographyProps={{ variant: "inherit" }}
className={classes.cardHeader}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { updateStatus } from "features/wizardStatusMessageSlice"
import { addObjectToFolder, deleteObjectFromFolder, modifyObjectTags } from "features/wizardSubmissionFolderSlice"
import objectAPIService from "services/objectAPI"
import schemaAPIService from "services/schemaAPI"
import { getObjectDisplayTitle } from "utils"
import { getObjectDisplayTitle, formatDisplayObjectType } from "utils"

const useStyles = makeStyles(theme => ({
container: {
Expand Down Expand Up @@ -169,7 +169,7 @@ const CustomCardHeader = (props: CustomCardHeaderProps) => {
onClick={onClickSubmit}
form={refForm}
>
{currentObject?.status === ObjectStatus.submitted ? "Update" : "Submit"} {objectType}
{currentObject?.status === ObjectStatus.submitted ? "Update" : "Submit"} {formatDisplayObjectType(objectType)}
</Button>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import WizardSavedObjectActions from "../WizardComponents/WizardSavedObjectActio
import WizardStepper from "../WizardComponents/WizardStepper"

import type { ObjectInsideFolderWithTags } from "types"
import { getItemPrimaryText } from "utils"
import { getItemPrimaryText, formatDisplayObjectType } from "utils"

const useStyles = makeStyles(theme => ({
summary: {
Expand Down Expand Up @@ -75,7 +75,7 @@ const WizardShowSummaryStep = (): React$Element<any> => {
<List key={schema} aria-label={schema} className={classes.listGroup}>
<div className={classes.schemaTitleRow}>
<Typography variant="subtitle1" fontWeight="fontWeightBold">
{schema.charAt(0).toUpperCase() + schema.substring(1)}
{formatDisplayObjectType(schema)}
</Typography>
<div className="objectAmount">{group[schema].length}</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ export const getItemPrimaryText = (item: ObjectInsideFolderWithTags): string =>
export const useQuery = (): URLSearchParams => {
return new URLSearchParams(useLocation().search)
}

export const formatDisplayObjectType = (objectType: string): string => {
if (objectType === ObjectTypes.dac){
return `${objectType.toUpperCase()}`
} else {
return `${objectType.charAt(0).toUpperCase()}${objectType.slice(1)}`
}
}

0 comments on commit 54d0dbb

Please sign in to comment.