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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Quintiq file version 2.0
#parent: #root
Method RefreshUIIsLastAttribute (
  shadow[KpiSnapshotSetData] queryResult,
  KpiLabel series,
  structured[KpiMetaData] metadatas,
  Boolean isLastSnapshotChecked
) id:Method_GlobalStateKpiTracker_RefreshUIIsLastAttribute
{
  #keys: '[146874.0.1589192524]'
  Body:
  [*
    // Updates the UI_IsLast attribute of the KpiValues to match the selected series / kpi.
    // Call this method after updating the 'UI_LabelValue' attribute.
    
    // First clean previously set flags.
    traverse( queryResult, SnapshotData.Value, v, v.UI_IsLast() )
    {
      v.UI_IsLast( false );
    }
    
    // Now, if the checkbox is checked and a Series has been selected,
    // determine which KpiValue objects represent the LAST snapshot of their
    // KPI & LabelValue of the selected Series (= Label)
    if( isLastSnapshotChecked and not isnull( series ) and not isnull( queryResult ) )
    {
      traverse( series, Value, serieValue )
      {
        traverse( metadatas, Elements, kpi )
        {
            lastValue := maxselect( queryResult, SnapshotData.Value, v,
                                    v.UI_LabelValue() = serieValue.Value() and
                                    v.Name() = kpi.Name(),
                                    v.UI_DateTime() );
            if( not isnull( lastValue ) )
            {
              lastValue.UI_IsLast( true );
            }
    
    
        }
      }
    }
  *]
}