Quintiq file version 2.0
#parent: #root
Method UpdateNavPanelSelections (
  structured[ProductInStockingPointInPeriod] pispips,
  Boolean isfocus
) id:Method_FormSupplyChainVisualization_UpdateNavPanelSelections
{
  #keys: '[139394.0.533530746]'
  Body:
  [*
    // Update nav panel selection
    entities := construct( Entitys );
    pisps := selectset( pispips, Elements.ProductInStockingPoint_MP, pispip, true );
    entities := selectset( pisps, Elements.StockingPoint_MP, sp, true );
    products := selectset( pisps, Elements.Product_MP, p, true );
    
    if( isfocus )
    {
      DataHolderUpdatedEntities.Data( entities.Copy())
      DataHolderUpdatedProduct.Data( products.Copy() );
      pispip := pispips.Element( 0 );
      DataHolderDisplayPISPIP.Data( pispip );
    }
    else
    {
      dhEntities := DataHolderCheckedEntities.Data().Copy();
      dhProduct := DataHolderCheckedProduct.Data().Copy();
      // Append new selection into nav panel
      previouslySelectedEntities := construct( Entitys );
      previouslySelectedPISPs := selectset( DataHolderSelectedPISPs.Data(), Elements, e, true );
      previouslySelectedEntities := selectset( previouslySelectedPISPs, Elements.StockingPoint_MP, sp, true );
      previouslySelectedProducts := selectset( previouslySelectedPISPs, Elements.Product_MP, p, true );
      
      // Append newly selected items
      tobeAddedEntities := entities.Difference( previouslySelectedEntities );
      tobeAddedProducts := products.Difference( previouslySelectedProducts );
      dhEntities := dhEntities.Add( tobeAddedEntities );
      dhProduct := dhProduct.Add( tobeAddedProducts );
        
      // Remove deselected items
      tobeRemovedEntities :=  previouslySelectedEntities.Difference( entities );
      tobeRemovedProducts := previouslySelectedProducts.Difference( products );                         
      dhEntities.Remove( tobeRemovedEntities );
      dhProduct.Remove( tobeRemovedProducts );
    
      if( not isnull( DataHolderDisplayPISPIP.Data() ) )
      {
        // Reappend root element
        dhEntities.Add( DataHolderDisplayPISPIP.Data().ProductInStockingPoint_MP().StockingPoint_MP() );
        dhProduct.Add( DataHolderDisplayPISPIP.Data().ProductInStockingPoint_MP().Product_MP() );
      }
      DataHolderUpdatedEntities.Data( dhEntities.Copy() );
      DataHolderUpdatedProduct.Data( dhProduct.Copy() );
    }
    
    DataHolderSelectedPISPs.Data( pisps.Copy() );
  *]
}
