fixed search bug

This commit is contained in:
undergroundwires
2020-01-11 07:18:02 +01:00
parent 5b743a67a4
commit 31364bdfec
2 changed files with 25 additions and 21 deletions

View File

@@ -2,7 +2,9 @@
- All notable changes to this project will be documented in this file.
## [Unreleased]
## Unreleased
- Fixed search bug
## [0.4.0] - 2020-01-11

View File

@@ -38,7 +38,7 @@
@Prop() public initialNodes?: ReadonlyArray<INode>;
public initialLiquourTreeNodes?: ILiquorTreeNewNode[] = null;
public liquorTreeOptions = DefaultOptions;
public liquorTreeOptions = this.getDefaults();
public convertExistingToNode = convertExistingToNode;
public mounted() {
@@ -98,6 +98,27 @@
}
return (this.$refs.treeElement as any).tree;
}
private getDefaults(): ILiquorTreeOptions {
return {
multiple: true,
checkbox: true,
checkOnSelect: true,
autoCheckChildren: true,
parentSelect: false,
keyboardNavigation: true,
deletion: (node) => !node.children || node.children.length === 0,
filter: {
matcher: (query: string, node: ILiquorTreeExistingNode) => {
if (!this.filterPredicate) {
throw new Error('Cannot filter as predicate is null');
}
return this.filterPredicate(convertExistingToNode(node));
},
emptyText: '🕵Hmm.. Can not see one 🧐',
},
};
}
}
function recurseDown(
@@ -132,25 +153,6 @@
}
return result;
}
const DefaultOptions: ILiquorTreeOptions = {
multiple: true,
checkbox: true,
checkOnSelect: true,
autoCheckChildren: true,
parentSelect: false,
keyboardNavigation: true,
deletion: (node) => !node.children || node.children.length === 0,
filter: {
matcher: (query: string, node: ILiquorTreeExistingNode) => {
if (!this.filterPredicate) {
throw new Error('Cannot filter as predicate is null');
}
return this.filterPredicate(convertExistingToNode(node));
},
emptyText: '🕵Hmm.. Can not see one 🧐',
},
};
</script>