Skip to content

Commit

Permalink
BASIRA #286 - Modifying fields on related locations and creators on a…
Browse files Browse the repository at this point in the history
…rtwork page
  • Loading branch information
dleadbetter committed Dec 19, 2024
1 parent 13bcc68 commit 071c3ce
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
2 changes: 1 addition & 1 deletion app/serializers/places_serializer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class PlacesSerializer < BaseSerializer
index_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country
index_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country, :url
show_attributes :id, :name, :place_type, :lat, :long, :city, :state, :country, :url, :database_value, :notes,
:same_as, :part_of, :authorized_vocabulary_url, qualifications: QualificationsSerializer

Expand Down
11 changes: 4 additions & 7 deletions client/src/components/ArtworkCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ const ArtworkCreators = (props: Props) => {
</SimpleLink>
</Header>
</Item.Header>
<Item.Meta>
{ Qualifiables.getValueListValue(item.person, 'Person', 'Nationality') }
</Item.Meta>
<Item.Description>
<RolesView
value={[
items={[
Qualifiables.getValueListValue(item, 'Person', 'Participation Role'),
Qualifiables.getValueListValue(item, 'Person', 'Participation Subrole')
]}
Expand All @@ -53,16 +50,16 @@ const ArtworkCreators = (props: Props) => {
<Item.Description
content={item.description}
/>
<Item.Description
content={item.notes}
/>
{ item.certainty && (
<Item.Extra>
<CertaintyLabel
value={item.certainty}
/>
</Item.Extra>
)}
<Item.Extra
content={item.notes}
/>
</Item.Content>
</Item>
))}
Expand Down
56 changes: 29 additions & 27 deletions client/src/components/Locations.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// @flow

import React from 'react';
import React, { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { Header, Item } from 'semantic-ui-react';
import _ from 'underscore';
import CertaintyLabel from './CertaintyLabel';
import type { Location } from '../types/Location';
import RolesView from './RolesView';
import Qualifiables from '../utils/Qualifiables';
Expand All @@ -15,9 +14,22 @@ type Props = {
items: Array<Location>
};

const LOCATION_SEPARATOR = ', ';

const Locations = (props: Props) => {
const { t } = useTranslation();

/**
* Concatenates the city, state, and country attributes for the passed place.
*
* @type {function(*): *}
*/
const getLocationView = useCallback((place) => _.compact([
place.city,
place.state,
place.country
]).join(LOCATION_SEPARATOR), []);

if (!props.items) {
return null;
}
Expand All @@ -43,40 +55,30 @@ const Locations = (props: Props) => {
</Header>
</Item.Header>
<Item.Meta
content={item.place?.country}
content={item.place?.place_type}
/>
<Item.Description>
<RolesView
value={[
Qualifiables.getValueListValue(item, 'Location', 'Role'),
Qualifiables.getValueListValue(item, 'Location', 'Subrole')
]}
/>
</Item.Description>
<Item.Description
content={item.description}
content={getLocationView(item.place)}
/>
<Item.Description
content={item.notes}
/>
{ item.certainty && (
<Item.Extra>
<CertaintyLabel
value={item.certainty}
/>
</Item.Extra>
)}
{ item.repository_work_url && (
<Item.Extra>
{ item.place?.url && (
<Item.Description>
<a
href={item.repository_work_url}
href={item.place.url}
rel='noreferrer'
target='_blank'
>
{ t('Common.buttons.viewSource') }
{ t('Locations.labels.viewInstitution') }
</a>
</Item.Extra>
</Item.Description>
)}
<Item.Extra>
<RolesView
items={[
Qualifiables.getValueListValue(item, 'Location', 'Role'),
Qualifiables.getValueListValue(item, 'Location', 'Subrole')
]}
/>
</Item.Extra>
</Item.Content>
</Item>
))}
Expand Down
17 changes: 11 additions & 6 deletions client/src/components/RolesView.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
// @flow

import React from 'react';
import { Label } from 'semantic-ui-react';
import _ from 'underscore';

type Props = {
value: Array<string>
items: Array<string>
};

const ROLES_SEPARATOR = ', ';

const RolesView = (props: Props) => {
const value = _.compact(props.value);
const items = _.compact(props.items);

if (_.isEmpty(value)) {
if (_.isEmpty(items)) {
return null;
}

return (
<span>{ value.join(ROLES_SEPARATOR) }</span>
<Label.Group>
{ _.map(items, (item) => (
<Label
content={item}
/>
))}
</Label.Group>
);
};

Expand Down
6 changes: 5 additions & 1 deletion client/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
"buttons": {
"back": "Back",
"cancel": "Cancel",
"viewSource": "View Source",
"save": "Save"
},
"errors": {
Expand Down Expand Up @@ -323,6 +322,11 @@
"edit": "Edit Location"
}
},
"Locations": {
"labels": {
"viewInstitution": "View Institution"
}
},
"NotesModal": {
"title": "Internal Notes"
},
Expand Down

0 comments on commit 071c3ce

Please sign in to comment.