Starting with VueJS

This commit is contained in:
scmmishra 2018-11-01 17:17:30 +05:30 committed by Aditya Hase
parent 1778b59efa
commit 84297fa349
3 changed files with 29 additions and 10 deletions

View File

@ -8,9 +8,9 @@ import AcademyCoursePage from "./web-academy/pages/AcademyCoursePage.vue";
Vue.use(VueRouter) Vue.use(VueRouter)
const routes = [ const routes = [
{path: '', component: AcademyHome}, {name: 'home', path: '', component: AcademyHome},
{path: '/Program/:code', component: AcademyProgramPage, props: true}, {name: 'program', path: '/Program/:code', component: AcademyProgramPage, props: true},
{path: '/Course', component: AcademyCoursePage}, {name: 'content', path: '/Program/:code/:course/:type/:content', component: AcademyCoursePage, props: true},
]; ];
const router = new VueRouter({ const router = new VueRouter({
@ -18,7 +18,7 @@ const router = new VueRouter({
}); });
frappe.ready(() => { frappe.ready(() => {
new Vue({ window.v = new Vue({
el: "#web-academy", el: "#web-academy",
router: router, router: router,
template: "<academy-root/>", template: "<academy-root/>",

View File

@ -1,6 +1,6 @@
<template> <template>
<div id="academy-root"> <div id="academy-root">
<router-view></router-view> <router-view :key="$route.fullPath"></router-view>
</div> </div>
</template> </template>
<script> <script>

View File

@ -1,17 +1,36 @@
<template> <template>
<div> <div>
<AcademyTopSection/> <AcademyTopSection :title="title" :description="description"/>
<AcademyCardList/> <AcademyList :title="'Featured Programs'" :description="'Master ERPNext'">
<AcademyProgramCard v-for="program in featured_programs" :key="program.name" :program_code="program"/>
</AcademyList>
</div> </div>
</template> </template>
<script> <script>
import AcademyTopSection from "../components/AcademyTopSection.vue" import AcademyTopSection from "../components/AcademyTopSection.vue"
import AcademyCardList from "../components/AcademyCardList.vue" import AcademyList from "../components/AcademyList.vue"
import AcademyProgramCard from "../components/AcademyProgramCard.vue"
export default { export default {
name: "AcademyHome", name: "AcademyHome",
data() {
return{
title: '',
description: '',
featured_programs: []
}
},
components: { components: {
AcademyTopSection, AcademyCardList AcademyTopSection, AcademyList, AcademyProgramCard
} },
mounted() {
frappe.call("erpnext.www.academy.get_portal_details").then(r => {
this.title = r.message.title,
this.description = r.message.description
});
frappe.call("erpnext.www.academy.get_featured_programs").then(r => {
this.featured_programs = r.message
});
},
}; };
</script> </script>