Quintiq file version 2.0
#parent: #root
Method Update () id:Method_SCK_ButtonSanityCheckBase_Update
{
  #keys: '[132254.0.10701001]'
  Body:
  [*
    // PRIVATE - Update the image and issue count on the sanity check button 
    
    // Pick one of the severities with highest level from all managers (from all datasets)
    sanity_panel := this.GetPanelSanityCheck();
    all_highest_severities := selectset( sanity_panel.DataHolderSanityManagers().Data(), Elements.HighestViolatedSeverity, svr, true );
    max_level := max( all_highest_severities, Elements, svr, true, svr.Level() );
    picked_highest_severity := select( all_highest_severities, Elements, svr, svr.Level() = max_level );
    
    // Determine the icon and nr of violations to show in the sanity check button
    picked_manager := select( sanity_panel.DataHolderSanityManagers().Data(), Elements, mgr, true );
    icon := "SMILEY-GREEN";
    tooltip := guard( picked_manager.TRANSLATION_SanityCheck_Passed(), "" );
    nr_of_violations := 0;
    if ( not isnull( picked_highest_severity ) )
    {  
      icon := picked_highest_severity.Icon();  
      tooltip := picked_manager.TRANSLATION_SanityCheck_Failed( picked_highest_severity );
     //get all the highest violated severity and sum the nrofviolationnotignored
      nr_of_violations := sum( sanity_panel.DataHolderSanityManagers().Data(), 
                               Elements.HighestViolatedSeverity, 
                               hvs, 
                               hvs.Level() = max_level, 
                               hvs.NrOfViolationsNotIgnored() );
    }
    
    // Update the button
    this.SetProperty( "Image", icon );
    this.SetProperty( "Tooltip", tooltip );
    this.SetProperty( "Text", ifexpr( nr_of_violations > 0, [String] nr_of_violations, "" ) );
  *]
}
