agjan 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/claude-code.js +9 -3
- package/dist/auto.js +4 -0
- package/dist/baseline.js +11 -8
- package/dist/cli.js +8 -0
- package/dist/commands/check.js +65 -13
- package/dist/commands/gates.js +9 -1
- package/dist/commands/lint.js +16 -5
- package/dist/commands/log.js +1 -1
- package/dist/commands/new.js +4 -3
- package/dist/commands/setup.js +91 -81
- package/dist/commands/skill.js +22 -0
- package/dist/commands/summary.js +37 -0
- package/dist/config.js +24 -0
- package/dist/fix.js +13 -10
- package/dist/git.js +57 -9
- package/dist/launcher.js +9 -3
- package/dist/progress-view.js +36 -23
- package/dist/progress.js +103 -38
- package/dist/qa.js +10 -5
- package/dist/review-policy.js +4 -1
- package/dist/review.js +82 -35
- package/dist/schema.js +85 -0
- package/dist/scope.js +12 -4
- package/dist/story.js +110 -0
- package/dist/tests-map.js +17 -11
- package/docs/guide.md +52 -7
- package/kit/domains/btp/domain.json +2 -2
- package/kit/hooks/guard.mjs +53 -9
- package/kit/skills/agjan-build/SKILL.md +19 -7
- package/kit/skills/agjan-design/SKILL.md +20 -1
- package/kit/skills/agjan-fix/SKILL.md +1 -1
- package/kit/skills/agjan-spec/SKILL.md +9 -3
- package/kit/skills/agjan-spec/references/elicitation.md +135 -0
- package/kit/skills/agjan-verify/SKILL.md +9 -1
- package/kit/skills/btp-architect/SKILL.md +7 -2
- package/kit/skills/btp-architect/references/deployment.md +43 -0
- package/kit/skills/btp-architect/references/security.md +59 -4
- package/kit/skills/cap-developer/SKILL.md +19 -7
- package/kit/skills/cap-developer/references/agents.md +90 -0
- package/kit/skills/cap-developer/references/handlers.md +88 -9
- package/kit/skills/cap-developer/references/modeling.md +41 -0
- package/kit/skills/cap-developer/references/project-setup.md +57 -7
- package/kit/skills/cap-developer/references/services.md +172 -7
- package/kit/skills/cap-developer/references/testing.md +79 -6
- package/kit/skills/cap-developer/references/typescript.md +8 -7
- package/kit/skills/cap-developer/references/validation-security.md +74 -2
- package/kit/skills/fiori-developer/SKILL.md +21 -1
- package/kit/skills/fiori-developer/references/accessibility.md +65 -0
- package/kit/skills/fiori-developer/references/app-setup.md +10 -3
- package/kit/skills/fiori-developer/references/elements-cookbook.md +71 -0
- package/kit/skills/fiori-developer/references/elements.md +82 -9
- package/kit/skills/fiori-developer/references/freestyle-ts.md +27 -0
- package/kit/skills/fiori-developer/references/testing.md +5 -0
- package/kit/skills/fiori-developer/references/ui5-basics.md +34 -1
- package/kit/skills/qa-tester/SKILL.md +11 -4
- package/kit/skills/qa-tester/references/techniques.md +123 -0
- package/kit/skills/solution-reviewer/SKILL.md +10 -0
- package/kit/skills/solution-reviewer/references/defects.md +154 -0
- package/kit/templates/agents-block.md +1 -1
- package/kit/templates/agjan-ci.yml +3 -0
- package/package.json +1 -1
- package/schemas/config.schema.json +1 -1
- package/schemas/reviews.schema.json +1 -1
|
@@ -17,7 +17,7 @@ import assert from 'node:assert/strict'
|
|
|
17
17
|
const { GET, POST, axios } = cds.test(import.meta.dirname + '/..')
|
|
18
18
|
axios.defaults.validateStatus = () => true // assert on status codes, not exceptions
|
|
19
19
|
const as = (user: string) => ({ auth: { username: user, password: user } })
|
|
20
|
-
const ID = '7a1e0c1a-0001-4c2b-9a5f-000000000001' // a row from
|
|
20
|
+
const ID = '7a1e0c1a-0001-4c2b-9a5f-000000000001' // a row from test/data, status New
|
|
21
21
|
const requests = '/odata/v4/leave/LeaveRequests'
|
|
22
22
|
|
|
23
23
|
// Draft-enabled: a new request is a draft first; the checks run when it is activated.
|
|
@@ -46,13 +46,17 @@ describe('LeaveService', () => {
|
|
|
46
46
|
it('TLR-AC6: only a manager approves, and only once', async () => {
|
|
47
47
|
const url = `${requests}(ID=${ID},IsActiveEntity=true)/LeaveService.approve`
|
|
48
48
|
assert.equal((await POST(url, {}, as('employee'))).status, 403)
|
|
49
|
-
|
|
50
|
-
assert.equal(
|
|
49
|
+
const approved = await POST(url, {}, as('manager'))
|
|
50
|
+
assert.equal(approved.status, 204)
|
|
51
|
+
assert.deepEqual(JSON.parse(approved.headers['sap-messages']).map((m: { message: string }) => m.message), ['The request is approved.'])
|
|
52
|
+
const again = await POST(url, {}, as('manager')) // the flow: approve only from New
|
|
53
|
+
assert.equal(again.status, 409)
|
|
54
|
+
assert.equal(again.data.error.message, 'Only new requests can be approved or rejected.')
|
|
51
55
|
})
|
|
52
56
|
it('TLR-AC7: a manager of another team can neither approve nor reject', async () => {
|
|
53
57
|
const other = `${requests}(ID=7a1e0c1a-0001-4c2b-9a5f-000000000002,IsActiveEntity=true)/LeaveService`
|
|
54
58
|
assert.equal((await POST(`${other}.approve`, {}, as('manager2'))).status, 403)
|
|
55
|
-
assert.equal((await POST(`${other}.
|
|
59
|
+
assert.equal((await POST(`${other}.decline`, { reason: 'no' }, as('manager2'))).status, 403)
|
|
56
60
|
})
|
|
57
61
|
})
|
|
58
62
|
```
|
|
@@ -75,6 +79,72 @@ describe('LeaveService', () => {
|
|
|
75
79
|
the whole draft choreography, including editing an active row).
|
|
76
80
|
- `cds.test` keeps the console quiet during tests; write diagnostics to a file if needed.
|
|
77
81
|
|
|
82
|
+
## Choosing the runner
|
|
83
|
+
|
|
84
|
+
CAP announced in its June 2026 release that it moves its own test suites to Node's runner
|
|
85
|
+
and Vitest, moves its samples and core packages to ESM, and will remove Jest support from
|
|
86
|
+
`cds.test` (`@cap-js/cds-test` 1.0 supports Vitest and Chai 6). `cds init` creates ESM
|
|
87
|
+
projects, which Jest handles badly.
|
|
88
|
+
|
|
89
|
+
- **New projects:** Node's runner (`node --test`, or `cds test`, a thin wrapper around it),
|
|
90
|
+
as in the example: no extra dependency. Vitest where the team wants its watch mode or
|
|
91
|
+
coverage report. **Never Jest.**
|
|
92
|
+
- **A project on Jest** keeps it until the team decides: porting the suite to Vitest is
|
|
93
|
+
technical work of its own (`/agjan-spec`, `kind: technical`), not part of a feature.
|
|
94
|
+
Under Jest, `cds.test`'s `expect` is only a lookalike of Chai's that lacks some APIs;
|
|
95
|
+
use Jest's own `expect` there.
|
|
96
|
+
- **Vitest** (checked with Vitest 5.0 and the example's tests): the file stays the same
|
|
97
|
+
except that `describe` and `it` come from `vitest`; `node:assert` works there too. Keep
|
|
98
|
+
the Playwright specs out and switch TypeScript mode on in `vitest.config.ts`, run with
|
|
99
|
+
`npx vitest run`:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { defineConfig } from 'vitest/config'
|
|
103
|
+
|
|
104
|
+
export default defineConfig({
|
|
105
|
+
test: {
|
|
106
|
+
include: ['test/**/*.test.ts'], // test/ui holds the Playwright specs
|
|
107
|
+
env: { CDS_TYPESCRIPT: 'true' }, // CAP loads .ts handlers only in TypeScript mode
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- **Without TypeScript mode, CAP serves the service without its `.ts` handlers and says
|
|
113
|
+
nothing:** the tests of annotations pass and those of handler rules fail (checked under
|
|
114
|
+
both runners: 5 of the example's 8 tests passed). A failing handler test in a TypeScript
|
|
115
|
+
project is checked with the project's test command, never with a bare `node --test` or
|
|
116
|
+
`vitest` on the file.
|
|
117
|
+
- In JavaScript, `cds.test` also provides `describe`, `it`, `beforeAll` and `expect` as
|
|
118
|
+
globals for every runner, so a file runs under each unchanged. TypeScript has no types
|
|
119
|
+
for those globals: import them from the runner, as above.
|
|
120
|
+
|
|
121
|
+
## Tests an expert adds
|
|
122
|
+
|
|
123
|
+
Beyond the happy path of each AC (each checked with `@sap/cds` 10.1):
|
|
124
|
+
|
|
125
|
+
- **Read-only input**: send what the client must not set and assert the stored value; CAP
|
|
126
|
+
drops it without an error:
|
|
127
|
+
|
|
128
|
+
<!-- checked: test/leaves.test.ts -->
|
|
129
|
+
```ts
|
|
130
|
+
it('TLR-AC10: an employee cannot set the status of a request; it starts as New', async () => {
|
|
131
|
+
const { status, data } = await create({ startDate: '2026-12-01', endDate: '2026-12-02', type_code: 'vacation', status_code: 'A' }, 'employee')
|
|
132
|
+
assert.equal(status, 201) // read-only input is dropped, not rejected
|
|
133
|
+
assert.equal(data.status_code, 'N')
|
|
134
|
+
})
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- **Messages**: a success message arrives in the `sap-messages` header:
|
|
138
|
+
`JSON.parse(res.headers['sap-messages'])[0].message`.
|
|
139
|
+
- **Boundaries**: one character over a `String(n)`, one decimal too many, the first and the
|
|
140
|
+
last allowed date, an empty string where `@mandatory` applies; each gets 400 with the
|
|
141
|
+
element as `target`.
|
|
142
|
+
- **Concurrency**: an action twice (the second answers 409, above); with `@odata.etag`, an
|
|
143
|
+
update without `If-Match` (428) and with an old ETag (412); in a draft app, a second user
|
|
144
|
+
opening a row another user edits.
|
|
145
|
+
- **Paging**: a collection larger than `cds.query.limit.max` comes back with
|
|
146
|
+
`@odata.nextLink`; code that reads all rows follows it.
|
|
147
|
+
|
|
78
148
|
## Rules
|
|
79
149
|
|
|
80
150
|
- Call `cds.test(…)` **first** in the file, before touching `cds.env` or other `cds`
|
|
@@ -88,8 +158,11 @@ describe('LeaveService', () => {
|
|
|
88
158
|
and an anonymous request (401).
|
|
89
159
|
- Mock as little as possible; the more is mocked, the less is tested. Mocking module
|
|
90
160
|
caches or timers can break the CAP server.
|
|
91
|
-
- Use the project's runner (
|
|
92
|
-
|
|
161
|
+
- Use the project's runner (section "Choosing the runner"); a new project gets Node's
|
|
162
|
+
runner or Vitest, never Jest.
|
|
163
|
+
- Compare what matters, not whole responses (ids and timestamps change): the error `code`
|
|
164
|
+
and `target`, the fields the AC names. Where a status may differ from the expected one,
|
|
165
|
+
let the assertion show why: `assert.equal(status, 400, JSON.stringify(data))`.
|
|
93
166
|
- agjan: every AC of a task gets at least one test whose name starts with its id, and
|
|
94
167
|
every validation gets a test of its failure case.
|
|
95
168
|
- If the project configures test results (`verify.cap.results`), the test command must
|
|
@@ -86,10 +86,8 @@ export class LeaveService extends cds.ApplicationService { override init() {
|
|
|
86
86
|
…
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
-
this.on(LeaveRequest.actions.
|
|
90
|
-
|
|
91
|
-
const n = await UPDATE(LeaveRequests, ID).where({ status_code: 'N' }).with({ status_code: 'A' })
|
|
92
|
-
if (!n) return req.reject(409, 'ONLY_NEW_REQUESTS')
|
|
89
|
+
this.on(LeaveRequest.actions.decline, async req => {
|
|
90
|
+
await UPDATE(req.subject).with({ reason: req.data.reason }) // the action's parameter
|
|
93
91
|
})
|
|
94
92
|
|
|
95
93
|
return super.init()
|
|
@@ -108,21 +106,24 @@ export class LeaveService extends cds.ApplicationService { override init() {
|
|
|
108
106
|
|
|
109
107
|
- `cds watch` detects `tsconfig.json` and runs the `.ts` files with tsx. Development only.
|
|
110
108
|
- Production: `cds build` compiles TypeScript with the `typescript` build task into
|
|
111
|
-
`gen/srv` (`.js` next to the CSN). Keep tests out of it with
|
|
109
|
+
`gen/srv` (`.js` next to the CSN). Keep tests and test tooling out of it with
|
|
110
|
+
`tsconfig.cdsbuild.json` (every `.ts` file it does not exclude is compiled and deployed;
|
|
111
|
+
a root `playwright.config.ts` ended up in `gen/srv` until it was excluded):
|
|
112
112
|
|
|
113
113
|
<!-- checked: tsconfig.cdsbuild.json -->
|
|
114
114
|
```json
|
|
115
115
|
{
|
|
116
116
|
"extends": "./tsconfig.json",
|
|
117
117
|
"compilerOptions": { "outDir": "./gen/srv" },
|
|
118
|
-
"exclude": ["node_modules", "gen", "app", "test"]
|
|
118
|
+
"exclude": ["node_modules", "gen", "app", "test", "playwright.config.ts"]
|
|
119
119
|
}
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
- Tests are `.ts` too, run by Node itself (type stripping, Node 22.18 or later). CAP
|
|
123
123
|
loads `.ts` service implementations only in TypeScript mode (`CDS_TYPESCRIPT`), which
|
|
124
124
|
must be set before `@sap/cds` loads: preload a setup file, and name the test files so
|
|
125
|
-
the runner does not take the setup for a test
|
|
125
|
+
the runner does not take the setup for a test. Without it the service runs without its
|
|
126
|
+
handlers and no error says so (testing.md, "Choosing the runner"):
|
|
126
127
|
|
|
127
128
|
<!-- checked: test/typescript.ts -->
|
|
128
129
|
```ts
|
|
@@ -19,7 +19,11 @@ handlers.
|
|
|
19
19
|
bound in parentheses to exclude it (`[(0), 100]`: above 0), use `_` for no bound
|
|
20
20
|
(`[(0), _]`: positive). On an `enum` element, `@assert.range` alone restricts input to
|
|
21
21
|
the enum values. (Open intervals and `_` need `@sap/cds` 8.5 or later.)
|
|
22
|
-
- `@assert.format: '<regex>'`: strings matching a pattern.
|
|
22
|
+
- `@assert.format: '<regex>'`: strings matching a pattern. Anchor it (`^…$`) and avoid
|
|
23
|
+
nested quantifiers (`(a+)+`): a regular expression that backtracks without end on a crafted
|
|
24
|
+
input is a denial of service.
|
|
25
|
+
- Lengths (`String(n)`) and decimal places (`Decimal(p,s)`) are checked by the type itself
|
|
26
|
+
(modeling.md); read-only and immutable elements are dropped from input (services.md).
|
|
23
27
|
- `@assert.target`: on a managed to-one association, checks that the referenced instance
|
|
24
28
|
exists (create and update). It validates user input; referential integrity is
|
|
25
29
|
`@assert.integrity`. A target created in the same deep insert is not found.
|
|
@@ -117,7 +121,7 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
|
|
|
117
121
|
service LeaveService {
|
|
118
122
|
@restrict: [
|
|
119
123
|
{ grant: ['READ', 'CREATE'], to: 'employee', where: 'employee_userId = $user' },
|
|
120
|
-
{ grant: ['READ', 'approve', '
|
|
124
|
+
{ grant: ['READ', 'approve', 'decline'], to: 'manager', where: 'employee.team.manager = $user' }
|
|
121
125
|
]
|
|
122
126
|
@odata.draft.enabled // Fiori elements creates and edits through drafts
|
|
123
127
|
entity LeaveRequests as projection on my.LeaveRequests { … };
|
|
@@ -139,6 +143,74 @@ service LeaveService {
|
|
|
139
143
|
and list them under "Run locally" in `docs/agjan/project.md`. Without the profile they also apply in production, where anyone could log in
|
|
140
144
|
with those passwords. Check: `NODE_ENV=production npx cds env get requires.auth.kind`
|
|
141
145
|
must not print `mocked` or `dummy`.
|
|
146
|
+
- Never reach rows in a handler that the user may not see: a query awaited in a handler is
|
|
147
|
+
not filtered by `@restrict` (handlers.md). Filter by the user yourself.
|
|
142
148
|
- Name roles after the spec's business roles; the same roles go into
|
|
143
149
|
`xs-security.json` (btp area). Every authorization change is a risk in the design and
|
|
144
150
|
gets its own review.
|
|
151
|
+
|
|
152
|
+
## What paths can reach (checked with @sap/cds 10.1)
|
|
153
|
+
|
|
154
|
+
`@restrict` filters the **rows** of the entity a request reads. Paths in a filter go
|
|
155
|
+
further: a projection with `*` keeps its associations, and a path follows them into
|
|
156
|
+
entities the service does not expose. In a copy of the example with a `salary` in
|
|
157
|
+
`Employees` and `Teams.members`, an employee who may read only their own request asked
|
|
158
|
+
`$filter=employee/team/members/any(m:m/salary gt 5500)`: their request came back (a
|
|
159
|
+
colleague earns more), and with 6500 not. That is an oracle on data no API returns,
|
|
160
|
+
although `$expand=employee` was refused because the target is not in `$metadata`. The
|
|
161
|
+
MCP `query` tool answered the same question (`exists employee.team.members[salary > 5500]`).
|
|
162
|
+
|
|
163
|
+
- **Expose a small projection of every association target** that a projection keeps, with
|
|
164
|
+
only the fields the service may show; CAP redirects the associations to it, so paths
|
|
165
|
+
reach only those fields:
|
|
166
|
+
|
|
167
|
+
```cds
|
|
168
|
+
@readonly @restrict: [{ grant: 'READ', where: 'userId = $user' }]
|
|
169
|
+
entity Employees as projection on my.Employees { userId, name, team }; // no salary
|
|
170
|
+
@readonly @restrict: [{ grant: 'READ', where: 'manager = $user' }]
|
|
171
|
+
entity Teams as projection on my.Teams { ID, name, manager }; // no members
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Then both questions answered 400 (`"salary" does not exist`, `"members" does not
|
|
175
|
+
exist`) and the example's tests still passed. A target's own `@restrict` applies when it
|
|
176
|
+
is read, not inside a path of another entity's filter: what the projection contains is
|
|
177
|
+
the limit.
|
|
178
|
+
- `excluding { employee }` also closes the path, but it removes the foreign key with it:
|
|
179
|
+
`@restrict` conditions and handlers that use it fail (500), and a key re-added as
|
|
180
|
+
`employee.userId as employee_userId` is read-only, so the handler could no longer set the
|
|
181
|
+
owner of a new request.
|
|
182
|
+
- Keep sensitive fields (salaries, health, ratings) out of entities that other exposed
|
|
183
|
+
entities reach by association, or reach them only through such projections. Test it:
|
|
184
|
+
a filter through each association to a sensitive field, as a user who may not see it
|
|
185
|
+
(qa-tester `techniques.md`).
|
|
186
|
+
|
|
187
|
+
## Personal data
|
|
188
|
+
|
|
189
|
+
When the spec involves people (employees, customers, contacts), the data protection rules
|
|
190
|
+
apply, and CAP automates them from annotations (CAP documentation, "Annotating Personal
|
|
191
|
+
Data"; confirm details with `search_docs`):
|
|
192
|
+
|
|
193
|
+
```cds
|
|
194
|
+
annotate my.Employees with @PersonalData : {
|
|
195
|
+
DataSubjectRole : 'Employee',
|
|
196
|
+
EntitySemantics : 'DataSubject' // or 'DataSubjectDetails', 'Other' (a request about one)
|
|
197
|
+
} {
|
|
198
|
+
userId @PersonalData.FieldSemantics : 'DataSubjectID';
|
|
199
|
+
name @PersonalData.IsPotentiallyPersonal;
|
|
200
|
+
// health data, religion, bank details: @PersonalData.IsPotentiallySensitive
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
- With the audit logging plugin (`cds add audit-logging`, `@cap-js/audit-logging`), reads of
|
|
205
|
+
sensitive and changes of personal fields are logged to the SAP Audit Log Service in
|
|
206
|
+
production and to the console in development. Adding it is a btp decision; annotating
|
|
207
|
+
the model is part of the cap design whenever the spec has personal data.
|
|
208
|
+
- Expose only the personal fields the use case needs (`excluding`), restrict who reads
|
|
209
|
+
them, and never write them to logs (`cds.log`) or error messages.
|
|
210
|
+
- The three obligations, and what CAP integrates for each (design decisions for the btp
|
|
211
|
+
area): *when was it stored or changed* is audit logging (above); *what do you store
|
|
212
|
+
about me* is personal data management; *delete what you store about me* is data
|
|
213
|
+
retention. CAP 10 adds the plugin `@cap-js/data-privacy` (beta in the CAP release of
|
|
214
|
+
June 2026) for SAP Data Privacy Integration: from the `@PersonalData` and `@ILM`
|
|
215
|
+
annotations it serves `/dpp/information` and `/dpp/retention`. Decide in the design when
|
|
216
|
+
the spec states such rights or retention periods.
|
|
@@ -66,10 +66,30 @@ then building blocks or custom sections and columns, and controller extensions l
|
|
|
66
66
|
|---|---|
|
|
67
67
|
| any UI5 code, views, i18n, `index.html`, CAP integration | `references/ui5-basics.md` |
|
|
68
68
|
| a new elements app: its files, TypeScript setup, `manifest.json`, `index.html`, serving and checking it | `references/app-setup.md` |
|
|
69
|
-
| an elements app (annotations, pages, value help, actions, side effects) | `references/elements.md` |
|
|
69
|
+
| an elements app (annotations, pages, value help, actions with confirmations and parameters, messages, side effects, draft status) | `references/elements.md` |
|
|
70
|
+
| accessibility: what Fiori elements does, what the app supplies, freestyle rules (landmarks, labels, headings, focus, shortcuts, announcements, target size), axe in the UI tests | `references/accessibility.md` |
|
|
71
|
+
| a requirement in the spec's words (default filters, required filters, tabs, highlighted rows, currencies, fields fixed after create, dependent value helps, inline rows, export, action texts and defaults) | `references/elements-cookbook.md` |
|
|
70
72
|
| a freestyle TypeScript app | `references/freestyle-ts.md` |
|
|
71
73
|
| UI tests (Playwright, optional; OPA5 in apps that have it) | `references/testing.md` |
|
|
72
74
|
|
|
75
|
+
## What every elements app gets right
|
|
76
|
+
|
|
77
|
+
Design each AC that a user does on a page down to these points, and build them; they are
|
|
78
|
+
what users notice first (`references/elements.md`):
|
|
79
|
+
|
|
80
|
+
- **Every action that changes what the page shows has a side effect**, or the page keeps the
|
|
81
|
+
old values until a reload; a button that may not run for a row is disabled per row
|
|
82
|
+
(`@Core.OperationAvailable`), not left to fail.
|
|
83
|
+
- **Hard-to-undo actions ask first** (`@Common.IsActionCritical`); **action parameters have
|
|
84
|
+
labels** (`@title`), or the dialog shows the technical name.
|
|
85
|
+
- **The service speaks to the user**: success as a toast (`req.notify`), errors with a
|
|
86
|
+
translated message and the field as target, so Fiori puts it at the field.
|
|
87
|
+
- **Users pick, they do not type** codes: value helps for every code and association,
|
|
88
|
+
readable texts next to IDs (`@Common.Text`).
|
|
89
|
+
- **Fields behave as the rules say**: mandatory, read-only, editable only on create
|
|
90
|
+
(`@Core.Immutable`), hidden; Create, Edit and Delete hidden where the service forbids them.
|
|
91
|
+
- **Every label is an i18n text**, and the app declares its locales.
|
|
92
|
+
|
|
73
93
|
## Both types
|
|
74
94
|
|
|
75
95
|
- The service comes first: the UI is built against the finished CAP service, and most ACs
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Accessibility
|
|
2
|
+
|
|
3
|
+
Distilled from the UI5 team's agent skill `ui5-best-practices-accessibility`
|
|
4
|
+
(`UI5/plugins-coding-agents`, Apache-2.0, commit `56bcdc8`) and SAP's UI5con 2026
|
|
5
|
+
accessibility hands-on (`SAP-samples/ui5con-2026-a11y-hands-on`, Apache-2.0), checked in a
|
|
6
|
+
browser with SAPUI5 1.145 on 2026-10-21. Rules restated; the UI5 API reference has the
|
|
7
|
+
details of each property.
|
|
8
|
+
|
|
9
|
+
UI5 builds most of accessibility into its controls (roles, keyboard handling, focus). What
|
|
10
|
+
it cannot know is the app's meaning: names, the outline of a page, what changed. That is
|
|
11
|
+
the app's part.
|
|
12
|
+
|
|
13
|
+
## Fiori elements: the app supplies the texts
|
|
14
|
+
|
|
15
|
+
The generated pages had no WCAG 2.2 A/AA violations in an axe scan (the example's list
|
|
16
|
+
report and object page). Their accessible names come from the annotations, so:
|
|
17
|
+
|
|
18
|
+
- every field, column, filter and action parameter has a label (`@title`, from i18n): a
|
|
19
|
+
screen reader reads the label, without one the technical name;
|
|
20
|
+
- every action has its `Label` or `@title`; `UI.HeaderInfo` has `TypeName` and `Title`;
|
|
21
|
+
- facets have a `Label` (they become the page's regions: the UI tests find them with
|
|
22
|
+
`getByRole('region', { name })`);
|
|
23
|
+
- messages come from the service in words a user understands (cap-developer
|
|
24
|
+
`handlers.md`).
|
|
25
|
+
|
|
26
|
+
Custom sections, columns and fragments are freestyle UI5: the rules below apply to them.
|
|
27
|
+
|
|
28
|
+
## Freestyle UI5: what to check
|
|
29
|
+
|
|
30
|
+
| Topic | Rule |
|
|
31
|
+
|---|---|
|
|
32
|
+
| **Landmarks** | `sap.m.Page` and `DynamicPage` get a `landmarkInfo` (`PageAccessibleLandmarkInfo`, `DynamicPageAccessibleLandmarkInfo`) with a role **and** a label for each area, so the page has one `main` and labeled regions; a sub-header of navigation (breadcrumbs) gets the role navigation; a `Panel` that is a region of its own gets `accessibleRole="Region"` (or `Complementary` for a side panel of filters). |
|
|
33
|
+
| **Labels** | Every input has a visible `Label` with `labelFor` (a `SimpleForm` or `Form` does this itself); where no visible label fits, `ariaLabelledBy` points at a text. An icon-only `Button` has a `tooltip`; an `Image` that shows content has `decorative="false"` **and** an `alt` (usually bound, `alt="{name}"`); a decorative one stays `decorative` (the default). A `Table` or `List` is named with `ariaLabelledBy` pointing at its title. A `Dialog` without a header (`showHeader="false"`) needs `ariaLabelledBy`; better, keep its `title`. |
|
|
34
|
+
| **Headings** | `sap.m.Title` renders `h2` unless `level` is set: give every title its level, one `H1` per page (the page title), sections `H2`, subsections `H3`, no level skipped. |
|
|
35
|
+
| **Focus and keyboard** | A `Dialog` or `Popover` sets `initialFocus` where the user should start; a large area that is a region of its own joins F6 navigation with `<core:CustomData key="sap-ui-fastnavgroup" value="true" writeToDom="true"/>`; never a `tabindex` above 0. |
|
|
36
|
+
| **Shortcuts** | Shortcuts for actions (Save, Delete) go through `core:CommandExecution` with the commands in `manifest.json` and buttons bound with `press="cmd:Save"`, so the button and the key do the same; always with a modifier key, never a bare letter. |
|
|
37
|
+
| **Changes the user cannot see** | A result that appears without a page change (saved, 3 results, an error) is also announced: `InvisibleMessage.getInstance().announce(text, InvisibleMessageMode.Polite)` (`Assertive` for errors), with the same text the page shows. |
|
|
38
|
+
| **Reading order** | The order in the view is the order a screen reader reads; do not reorder with CSS what should be read in another order. `ariaDescribedBy` points at elements that exist. |
|
|
39
|
+
| **Target size** | Small interactive texts (`Link`, `ObjectIdentifier`, `ObjectStatus` and similar) inside a list item or table cell get `reactiveAreaMode="Overlay"`, or spacing around them. |
|
|
40
|
+
|
|
41
|
+
All texts here come from i18n (with translator notes, `ui5-basics.md`).
|
|
42
|
+
|
|
43
|
+
## Checking it
|
|
44
|
+
|
|
45
|
+
- **The UI tests already check names:** a Playwright locator by role and name
|
|
46
|
+
(`getByRole('button', { name: 'Approve' })`) only finds a control whose accessible name
|
|
47
|
+
is that text. Locate by role and name, never by id or CSS (`testing.md`).
|
|
48
|
+
- **An axe scan per page** finds what names do not: missing landmarks, images without
|
|
49
|
+
`alt`, contrast. Where the spec has an accessibility requirement, add one to the UI
|
|
50
|
+
tests (`npm add -D @axe-core/playwright`; checked with 4.11 on the example, which had no
|
|
51
|
+
violations, and a planted image without `alt` was reported as critical):
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import AxeBuilder from '@axe-core/playwright'
|
|
55
|
+
|
|
56
|
+
test('the request page has no accessibility violations', async ({ page }) => {
|
|
57
|
+
// … open the page as in the other tests, then:
|
|
58
|
+
const { violations } = await new AxeBuilder({ page })
|
|
59
|
+
.withTags(['wcag2a', 'wcag2aa', 'wcag21aa', 'wcag22aa']).analyze()
|
|
60
|
+
expect(violations.map(v => v.id)).toEqual([])
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Neither replaces a review of custom views with the topics above, and a screen reader
|
|
65
|
+
(VoiceOver, NVDA) on the main flow finds what no tool does.
|
|
@@ -95,7 +95,7 @@ builder:
|
|
|
95
95
|
"sap.app": {
|
|
96
96
|
"id": "leaves.requests",
|
|
97
97
|
"type": "application",
|
|
98
|
-
"i18n": "i18n
|
|
98
|
+
"i18n": { "bundleName": "leaves.requests.i18n.i18n", "supportedLocales": [""], "fallbackLocale": "" },
|
|
99
99
|
"applicationVersion": { "version": "1.0.0" },
|
|
100
100
|
"title": "{{appTitle}}",
|
|
101
101
|
"dataSources": {
|
|
@@ -108,7 +108,7 @@ builder:
|
|
|
108
108
|
"dependencies": { "minUI5Version": "1.136.0", "libs": { "sap.m": {}, "sap.ui.core": {}, "sap.fe.templates": {} } },
|
|
109
109
|
"contentDensities": { "compact": true, "cozy": true },
|
|
110
110
|
"models": {
|
|
111
|
-
"i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "leaves.requests.i18n.i18n" } },
|
|
111
|
+
"i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "leaves.requests.i18n.i18n", "supportedLocales": [""], "fallbackLocale": "" } },
|
|
112
112
|
"": { "dataSource": "mainService", "preload": true, "settings": { "operationMode": "Server", "autoExpandSelect": true, "earlyRequests": true } }
|
|
113
113
|
},
|
|
114
114
|
"routing": {
|
|
@@ -124,7 +124,7 @@ builder:
|
|
|
124
124
|
},
|
|
125
125
|
"LeaveRequestsObjectPage": {
|
|
126
126
|
"type": "Component", "id": "LeaveRequestsObjectPage", "name": "sap.fe.templates.ObjectPage",
|
|
127
|
-
"options": { "settings": { "contextPath": "/LeaveRequests", "editableHeaderContent": false } }
|
|
127
|
+
"options": { "settings": { "contextPath": "/LeaveRequests", "editableHeaderContent": false, "enhanceI18n": "i18n/fe-texts.properties" } }
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
@@ -135,7 +135,14 @@ builder:
|
|
|
135
135
|
- `_version` 2.0.0 with `minUI5Version` 1.136.0 or later: the linter rejects older
|
|
136
136
|
manifests. Do not use the deprecated `synchronizationMode` model setting.
|
|
137
137
|
- `dataSources.mainService.uri` is the service's path (`/odata/v4/<service path>/`).
|
|
138
|
+
- Say which locales the app's `webapp/i18n` has: with only `i18n.properties`,
|
|
139
|
+
`"supportedLocales": [""], "fallbackLocale": ""` in `sap.app.i18n` and in the i18n model.
|
|
140
|
+
Without it the UI5 tooling warns on every start that the fallback locale `en` is missing
|
|
141
|
+
(checked with `cds serve` and the UI5 linter, which reports no findings either way). An app
|
|
142
|
+
with `i18n_de.properties` lists `["", "de"]`.
|
|
138
143
|
- `contextPath` names the entity set; the object page route's pattern uses its name.
|
|
144
|
+
- `enhanceI18n` names a file of replaced standard texts for that page (here the
|
|
145
|
+
confirmation text of Approve, `elements-cookbook.md`).
|
|
139
146
|
|
|
140
147
|
## Component.ts
|
|
141
148
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Fiori elements cookbook: what the spec asks for, and how
|
|
2
|
+
|
|
3
|
+
Distilled from the SAP Fiori elements feature showcase (`SAP-samples/fiori-elements-feature-showcase`,
|
|
4
|
+
Apache-2.0, commit `ecbb43c`, 2026-06-09) and the SAPUI5 documentation behind it, written for
|
|
5
|
+
CAP CDS and the leave requests of the examples. Entries marked **checked** were tried in a
|
|
6
|
+
browser with SAPUI5 1.145 and `@sap/cds` 10.1 on 2026-10-21; every CDS snippet here
|
|
7
|
+
compiles with `cds compile srv app --to edmx`. Rules restated; the showcase README (search
|
|
8
|
+
term per feature) and `search_docs` have the details.
|
|
9
|
+
|
|
10
|
+
Read `elements.md` first. Annotations before `manifest.json`, `manifest.json` before code.
|
|
11
|
+
Manifest settings go under the page's target in `sap.ui5.routing.targets.<target>.options.settings`;
|
|
12
|
+
the Application Modeler of SAP Fiori tools writes them too.
|
|
13
|
+
|
|
14
|
+
## List report: finding the right rows
|
|
15
|
+
|
|
16
|
+
| The spec says | Use |
|
|
17
|
+
|---|---|
|
|
18
|
+
| "by default the list shows open requests" | `status @Common.FilterDefaultValue : 'N'` on the element (**checked**: the filter starts with the token `N`, the code, not its text). It is ignored once the user picks another variant; for several values or a range use a `UI.SelectionPresentationVariant`. |
|
|
19
|
+
| "the user must choose a type before searching" | `Capabilities.FilterRestrictions : { RequiredProperties : [ type_code ] }` on the entity (**checked**: the field gets a `*`, and Go without it says "Type is a required field."). Nothing loads until it is filled, so use it only where the list is too big to show unfiltered. |
|
|
20
|
+
| "fewer filters to choose from" | `@UI.HiddenFilter` on elements nobody filters by; `UI.FilterFacets : [ { Target : '@UI.FieldGroup#Request', Label : … } ]` groups the rest in Adapt Filters. |
|
|
21
|
+
| "search regardless of upper or lower case" | `annotate LeaveService with @Capabilities.FilterFunctions : [ 'tolower' ];` (the whole service: filter bar, table filters, value helps). |
|
|
22
|
+
| "filter by period: this year, last month" | Semantic dates for a `Date` field: `Capabilities.FilterRestrictions : { FilterExpressionRestrictions : [ { Property : 'startDate', AllowedExpressions : 'SingleRange' } ] }`; a default range in the manifest, `controlConfiguration["@com.sap.vocabularies.UI.v1.SelectionFields"].filterFields.startDate.settings.defaultValues: [{ "operator": "LASTYEARS", "values": [1] }]` (operators in capitals). |
|
|
23
|
+
| "tabs: open, approved, all" | One `UI.SelectionVariant #open : { Text : '{i18n>Open}', SelectOptions : [ { PropertyName : status_code, Ranges : [ { Sign : #I, Option : #EQ, Low : 'N' } ] } ] }` per view. In the manifest, `views.paths: [{ "key": "open", "annotationPath": "com.sap.vocabularies.UI.v1.SelectionVariant#open" }, …]` gives tabs with a table each (they may show other entity sets or `SelectionPresentationVariant`s with other columns), or `controlConfiguration["@com.sap.vocabularies.UI.v1.LineItem"].tableSettings.quickVariantSelection.paths` gives a segmented button over one table. `showCounts: true` costs one `$count` request per view. |
|
|
24
|
+
| "sorted by start date" | `UI.PresentationVariant : { SortOrder : [ { Property : startDate, Descending : true } ], Visualizations : [ '@UI.LineItem' ] }` |
|
|
25
|
+
|
|
26
|
+
## List report: reading the rows
|
|
27
|
+
|
|
28
|
+
| The spec says | Use |
|
|
29
|
+
|---|---|
|
|
30
|
+
| "requests that need attention stand out" | `UI.LineItem.@UI.Criticality : status.criticality` on the entity colors the row's edge (**checked**: rows get the warning highlight for criticality 2), besides the colored status cell (`Criticality` in the `DataField`). |
|
|
31
|
+
| "amount with its currency", "quantity with its unit" | `amount @Measures.ISOCurrency : currency_code`, `quantity @Measures.Unit : unit_code`, `percent @Measures.Unit : '%'`: one column shows both, and personalization cannot separate them. The decimals shown follow the type's scale. |
|
|
32
|
+
| "number and name in one column" | `@Common.Text` with `@Common.TextArrangement` (`elements.md`); several values: a `UI.FieldGroup` referenced with `UI.DataFieldForAnnotation`. |
|
|
33
|
+
| "the request number in bold, with the draft state" | `@Common.SemanticKey : [ requestNo ]` and the field in `UI.LineItem` (`elements.md`). |
|
|
34
|
+
| "a link to the document" | `{ $Type : 'UI.DataFieldWithUrl', Value : documentName, Url : documentUrl }` in `UI.LineItem`. |
|
|
35
|
+
| "select several and act on all" | `tableSettings: { "selectionMode": "Multi" }` under the `LineItem` control configuration; a bound action in the toolbar then runs for every selected row. |
|
|
36
|
+
| "many actions, one button" | `controlConfiguration["@com.sap.vocabularies.UI.v1.LineItem"].actions.<id>: { "text": "{i18n>More}", "menu": ["DataFieldForAction::LeaveService.approve", …] }`; an unbound action is `DataFieldForAction::LeaveService.EntityContainer::<name>`. |
|
|
37
|
+
|
|
38
|
+
## Creating and editing
|
|
39
|
+
|
|
40
|
+
| The spec says | Use |
|
|
41
|
+
|---|---|
|
|
42
|
+
| "the start date is set when the request is created and cannot change" | `startDate @Core.Immutable` (**checked**: Create first opens a "New Object" dialog asking for every immutable field, Continue then opens the draft; the service ignores later changes, cap-developer `services.md`). Every immutable field is in that dialog, so keep them few. |
|
|
43
|
+
| "a hint in the empty field" | `comment @UI.Placeholder : '{i18n>CommentPlaceholder}'` (**checked**: the text field shows it while empty; a path to a property also works). |
|
|
44
|
+
| "only drafts can be edited, approved ones not" | Path-based restrictions on the entity: `UI.UpdateHidden : <Boolean path or expression>` hides Edit (`Capabilities.UpdateRestrictions` would make fields read-only but keep the button), `UI.CreateHidden`, `Capabilities.DeleteRestrictions : { Deletable : <Boolean path> }`. The service still enforces it (`@restrict`). |
|
|
45
|
+
| "start and end as one field" | `UI.ConnectedFields #period : { Label : '{i18n>Period}', Template : '{startDate} – {endDate}', Data : { startDate : { $Type : 'UI.DataField', Value : startDate }, endDate : { $Type : 'UI.DataField', Value : endDate } } }`, referenced from a `UI.FieldGroup` with `{ $Type : 'UI.DataFieldForAnnotation', Target : '@UI.ConnectedFields#period' }`. Forms only, not tables or headers; `$Type` in `Data` is required. |
|
|
46
|
+
| "regions of the chosen country only" | Dependent value help: in the `@Common.ValueList` of `region`, add `{ $Type : 'Common.ValueListParameterIn', LocalDataProperty : country_code, ValueListProperty : 'country_code' }` (a `…FilterOnly` parameter keeps that column out of the dialog's filters). A fixed filter is `{ $Type : 'Common.ValueListParameterConstant', ValueListProperty : 'country_code', Constant : 'DE' }`. |
|
|
47
|
+
| "a few choices shown at once" | Radio buttons instead of a dropdown: `type @(Common : { ValueListWithFixedValues.@Common.ValueListShowValuesImmediately })` with the fixed-values value list. Pages only, not action dialogs; the CDS compiler warns that this nested annotation is experimental, so use it only when the spec asks. |
|
|
48
|
+
| "add items in the table directly" | On the object page, for a composition's table: `controlConfiguration["items/@com.sap.vocabularies.UI.v1.LineItem"].tableSettings.creationMode: { "name": "Inline", "createAtEnd": true }`. |
|
|
49
|
+
| "download the table to Excel" | List reports offer Export by default; object page tables need `tableSettings: { "enableExport": true }`. |
|
|
50
|
+
| "the header fields are not editable" | `"editableHeaderContent": false` on the object page target (the example sets it). |
|
|
51
|
+
| "a section only in edit mode" | `@UI.Hidden : IsActiveEntity` on the facet (`UI.ReferenceFacet`); `UI.Hidden` takes a Boolean path or value, no expressions. |
|
|
52
|
+
|
|
53
|
+
## Actions
|
|
54
|
+
|
|
55
|
+
| The spec says | Use |
|
|
56
|
+
|---|---|
|
|
57
|
+
| "ask before approving", with its own text | `@Common.IsActionCritical` (`elements.md`), and the text in a file the target names: `"enhanceI18n": "i18n/fe-texts.properties"` in the object page target's settings, with `C_OPERATIONS_ACTION_CONFIRM_MESSAGE\|LeaveRequests\|approve=Approve this request? The employee is informed.` (**checked**: the dialog shows that text instead of "Perform this action?"). Other standard texts can be replaced the same way (keys in the SAPUI5 documentation, "Localization of UI Texts"). |
|
|
58
|
+
| "the user enters a value for the action, with a suggestion" | Annotations on the parameter in the service's action definition: `action extend(@(title : '{i18n>Days}', UI.ParameterDefaultValue : 1) days : Integer)`; a value help for a parameter is a `@Common.ValueList` on it, written the same way, with `LocalDataProperty : days`. |
|
|
59
|
+
| "the user is told it worked" | `req.notify` in the service: a toast (`elements.md`). |
|
|
60
|
+
| "go to the related app" | `UI.DataFieldForIntentBasedNavigation` with `SemanticObject` and `Action`, and the target app's `crossNavigation.inbounds`; it works inside SAP Build Work Zone, not in a standalone `index.html` (btp-architect). |
|
|
61
|
+
|
|
62
|
+
## Layout
|
|
63
|
+
|
|
64
|
+
- **List and object side by side** (Flexible Column Layout): set it in the Application
|
|
65
|
+
Modeler (Page Map, global page settings); it changes `routing` and the targets.
|
|
66
|
+
- **Header facets** (key figures in the object page header): `UI.HeaderFacets` with
|
|
67
|
+
`UI.ReferenceFacet`s to `UI.DataPoint`s (a value with criticality, a rating, a progress
|
|
68
|
+
bar) or a `UI.FieldGroup`. Keep it to what users decide with.
|
|
69
|
+
- Micro charts, contact quick views, custom sections and columns are in the showcase
|
|
70
|
+
(search terms in its README); prefer annotations, and building blocks before controller
|
|
71
|
+
code (`elements.md`, Extensions).
|
|
@@ -8,6 +8,9 @@ Distilled from the SAPUI5 and SAP Fiori tools documentation (`SAP-docs/sapui5`,
|
|
|
8
8
|
browser with `@sap/cds` 10.1 and SAPUI5 1.14x on 2026-10-18. Rules restated; check details
|
|
9
9
|
and current syntax with `search_docs`.
|
|
10
10
|
|
|
11
|
+
For a requirement in the spec's own words ("by default only open requests", "tabs per
|
|
12
|
+
status", "regions of the chosen country"), look it up in `elements-cookbook.md`.
|
|
13
|
+
|
|
11
14
|
## Where things go
|
|
12
15
|
|
|
13
16
|
- UI annotations in the app's `annotations.cds` (`app/<app>/annotations.cds`), pulled in by
|
|
@@ -54,6 +57,15 @@ and current syntax with `search_docs`.
|
|
|
54
57
|
- Read-only, mandatory and hidden: `@readonly` and `@mandatory` in CDS first; the
|
|
55
58
|
`Common.FieldControl` and `UI.Hidden` annotations for conditions
|
|
56
59
|
(`@Common.FieldControl: #Mandatory`, or path-based to a property).
|
|
60
|
+
- Editable when created, read-only afterwards (a number, a start that must not move):
|
|
61
|
+
`@Core.Immutable` on the element; the service also ignores later changes to it
|
|
62
|
+
(cap-developer `services.md`).
|
|
63
|
+
- Code lists get a value help from CAP by themselves, labeled with the entity's name and
|
|
64
|
+
showing only the code; annotate the field as in the example for a readable column and a
|
|
65
|
+
dropdown.
|
|
66
|
+
- Draft status in lists: with `@Common.SemanticKey: [<field>]` on the entity and that field
|
|
67
|
+
in `UI.LineItem`, Fiori shows "Draft", "Locked by …" and "Unsaved changes" in that column
|
|
68
|
+
(SAPUI5 documentation); without a semantic key the place depends on the table type.
|
|
57
69
|
|
|
58
70
|
## Actions
|
|
59
71
|
|
|
@@ -62,6 +74,25 @@ and current syntax with `search_docs`.
|
|
|
62
74
|
page header). The action's authorization is the service's `@restrict`.
|
|
63
75
|
- Do not use determining actions (`Determining: true`) for new designs; they are
|
|
64
76
|
deprecated.
|
|
77
|
+
- **Critical actions ask first:** `@Common.IsActionCritical` on the action makes Fiori ask
|
|
78
|
+
"Perform this action?" (OK, Cancel) before it runs. Use it for what is hard to undo
|
|
79
|
+
(approve, delete, send). It works only for actions without a parameter dialog; an action
|
|
80
|
+
with parameters already shows a dialog.
|
|
81
|
+
- **Parameters are a dialog:** an action with parameters opens a dialog with one field per
|
|
82
|
+
parameter, named by its `@title`, or by the raw parameter name without one. In the
|
|
83
|
+
`actions { … }` block the action's own annotations come first, then the parameters:
|
|
84
|
+
`decline @Core.OperationAvailable : … (reason @title : '{i18n>Reason}' @UI.MultiLineText);`.
|
|
85
|
+
`@mandatory` on the parameter (in the service) marks it required.
|
|
86
|
+
- **What the action says back:** the service's message decides how Fiori answers:
|
|
87
|
+
`req.notify` a toast, `req.info` and `req.warn` a dialog to close, `req.reject` an error
|
|
88
|
+
dialog with its message (cap-developer `handlers.md`). A confirmation of success is a toast.
|
|
89
|
+
- **Actions of a status flow** (`@flow.status`, cap-developer `services.md`) get their
|
|
90
|
+
buttons, enablement and refresh from CAP: in the object page header and, as well, in the
|
|
91
|
+
list's table toolbar (select a row, then act). Give each action a `@title`, or the
|
|
92
|
+
buttons show `{i18n>approve}`; to keep one out of the list, put it in `UI.LineItem`
|
|
93
|
+
yourself with `![@UI.Hidden]: true`. UI tests then find a second button of that name:
|
|
94
|
+
wait for the object page (its heading) before locating it.
|
|
95
|
+
- All checked in a browser with SAPUI5 1.145 on 2026-10-21 (the example below).
|
|
65
96
|
- Paths in annotations of a bound action start with its binding parameter (`in/…`): see
|
|
66
97
|
"Paths in action annotations" below.
|
|
67
98
|
|
|
@@ -75,6 +106,41 @@ and current syntax with `search_docs`.
|
|
|
75
106
|
|
|
76
107
|
## Extensions
|
|
77
108
|
|
|
109
|
+
When annotations and `manifest.json` settings cannot do what the spec asks, extend in this
|
|
110
|
+
order, each step keeping more of what Fiori elements provides (the SAP Fiori development
|
|
111
|
+
portal, `https://ui5.sap.com/test-resources/sap/fe/core/fpmExplorer/index.html`, shows
|
|
112
|
+
each with running samples):
|
|
113
|
+
|
|
114
|
+
1. **Building blocks** (`sap.fe.macros`): `macros:Table`, `macros:FilterBar`,
|
|
115
|
+
`macros:Field`, `macros:Chart` render from the annotations with the full behavior
|
|
116
|
+
(personalization, export, value helps, draft). A `FilterBar` and a `Table` work
|
|
117
|
+
together through the table's `filterBar="<FilterBar id>"`.
|
|
118
|
+
2. **A custom section** on the object page, or a custom column or action: a fragment
|
|
119
|
+
registered in the page target's settings, which can hold building blocks. Checked in a
|
|
120
|
+
browser with SAPUI5 1.145 (the section appeared after "Decision", as a region named by
|
|
121
|
+
its title, with the field's value formatted like the page's):
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
"content": { "body": { "sections": { "notes": {
|
|
125
|
+
"template": "leaves.requests.ext.fragment.Notes",
|
|
126
|
+
"position": { "placement": "After", "anchor": "decision" },
|
|
127
|
+
"title": "{i18n>Notes}" } } } }
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```xml
|
|
131
|
+
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns:macros="sap.fe.macros">
|
|
132
|
+
<macros:Field id="startDateField" metaPath="startDate" readOnly="true"/>
|
|
133
|
+
</core:FragmentDefinition>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The `anchor` is the `ID` of a facet in the annotations (`UI.ReferenceFacet` with `ID`).
|
|
137
|
+
3. **A custom page** (the "Custom Page" template of the Fiori tools generator) built from
|
|
138
|
+
building blocks, inside the same app and routing.
|
|
139
|
+
4. **A controller extension** for behavior (edit flow, routing, navigation), registered in
|
|
140
|
+
`manifest.json` and working through the page's `ExtensionAPI`.
|
|
141
|
+
|
|
142
|
+
Freestyle content in sections and pages follows `ui5-basics.md` and `accessibility.md`.
|
|
143
|
+
|
|
78
144
|
- In controller extensions and custom code, use only the documented `extensionAPI` and
|
|
79
145
|
building block APIs. Never access or change controls, models or other objects the
|
|
80
146
|
framework creates internally: they change between versions.
|
|
@@ -88,10 +154,12 @@ Annotations of a bound action address the entity through its **binding parameter
|
|
|
88
154
|
CAP names `in` (`@cds.odata.bindingparameter.name: '_it'` renames it). Paths without the
|
|
89
155
|
prefix are wrong here.
|
|
90
156
|
|
|
91
|
-
- `@Core.OperationAvailable
|
|
92
|
-
|
|
157
|
+
- `@Core.OperationAvailable : ($self.canDecide)` enables the button per row (a Boolean
|
|
158
|
+
element, for example a virtual one set in an after-READ handler); CAP writes the path
|
|
159
|
+
as `in/canDecide`. Prefer this expression form to `{ $edmJson: { $Path: 'in/canDecide' } }`,
|
|
160
|
+
which a status flow replaces with its own condition (checked with `@sap/cds` 10.1).
|
|
93
161
|
- `@Common.SideEffects: { TargetProperties: ['in/status_code', 'in/canDecide'] }` refreshes
|
|
94
|
-
those fields after the action (no draft needed).
|
|
162
|
+
those fields after the action (no draft needed); a status flow adds its status itself.
|
|
95
163
|
- **Checked in a browser:** with the side effect, the status shows the new value right
|
|
96
164
|
after the click and the button disables itself; **without it, the page keeps the old
|
|
97
165
|
status and the enabled button** until a reload. An action that changes data shown on the
|
|
@@ -108,7 +176,8 @@ app may delete or create (Fiori shows Delete otherwise), path-based
|
|
|
108
176
|
|
|
109
177
|
`app/requests/annotations.cds` for the leave requests of `cap-developer`'s examples: list
|
|
110
178
|
report with filters and a colored status, object page with two sections, value helps as
|
|
111
|
-
dropdowns, Approve and Reject buttons enabled per row and refreshing the page
|
|
179
|
+
dropdowns, Approve and Reject buttons enabled per row and refreshing the page, Approve
|
|
180
|
+
confirmed by the user, Reject asking for a labeled reason.
|
|
112
181
|
|
|
113
182
|
<!-- checked: app/requests/annotations.cds -->
|
|
114
183
|
```cds
|
|
@@ -132,7 +201,7 @@ annotate service.LeaveRequests with @(
|
|
|
132
201
|
],
|
|
133
202
|
UI.Identification : [
|
|
134
203
|
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.approve', Label : '{i18n>Approve}' },
|
|
135
|
-
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.
|
|
204
|
+
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.decline', Label : '{i18n>Reject}' },
|
|
136
205
|
],
|
|
137
206
|
UI.Facets : [
|
|
138
207
|
{ $Type : 'UI.ReferenceFacet', ID : 'request', Label : '{i18n>Request}', Target : '@UI.FieldGroup#Request' },
|
|
@@ -165,10 +234,14 @@ annotate service.LeaveRequests with {
|
|
|
165
234
|
};
|
|
166
235
|
|
|
167
236
|
annotate service.LeaveRequests actions {
|
|
168
|
-
approve @
|
|
169
|
-
@
|
|
170
|
-
|
|
171
|
-
@Common.SideEffects : { TargetProperties : [ 'in/
|
|
237
|
+
approve @title : '{i18n>Approve}'
|
|
238
|
+
@Core.OperationAvailable : ($self.canDecide) // the flow would only check the status
|
|
239
|
+
@Common.IsActionCritical
|
|
240
|
+
@Common.SideEffects : { TargetProperties : [ 'in/canDecide' ] }; // the flow adds the status
|
|
241
|
+
decline @title : '{i18n>Reject}' // the spec's word
|
|
242
|
+
@Core.OperationAvailable : ($self.canDecide)
|
|
243
|
+
@Common.SideEffects : { TargetProperties : [ 'in/reason', 'in/canDecide' ] }
|
|
244
|
+
(reason @title : '{i18n>Reason}' @UI.MultiLineText);
|
|
172
245
|
};
|
|
173
246
|
```
|
|
174
247
|
|