Skip to content

Commit

Permalink
fix: APPS-2091 update search config with filters for the listing page…
Browse files Browse the repository at this point in the history
…s. (#579)

* fix: initial  fixes

* fix: Add endowments and events and exhibiitons list

* fix: rebase and final donar and adding array for es field names

* fix: add percy snapshot command for 2 new specs added by other PR

* fix: null donor issue

* fix: asyncdata cannot use this.*, so moved the methods outside export default
  • Loading branch information
pghorpade authored Dec 8, 2022
1 parent fea6e2f commit dcd3545
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 85 deletions.
1 change: 1 addition & 0 deletions cypress/integration/resource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("Resource page", () => {
"contain",
`Animals are Excellent and Flowers are Fluffy`
)
cy.percySnapshot({ widths: [768, 992, 1200] })
})

context("When there isn't an entry in craft", () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/integration/service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("Service page", () => {
"contain",
`Service with all flexible page block types`
)
cy.percySnapshot({ widths: [768, 992, 1200] })
})

context("When there isn't an entry in craft", () => {
Expand Down
1 change: 1 addition & 0 deletions gql/queries/ArticleDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
query ArticleNewsDetail($slug: [String!]) {
entry(section: "article", slug: $slug) {
... on article_article_Entry {
postDate
id
slug
uri
Expand Down
1 change: 1 addition & 0 deletions gql/queries/CollectionDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

query CollectionDetail($slug: [String!]) {
entry(section: "collection", slug: $slug) {
postDate
id
physicalDigital
uri
Expand Down
52 changes: 30 additions & 22 deletions gql/queries/EndowmentDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,38 @@ query EndowmentDetail($slug: [String!]) {
altText
}
}
... on endowment_endowments_Entry {
alternativeName {
... on alternativeName_alternativeName_BlockType {
languageAltName
fullName
}
}
endowmentDescription
subjectAreas {
title
alternativeName {
... on alternativeName_alternativeName_BlockType {
languageAltName
fullName
}
donors {
... on donors_donor_BlockType {
firstName
lastName
}
}
endowmentDescription
subjectAreas {
title
}
donors {
... on donors_donor_BlockType {
firstName
lastName
}
to: donationUrl
spakCode
associatedLocations {
title
uri
}
endowmentDescription
subjectAreas {
title
}
donors {
... on donors_donor_BlockType {
firstName
lastName
}
...AllFpbWithNoBanner
}
to: donationUrl
spakCode
associatedLocations {
title
uri
}
...AllFpbWithNoBanner
}
}
}
1 change: 1 addition & 0 deletions gql/queries/EventDetail.gql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ query EventDetail($slug: [String!]) {
event: entry(section: "event", slug: $slug) {
... on event_event_Entry {
id
uri
typehandle
sectionHandle
title
Expand Down
26 changes: 18 additions & 8 deletions pages/collections/explore/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</div>

<divider-way-finder
v-if="(page.blocks.length > 0)"
v-if="page.blocks.length > 0"
class="divider-way-finder"
color="default"
/>
Expand All @@ -66,7 +66,11 @@
/>

<section-wrapper
v-if="(parsedServicesAndResources.length > 0 || parsedEndowments.length > 0 || parsedAssociatedStaffMember.length > 0)"
v-if="
parsedServicesAndResources.length > 0 ||
parsedEndowments.length > 0 ||
parsedAssociatedStaffMember.length > 0
"
theme="divider"
>
<divider-way-finder
Expand All @@ -86,7 +90,10 @@
/>

<divider-way-finder
v-if="(parsedEndowments.length > 0 || parsedAssociatedStaffMember.length > 0)"
v-if="
parsedEndowments.length > 0 ||
parsedAssociatedStaffMember.length > 0
"
class="divider-way-finder"
color="default"
/>
Expand All @@ -101,7 +108,7 @@
/>

<divider-way-finder
v-if="(parsedAssociatedStaffMember.length > 0)"
v-if="parsedAssociatedStaffMember.length > 0"
class="divider-way-finder"
color="default"
/>
Expand Down Expand Up @@ -134,7 +141,7 @@ export default {
slug: params.slug,
})
if (!data.entry) {
error({ statusCode: 404, message: 'Page not found' })
error({ statusCode: 404, message: "Page not found" })
}
// console.log("Data fetched: " + JSON.stringify(data))
if (data) await $elasticsearchplugin.index(data.entry, params.slug)
Expand Down Expand Up @@ -184,7 +191,8 @@ export default {
image: _get(obj, "image[0].image[0]", null),
title: _get(obj, "title", ""),
description: _get(obj, "description", ""),
category: obj.donors.length > 0 ? this.parsedDonors(obj) : "",
category:
obj.donors.length > 0 ? this.parsedDonors(obj) : "",
}
})
} else {
Expand All @@ -206,7 +214,9 @@ export default {
parsedDonors(obj) {
let donorNames = []
obj.donors.map((donor) => {
donor.firstName == null ? donorNames.push(`${donor.lastName}`) : donorNames.push(`${donor.firstName} ${donor.lastName}`)
donor.firstName == null
? donorNames.push(`${donor.lastName}`)
: donorNames.push(`${donor.firstName} ${donor.lastName}`)
})
if (donorNames.length == 1) {
Expand All @@ -219,7 +229,7 @@ export default {
return `Donors: ${names}`
}
},
}
},
}
</script>

Expand Down
79 changes: 55 additions & 24 deletions pages/give/endowments/_slug.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,61 @@ import _get from "lodash/get"
// GQL
import ENDOWMENT_DETAIL from "~/gql/queries/EndowmentDetail"
function parsedDonorsForES(donors) {
if (donors && donors.length > 0) {
computeDonors(donors)
} else {
return ""
}
}
function computeDonors(donors) {
let donorNames = []
for (let donor of donors) {
let name = ""
if (
donor.firstName &&
donor.firstName !== "" &&
(!donor.lastName || donor.lastName === "")
) {
name = donor.firstName
} else if (
donor.firstName &&
donor.firstName !== "" &&
donor.lastName &&
donor.lastName !== ""
) {
name = donor.firstName + " " + donor.lastName
} else {
name = donor.lastName
}
if (name !== "") donorNames.push(name)
}
if (donorNames.length == 1) {
return `${donorNames[0]}`
} else {
let names = [
donorNames.slice(0, -1).join(", "),
donorNames.slice(-1)[0],
].join(donorNames.length < 2 ? "" : " and ")
return `${names}`
}
}
export default {
async asyncData({ $graphql, params, $elasticsearchplugin, error }) {
async asyncData({ $graphql, params, $elasticsearchplugin, error, app }) {
const data = await $graphql.default.request(ENDOWMENT_DETAIL, {
slug: params.slug,
})
if (!data.entry) {
error({ statusCode: 404, message: 'Page not found' })
error({ statusCode: 404, message: "Page not found" })
}
if (data) await $elasticsearchplugin.index(data.entry, params.slug)
if (data && data.entry) {
data.entry.donorNames = parsedDonorsForES(data.entry.donors)
await $elasticsearchplugin.index(data.entry, params.slug)
}
return {
page: _get(data, "entry", {}),
}
Expand All @@ -109,20 +155,7 @@ export default {
computed: {
parsedDonors() {
if (this.page.donors && this.page.donors.length > 0) {
let donors = this.page.donors
let donorNames = []
donors.map((donor) => {
donorNames.push(`${donor.firstName} ${donor.lastName}`)
})
if (donorNames.length == 1) {
return `${donorNames[0]}`
} else {
let names = [
donorNames.slice(0, -1).join(", "),
donorNames.slice(-1)[0],
].join(donorNames.length < 2 ? "" : " and ")
return `${names}`
}
return computeDonors(this.page.donors)
} else {
return ""
}
Expand Down Expand Up @@ -156,12 +189,12 @@ export default {
}
.description {
max-width: 596px;
max-width: 596px;
.description-text {
padding-right: 0;
}
.description-text {
padding-right: 0;
}
}
.donors {
@include step-1;
Expand All @@ -174,7 +207,6 @@ export default {
margin-bottom: 20px;
}
.catalog-link {
font-family: var(--font-secodary);
font-size: 20px;
Expand All @@ -200,11 +232,10 @@ export default {
}
}
@media #{$medium} {
@media #{$medium} {
.description {
max-width: 100%;
}
}
}
</style>
4 changes: 2 additions & 2 deletions pages/help/services-resources/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ export default {
this.helptopic = {}
const results = await this.$dataApi.keywordSearchWithFilters(
this.$route.query.q || "*",
config.staff.searchFields,
config.serviceOrResources.searchFields,
"sectionHandle:serviceOrResource OR sectionHandle:workshopSeries OR sectionHandle:externalResource OR sectionHandle:helpTopic",
[],
"",
config.serviceOrResources.sortField,
config.serviceOrResources.resultFields,
[]
)
Expand Down
Loading

3 comments on commit dcd3545

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.