|
| 1 | +-- Auto-layout of a microflow written with no @position: long main lines, guards |
| 2 | +-- and wide enumeration splits. |
| 3 | +-- |
| 4 | +-- Measured on a generated app of 41 microflows (Mendix 11.12.1, mxcli v0.23.0), none |
| 5 | +-- of them carrying an @position: nothing overlapped, and the widest flow was |
| 6 | +-- 6930x160 px - four screens of sideways scrolling. Every guard left 370px of bare |
| 7 | +-- main line above its own branch (40px between any two activities), a merge stood |
| 8 | +-- 120px after its branch, and a 7-case split sent its fourth case out of the split's |
| 9 | +-- LEFT corner and its fifth onwards onto the TOP of their activities, because the |
| 10 | +-- anchor pair was storing the case order. |
| 11 | +-- |
| 12 | +-- Open the three flows in Studio Pro after exec: |
| 13 | +-- MF_LayoutLong wraps onto rows; the joining line runs between the rows |
| 14 | +-- MF_LayoutGuards each activity after a guard stands in the branch's column |
| 15 | +-- MF_LayoutCases case lines leave the split top / right / bottom, 2-3-2 |
| 16 | +-- |
| 17 | +-- mendixlabs/mxcli#1154 |
| 18 | + |
| 19 | +CREATE ENUMERATION MyFirstModule.LayoutStatus ( |
| 20 | + NewOrder 'New', Confirmed 'Confirmed', InProgress 'In progress', Shipped 'Shipped', |
| 21 | + Delivered 'Delivered', Invoiced 'Invoiced' |
| 22 | +); |
| 23 | + |
| 24 | +CREATE MICROFLOW MyFirstModule.MF_LayoutLong () |
| 25 | +BEGIN |
| 26 | + LOG INFO 'step 1'; |
| 27 | + LOG INFO 'step 2'; |
| 28 | + LOG INFO 'step 3'; |
| 29 | + LOG INFO 'step 4'; |
| 30 | + LOG INFO 'step 5'; |
| 31 | + LOG INFO 'step 6'; |
| 32 | + LOG INFO 'step 7'; |
| 33 | + LOG INFO 'step 8'; |
| 34 | + LOG INFO 'step 9'; |
| 35 | + LOG INFO 'step 10'; |
| 36 | + LOG INFO 'step 11'; |
| 37 | + LOG INFO 'step 12'; |
| 38 | + LOG INFO 'step 13'; |
| 39 | + LOG INFO 'step 14'; |
| 40 | + LOG INFO 'step 15'; |
| 41 | + LOG INFO 'step 16'; |
| 42 | + LOG INFO 'step 17'; |
| 43 | + LOG INFO 'step 18'; |
| 44 | + LOG INFO 'step 19'; |
| 45 | + LOG INFO 'step 20'; |
| 46 | + LOG INFO 'step 21'; |
| 47 | + LOG INFO 'step 22'; |
| 48 | + LOG INFO 'step 23'; |
| 49 | + LOG INFO 'step 24'; |
| 50 | + LOG INFO 'step 25'; |
| 51 | + LOG INFO 'step 26'; |
| 52 | + LOG INFO 'step 27'; |
| 53 | + LOG INFO 'step 28'; |
| 54 | + LOG INFO 'step 29'; |
| 55 | + LOG INFO 'step 30'; |
| 56 | + LOG INFO 'step 31'; |
| 57 | + LOG INFO 'step 32'; |
| 58 | + LOG INFO 'step 33'; |
| 59 | + LOG INFO 'step 34'; |
| 60 | + LOG INFO 'step 35'; |
| 61 | + LOG INFO 'step 36'; |
| 62 | + LOG INFO 'step 37'; |
| 63 | + LOG INFO 'step 38'; |
| 64 | + LOG INFO 'step 39'; |
| 65 | + LOG INFO 'step 40'; |
| 66 | +END; |
| 67 | +/ |
| 68 | + |
| 69 | +CREATE MICROFLOW MyFirstModule.MF_LayoutGuards ($Amount: Integer, $Limit: Integer) |
| 70 | +RETURNS Boolean AS $IsAccepted |
| 71 | +BEGIN |
| 72 | + IF $Amount = 0 THEN |
| 73 | + LOG WARNING 'nothing to place'; |
| 74 | + RETURN false; |
| 75 | + END IF; |
| 76 | + LOG INFO 'amount present'; |
| 77 | + IF $Amount > $Limit THEN |
| 78 | + LOG WARNING 'over the limit'; |
| 79 | + RETURN false; |
| 80 | + END IF; |
| 81 | + IF $Limit < 0 THEN |
| 82 | + LOG WARNING 'no credit at all'; |
| 83 | + RETURN false; |
| 84 | + END IF; |
| 85 | + LOG INFO 'accepted'; |
| 86 | + RETURN true; |
| 87 | +END; |
| 88 | +/ |
| 89 | + |
| 90 | +CREATE MICROFLOW MyFirstModule.MF_LayoutCases ($Status: MyFirstModule.LayoutStatus) |
| 91 | +RETURNS String AS $Next |
| 92 | +BEGIN |
| 93 | + DECLARE $Next String = ''; |
| 94 | + CASE $Status |
| 95 | + WHEN NewOrder THEN |
| 96 | + SET $Next = 'Confirmed'; |
| 97 | + WHEN Confirmed THEN |
| 98 | + SET $Next = 'InProgress'; |
| 99 | + WHEN InProgress THEN |
| 100 | + SET $Next = 'Shipped'; |
| 101 | + WHEN Shipped THEN |
| 102 | + SET $Next = 'Delivered'; |
| 103 | + WHEN Delivered THEN |
| 104 | + SET $Next = 'Invoiced'; |
| 105 | + WHEN Invoiced THEN |
| 106 | + SET $Next = 'Invoiced'; |
| 107 | + WHEN (empty) THEN |
| 108 | + SET $Next = 'NewOrder'; |
| 109 | + END CASE; |
| 110 | + RETURN $Next; |
| 111 | +END; |
| 112 | +/ |
0 commit comments