-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDPA-2727] Added support for custom modules (#437)
* [SDPA-2727] Added support for custom modules * Added support fow allowing no tide folder in project
- Loading branch information
1 parent
b12c53c
commit 55e4f84
Showing
48 changed files
with
1,156 additions
and
247 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<!-- Override the template if need--> | ||
<button class="example-button"><slot></slot></button> | ||
</template> | ||
|
||
<script> | ||
// Extend Ripple component if need. https://vuejs.org/v2/api/#extends | ||
// Please be careful as extending will introduce complexity in maintenance. | ||
import RplButton from '@dpc-sdp/ripple-button' | ||
export default { | ||
extends: RplButton, | ||
name: 'ExampleButton', | ||
created: function () { | ||
console.log('Extending works.') | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<template> | ||
<h1>{{text}}</h1> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'exampleMessage', | ||
props: { | ||
text: String | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<div> | ||
<h1>Example for extending component</h1> | ||
<example-button href="#" theme="primary" >Extending RplButton</example-button> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ExampleButton from './../../components/examples/Button' | ||
export default { | ||
components: { | ||
ExampleButton | ||
}, | ||
layout: 'minimal' | ||
} | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
export default { | ||
getFormData: async setFilterOptions => { | ||
const eventCategoryValues = await setFilterOptions({ | ||
fieldName: 'field_event_category_name' | ||
}) | ||
const eventNameValues = await setFilterOptions({ | ||
fieldName: 'field_event_details_event_requirements_name' | ||
}) | ||
return { | ||
title: "What's on in Victoria", | ||
searchPlaceholder: 'Search by keyword or location', | ||
theme: 'light', | ||
allowBlank: true, | ||
filterForm: { | ||
tideId: 'tide_search_form', | ||
tag: 'rpl-fieldset', | ||
model: { | ||
// Multi-value fields should always be an array. | ||
field_event_category_name: [], | ||
field_event_date_end_value: '', | ||
location: '', | ||
field_event_details_event_requirements_name: [] | ||
}, | ||
schema: { | ||
groups: [ | ||
{ | ||
fields: [ | ||
{ | ||
type: 'rplchecklist', | ||
styleClasses: ['form-group--col-two'], | ||
label: 'Select an event category', | ||
model: 'field_event_category_name', | ||
values: eventCategoryValues, | ||
placeholder: 'Select a topic', | ||
// TODO: Update 'filter' key to 'query' to make purpose clearer. | ||
filter: { | ||
type: 'term', | ||
operator: '' | ||
} | ||
}, | ||
{ | ||
type: 'input', | ||
inputType: 'text', | ||
maxlength: 50, | ||
styleClasses: ['form-group--col-two'], | ||
label: 'Location', | ||
model: 'location', | ||
placeholder: 'Start typing suburb or postcode...', | ||
filter: { | ||
type: 'multiMatch', | ||
operator: '', | ||
fields: [ | ||
'field_event_details_event_locality', | ||
'field_event_details_event_postal_code' | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
fields: [ | ||
{ | ||
type: 'rpldatepicker', | ||
ranged: false, | ||
styleClasses: ['form-group--col-two'], | ||
label: 'Select an event date', | ||
model: 'field_event_date_end_value', | ||
placeholder: 'DD/MM/YYYY', | ||
filter: { | ||
type: 'date', | ||
operator: 'lte' | ||
} | ||
}, | ||
{ | ||
type: 'rplchecklist', | ||
label: 'Event requirements', | ||
styleClasses: ['form-group--col-two'], | ||
model: 'field_event_details_event_requirements_name', | ||
// TODO: There are no values for this field how can we programmactically hide a field in this instance. | ||
values: eventNameValues, | ||
placeholder: 'Please select', | ||
filter: { | ||
type: 'term', | ||
operator: '' | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
fields: [ | ||
{ | ||
type: 'rplsubmitloader', | ||
buttonText: 'Apply change', | ||
loading: false, | ||
autoUpdate: true, | ||
styleClasses: ['form-group--inline'] | ||
}, | ||
{ | ||
type: 'rplclearform', | ||
buttonText: 'Clear search filters', | ||
styleClasses: ['form-group--inline'] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
formOptions: { | ||
validateAfterLoad: false, | ||
validateAfterChanged: false | ||
}, | ||
formState: {} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { latestEvents } from './mapping-fetchers' | ||
|
||
export const getCardCarouselEvents = async (mapping) => { | ||
// A little hack here to change latst event query limit to 9 for card carousel. | ||
latestEvents.args[3] = { | ||
offset: 0, | ||
limit: 9 | ||
} | ||
return mapping.filter(mapping.fetch(latestEvents), ['eventLatestEvents']).then(cards => { | ||
// Reassemble the data with a component name data structure so we can render them by vue dynamic components. | ||
return cards.map(card => { | ||
return { | ||
name: 'rpl-card-event', | ||
data: card | ||
} | ||
}) | ||
}) | ||
} |
41 changes: 41 additions & 0 deletions
41
examples/vic-gov-au/tide/modules/event/mapping-fetchers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This file provides fetcher objects for our mapping to fetch data from Tide API. | ||
// const moment = require('moment-timezone') | ||
|
||
module.exports = { | ||
latestEvents: { | ||
method: 'getContentList', | ||
args: [ | ||
'event', | ||
{ | ||
// TODO: https://digital-engagement.atlassian.net/browse/SDPA-1938 | ||
// 'date-filter': { | ||
// condition: { | ||
// path: 'field_event_details.0.field_paragraph_date_range.end_value', | ||
// operator: '>', | ||
// value: moment().tz('Australia/Melbourne').format() | ||
// } | ||
// } | ||
}, | ||
[ | ||
'field_event_details', | ||
'field_featured_image', | ||
'field_featured_image.field_media_image' | ||
], | ||
{ | ||
offset: 0, | ||
limit: 6 | ||
}, | ||
{ | ||
'sort-end': { | ||
path: 'field_event_details.0.field_paragraph_date_range.end_value' | ||
}, | ||
'sort-start': { | ||
path: 'field_event_details.0.field_paragraph_date_range.value' | ||
} | ||
}, | ||
{ | ||
allPages: false | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Filters for adding extra process on a mapping value | ||
|
||
// Create more filters if need. | ||
module.exports = { | ||
eventLatestEvents: async (list, { mapping }) => { | ||
try { | ||
const latestEvents = await list | ||
return latestEvents.map(item => { | ||
const location = mapping.parseField(['field_event_details', 0, 'field_paragraph_location'], item) | ||
return { | ||
image: mapping.parseField(['field_featured_image', 'field_media_image', 'url'], item), | ||
dateStart: mapping.parseField(['field_event_details', 0, 'field_paragraph_date_range', 'value'], item), | ||
dateEnd: mapping.parseField(['field_event_details', 0, 'field_paragraph_date_range', 'end_value'], item), | ||
location: mapping.filter(location, ['paragraphLocation']), | ||
title: item.title, | ||
summary: item.field_landing_page_summary, | ||
link: { text: 'See event details', url: item.path.url } | ||
} | ||
}) | ||
} catch (err) { | ||
// TODO: log error to log system when ops got it. | ||
// console.log(err) | ||
return [] | ||
} | ||
}, | ||
|
||
eventCtaCard: (fieldParagraphCtaCardEvent, { mapping }) => { | ||
if (!fieldParagraphCtaCardEvent.field_paragraph_cta) { | ||
return null | ||
} | ||
|
||
let image = '' | ||
if (fieldParagraphCtaCardEvent.field_paragraph_media) { | ||
const media = fieldParagraphCtaCardEvent.field_paragraph_media | ||
if (media.field_media_image) { | ||
image = media.field_media_image.url || media.field_media_image.uri | ||
} | ||
} | ||
|
||
const link = mapping.parseField('field_paragraph_cta', fieldParagraphCtaCardEvent) | ||
return { | ||
image: image, | ||
title: fieldParagraphCtaCardEvent.field_paragraph_title, | ||
summary: mapping.parseField(['field_paragraph_body', 'processed'], fieldParagraphCtaCardEvent), | ||
link: mapping.filter(link, ['paragraphCta']) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = function () { | ||
this.extendRoutes((routes, resolve) => { | ||
routes.push({ | ||
name: 'tidewhatson', | ||
path: '/whatson', | ||
component: '~/tide/modules/event/pages/search.vue' | ||
}) | ||
}) | ||
} |
Oops, something went wrong.