yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Quintiq file version 2.0
#parent: #root
StaticMethod CanDragAndDropStockingPointNodes (
  Unit dpfocusedunit,
  output String feedback_o,
  StockingPoint_MPs stockingpoints
) as Boolean
{
  Description:
  [*
    If current supply chain view is displaying all root unit, dragging and dropping of resource nodes should not be allowed (Resource nodes are unit nodes that has parent)
    control / shift key is to prevent collision with other drag and drop.
  *]
  TextBody:
  [*
    feedback_o := '';
    
    /*
    Count how many number of selected stocking points which do not belong to any unit
    If there are none, (e.g. all stocking points belong to a unit), proceed with the next check
    If there are some. (e.g. still have some stocking points belong to a unit), drag and drop should not be allowed.
    If all of them do not belong to any unit, drag and drop is only allowed in root level.
    */
    
    nullsp := counter( stockingpoints, Elements, sp, isnull( sp.Unit() ) );
    
    if( nullsp = 0 )
    {
      // Check whether the selected stocking points belong to the units of same level
      if( stockingpoints.Size() > 0 and exists( stockingpoints, Elements, sp,
                                                sp.Unit() <> stockingpoints.Element( 0 ).Unit() ) )
      {
        feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DifferentLevel();
      }
    
      else
      {
        level := stockingpoints.Element( 0 ).Unit().Level() + 1; //+ 1 because stocking point belongs to that unit.
        parentname := guard( stockingpoints.Element( 0 ).Unit().Name(), '' );
    
        if( not isnull( dpfocusedunit )  )
        {
          //e.g. Units dragged is level 3, current focusedunit is level 1
          if( dpfocusedunit.Level() + 1 <> level or parentname <> dpfocusedunit.Name() )
          {
            feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowards( parentname );
          }
        }
        else
        {
            feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowards( parentname );
        }
      }
    }
    
    else if( nullsp < stockingpoints.Size() )
    {
      feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DifferentLevel();
    }
    
    else if( nullsp = stockingpoints.Size() and not isnull( dpfocusedunit ) )
    {
      feedback_o := Translations::MP_SupplyChainView_CanDragAndDropStockingPointNodes_DrillTowardsRootLevel();
    }
    
    return feedback_o = '';
  *]
}