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
51
52
53
54
55
56
57
Quintiq file version 2.0
#parent: #root
StaticMethod CanDragAndDropResourceNodes (
  Unit dpfocusedunit,
  output String feedback_o,
  Units units
) declarative remote 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:
  [*
    // 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
    feedback_o := '';
    
    // Check if the selected set of units has different parents
    if( units.Size() > 0 and exists( units, Elements, el, el.Parent() <> units.Element( 0 ).Parent() ) )
    {
      feedback_o := Translations::MP_SupplyChainView_CanDragAndDropResourceNodes_DifferentLevel();
    }
    else
    {
      level := units.Element( 0 ).Level();
      parentname := guard( units.Element( 0 ).Parent().Name(), '' );
      // Check if dpfocusedunit is null
      if( isnull( dpfocusedunit ) )
      {
        // Check if level is not equals to 1
        if( level <> 1 )
        {
        feedback_o := Translations::MP_SupplyChainView_CanDragAndDropResourceNodes_DrillTowards( parentname );
        }
      }
      else
      {
        // Check if dpfocusedunit's level + 1 is not equals to level
        // or dpfocusedunit's name is not equals to parentname
        if( dpfocusedunit.Level() + 1 <> level or parentname <> dpfocusedunit.Name() )
        {
          feedback_o := Translations::MP_SupplyChainView_CanDragAndDropResourceNodes_DrillTowards( parentname );
    
          // Check if level equals to 1
          if( level = 1 )
          {
            feedback_o := Translations::MP_SupplyChainView_CanDragAndDropResourceNodes_DrillTowardsRootLevel();
          }
        }
      }
    }
    
    return feedback_o = '';
  *]
}