JavaScript:
new CMSStartD1Connector({
el: document.getElementById("destiny-output"),
config: CMSConfigObject.destinyOne,
setup: ({vue, status, searchStatus, functions, filterOptions, currentFilters, courses, 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
courses: 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
courses.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("courses: ", courses.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("courses: ", courses.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: 'Term', // visual label
optionKey: 'semesters', // key in active filters
},
{
label: 'Status', // visual label
optionKey: 'availability', // key in active filters
},
{
label: 'Day of week', // visual label
optionKey: 'startDays', // key in active filters
},
{
label: 'Location', // visual label
optionKey: 'campuses', // key in active filters
},
{
label: 'Instructor', // visual label
optionKey: 'instructor', // key in active filters
type: 'text',
},
{
label: 'Accreditor', // visual label
optionKey: 'accreditingAssociations', // key in active filters
},
{
label: 'Delivery', // visual label
optionKey: 'instructionMethods', // key in active filters
},
{
label: 'Course Category', // visual label
optionKey: 'categories', // key in active filters
},
{
label: 'Start Time', // visual label
optionKey: 'startTimes', // key in active filters
},
{
label: 'Start Month', // visual label
optionKey: 'startMonths', // key in active filters
},
{
label: 'Subject', // visual label
optionKey: 'programAreaStreams', // key in active filters
type: 'multiselect-tree',
},
],
};
},
});