lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
Quintiq file version 2.0
#parent: #root
Method SetDefaultValue (
  LibCal_CalendarRegistry owner
) id:Method_DialogCreateEditEventType_SetDefaultValue
{
  #keys: '[415136.0.725511682]'
  Body:
  [*
    // Set default + init dialog
    dialogInstance := dhDialogData.Data().WrappedInstance();
    isNew := isnull( dialogInstance );
    
    // Extract the parent product by filtering out the descendents of the selected products in order to prevent circularity
    eventtypes := construct( LibCal_EventTypes );
    if( isNew
        or dialogInstance.IsLeaf() ) // Is leaf
    {
      eventtypes := selectset( owner, EventType, et, true );
      currentScope := dhDialogDatas.Data();
    
      eventtypes := eventtypes.Difference( currentScope );
    }
    else if( not dialogInstance.HasParent() ) // Is root level
    {
      eventtypes := selectset( owner, RootEventType, et, et <> dialogInstance );
    }
    else // Has Parent and Child
    {
      allEventTypes := selectset( owner, EventType, et, et <> dialogInstance );
      myChildren := selectset( dialogInstance, AllChildren.AsChildren, c, true );
    
      eventtypes := allEventTypes.Difference( myChildren );
    }
    
    dhParentEventTypeSelection.Data( eventtypes.Copy() );
  *]
}