Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of exhibits in the UI #1665

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
<span class="has-text-weight-bold">{{ $t('full_record.finding_aid') }}: </span>
<a class="finding-aid" :href="recordData.findingAidUrl">{{ recordData.findingAidUrl }}</a>
</li>
<li class="exhibits" v-if="fieldExists(recordData.exhibits)">
<span class="has-text-weight-bold">{{ $t('full_record.related_digital_exhibits') }}: </span>
<template v-for="(exhibit_link, title, index) in recordData.exhibits">
<a :href="exhibit_link">{{ title }}</a>
<template v-if="hasMoreExhibits(index, recordData.exhibits)">; </template>
</template>
</li>
<li v-if="fieldExists(recordData.briefObject.creator)">
<span class="has-text-weight-bold">{{ $t('full_record.creator') }}: </span>
{{ recordData.briefObject.creator.join('; ') }}
Expand Down Expand Up @@ -55,12 +62,6 @@
{{ recordData.embargoDate }}
</li>
<abstract v-if="recordData.briefObject.abstractText" :brief-object="recordData.briefObject"/>
<li v-if="fieldExists(recordData.exhibits)">
<span class="has-text-weight-bold">{{ $t('full_record.related_digital_exhibits') }}: </span>
<template v-for="(exhibit, index) in recordData.exhibits">
<a :href="exhibit.value">{{ exhibit.key }}</a><template v-if="index < recordData.exhibits.length - 1">;</template>
</template>
</li>
</ul>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
<strong>{{ $t('full_record.finding_aid') }}: </strong>
<a :href="recordData.findingAidUrl">{{ recordData.findingAidUrl }}</a>
</p>
<abstract v-if="recordData.briefObject.abstractText" :brief-object="recordData.briefObject"/>
<p v-if="fieldExists(recordData.exhibits)">
<p class="exhibits" v-if="fieldExists(recordData.exhibits)">
<strong>{{ $t('full_record.related_digital_exhibits') }}: </strong>
<template v-for="(exhibit, index) in recordData.exhibits">
<a :href="exhibit.value">{{ exhibit.key }}</a><template v-if="index < recordData.exhibits.length - 1">;</template>
<template v-for="(exhibit_link, title, index) in recordData.exhibits">
<a :href="exhibit_link">{{ title }}</a>
<template v-if="hasMoreExhibits(index, recordData.exhibits)">; </template>
</template>
</p>
<abstract v-if="recordData.briefObject.abstractText" :brief-object="recordData.briefObject"/>
<p><a @click.prevent="displayMetadata()" href="#">{{ $t('full_record.additional_metadata') }}</a></p>
</div>
<restricted-content :record-data="recordData"></restricted-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
<span class="has-text-weight-bold">{{ $t('full_record.finding_aid') }}: </span>
<a class="finding-aid" :href="recordData.findingAidUrl">{{ recordData.findingAidUrl }}</a>
</li>
<li class="exhibits" v-if="fieldExists(recordData.exhibits)">
<span class="has-text-weight-bold">{{ $t('full_record.related_digital_exhibits') }}: </span>
<template v-for="(exhibit_link, title, index) in recordData.exhibits">
<a :href="exhibit_link">{{ title }}</a>
<template v-if="hasMoreExhibits(index, recordData.exhibits)">; </template>
</template>
</li>
<li v-if="fieldExists(recordData.briefObject.creator)">
<span class="has-text-weight-bold">{{ $t('full_record.creator') }}: </span>
{{ recordData.briefObject.creator.join('; ') }}
Expand All @@ -51,12 +58,6 @@
{{ recordData.embargoDate }}
</li>
<abstract v-if="recordData.briefObject.abstractText" :brief-object="recordData.briefObject"/>
<li v-if="fieldExists(recordData.exhibits)">
<span class="has-text-weight-bold">{{ $t('full_record.related_digital_exhibits') }}: </span>
<template v-for="(exhibit, index) in recordData.exhibits">
<a :href="exhibit.value">{{ exhibit.key }}</a><template v-if="index < recordData.exhibits.length - 1">;</template>
</template>
</li>
<li>
<router-link id="parent-url" :to="parentWorkUrl">{{ $t('full_record.view_parent_work') }}</router-link>
</li>
Expand Down
4 changes: 4 additions & 0 deletions static/js/vue-cdr-access/src/mixins/fullRecordUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export default {

editDescriptionUrl(id) {
return `https://${window.location.host}/admin/describe/${id}`;
},

hasMoreExhibits(current_exhibit, exhibits) {
return current_exhibit < Object.keys(exhibits).length - 1;
}
}
}
26 changes: 25 additions & 1 deletion static/js/vue-cdr-access/tests/unit/aggregateRecord.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,11 @@ const record = {
viewerPid: "8a2f05e5-d2b7-4857-ae71-c24aa28484c1",
dataFileUrl: "content/8a2f05e5-d2b7-4857-ae71-c24aa28484c1",
markedForDeletion: false,
resourceType: "Work"
resourceType: "Work",
exhibits: {
"The Cartoons of Boxy": "https://exhibits.lib.unc.edu/exhibits/show/boxycartoons/intro",
"The Cartoons of Dwane Powell": "https://exhibits.lib.unc.edu/exhibits/show/dwanepowellcartoons/intro"
}
}

let wrapper, router;
Expand Down Expand Up @@ -613,6 +617,26 @@ describe('aggregateRecord.vue', () => {
expect(wrapper.find('.embargo').text()).toEqual(expect.stringMatching(/Embargoed Until:\s+2199-01-01/))
});

it("displays a list of exhibits separated by semicolons", () => {
let exhibits = wrapper.find('.exhibits');
expect(exhibits.exists()).toBe(true);
expect(exhibits.html()).toEqual(expect.stringMatching(/<a.href=.*boxycartoons.*>The.Cartoons.of.Boxy<\/a>;\s<a.href=.*dwanepowellcartoons.*>The Cartoons.of.Dwane.Powell<\/a>/));
});

it("displays a list with one exhibit without semicolons", async () => {
let updated_record = cloneDeep(record);
updated_record.exhibits = {
"The Epigraphs of Boxy": "https://exhibits.lib.unc.edu/exhibits/show/boxyepi/intro"
};
await wrapper.setProps({
recordData: updated_record
});
let exhibits = wrapper.find('.exhibits');
expect(exhibits.exists()).toBe(true);
// Regex looks to see that there's no semicolon after the last </a>
expect(exhibits.html()).toEqual(expect.stringMatching(/<a.href=.*boxyepi.*>The.Epigraphs.of.Boxy<\/a>(?!;)/));
});

it("displays a list of neighbor works", () => {
expect(wrapper.findComponent({ name: 'neighborList' }).exists()).toBe(true);
});
Expand Down
Loading