JavaScript:
new CMSStartD1Connector({
el: document.getElementById("destiny-output"),
config: CMSConfigObject.destinyOne,
setup: ({vue, status, courseStatus, functions, certificate, course}) => {
/*
vue refs must be accessed with .value
status: object containing info on view state. Contains 'state' and 'errorMessage' properties
courseStatus: object containing info on course state. Contains 'state' and 'errorMessage' properties
functions: object containing various functions
certificate: vue ref object containing certificate information
course: vue ref object containing course (retrieved from functions.fetchCourse())
Example of access:
filterOptions.value.availability.default
currentFilters.availability
courses.value[0].name
pagination.currentPage.value
keyword.value
*/
// 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',
});
// certificate and course are null until the data is loaded
console.log("certificate: ", certificate.value);
console.log("course: ", course.value);
// Watch for the 'ready' state to know they're loaded and the view is ready
vue.watch(status, () => {
if (status.state === 'ready') {
console.log("loaded certificate: ", certificate.value);
// Override default page title
functions.setPageTitle('My Page');
}
});
vue.watch(courseStatus, () => {
if (courseStatus.state === 'ready' && course.value) {
console.log("loaded course: ", course.value);
}
});
// Return anything you want to be available in the template as an object
// (Note: template refs must be returned in order to function)
return {
exampleReactive,
};
},
});