admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Quintiq file version 2.0
#parent: #root
Function CalcDisplayIndex
{
  TextBody:
  [*
    value := 0;
    // For root element we will either increase from the last child of the previous root step display index
    if( this.IsRootElement()
        and not isnull( this.PreviousRootStepDefinition() ) )
    {
    value := guard( this.PreviousRootStepDefinition().LastChildDefinition().DisplayIndex() + 1,
                        this.PreviousRootStepDefinition().DisplayIndex() + 1 );
    }
    
    // For non-root, we will increase from first sibling or from previous sibling last child..so on..
    else  
    {
      value := guard( this.PreviousChildDefinition().LastChildDefinition().DisplayIndex() + 1,
                      guard( this.PreviousChildDefinition().DisplayIndex() + 1,
                             guard( this.ParentDefinition().DisplayIndex() + 1, 0 ) ) );
    }
    
    this.DisplayIndex( [Number]value );
  *]
}