本文整理汇总了TypeScript中app/core/ui-services/tree.service.TreeService.getTreeWithoutSelection方法的典型用法代码示例。如果您正苦于以下问题:TypeScript service.TreeService.getTreeWithoutSelection方法的具体用法?TypeScript service.TreeService.getTreeWithoutSelection怎么用?TypeScript service.TreeService.getTreeWithoutSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app/core/ui-services/tree.service.TreeService
的用法示例。
在下文中一共展示了service.TreeService.getTreeWithoutSelection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: bulkMoveItems
/**
* Triggers the selected motions to be moved in the call-list (sort_parent, weight)
* as children or as following after a selected motion.
*
* @param motions The motions to move
*/
public async bulkMoveItems(motions: ViewMotion[]): Promise<void> {
const title = this.translate.instant(
'This will move all selected motions under or after the following motion in the call list:'
);
const options = [this.translate.instant('Set as parent'), this.translate.instant('Insert after')];
const allMotions = this.repo.getViewModelList();
const tree = this.treeService.makeTree(allMotions, 'weight', 'sort_parent_id');
const itemsToMove = this.treeService.getTopItemsFromTree(tree, motions);
const selectableItems = this.treeService.getTreeWithoutSelection(tree, motions);
const selectedChoice = await this.choiceService.open(title, selectableItems, false, options);
if (selectedChoice) {
if (selectedChoice.action === options[0]) {
// set choice as parent
this.repo.sortMotionBranches(itemsToMove, selectedChoice.items as number);
} else if (selectedChoice.action === options[1]) {
// insert after chosen
const olderSibling = this.repo.getViewModel(selectedChoice.items as number);
const parentId = olderSibling ? olderSibling.sort_parent_id : null;
const siblings = this.repo.getViewModelList().filter(motion => motion.sort_parent_id === parentId);
const idx = siblings.findIndex(sib => sib.id === olderSibling.id);
const before = siblings.slice(0, idx + 1);
const after = siblings.slice(idx + 1);
const sum = [].concat(before, itemsToMove, after);
this.repo.sortMotionBranches(sum, parentId);
}
}
}