This commit fixes an issue where the check state of categories was lost when toggling between card and tree views. This is solved by immediately emitting node state changes for all nodes. This ensures consistent view transitions without any loss of node state information. Furthermore, this commit includes added unit tests for the modified code sections.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import {
|
|
WatchSource, readonly, shallowRef, triggerRef,
|
|
} from 'vue';
|
|
import { TreeRoot } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/TreeRoot';
|
|
import { useCurrentTreeNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/UseCurrentTreeNodes';
|
|
import { QueryableNodes } from '@/presentation/components/Scripts/View/Tree/TreeView/TreeRoot/NodeCollection/Query/QueryableNodes';
|
|
import { QueryableNodesStub } from './QueryableNodesStub';
|
|
|
|
export class UseCurrentTreeNodesStub {
|
|
public treeWatcher: WatchSource<TreeRoot> | undefined;
|
|
|
|
private nodes = shallowRef<QueryableNodes>(new QueryableNodesStub());
|
|
|
|
public withQueryableNodes(nodes: QueryableNodes): this {
|
|
this.nodes.value = nodes;
|
|
return this;
|
|
}
|
|
|
|
public triggerNewNodes(nodes: QueryableNodes) {
|
|
this.nodes.value = nodes;
|
|
triggerRef(this.nodes);
|
|
}
|
|
|
|
public get(): typeof useCurrentTreeNodes {
|
|
return (treeWatcher: WatchSource<TreeRoot>) => {
|
|
this.treeWatcher = treeWatcher;
|
|
return {
|
|
nodes: readonly(this.nodes),
|
|
};
|
|
};
|
|
}
|
|
}
|