feat: Report links in dashboard
This commit is contained in:
parent
f75aa3beff
commit
0396dff959
3 changed files with 34 additions and 1 deletions
|
|
@ -238,6 +238,7 @@
|
|||
"public/js/frappe/form/templates/form_dashboard.html",
|
||||
"public/js/frappe/form/templates/form_document_flow.html",
|
||||
"public/js/frappe/form/templates/form_links.html",
|
||||
"public/js/frappe/form/templates/report_links.html",
|
||||
"public/js/frappe/form/templates/attachment.html",
|
||||
"public/js/frappe/form/templates/form_footer.html",
|
||||
"public/js/frappe/form/templates/timeline.html",
|
||||
|
|
|
|||
|
|
@ -153,7 +153,8 @@ frappe.ui.form.Dashboard = Class.extend({
|
|||
|
||||
var show = false;
|
||||
|
||||
if(this.data && (this.data.transactions || []).length) {
|
||||
if(this.data && ((this.data.transactions || []).length
|
||||
|| (this.data.reports || []).length)) {
|
||||
if(this.data.docstatus && this.frm.doc.docstatus !== this.data.docstatus) {
|
||||
// limited docstatus
|
||||
return;
|
||||
|
|
@ -263,11 +264,19 @@ frappe.ui.form.Dashboard = Class.extend({
|
|||
$(frappe.render_template('form_links', this.data))
|
||||
.appendTo(this.transactions_area)
|
||||
|
||||
$(frappe.render_template('report_links', this.data))
|
||||
.appendTo(this.transactions_area)
|
||||
|
||||
// bind links
|
||||
this.transactions_area.find(".badge-link").on('click', function() {
|
||||
me.open_document_list($(this).parent());
|
||||
});
|
||||
|
||||
// bind reports
|
||||
this.transactions_area.find(".report-link").on('click', function() {
|
||||
me.open_report($(this).parent());
|
||||
});
|
||||
|
||||
// bind open notifications
|
||||
this.transactions_area.find('.open-notification').on('click', function() {
|
||||
me.open_document_list($(this).parent(), true);
|
||||
|
|
@ -280,6 +289,11 @@ frappe.ui.form.Dashboard = Class.extend({
|
|||
|
||||
this.data_rendered = true;
|
||||
},
|
||||
open_report: function($link) {
|
||||
let report = $link.attr('data-report')
|
||||
frappe.route_options[this.data.fieldname] = this.frm.doc.name;
|
||||
frappe.set_route("query-report", report)
|
||||
},
|
||||
open_document_list: function($link, show_open) {
|
||||
// show document list with filters
|
||||
var doctype = $link.attr('data-doctype'),
|
||||
|
|
|
|||
18
frappe/public/js/frappe/form/templates/report_links.html
Normal file
18
frappe/public/js/frappe/form/templates/report_links.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<div class="form-documents">
|
||||
{% for (var i=0; i < reports.length; i++) { %}
|
||||
{% if((i % 2)===0) { %}<div class="row">{% } %}
|
||||
<div class="col-xs-6">
|
||||
<h6>{{ reports[i].label }}</h6>
|
||||
{% for (var j=0; j < reports[i].items.length; j++) {
|
||||
var report = reports[i].items[j]; %}
|
||||
<div class="document-link"
|
||||
data-report="{{ report }}">
|
||||
<a class="report-link small">{{ __(report) }}</a>
|
||||
</div>
|
||||
{% } %}
|
||||
</div>
|
||||
{% if((i % 2)===1) { %}</div>{% } %}
|
||||
{% } %}
|
||||
<!-- finally, close one-column row -->
|
||||
{% if((i % 2)===0) { %}</div>{% } %}
|
||||
</div>
|
||||
Loading…
Add table
Reference in a new issue