chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
46
47
48
49
50
51
52
53
54
55
56
Quintiq file version 2.0
#parent: CustomDrawComponentSupplyChainVisualization/CustomDrawDataLayerNode
Response OnClickObject (
  shadow[SCVPISPIPNode] object
) id:Response_CustomDrawComponentSupplyChainVisualization_CustomDrawDataLayerNode_OnClickObject
{
  #keys: '[132894.0.1050777934]'
  Body:
  [*
    // Click expand nav panel selection
    pispip := object.ProductInStockingPointInPeriod();
    pisp := pispip.ProductInStockingPoint_MP(); 
    
    index := DataHolderSelectedNodes.Data().Find( object );
    found := index >= 0;                    
    
    // Verify the node clicked is not the focused one( double clicked )
    // because we are not going to make any changes to the list
    // if the user clicks on the focused node
    notInFocus := not exists( DataHolderFocusedPISPIP.Data(), Elements, e, 
                              e.ProductInStockingPoint_MP() = pisp )
    
    if( notInFocus )
    {
      if ( action.IsControl() or action.IsShift() )
      {
        if( found ) // Deselect object if we ctrl / shift click on a selected node
        {
          DataHolderSelectedNodes.Data().Delete( index );
          
          DataHolderProducts.Data().Delete( DataHolderProducts.Data().Find( pisp.Product_MP() ) );
          DataHolderStockingPoints.Data().Delete( DataHolderStockingPoints.Data().Find( pisp.StockingPoint_MP() ) );
        }
        else // Add it to the current selection if it has yet been selected
        {
          DataHolderSelectedNodes.Data().Add( object );
          DataHolderProducts.Data().Add( pisp.Product_MP() )
          DataHolderStockingPoints.Data().Add( pisp.StockingPoint_MP() );
        }
      }
      // If the user clicks on a node instead of ctrl / shift clicking, 
      // we flush all the previously selected nodes and select only the one newly clicked
      else 
      {                                                   
        // Clear previously selected nodes
        FormSupplyChainVisualization.ClearSelectedNodes();
        // Add newly clicked node into selection
        DataHolderSelectedNodes.Data().Add( object );
        DataHolderProducts.Data().Add( pisp.Product_MP() );
        DataHolderStockingPoints.Data().Add( pisp.StockingPoint_MP() );
      }
    }
  *]
  CanBindMultiple: false
  DefinitionID: 'Responsedef_CustomDrawBaseDataLayer_OnClickObject'
}