2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30: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, schemaName: string,
rawValueMap: RawValueMap | RawValueMap[] rawValueMap: RawValueMap | RawValueMap[]
): DocValueMap | DocValueMap[] { ): DocValueMap | DocValueMap[] {
rawValueMap ??= {};
if (Array.isArray(rawValueMap)) { if (Array.isArray(rawValueMap)) {
return rawValueMap.map((dv) => this.#toDocValueMap(schemaName, dv)); return rawValueMap.map((dv) => this.#toDocValueMap(schemaName, dv));
} else { } else {
@ -48,6 +49,7 @@ export class Converter {
schemaName: string, schemaName: string,
docValueMap: DocValueMap | DocValueMap[] docValueMap: DocValueMap | DocValueMap[]
): RawValueMap | RawValueMap[] { ): RawValueMap | RawValueMap[] {
docValueMap ??= {};
if (Array.isArray(docValueMap)) { if (Array.isArray(docValueMap)) {
return docValueMap.map((dv) => this.#toRawValueMap(schemaName, dv)); return docValueMap.map((dv) => this.#toRawValueMap(schemaName, dv));
} else { } else {

View File

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

View File

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

View File

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

View File

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