Skip to content

Commit

Permalink
perf: 单个 tree-item 的 select 操作
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoJiSen committed Jun 3, 2024
1 parent 832303b commit df76fc7
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions src/app/elements/asset-tree/asset-tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ export class ElementAssetTreeComponent implements OnInit {
title: 'title'
}
},
check: {
enable: false,
chkboxType: { 'Y': 'ps', 'N': 'ps' }
},
};
pos = {left: '100px', top: '200px'};
isShowRMenu = false;
Expand Down Expand Up @@ -146,20 +150,20 @@ export class ElementAssetTreeComponent implements OnInit {
'hide': checkedLeafs.length === 0 || !treeChecked,
'click': this.onMenuConnectChecked.bind(this)
},
{
'id': 'connect',
'name': 'Connect',
'fa': 'fa-terminal',
'hide': cnode.isParent && !this.isK8s,
'click': this.onMenuConnect.bind(this)
},
{
'id': 'new-connection',
'name': 'Open in new window',
'fa': 'fa-external-link',
'hide': this.isK8s || cnode.isParent,
'click': this.onMenuConnectNewTab.bind(this)
},
// {
// 'id': 'connect',
// 'name': 'Connect',
// 'fa': 'fa-terminal',
// 'hide': cnode.isParent && !this.isK8s,
// 'click': this.onMenuConnect.bind(this)
// },
// {
// 'id': 'new-connection',
// 'name': 'Open in new window',
// 'fa': 'fa-external-link',
// 'hide': this.isK8s || cnode.isParent,
// 'click': this.onMenuConnectNewTab.bind(this)
// },
{
'id': 'split-connect',
'name': 'Split connect',
Expand Down Expand Up @@ -214,6 +218,13 @@ export class ElementAssetTreeComponent implements OnInit {
'fa': 'fa-star',
'hide': !this.isAssetFavorite() || this.isK8s || cnode.isParent,
'click': this.onMenuFavorite.bind(this)
},
{
'id': 'batch-select',
'name': 'Batch Select',
'fa': 'fa-check-square',
'hide': false,
'click': this.onBatchSelect.bind(this)
}
];
}
Expand Down Expand Up @@ -244,6 +255,21 @@ export class ElementAssetTreeComponent implements OnInit {
}
}

onBatchSelect() {
const tree = this.rightClickSelectNode.ztree;
const currentChecked = tree.setting.check.enable;

this.rightClickSelectNode.checked = !this.rightClickSelectNode.checked;

if (currentChecked) {
tree.checkAllNodes(false);
}
setTimeout(() => {
tree.setting.check.enable = !currentChecked;
tree.refresh();
});
}

onNodeClick(event, treeId, treeNode, clickFlag) {
const ztree = this.trees.find(t => t.name === treeId).ztree;
if (treeNode.isParent) {
Expand Down

0 comments on commit df76fc7

Please sign in to comment.