mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
clear result when TargetSchema changed
This commit is contained in:
parent
8d1f3bbabb
commit
61215f1a38
@ -41,6 +41,38 @@ export default {
|
||||
|
||||
return schemaName;
|
||||
},
|
||||
async getOptions() {
|
||||
this.results = [];
|
||||
const schemaName = this.getTargetSchemaName();
|
||||
if (!schemaName) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.results?.length) {
|
||||
return this.results;
|
||||
}
|
||||
|
||||
const schema = fyo.schemaMap[schemaName];
|
||||
const filters = await this.getFilters();
|
||||
|
||||
const fields = [
|
||||
...new Set(['name', schema.titleField, this.df.groupBy]),
|
||||
].filter(Boolean);
|
||||
|
||||
const results = await fyo.db.getAll(schemaName, {
|
||||
filters,
|
||||
fields,
|
||||
});
|
||||
return (this.results = results
|
||||
.map((r) => {
|
||||
const option = { label: r[schema.titleField], value: r.name };
|
||||
if (this.df.groupBy) {
|
||||
option.group = r[this.df.groupBy];
|
||||
}
|
||||
return option;
|
||||
})
|
||||
.filter(Boolean));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user