2018-10-10 18:51:03 +00:00
|
|
|
<template>
|
2019-08-01 11:52:58 +00:00
|
|
|
<div class="bg-white">
|
2018-10-22 20:32:37 +00:00
|
|
|
<page-header :title="listConfig.title" />
|
2018-10-10 18:51:03 +00:00
|
|
|
<div class="px-4 py-3">
|
|
|
|
<list-toolbar
|
2018-10-22 20:32:37 +00:00
|
|
|
:listConfig="listConfig"
|
2018-10-10 18:51:03 +00:00
|
|
|
@newClick="openNewForm"
|
2018-10-22 19:10:45 +00:00
|
|
|
@filterList="keyword => filterList(keyword)"
|
2018-10-10 18:51:03 +00:00
|
|
|
class="mb-4"
|
|
|
|
/>
|
2019-08-01 11:52:58 +00:00
|
|
|
<list :listConfig="listConfig" />
|
2018-10-10 18:51:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import frappe from 'frappejs';
|
2018-10-22 19:10:45 +00:00
|
|
|
import Observable from 'frappejs/utils/observable';
|
2018-10-10 18:51:03 +00:00
|
|
|
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';
|
2018-10-10 18:51:03 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ListView',
|
2018-10-22 20:32:37 +00:00
|
|
|
props: ['listName'],
|
2018-10-10 18:51:03 +00:00
|
|
|
components: {
|
|
|
|
PageHeader,
|
|
|
|
ListToolbar,
|
|
|
|
List
|
|
|
|
},
|
2018-10-22 19:10:45 +00:00
|
|
|
created() {
|
|
|
|
frappe.listView = new Observable();
|
|
|
|
},
|
2018-10-10 18:51:03 +00:00
|
|
|
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() {
|
2019-08-01 13:00:52 +00:00
|
|
|
if (listConfigs[this.listName]) {
|
|
|
|
return listConfigs[this.listName];
|
|
|
|
} else {
|
|
|
|
frappe.call({
|
|
|
|
method: 'show-dialog',
|
|
|
|
args: {
|
|
|
|
title: 'Not Found',
|
|
|
|
message: `${this.listName} List not Registered`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.$router.go(-1);
|
|
|
|
}
|
2018-10-10 18:51:03 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-01 11:52:58 +00:00
|
|
|
};
|
2018-10-10 18:51:03 +00:00
|
|
|
</script>
|