Insert box inside while loop

+2 votes
asked Jul 27, 2019 in Question / help by muteboy (200 points)

I'm making an Activity Diagram, where multiple parties are performing actions, and setting a status in the system.

Here's my simple example:

http://www.plantuml.com/plantuml/uml/TP71IiD048Rl-nG_yT92rNkAjY81Uscb1K7miYQJPB6T2RkZGSZ3kqdJAeeGo3BiF_FDjykWrklxOM-wUs7rDbVndHcgnbD3LatwwAMHG7F3eWJlgbfJQEq2ugSr8QQSiBdOUCiLfJkrIhZ1c2kk_ms6uMOWXUDZuJCe7KoNSUMOAAAaM_fmrCv76hIrsnCcTtbEZLAncFQz9klD3DliQRNBfkRozZdRpKsv5wkEAtmFHufL2Jj68-5QPc2AHvMUOkHHGT9F3PJ0Se5Ay6hpDsZyKocUa8oh9LSl_20jSijOmN4Whp426KJWA2BKjg7JWibw4vjwB-tYZwznfr--N3a4NVG25yxqiw5wyjJJ_rIgSkvcWafZbiH5VEOl

@startuml
|Contractor|
start
repeat
:Propose;
note right: this is the action
#Orange:State = Proposed/
note right: this is the state set in the system
|Engineer|
:Review;
repeat while (Accepted?) is (NO, REVISE)
->YES;
floating note right : If accepted = No, need to set state to "Revise" and go back to before "Propose".\nHow can I insert an orange State shape in the "NO" arrow?
#Orange:State = Accepted/
note right: if the item is accepted, the Engineer sets the state to Accepted
stop
@enduml

Here's the narrative.

  1. Contractor proposes an item, and sets Status to Proposed.
  2. Engineer reviews item.
    1. If accepted, Engineer sets Status to Accepted and we move on.
    2. If the Engineer does not accept the item, they set the Status to Revise, and the arrow should then go back to the Contractor's Propose box. 
How can I add a box to show the Engineer setting the Status to Revise before the arrow goes back to Propose?
Am I using the right kind of diagram? I do want the swimlanes.
Grateful for any suggestions,
Matthew

1 Answer

0 votes
answered Sep 6, 2023 by The-Lu (74,900 points)

Hi M, and all,

[]Here is an answer to an old question],wink

Since:

You can use `backward` as:

@startuml
<style>
.save {
  BackgroundColor Orange
}
</style>
|Contractor|
start
repeat
:Propose;
note right: this is the action
:State = Proposed; <<save>>
note right: this is the state set in the system
|Engineer|
:Review;
backward:State = Revise; <<save>>
repeat while (Accepted?) is (NO)
->YES;
floating note right
If accepted = No,
need to set state to "Revise"
and go back to before "Propose".
end note
:State = Accepted; <<save>>
note right
if the item is accepted,
the Engineer sets the state to Accepted
end note
stop
@enduml

Now remains only the issues to color or style the backward element: blush

Enjoy,
Regards
Th.

commented Sep 12, 2023 by The-Lu (74,900 points)

Hi all,

FYI, the color/style issue is now fixed with the last snapshot, see here:
- https://github.com/plantuml/plantuml/issues/1531#issuecomment-1714334386

Thanks PlantUML team, yes
Regards,
Th.

...