2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 19:29:02 +00:00
books/client/desk/listpage.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-02-08 09:38:47 +00:00
const frappe = require('frappejs');
2018-01-30 12:03:04 +00:00
const Page = require('frappejs/client/view/page');
const view = require('frappejs/client/view');
2018-02-08 09:38:47 +00:00
module.exports = class ListPage extends Page {
2018-03-05 16:45:21 +00:00
constructor(name) {
2018-02-14 16:44:50 +00:00
2018-02-19 16:41:10 +00:00
// if center column is present, list does not have its route
const hasRoute = frappe.desk.center ? false : true;
2018-02-14 16:44:50 +00:00
2018-02-19 16:41:10 +00:00
super({
2018-03-05 16:45:21 +00:00
title: frappe._("List"),
2018-02-19 16:41:10 +00:00
parent: hasRoute ? frappe.desk.body : frappe.desk.center,
hasRoute: hasRoute
});
2018-02-14 16:44:50 +00:00
2018-03-05 16:45:21 +00:00
this.list = new (view.getListClass(name))({
doctype: name,
2018-02-19 16:41:10 +00:00
parent: this.body,
page: this
});
2018-02-14 16:44:50 +00:00
frappe.docs.on('change', (params) => {
2018-03-05 16:45:21 +00:00
if (params.doc.doctype === this.list.meta.name) {
this.list.refreshRow(params.doc);
}
2018-02-19 16:41:10 +00:00
});
}
2018-03-05 16:45:21 +00:00
async show(params) {
super.show();
this.setTitle(name===this.list.doctype ? (this.list.meta.label || this.list.meta.name) : name);
frappe.desk.body.activePage.hide();
await this.list.refresh();
}
2018-01-30 12:03:04 +00:00
}