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'
}
