2
0
mirror of https://github.com/frappe/books.git synced 2025-01-25 16:18:33 +00:00
books/client/desk/listpage.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

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