forked from sachatrauwaen/vuecrud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrudApp.js
64 lines (55 loc) · 2.02 KB
/
CrudApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Vue from 'vue'
import VueRouter from 'vue-router'
import VueCrud from './index'
import OaConnector from './connectors/OaConnector'
export default {
create(id, layout) {
Vue.use(VueRouter);
Vue.use(VueCrud);
const crudGrid = Vue.component('oa-crud-grid');
const crudForm = Vue.component('oa-crud-form');
// const crudGrid = Vue.component('OaCrudGrid');
// const crudForm = Vue.component('OaCrudForm');
const router = new VueRouter({
//scrollBehavior: () => ({ y: 0 }),
routes: [
{ path: '/:module/:resource', component: crudGrid, name: 'grid' },
{ path: '/:module/:resource/edit/:id', component: crudForm, name: 'edit' },
{ path: '/:module/:resource/add', component: crudForm, name: 'add' }
]
});
new Vue({
router: router,
connector: OaConnector,
//render: h => h('router-view')
//render: h => h(layout, [h('router-view')]),
render(h) {
return h(layout, {
scopedSlots: {
default: () => {
return h('router-view')
}
},
props: {
title: this.pageTitle
}
})
},
computed: {
messages() {
return OaConnector.messages(this.$route.params.module);
},
pageTitle: function () {
if (this.$route.params.resource) {
let key = this.$route.params.resource.capitalize() + 's';
let title = this.messages[[this.$route.params.resource.capitalize() + 's']]
return title ? title : key;
}
else {
return 'Crud app';
}
}
}
}).$mount(id)
}
}