fix: code formatting
This commit is contained in:
parent
d3c630927f
commit
c84321d638
4 changed files with 28 additions and 47 deletions
|
|
@ -297,7 +297,8 @@ class DashboardChart {
|
|||
setup_filter_button() {
|
||||
|
||||
this.is_document_type = this.chart_doc.chart_type!== 'Report' && this.chart_doc.chart_type!=='Custom';
|
||||
this.filter_button = $(`<div class="filter-chart btn btn-default btn-xs pull-right">${__("Set Filters")}</div>`);
|
||||
this.filter_button =
|
||||
$(`<div class="filter-chart btn btn-default btn-xs pull-right">${__("Set Filters")}</div>`);
|
||||
this.filter_button.prependTo(this.chart_container);
|
||||
|
||||
this.filter_button.on('click', () => {
|
||||
|
|
@ -377,8 +378,8 @@ class DashboardChart {
|
|||
|
||||
set_chart_actions(actions) {
|
||||
this.chart_actions = $(`<div class="chart-actions btn-group dropdown pull-right">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false"> <button class="btn btn-default btn-xs"><span class="caret"></span></button>
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<button class="btn btn-default btn-xs"><span class="caret"></span></button>
|
||||
</a>
|
||||
<ul class="dropdown-menu" style="max-height: 300px; overflow-y: auto;">
|
||||
${actions.map(action => `<li><a data-action="${action.action}">${action.label}</a></li>`).join('')}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,13 @@ frappe.ui.form.on('Dashboard Chart', {
|
|||
]
|
||||
if (filters.length > 0) {
|
||||
filters.forEach( filter => {
|
||||
const filter_row = $(`<tr><td>${filter[1]}</td><td>${filter[2] || ""}</td><td>${filter[3]}</td></tr>`);
|
||||
const filter_row =
|
||||
$(`<tr>
|
||||
<td>${filter[1]}</td>
|
||||
<td>${filter[2] || ""}</td>
|
||||
<td>${filter[3]}</td>
|
||||
</tr>`);
|
||||
|
||||
table.find('tbody').append(filter_row);
|
||||
filters_set = true;
|
||||
});
|
||||
|
|
@ -265,7 +271,13 @@ frappe.ui.form.on('Dashboard Chart', {
|
|||
fields.map( f => {
|
||||
if (filters[f.fieldname]) {
|
||||
let condition = '=';
|
||||
const filter_row = $(`<tr><td>${f.label}</td><td>${condition}</td><td>${filters[f.fieldname] || ""}</td></tr>`);
|
||||
const filter_row =
|
||||
$(`<tr>
|
||||
<td>${f.label}</td>
|
||||
<td>${condition}</td>
|
||||
<td>${filters[f.fieldname] || ""}</td>
|
||||
</tr>`);
|
||||
|
||||
table.find('tbody').append(filter_row);
|
||||
filters_set = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ frappe.dashboard_utils = {
|
|||
|
||||
render_chart_filters: function(filters, button_class, container, append) {
|
||||
filters.forEach(filter => {
|
||||
let chart_filter_html = `<div class="${button_class} btn-group dropdown pull-right">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<button class="btn btn-default btn-xs">
|
||||
<span class="filter-label">${filter.label}</span>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
let chart_filter_html =
|
||||
`<div class="${button_class} btn-group dropdown pull-right">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<button class="btn btn-default btn-xs">
|
||||
<span class="filter-label">${filter.label}</span>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
</a>`;
|
||||
let options_html;
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ frappe.dashboard_utils = {
|
|||
if ($el.attr('data-fieldname')) {
|
||||
fieldname = $el.attr('data-fieldname');
|
||||
}
|
||||
|
||||
let selected_item = $el.text();
|
||||
$el.parents(`.${button_class}`).find('.filter-label').text(selected_item);
|
||||
filter.action(selected_item, fieldname);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ frappe.report_utils = {
|
|||
}
|
||||
return accumulator;
|
||||
}, []);
|
||||
|
||||
function get_options(fields) {
|
||||
return fields.map((field) => {
|
||||
if (field.fieldname) {
|
||||
|
|
@ -62,6 +63,7 @@ frappe.report_utils = {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
const numeric_fields = columns.filter((col, i) => indices.includes(i));
|
||||
const non_numeric_fields = columns.filter((col, i) => !indices.includes(i))
|
||||
|
||||
|
|
@ -134,40 +136,4 @@ frappe.report_utils = {
|
|||
return filter_values;
|
||||
},
|
||||
|
||||
// get_filter(fieldname, report_name) {
|
||||
// let filters = frappe.query_reports[report_name].filters;
|
||||
// console.log('filters', filters);
|
||||
// const field = (filters || []).find(f => f.fieldname === fieldname);
|
||||
// if (!field) {
|
||||
// console.warn(`[Query Report] Invalid filter: ${fieldname}`);
|
||||
// }
|
||||
// return field;
|
||||
// },
|
||||
|
||||
// get_filter_value(fieldname, report_name) {
|
||||
// const field = this.get_filter(fieldname, report_name);
|
||||
// console.log('field', field);
|
||||
// return field ? field.get_value() : null;
|
||||
// },
|
||||
|
||||
// set_filter_value(fieldname, value) {
|
||||
// let field_value_map = {};
|
||||
// if (typeof fieldname === 'string') {
|
||||
// field_value_map[fieldname] = value;
|
||||
// } else {
|
||||
// field_value_map = fieldname;
|
||||
// }
|
||||
|
||||
// this._no_refresh = true;
|
||||
// Object.keys(field_value_map)
|
||||
// .forEach((fieldname, i, arr) => {
|
||||
// const value = field_value_map[fieldname];
|
||||
|
||||
// if (i === arr.length - 1) {
|
||||
// this._no_refresh = false;
|
||||
// }
|
||||
|
||||
// this.get_filter(fieldname).set_value(value);
|
||||
// });
|
||||
// },
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue