@@ -121,7 +121,7 @@ export abstract class AbstractGanttOutputComponent<
121121 this . chartLayer . updateChart ( this . filterExpressionsMap ( ) ) ;
122122 } , 500 ) ;
123123
124- static NEW_ID_KEY = - 3 ;
124+ private NEW_ID_KEY = - 3 ;
125125
126126 constructor ( props : P ) {
127127 super ( props ) ;
@@ -447,7 +447,7 @@ export abstract class AbstractGanttOutputComponent<
447447 const { collapsedNodes, emptyNodes } = this . state ;
448448
449449 // Convert duplicate ID back to original ID for checking
450- const originalId = entry . id < - 1 ? AbstractGanttOutputComponent . getOriginalId ( entry . id ) : entry . id ;
450+ const originalId = entry . id < - 1 ? this . getOriginalId ( entry . id ) : entry . id ;
451451
452452 // Check for empty nodes
453453 if ( this . shouldHideEmptyNodes && emptyNodes . includes ( originalId ) ) {
@@ -1028,9 +1028,7 @@ export abstract class AbstractGanttOutputComponent<
10281028
10291029 // Add pinned rows at the beginning
10301030 const pinnedRowIds = pinnedRows
1031- ? pinnedRows
1032- . filter ( id => chartTree . some ( entry => entry . id === id ) )
1033- . map ( id => AbstractGanttOutputComponent . createNewId ( id ) )
1031+ ? pinnedRows . filter ( id => chartTree . some ( entry => entry . id === id ) ) . map ( id => this . createNewId ( id ) )
10341032 : [ ] ;
10351033 const rowIds = [ ...pinnedRowIds , ...regularRowIds ] ;
10361034
@@ -1054,7 +1052,7 @@ export abstract class AbstractGanttOutputComponent<
10541052
10551053 const strategy = additionalProperties ?. filter_query_parameters ?. strategy ;
10561054 const ids = rowIds ? rowIds : this . getTimegraphRowIds ( ) . rowIds ;
1057- const originalIds = ids . map ( id => ( id < - 1 ? AbstractGanttOutputComponent . getOriginalId ( id ) : id ) ) ;
1055+ const originalIds = ids . map ( id => ( id < - 1 ? this . getOriginalId ( id ) : id ) ) ;
10581056
10591057 const { start, end } = range ;
10601058 const newRange : TimelineChart . TimeGraphRange = range ;
@@ -1501,7 +1499,7 @@ export abstract class AbstractGanttOutputComponent<
15011499 * @param {number } id TreeNode id number
15021500 */
15031501 public onRowClick = ( id : number ) : void => {
1504- const originalId = id < - 1 ? AbstractGanttOutputComponent . getOriginalId ( id ) : id ;
1502+ const originalId = id < - 1 ? this . getOriginalId ( id ) : id ;
15051503 const rowIndex = getIndexOfNode (
15061504 originalId ,
15071505 listToTree ( this . state . chartTree , this . state . columns ) ,
@@ -1634,7 +1632,7 @@ export abstract class AbstractGanttOutputComponent<
16341632 public onPin = ( id : number ) : void => {
16351633 const rows = this . state . pinnedRows ? this . state . pinnedRows . slice ( ) : [ ] ;
16361634 // Handle both original ID and duplicate ID
1637- const originalId = id < - 1 ? AbstractGanttOutputComponent . getOriginalId ( id ) : id ;
1635+ const originalId = id < - 1 ? this . getOriginalId ( id ) : id ;
16381636 const index = rows . indexOf ( originalId ) ;
16391637 if ( index === - 1 ) {
16401638 rows . push ( originalId ) ;
@@ -1647,11 +1645,38 @@ export abstract class AbstractGanttOutputComponent<
16471645 } ) ;
16481646 } ;
16491647
1650- static createNewId ( originalId : number ) {
1651- return originalId ^ this . NEW_ID_KEY ;
1648+ private getLastEntryId ( ) {
1649+ const lastEntryIndex = this . state . chartTree . length - 1 ;
1650+ const lastEntry = this . state . chartTree [ lastEntryIndex ] ;
1651+ return lastEntry . id ;
16521652 }
16531653
1654- static getOriginalId ( newId : number ) {
1655- return newId ^ this . NEW_ID_KEY ;
1654+ protected createNewId ( originalId : number ) {
1655+ const newId = originalId ^ this . NEW_ID_KEY ;
1656+ return newId === - 1 ? ( this . getLastEntryId ( ) + 1 ) ^ this . NEW_ID_KEY : newId ;
1657+ }
1658+
1659+ protected getOriginalId ( newId : number ) {
1660+ const original1 = newId ^ this . NEW_ID_KEY ;
1661+ const original2 = original1 === this . getLastEntryId ( ) + 1 ? - 1 ^ this . NEW_ID_KEY : original1 ;
1662+ return original2 ;
1663+ }
1664+
1665+ protected getEntriesWithPinned ( ) {
1666+ const pinnedEntries = this . state . pinnedRows
1667+ ? this . state . pinnedRows
1668+ . map ( id => this . state . chartTree . find ( entry => entry . id === id ) )
1669+ . filter ( entry => entry !== undefined )
1670+ . map ( entry => ( { ...entry , id : this . createNewId ( entry . id ) , parentId : - 1 } ) )
1671+ : [ ] ;
1672+ const entriesWithPinned = [ ...pinnedEntries , ...this . state . chartTree ] ;
1673+ return entriesWithPinned ;
1674+ }
1675+
1676+ protected getExtendedPinnedRows ( ) {
1677+ const extendedPinnedRows = this . state . pinnedRows
1678+ ? [ ...this . state . pinnedRows , ...this . state . pinnedRows . map ( id => this . createNewId ( id ) ) ]
1679+ : [ ] ;
1680+ return extendedPinnedRows ;
16561681 }
16571682}
0 commit comments