JavaScript:
new CMSStartD1Connector({
el: document.getElementById("destiny-output"),
config: CMSConfigObject.destinyOne,
setup: ({vue, status, searchStatus, functions, filterOptions, currentFilters, certificates, pagination, searched, keyword}) => {
/*
vue refs must be accessed with .value
status: object containing info on view state. Contains 'state' and 'errorMessage' properties
searchStatus: object containing info on searchingstate. Contains 'state' and 'errorMessage' properties
functions: object containing various functions
filterOptions: vue ref object with information on what filters are available and their corresponding options
currentFilters: vue reactive object detailing current filter values
certificates: vue ref object containing search results
pagination: object of vue refs containing info about pagination. Contains 'currentPage', 'numPages' and 'numTotalCourses' properties
searched: vue ref boolean specifying if a search has been performed (false on load, true after first search has been executed)
keyword: vue ref string specifying the value of the keyword search input
Example of access:
filterOptions.value.availability.default
currentFilters.availability
certificates.value[0].name
pagination.currentPage.value
keyword.value
*/
/* EXAMPLE CODE */
// Vue utilities are properties of vue (vue.ref, vue.reactive, etc)
// Available vue utilities: ref, reactive, computed, onMounted, onUnmounted, watch, watchEffect, nextTick, onUpdated
const exampleRef = vue.ref(null);
const exampleReactive = vue.reactive({
prop1: 'value 1',
prop2: 'value 2',
});
// filterOptions is null until the data is loaded
console.log("filterOptions: ", filterOptions.value);
// courses is are null until a search is performed
console.log("certificates: ", certificates.value);
// Watch for the 'ready' state to know filterOptions are loaded and the view is ready
vue.watch(status, () => {
if (status.state === 'ready') {
console.log("filterOptions: ", filterOptions.value);
// Override default page title
functions.setPageTitle('My Page');
}
});
// Watch for the 'ready' state to know courses are loaded
vue.watch(searchStatus, () => {
if (searchStatus.state === 'ready') {
console.log("certificates: ", certificates.value);
}
});
/* /EXAMPLE CODE */
// Return anything you want to be available in the template as an object
// (Note: template refs must be returned in order to function)
return {
resetFilters () {
functions.resetFilters();
functions.search();
},
filters: [
{
label: 'Type',
optionKey: 'types',
},
{
label: 'Interest Area',
optionKey: 'interestAreas',
},
{
label: 'Subject', // visual label
optionKey: 'programAreaStreams', // key in active filters
type: 'multiselect-tree',
},
],
};
},
});