limj
2023-10-24 93652435728de839582440eefd5122c281181d35
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
Quintiq file version 2.0
#parent: #root
Method EditUnitCapacityFromListUnitPeriodQuantity (
  internal[GUIComponent] parent,
  structured[UnitPeriodQuantity] selection
) id:Method_DialogCreateEditUnitCapacity_EditUnitCapacityFromListUnitPeriodQuantity
{
  #keys: '[107528.0.125617852]'
  Body:
  [*
    // Edit the unit capacity of the selection unit period quantities from periods list
    
    isbatchedit := selection.Size() > 1;
    Dialog.ShowHideComponentForBatchEdit( isbatchedit, false, true );
    
    // Need this for excluding itself in pre-condition primary keys checking.
    upq := selection.Element( 0 );
    data := shadow( selection.Element( 0 ).UnitCapacity() );
    
    // In case selection.Element( 0 ) doesn't bind to any unit capacity, calling SetDefaultValue method will return null error.
    // Check start in case of editing from UPQ later than the existing UC, the Start date will be off if we pass in existing UC
    if( isnull( data )
        or data.Start() <> selection.Element( 0 ).Start() )
    {
      data := selection.Element( 0 ).Unit().UnitCapacity( relshadow, UnitID := upq.Unit().ID(), Start := upq.Start() );
    }
    
    Dialog.Data( data );
    
    // Need this so that when the upt doesn't not have a unit capacity, the fields in this Dialog will not be blank.
    Dialog.SetDefaultValue( selection.Element( 0 ) );
    
    result := this.DoModal( parent );
    
    if ( result > 0 )
    {
      UnitCapacity::CreateOrUpdateForUnitPeriodQuantitys( selection,
                                                          not isbatchedit or CheckBoxBatchEditCapacity.Checked(),
                                                          data.TimeUnit(),
                                                          data.MinCapacity(),
                                                          data.MaxCapacity(),
                                                          not isbatchedit or CheckBoxBatchEditMaxLoadPercentage.Checked(),
                                                          data.MaximumLoadPercentage(),
                                                          not isbatchedit or CheckBoxBatchEditNrOfUnitsOpen.Checked(),
                                                          data.NrOfUnitsOpen(),
                                                          CheckBoxThisPeriodOnwards.Checked() );
    
    }
  *]
}