yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method RefreshUIIsLastAttribute (
  shadow[KpiSnapshotSetData] queryResult,
  KpiLabel series,
  Boolean isLastSnapshotChecked,
  structured[KpiMetaData] metadatas
) id:Method_Kpi_GlobalState_RefreshUIIsLastAttribute
{
  #keys: '[146874.0.1589144606]'
  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( selectset( queryResult, SnapshotData.Value, v, v.UI_IsLast() ), Elements, val )
    {
      val.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 ) )
    {
      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 )
          }
        }
      }
    }
  *]
}