fixed search bug
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
- All notable changes to this project will be documented in this file.
|
- All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [Unreleased]
|
## Unreleased
|
||||||
|
|
||||||
|
- Fixed search bug
|
||||||
|
|
||||||
## [0.4.0] - 2020-01-11
|
## [0.4.0] - 2020-01-11
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
@Prop() public initialNodes?: ReadonlyArray<INode>;
|
@Prop() public initialNodes?: ReadonlyArray<INode>;
|
||||||
|
|
||||||
public initialLiquourTreeNodes?: ILiquorTreeNewNode[] = null;
|
public initialLiquourTreeNodes?: ILiquorTreeNewNode[] = null;
|
||||||
public liquorTreeOptions = DefaultOptions;
|
public liquorTreeOptions = this.getDefaults();
|
||||||
public convertExistingToNode = convertExistingToNode;
|
public convertExistingToNode = convertExistingToNode;
|
||||||
|
|
||||||
public mounted() {
|
public mounted() {
|
||||||
@@ -98,6 +98,27 @@
|
|||||||
}
|
}
|
||||||
return (this.$refs.treeElement as any).tree;
|
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(
|
function recurseDown(
|
||||||
@@ -132,25 +153,6 @@
|
|||||||
}
|
}
|
||||||
return result;
|
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>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user