Frappe list view plugin that allows more customisations.
A small Frappe list view plugin that allows the following modifications: 1. Setting additional fields to fetch without displaying their values 1. Setting additional filters in the data query 3. Setting the number of rows to display per page 4. Setting parser function to modify row values on time
⚠️ Important ⚠️
All the following options must be placed inside the "query" object. Check the Example below.
Option | Description |
---|---|
fields | The additional list of fields to fetch without displaying their values. -Type: Array -Example: ['isapproved', 'ispaid'] |
filters | The additional filter conditions to customize the data fetched. -Type: Object or Array -Example: {isapproved: 1, ispaid: 0} or [['isapproved', '=', 1], ['ispaid', '=', 0]] |
page_length | The number of rows to display per page. -Type: Integer -Example: 50 |
parser | The function that modifies row values on time. Must call resolve() after modification is done. -Type: Function -Parameter: row, resolve -Example: Check both ways listed in the example code below |
frappe.listview_settings['DocType'] = {
// The list view modifications
query: {
// No columns will be created for these fields
fields: ['is_approved', 'is_paid'],
// Additional filters (array or object) to customize query
filters: {
is_approved: 1,
is_paid: 1,
},
// Only 50 rows will be displayed per page
page_length: 50,
// The function that modifies row values using one of the following ways
parser: function(row, resolve) {
// 1. Simply change row values directly
row.actual_qty = 10;
resolve();
// 2. Query db and modify row value
frappe.db.get_value('DocType', row.name, 'actual_qty')
.then(function(ret) {
if (ret && $.isPlainObjecr(ret)) ret = ret.message || ret;
row.actual_qty = ret;
resolve();
});
},
},
// The fields listed above can be used inside the following functions
get_indicator: function(doc) {
if (doc.is_paid) {
return [__('Paid'), 'blue', 'is_paid,=,Yes|is_approved,=,Yes'];
}
if (doc.is_approved) {
return [__('Approved'), 'green', 'is_paid,=,No|is_approved,=,Yes'];
}
return [__('Pending'), 'gray', 'is_paid,=,No|is_approved,=,No'];
},
formatters: {
name: function(value, field, doc) {
let html = value;
if (doc.is_approved) {
html += ' <span class="fa fa-check"></span>';
}
return html;
},
},
};
If you find bug in the plugin, please create a bug report and let us know about it.
No reviews yet, be the first to review.