Skip to content

Commit

Permalink
fixing /home/ prefix, Search filter behavior tweaks (#602)
Browse files Browse the repository at this point in the history
* fixing final instance of unfiltered links to account for /home/ prefix

* clean up

* tweaks to filter behavior for EDU, adding target audience to event search cards

* fixing a regression in SearchFilterGroup
  • Loading branch information
stephiescastle committed Sep 6, 2024
1 parent 940c225 commit d61968b
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
21 changes: 11 additions & 10 deletions packages/vue/src/components/BaseButton/BaseButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ export default defineComponent({
return 'button'
}
},
// necessary for valid html
// must account for <a>, <nuxt-link>, and <button> use-cases
theHref(): string | undefined {
if (this.tag === 'nuxt-link') {
return this.to as string
} else if (this.tag === 'a') {
return this.href
}
return undefined
},
computedTo() {
let toValue = this.to
// filter out unnecessary `/home/` prefix from wagtail default site urlPaths
Expand All @@ -83,6 +73,17 @@ export default defineComponent({
}
return toValue
},
// necessary for valid html
// must account for <a>, <nuxt-link>, and <button> use-cases
theHref(): string | undefined {
let href = undefined
if (this.computedTo && typeof this.computedTo === 'string') {
href = this.computedTo
} else if (this.tag === 'a') {
href = this.href
}
return href
},
variantClass(): string {
let classes = variants[this.variant]
if (!this.$slots.default && this.$slots.icon) {
Expand Down
8 changes: 7 additions & 1 deletion packages/vue/src/components/BlockLinkCard/BlockLinkCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@
>
{{ theItem.title }}
</component>
<p
v-if="(theItem as EventCardObject).targetAudience"
:class="{ 'mt-2': !large, 'mt-4': large }"
>
<strong>Target Audience:</strong> {{ (theItem as EventCardObject).targetAudience }}
</p>
<p
v-if="theItem.date && !themeStore.isEdu"
class="text-gray-mid-dark mt-2"
class="text-gray-mid-dark"
:class="{ 'mt-2': !large, 'mt-4': large }"
>
{{ theItem.date }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<template>
<div
v-if="
typeof groupKey !== 'undefined' &&
typeof buckets !== 'undefined' &&
bucketsLength >= 1 &&
!hideFilterGroups.includes(groupKey)
"
v-if="showFilterGroup"
:id="`filterGroup_${groupKey}`"
class="border-gray-light-mid col-span-3 pb-4 mb-4 border-b"
>
<!-- bucket key param -->
<legend class="md:mb-3 text-body-md mb-2 font-bold leading-normal tracking-wide">
{{ groupTitle }}
</legend>
<div class="buckets">
<div
v-if="buckets?.length"
class="buckets"
>
<div
v-for="(bucket, index) in buckets"
:key="bucket.key"
Expand Down Expand Up @@ -43,6 +41,7 @@
</div>
</div>
</div>
<div v-else><span class="text-sm text-gray-mid-dark">No matching filters</span></div>
<!--
TODO: this logic could probably cleaner. It flows in the opposite way of the loop
for making checkboxes above.
Expand Down Expand Up @@ -116,6 +115,18 @@ export default {
},
bucketsLength() {
return this.buckets.length
},
showFilterGroup() {
if (this.themeStore.isEdu) {
return this.groupTitle && !this.hideFilterGroups.includes(this.groupKey)
} else {
return (
typeof this.groupKey !== 'undefined' &&
typeof this.buckets !== 'undefined' &&
this.bucketsLength >= 1 &&
!this.hideFilterGroups.includes(this.groupKey)
)
}
}
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
ongoing,
primarySubject,
gradeLevels,
time
time,
targetAudience
}
}"
show-calendar-chip
Expand Down Expand Up @@ -343,6 +344,10 @@ export default defineComponent({
type: Boolean,
default: false
},
targetAudience: {
type: String,
default: undefined
},
primarySubject: {
type: Object as PropType<PrimarySubjectObject>,
default: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
ongoing,
primarySubject,
gradeLevels,
time
time,
targetAudience
}
}"
:heading-level="headingLevel"
Expand Down Expand Up @@ -174,6 +175,10 @@ export default defineComponent({
type: Boolean,
default: false
},
targetAudience: {
type: String,
default: undefined
},
location: {
type: String,
default: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
:end-time="page.endTime"
:event-type="page.eventType"
:ongoing="page.ongoing"
:target-audience="page.targetAudience"
:location="page.location"
:primary-subject="page.primarySubject as unknown as PrimarySubjectObject"
:grade-levels="page.gradeLevels as unknown as GradeLevelsObject[]"
Expand All @@ -55,6 +56,7 @@
:end-time="page.endTime"
:event-type="page.eventType"
:ongoing="page.ongoing"
:target-audience="page.targetAudience"
:location="page.location"
:primary-subject="page.primarySubject as unknown as PrimarySubjectObject"
:grade-levels="page.gradeLevels as unknown as GradeLevelsObject[]"
Expand Down Expand Up @@ -216,6 +218,10 @@ export default defineComponent({
handle === 'edu_events_edueventpage'
? page._source.edu_events_edueventpage__ongoing
: undefined
page.targetAudience =
handle === 'edu_events_edueventpage'
? page._source.edu_events_edueventpage__target_audience
: undefined
// edu resources
page.gradeLevels = gradeLevels
page.time = time
Expand Down
6 changes: 4 additions & 2 deletions packages/vue/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ export interface ElasticSearchPage {
eventType?: string
ongoing?: boolean
primarySubject?: string
gradeLevels: string
time: string
gradeLevels?: string
time?: string
targetAudience?: string
}

export interface FormOption {
Expand Down Expand Up @@ -136,6 +137,7 @@ export interface EventCardObject extends Card {
locationName?: string
location?: string
locationLink?: string
targetAudience?: string
}

export interface PrimarySubjectObject {
Expand Down

0 comments on commit d61968b

Please sign in to comment.