mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
Fix Reportpage filter layout
This commit is contained in:
parent
b6562fe7f3
commit
125b3f5cb1
@ -434,7 +434,7 @@ module.exports = class Database extends Observable {
|
||||
comparisonValue.map(v => '?').join(', ') :
|
||||
'?';
|
||||
|
||||
return `${field} ${operator} (${placeholder})`;
|
||||
return `ifnull(${field}, '') ${operator} (${placeholder})`;
|
||||
});
|
||||
|
||||
let values = filtersArray.reduce((acc, filter) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const Page = require('frappejs/client/view/page');
|
||||
const Form = require('frappejs/client/view/form');
|
||||
const FormLayout = require('frappejs/client/view/formLayout');
|
||||
const DataTable = require('frappe-datatable');
|
||||
const frappe = require('frappejs');
|
||||
const utils = require('frappejs/client/ui/utils');
|
||||
@ -35,18 +35,19 @@ module.exports = class ReportPage extends Page {
|
||||
}
|
||||
|
||||
makeFilters() {
|
||||
this.form = new Form({
|
||||
this.filters = new FormLayout({
|
||||
parent: this.filterWrapper,
|
||||
meta: { fields: this.filterFields },
|
||||
fields: this.filterFields,
|
||||
doc: new Observable(),
|
||||
inline: true,
|
||||
container: this
|
||||
inline: true
|
||||
});
|
||||
|
||||
this.filterWrapper.appendChild(this.filters.form);
|
||||
}
|
||||
|
||||
getFilterValues() {
|
||||
const values = {};
|
||||
for (let control of this.form.formLayout.controlList) {
|
||||
for (let control of this.filters.controlList) {
|
||||
values[control.fieldname] = control.getInputValue();
|
||||
if (control.required && !values[control.fieldname]) {
|
||||
frappe.ui.showAlert({message: frappe._('{0} is mandatory', control.label), color: 'red'});
|
||||
@ -64,8 +65,8 @@ module.exports = class ReportPage extends Page {
|
||||
async run() {
|
||||
if (frappe.params && frappe.params.filters) {
|
||||
for (let key in frappe.params.filters) {
|
||||
if (this.form.controls[key]) {
|
||||
this.form.controls[key].setInputValue(frappe.params.filters[key]);
|
||||
if (this.filters.controls[key]) {
|
||||
this.filters.controls[key].setInputValue(frappe.params.filters[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ class DateControl extends BaseControl {
|
||||
'mm/dd/yyyy': 'm/d/Y',
|
||||
'mm-dd-yyyy': 'm-d-Y'
|
||||
}
|
||||
let altFormat = dateFormat[frappe.SystemSettings.dateFormat];
|
||||
let altFormat = frappe.SystemSettings ?
|
||||
dateFormat[frappe.SystemSettings.dateFormat] :
|
||||
dateFormat['yyyy-mm-dd'];
|
||||
|
||||
super.make();
|
||||
this.input.setAttribute('type', 'text');
|
||||
|
@ -3,7 +3,7 @@ const controls = require('./controls');
|
||||
const Observable = require('frappejs/utils/observable');
|
||||
|
||||
module.exports = class FormLayout extends Observable {
|
||||
constructor({fields, doc, layout, events = []}) {
|
||||
constructor({fields, doc, layout, inline = false, events = []}) {
|
||||
super();
|
||||
Object.assign(this, arguments[0]);
|
||||
this.controls = {};
|
||||
@ -14,6 +14,11 @@ module.exports = class FormLayout extends Observable {
|
||||
this.form = document.createElement('div');
|
||||
this.form.classList.add('form-body');
|
||||
|
||||
if (this.inline) {
|
||||
this.form.classList.add('row');
|
||||
this.form.classList.add('p-0');
|
||||
}
|
||||
|
||||
this.makeLayout();
|
||||
|
||||
if (doc) {
|
||||
@ -63,6 +68,9 @@ module.exports = class FormLayout extends Observable {
|
||||
let control = controls.makeControl({field: field, form: this, parent: parent});
|
||||
this.controlList.push(control);
|
||||
this.controls[field.fieldname] = control;
|
||||
if (this.inline) {
|
||||
control.inputContainer.classList.add('col');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user