@@ -432,20 +432,7 @@ export default {
432
432
* @returns {Family[]} array containing nested structure of families
433
433
*/
434
434
treeDropDownFamily () {
435
- if (this .familyArrayStore .length ) {
436
- const ret = []
437
- for (const rootFamily of this .getTree ()) {
438
- ret .push (rootFamily)
439
- }
440
- return ret
441
- } else {
442
- return [
443
- {
444
- name: ' No families' ,
445
- disabled: true
446
- }
447
- ]
448
- }
435
+ return this .familyArrayStore .length ? this .getTree () : [{ name: ' No families' , disabled: true }]
449
436
},
450
437
/**
451
438
* Gets the array of cycles for use in vuetify toolbar drop down
@@ -563,7 +550,7 @@ export default {
563
550
* @returns {String[]} array of family names
564
551
*/
565
552
familyArrayStore () {
566
- return this .namespaces .filter ((family ) => { return family .name !== ' root' }). map (( family ) => family .name )
553
+ return this .namespaces .flatMap ((family ) => family .name !== ' root' ? family .name : [] )
567
554
},
568
555
controlGroups () {
569
556
return [
@@ -673,24 +660,15 @@ export default {
673
660
* @returns {Family[]} array containing nested structure of families
674
661
*/
675
662
getTree () {
676
- const counter = {
677
- value: 0 ,
678
- next () {
679
- this .value = this .value + 1
680
- return this .value
681
- }
682
- }
683
-
684
663
const root = {
685
- id: counter .next (),
686
664
name: ' root' ,
687
665
children: []
688
666
}
689
667
if (this .workflows ) {
690
668
const tokens = this .workflows [0 ].tokens .clone ({ cycle: ' $namespace|root' })
691
669
const node = this .cylcTree .$index [tokens .id ]
692
670
if (node) {
693
- return this .getTreeHelper (root, node, counter ).children
671
+ return this .getTreeHelper (root, node).children
694
672
}
695
673
}
696
674
},
@@ -701,27 +679,23 @@ export default {
701
679
* @property {number} counter - counter used for index
702
680
* @returns {Family} nested structure of families
703
681
*/
704
- getTreeHelper (store , node , counter ) {
682
+ getTreeHelper (store , node ) {
705
683
let tempItem
706
684
const isParent = this .collapseFamily .includes (node .name )
707
685
const isAncestor = this .allParentLookUp [node .name ].some (element => {
708
686
return this .collapseFamily .includes (element)
709
687
})
710
688
const disabled = isParent || isAncestor
711
689
for (const childFamily of node .node .descendants ) {
712
- if (this .namespaces .some ((obj ) => obj .name === childFamily)) {
713
- const childTokens = this .workflows [0 ].tokens .clone ({ cycle: ` $namespace|${ childFamily} ` })
714
- const childNode = this .cylcTree .$index [childTokens .id ]
715
- if (childNode .node .firstParent .id === node .id ) {
716
- tempItem = {
717
- id: counter .next (),
718
- name: childFamily,
719
- children: [],
720
- disabled
721
- }
722
- this .getTreeHelper (tempItem, childNode, counter)
723
- store .children .push (tempItem)
690
+ const childNamespace = this .namespaces .find ((obj ) => obj .name === childFamily)
691
+ if (childNamespace? .node .firstParent .id === node .id ) {
692
+ tempItem = {
693
+ name: childFamily,
694
+ children: [],
695
+ disabled
724
696
}
697
+ this .getTreeHelper (tempItem, childNamespace)
698
+ store .children .push (tempItem)
725
699
}
726
700
}
727
701
return store
0 commit comments