2
0
mirror of https://github.com/frappe/books.git synced 2024-12-31 22:11:48 +00:00

feat: Group Items in Link field

This commit is contained in:
Faris Ansari 2020-04-30 16:41:20 +05:30
parent c2509e4105
commit fb0744ba2b
2 changed files with 14 additions and 3 deletions

View File

@ -5,9 +5,11 @@ module.exports = {
{
fieldname: 'account',
label: 'Account',
placeholder: 'Account',
fieldtype: 'Link',
target: 'Account',
required: 1,
groupBy: 'rootType',
getFilters: () => ({ isGroup: 0 })
},
{

View File

@ -19,13 +19,22 @@ export default {
doctype,
filters,
fields: [
...new Set(['name', meta.titleField, ...meta.getKeywordFields()])
]
...new Set([
'name',
meta.titleField,
this.df.groupBy,
...meta.getKeywordFields()
])
].filter(Boolean)
});
let createNewOption = this.getCreateNewOption();
let suggestions = results
.map(r => {
return { label: r[meta.titleField], value: r.name };
let option = { label: r[meta.titleField], value: r.name };
if (this.df.groupBy) {
option.group = r[this.df.groupBy];
}
return option;
})
.concat(this.df.disableCreation ? null : createNewOption)
.filter(Boolean);