admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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 InitializeCapacity () id:Method_LibCal_dlgEvent_InitializeCapacity
{
  #keys: '[131094.1.420576130]'
  Body:
  [*
    event     := this.Data(); 
    eventType := event.Type();
    
    // Extensible method USE_PARTIAL_CAPACITY indicates if partial capacity is allowed.
    useParticalCapacity := LibCal_Event::USE_PARTIAL_CAPACITY();
    
    // Show an additional radiobutton + editfield or the capacity when applicable.
    if( useParticalCapacity )
    {
      rbgEventType.ButtonLabels( rbgEventType.ButtonLabels() + "   ;Capacity" );
      rbgEventType.ButtonValues( rbgEventType.ButtonValues() + ";" + LibCal_Event::TYPE_PARTIAL() );
    }
    else
    {
      // Partial capacity should not be used. Convert it to Unavailable or Available.
      // This is an edge case that can only happen via import, or when using partial capacity was first enabled and later disabled.
      if( eventType = LibCal_Event::TYPE_PARTIAL() )
      {
        if( event.PartialCapacity() = 0.0 )
        {
          eventType := LibCal_Event::TYPE_UNAVAILABLE();
        }
        else
        {
          eventType := LibCal_Event::TYPE_AVAILABLE();
        }
        
        this.UserData( 1 );  // Register that a message should be shown to inform the user that the EventType and Capacity is changed.
                             // The message is triggered in the OnCreated-response of the Dialog.
      }
    }
    
    // Set the value of the radiobutton.
    rbgEventType.BoundValue( eventType );
    
    // Always set the value in the editfield for the capacity...
    capacity := this.RealToString( event.PartialCapacity() ); 
    edtCapacity.Text( capacity );
    
    // ... but only show the editfield if applicable.
    edtCapacity.Visible( useParticalCapacity );
  *]
}