2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00

fix: prevent errors cause undef or null

This commit is contained in:
18alantom 2022-08-24 16:06:48 +05:30
parent b7810ee25e
commit 67e38e4729
5 changed files with 13 additions and 4 deletions

View File

@ -37,6 +37,7 @@ export class Converter {
schemaName: string,
rawValueMap: RawValueMap | RawValueMap[]
): DocValueMap | DocValueMap[] {
rawValueMap ??= {};
if (Array.isArray(rawValueMap)) {
return rawValueMap.map((dv) => this.#toDocValueMap(schemaName, dv));
} else {
@ -48,6 +49,7 @@ export class Converter {
schemaName: string,
docValueMap: DocValueMap | DocValueMap[]
): RawValueMap | RawValueMap[] {
docValueMap ??= {};
if (Array.isArray(docValueMap)) {
return docValueMap.map((dv) => this.#toRawValueMap(schemaName, dv));
} else {

View File

@ -551,7 +551,7 @@ function pruneAccountTree(accountTree: AccountTree) {
function getPrunedChildren(children: AccountTreeNode[]): AccountTreeNode[] {
return children.filter((child) => {
if (child.children) {
if (child.children?.length) {
child.children = getPrunedChildren(child.children);
}

View File

@ -153,8 +153,11 @@ export default {
.map(({ item }) => item);
},
setSuggestion(suggestion) {
this.linkValue = suggestion.label;
this.triggerChange(suggestion.value);
if (suggestion) {
this.linkValue = suggestion.label;
this.triggerChange(suggestion.value);
}
this.toggleDropdown(false);
},
onFocus(e, toggleDropdown) {

View File

@ -188,7 +188,7 @@ export default {
return emptyMessage;
},
async selectItem(d) {
if (!d.action) {
if (!d?.action) {
return;
}

View File

@ -156,6 +156,10 @@ export default defineComponent({
this.pageEnd = end;
},
setUpdateListeners() {
if (!this.schemaName) {
return;
}
const listener = () => {
this.updateData();
};