Skip to content

Commit

Permalink
Merge branch 'develop' into feature/firefox-radio-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly authored Apr 11, 2024
2 parents e007c2a + 6acdc71 commit 3ecc847
Show file tree
Hide file tree
Showing 25 changed files with 1,409 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to: .example.env
# If your site needs a new environment variable please log an issue with SDP support so it can be added via the config management database

# Tide Drupal CMS URL - change this to the project CMS as required
NUXT_PUBLIC_TIDE_BASE_URL=https://develop.content.reference.sdp.vic.gov.au/
NUXT_PUBLIC_TIDE_BASE_URL=https://develop.content.reference.sdp.vic.gov.au
# Tide site taxonomy id - change this to the project site ID as required
NUXT_PUBLIC_TIDE_SITE=8888
# SDP common GTM container - this should be common to all SDP sites utilising WoVG analytics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Given(
cy.intercept('POST', url, (req) => {
// Filter out the aggregation requests (they have size=1)
if (req.body.size === 0) {
req.alias = 'aggReq' // assign an alias to aggregations
req.alias = alias || 'aggReq' // assign an alias to aggregations
req.reply({
statusCode: status,
fixture: fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ When(
}
)

Then(`the map no results message should be visible`, (term) => {
Then(`the map no results message should be visible`, () => {
cy.get('.tide-custom-collection-no-results').should('be.visible')
})
Then(`the map no results message should contain {string}`, (term) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ When('I click the search suggestion labelled {string}', (label: string) => {
.click()
})

Then('the search suggestions should not be displayed', (option: string) => {
Then('the search suggestions should not be displayed', () => {
cy.get('#tide-search-bar__menu').should('not.exist')
})

Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-tide-api/src/utils/anchorLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('anchor link utilities', () => {
{ text: 'Second Heading', id: 'second-heading', type: 'h2' },
{ text: 'Third Heading', id: 'third-heading', type: 'h3' },
{
text: 'Special Character & < > Heading',
text: 'Special Character & < > Heading',
id: 'special-character-heading',
type: 'h2'
},
Expand All @@ -86,7 +86,7 @@ describe('anchor link utilities', () => {
expect(getAnchorLinksFromHTML(html)).toEqual([
{ text: 'Second Heading', id: 'second-heading', type: 'h2' },
{
text: 'Special Character &amp; &lt; &gt; Heading',
text: 'Special Character & < > Heading',
id: 'special-character-heading',
type: 'h2'
},
Expand Down
24 changes: 23 additions & 1 deletion packages/ripple-tide-api/src/utils/anchorLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const getAnchorLinksFromHTML = (
// Ignore empty headings.
if (textExists(item.text)) {
result.push({
text: item.text,
text: decodeSpecialCharacters(item.text),
id: getAnchorLinkId(item.text),
type: item.type
})
Expand Down Expand Up @@ -88,3 +88,25 @@ export const textExists = (text) => {
// Text exists if characters remain after spaces and &nbsp; are removed.
return text.replace(/\s|&nbsp;/g, '').length > 0
}

const decodeSpecialCharacters = (html) => {
const map = {
'&amp;': '&',
'&gt;': '>',
'&lt;': '<',
'&apos;': "'",
'&#039;': "'",
'&quot;': '"',
'&nbsp;': ' '
}
let replaceableCodes = '('
let first = true
for (const code in map) {
replaceableCodes += first ? code : `|${code}`
first = false
}
replaceableCodes += ')'
return html.replace(new RegExp(replaceableCodes, 'gi'), (code) => {
return map[code.toLowerCase()]
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const markupTranspiler = (
const $body = $('body')
let markupData = {}

if (Object.keys(plugins).length > 1) {
if (Object.keys(plugins).length) {
// Load plugins to transpile embedded components
for (const [index, plugin] of plugins.entries()) {
$.prototype[`plugin${index}`] = plugin
Expand Down
4 changes: 2 additions & 2 deletions packages/ripple-tide-api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ declare module 'nitropack' {

// Mapping util interfaces
export function getAddress(address: any): string
export function getBody(body: any): string
export function getBody(body: any, customPlugins?: (() => void)[]): string
export function getBodyFromField(
field: string,
path: string | string[],
fallback: any
fallback?: any
): string
export function getField(
field: string,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
getBody,
getField,
getImageFromField,
getLinkFromField
} from '@dpc-sdp/ripple-tide-api'
Expand All @@ -26,19 +25,16 @@ export const callToActionMapping = (
)

const link = getLinkFromField(field, 'field_paragraph_cta')
const style = getField(field, 'field_paragraph_cta_style')

return {
component: 'TideLandingPageCallToAction',
id: field.drupal_internal__id,
layout: style === 'card' ? 'card' : undefined,
props: {
title: field.field_paragraph_title,
image: image,
url: link?.url,
ctaText: link?.text,
summary: getBody(field.field_paragraph_body?.processed),
stacked: style === 'card'
summary: getBody(field.field_paragraph_body?.processed)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { getActiveFilterURL, ref } from '#imports'
import { getActiveFiltersTally, getActiveFilterURL, ref } from '#imports'
import { submitForm } from '@formkit/vue'
import useTideSearch from './../../composables/useTideSearch'
import type {
Expand Down Expand Up @@ -164,6 +164,7 @@ const {
results,
filterForm,
appliedFilters,
resetFilters,
submitSearch,
goToPage,
page,
Expand Down Expand Up @@ -314,8 +315,8 @@ const handleFilterReset = (event: rplEventPayload) => {
)
searchTerm.value = ''
filterForm.value = {}
locationQuery.value = null
resetFilters()
submitSearch()
closeMapPopup()
}
Expand Down Expand Up @@ -362,17 +363,7 @@ const handleToggleFilters = () => {
}
const numAppliedFilters = computed(() => {
return Object.values(appliedFilters.value).filter((value) => {
if (!value) {
return false
}
if (Array.isArray(value) && !value.length) {
return false
}
return true
}).length
return getActiveFiltersTally(appliedFilters.value)
})
const toggleFiltersLabel = computed(() => {
Expand Down Expand Up @@ -530,8 +521,8 @@ const reverseFields = computed(
<TideSearchResultsLoadingState :isActive="isBusy">
<TideSearchError v-if="searchError" class="rpl-u-margin-t-8" />
<TideCustomCollectionNoResults
class="rpl-u-margin-t-8 rpl-u-margin-b-8"
v-else-if="!isBusy && !results?.length"
class="rpl-u-margin-t-8 rpl-u-margin-b-8"
/>

<component
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export default {
searchListingConfig: {
resultsPerPage: 20,
formTheme: 'default',
hideSearchForm: false,
labels: {
submit: 'Submit search',
placeholder: 'Start typing search term...'
},
customSort: [{ 'title.keyword': 'asc' }]
},
queryConfig: {
multi_match: {
query: '{{query}}',
fields: [
'title^3',
'field_landing_page_summary^2',
'body',
'field_paragraph_body',
'summary_processed'
]
}
},
globalFilters: [
{ terms: { type: ['news'] } },
{ terms: { field_node_site: [8888] } }
],
userFilters: [
{
id: 'topic',
component: 'TideSearchFilterDropdown',
filter: { type: 'terms', value: 'field_topic_name' },
aggregations: { field: 'topic', source: 'taxonomy' },
props: {
id: 'topic',
label: 'Topics',
placeholder: 'Select a topic',
type: 'RplFormDropdown',
multiple: true,
options: [
{
id: '1',
label: 'Option 1',
value: 'Option 1',
parent: null
}
]
}
},
{
id: 'tags',
component: 'TideSearchFilterCheckbox',
filter: {
type: 'terms',
value: 'field_tags_name',
multiple: false
},
props: {
id: 'tags',
label: 'Tags',
checkboxLabel: 'Only show demo tag',
onValue: 'Demo Tag'
}
}
],
results: {
layout: {
component: 'TideSearchResultsTable',
props: {
showExtraContent: true,
columns: [
{ label: 'Title', objectKey: 'title', cols: 4 },
{ label: 'Tags', objectKey: 'field_tags_name' }
],
extraContent: {
items: [
{ label: 'Topics', objectKey: 'field_topic_name' },
{ label: 'Date', objectKey: 'field_news_date' }
]
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
export default {
searchListingConfig: {
hideSearchForm: false,
resultsPerPage: 12,
labels: {
submit: 'Submit search',
placeholder: 'Start typing search term...'
},
customSort: [{ created: 'desc' }, { 'title.keyword': 'asc' }],
formTheme: 'default'
},
queryConfig: {
multi_match: {
query: '{{query}}',
fields: [
'field_landing_page_summary^2',
'field_paragraph_body',
'summary_processed',
'title',
'body'
]
}
},
globalFilters: [
{ terms: { status: [true] } },
{ terms: { field_node_site: [8888] } },
{ terms: { type: ['news'] } },
{ terms: { field_topic_name: ['Demo Topic'] } }
],
userFilters: [
{
id: 'department',
component: 'TideSearchFilterDropdown',
filter: { type: 'terms', value: 'field_department_name' },
aggregations: { field: 'department', source: 'taxonomy' },
props: {
id: 'department',
label: 'Departments',
placeholder: 'Select a department',
type: 'RplFormDropdown',
multiple: true,
options: [
{
id: '1',
label: 'Option 1',
value: 'Option 1',
parent: null
}
]
}
},
{
id: 'topic',
component: 'TideSearchFilterDropdown',
aggregations: { field: 'topic', source: 'taxonomy' },
filter: { type: 'terms', value: 'field_topic_name' },
props: {
id: 'topic',
label: 'Topic',
placeholder: 'Select a topic',
type: 'RplFormDropdown',
multiple: true,
options: [
{
id: '1',
label: 'Option 1',
value: 'Option 1',
parent: null
}
]
}
},
{
id: 'tags',
component: 'TideSearchFilterCheckbox',
filter: { type: 'terms', value: 'field_tags_name', multiple: false },
props: {
id: 'tags',
label: 'Tags',
checkboxLabel: 'Only show demo tag',
onValue: 'Demo Tag'
}
}
],
results: {
layout: { component: 'TideSearchResultsList', props: { customProp: true } },
item: { '*': { component: 'TideSearchResult' } }
},
layoutConfig: { belowFilter: { component: 'TideCustomBelowFilterComponent' } }
}
Loading

0 comments on commit 3ecc847

Please sign in to comment.