2
0
mirror of https://github.com/frappe/books.git synced 2025-01-10 18:24:40 +00:00
books/src/pages/ListView/index.vue

56 lines
1.3 KiB
Vue
Raw Normal View History

<template>
<div class="bg-light">
2018-10-22 20:32:37 +00:00
<page-header :title="listConfig.title" />
<div class="px-4 py-3">
<list-toolbar
2018-10-22 20:32:37 +00:00
:listConfig="listConfig"
@newClick="openNewForm"
@filterList="keyword => filterList(keyword)"
class="mb-4"
/>
<list
2018-10-22 20:32:37 +00:00
:listConfig="listConfig"
/>
</div>
</div>
</template>
<script>
import frappe from 'frappejs';
import Observable from 'frappejs/utils/observable';
import PageHeader from '@/components/PageHeader';
import ListToolbar from './ListToolbar';
import List from './List';
2018-10-22 20:32:37 +00:00
import listConfigs from './listConfig';
export default {
name: 'ListView',
2018-10-22 20:32:37 +00:00
props: ['listName'],
components: {
PageHeader,
ListToolbar,
List
},
created() {
frappe.listView = new Observable();
},
methods: {
async openNewForm() {
2018-10-22 20:32:37 +00:00
const doctype = this.listConfig.doctype;
const doc = await frappe.getNewDoc(doctype);
if (this.listConfig.filters) {
doc.set(this.listConfig.filters);
}
this.$router.push(`/edit/${doctype}/${doc.name}`);
doc.on('afterInsert', () => {
this.$router.push(`/edit/${doctype}/${doc.name}`);
});
}
},
computed: {
listConfig() {
return listConfigs[this.listName];
}
}
}
</script>