Skip to content

feat: status-transition flows#12

Merged
sjvans merged 32 commits into
mainfrom
flows
Dec 4, 2025
Merged

feat: status-transition flows#12
sjvans merged 32 commits into
mainfrom
flows

Conversation

@sjvans

@sjvans sjvans commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

summary

makes use of new status-transition flows feature of cds^9.5:

  • check entry state(s) for action → previously unchecked
  • set to exit state for action → remove custom handlers
  • automatically add ui artifacts → remove unnecessary annotations

cds w --profile flow

extends to a more complex flow incl. usage of @to: $flow.previous.
for that, status InReview and Blocked as well as actions reviewTravel, reopenTravel, blockTravel, and unblockTravel were added in order to create a scenario where the previous state of Blocked can be either Open or InReview.

visualization of the flow:
image


related

@sjvans sjvans changed the title feat: add status transition flows feat: add status transition flows (incl. @to: $flow.previous) Nov 23, 2025
@sjvans sjvans changed the title feat: add status transition flows (incl. @to: $flow.previous) feat: status transition flows Dec 1, 2025
@sjvans sjvans changed the title feat: status transition flows feat: status-transition flows Dec 1, 2025
@sjvans
sjvans marked this pull request as ready for review December 1, 2025 00:21

@danjoa danjoa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍
Please see my comments before merging...

Comment thread srv/travel-service.cds
Comment on lines +18 to +24
// Define flow for Travels
annotate Travels with @flow.status: Status actions {
rejectTravel @from: #Open @to: #Canceled;
acceptTravel @from: #Open @to: #Accepted;
deductDiscount @from: #Open;
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move that to a separate file srv/travel-flow.cds ?

@sjvans sjvans Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately leads to an interesting error with profile flow:

xtravels % cds w --profile flow

cds serve all --with-mocks --in-memory? --profile flow 
( live reload enabled for browsers ) 

        ___________________________
 
[ERROR] srv/travel-flow.cds:5:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“rejectTravel”)
[ERROR] srv/travel-flow.cds:6:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“acceptTravel”)
[ERROR] xmpls/flow/flow-previous.cds:18:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“acceptTravel”)
[ERROR] xmpls/flow/flow-previous.cds:19:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“rejectTravel”)

→ i'll follow up with the compiler team

Comment thread db/schema.cds
Comment thread cds Outdated
Comment thread xmpls/flow/flow-previous.cds
Comment thread app/travels/field-control.cds
@sjvans
sjvans merged commit 8e129e4 into main Dec 4, 2025
3 checks passed
@sjvans
sjvans deleted the flows branch December 4, 2025 10:14
sjvans added a commit to capire/xtravels-java that referenced this pull request Dec 15, 2025
### summary

makes use of new status-transition flows feature of cds-services^4.5 and
cds^9.5:
- check entry state(s) for action → previously unchecked → TODO: true?
- set to exit state for action → remove custom handlers
- automatically add ui artifacts → remove unnecessary annotations

### `CDS_ENV=flow mvn cds:watch`

extends to a more complex flow incl. usage of `@to: $flow.previous`.
for that, status `InReview` and `Blocked` as well as actions
`reviewTravel`, `reopenTravel`, `blockTravel`, and `unblockTravel` were
added in order to create a scenario where the previous state of
`Blocked` can be either `Open` or `InReview`.

visualization of the flow:
<img width="913" height="444" alt="image"
src="https://github.com/user-attachments/assets/8dd98cdf-7a01-4e55-85bc-a2a7d69fdd16"
/>

---

### related

- capire/xtravels#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants