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.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { TreeNodeStateChangedEmittedEvent } from '@/presentation/components/Scripts/View/Tree/TreeView/Bindings/TreeNodeStateChangedEmittedEvent';
|
|
import { TreeNodeCheckState } from '@/presentation/components/Scripts/View/Tree/TreeView/Node/State/CheckState';
|
|
import { TreeNodeStateDescriptor } from '@/presentation/components/Scripts/View/Tree/TreeView/Node/State/StateDescriptor';
|
|
import { ReadOnlyTreeNode } from '@/presentation/components/Scripts/View/Tree/TreeView/Node/TreeNode';
|
|
import { TreeNodeStateDescriptorStub } from './TreeNodeStateDescriptorStub';
|
|
|
|
export class TreeNodeStateChangedEmittedEventStub implements TreeNodeStateChangedEmittedEvent {
|
|
public node: ReadOnlyTreeNode;
|
|
|
|
public oldState?: TreeNodeStateDescriptor;
|
|
|
|
public newState: TreeNodeStateDescriptor;
|
|
|
|
public withNode(node: ReadOnlyTreeNode): this {
|
|
this.node = node;
|
|
return this;
|
|
}
|
|
|
|
public withNewState(newState: TreeNodeStateDescriptor): this {
|
|
this.newState = newState;
|
|
return this;
|
|
}
|
|
|
|
public withOldState(oldState: TreeNodeStateDescriptor): this {
|
|
this.oldState = oldState;
|
|
return this;
|
|
}
|
|
|
|
public withCheckStateChange(change: {
|
|
readonly oldState: TreeNodeCheckState,
|
|
readonly newState: TreeNodeCheckState,
|
|
}) {
|
|
return this
|
|
.withOldState(
|
|
new TreeNodeStateDescriptorStub().withCheckState(change.oldState),
|
|
)
|
|
.withNewState(
|
|
new TreeNodeStateDescriptorStub().withCheckState(change.newState),
|
|
);
|
|
}
|
|
}
|