Skip to content

[COMMS-876] Single-line/multi-line layout argument for attribute value macros - #24257

Merged
akabiru merged 14 commits into
devfrom
feature/comms-876-adjust-ckeditor-version-macros-single-line-multi-line-layout-argument-for-attribute-value-macros
Jul 17, 2026
Merged

[COMMS-876] Single-line/multi-line layout argument for attribute value macros#24257
akabiru merged 14 commits into
devfrom
feature/comms-876-adjust-ckeditor-version-macros-single-line-multi-line-layout-argument-for-attribute-value-macros

Conversation

@akabiru

@akabiru akabiru commented Jul 14, 2026

Copy link
Copy Markdown
Member

Ticket: https://community.openproject.org/wp/COMMS-876

Multi-value attributes such as target versions render one value per line, which does not always fit the text around a macro. Attribute value macros now accept an optional trailing layout argument (workPackageValue:X:targetVersions:singleline or :multiline, multi-line being the default) so authors can choose.

  • Web macro parsing: the text-formatting matcher parses the argument, including the id-less relative form, and hands it to the macro element as data-layout
  • Frontend rendering of the single-line variant
  • Layout argument on the PDF/export macro path
  • Legacy version attribute mapped to the single-line behaviour

CkEditor render

macro-layout-verification

PDF Export

Screenshot 2026-07-15 at 8 20 53 PM

@akabiru akabiru changed the title Feature/COMMS-876: Single-line/multi-line layout argument for attribute value macros [COMMS-876] Single-line/multi-line layout argument for attribute value macros Jul 14, 2026
@akabiru akabiru self-assigned this Jul 14, 2026
@akabiru akabiru added this to the 17.8.x milestone Jul 14, 2026
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/projects/lists/filters_spec.rb[1:6:1]
  • rspec ./spec/features/workflows/edit_spec.rb[1:5:6]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24257, linked for reference only):

- `rspec ./spec/features/projects/lists/filters_spec.rb[1:6:1]`
- `rspec ./spec/features/workflows/edit_spec.rb[1:5:6]`

Treat this as a standalone task, unrelated to PR #24257. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24257 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @akabiru to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @akabiru, and request a review from @akabiru.
On every commit, set @akabiru as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@akabiru
akabiru force-pushed the feature/comms-876-adjust-ckeditor-version-macros-single-line-multi-line-layout-argument-for-attribute-value-macros branch from 704c960 to b29661a Compare July 14, 2026 16:28
akabiru added 4 commits July 14, 2026 19:35
Multi-value attributes such as target versions need both block and
inline renderings depending on the surrounding text; an optional
singleline/multiline macro argument lets authors choose.
The macro element's layout argument flows through displayFieldOptions;
a singleline option selects a comma-joined display field instead of
the one-per-line variants used in the single view context.
Mirrors the web matcher grammar and threads the layout to the export
formatter's array separator. Multi-value macros now default to one
value per line (markdown hard break) instead of a comma-joined list,
matching the web rendering.
workPackageValue:X:version now renders all target versions of the work
package, single-line by default so legacy macros keep their inline
shape within existing content. Applies to both the web and export
render paths.
@akabiru
akabiru force-pushed the feature/comms-876-adjust-ckeditor-version-macros-single-line-multi-line-layout-argument-for-attribute-value-macros branch from b29661a to efe27bf Compare July 14, 2026 16:36
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/storages/spec/features/hide_attachments_spec.rb[1:2:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24257, linked for reference only):

- `rspec ./modules/storages/spec/features/hide_attachments_spec.rb[1:2:1]`

Treat this as a standalone task, unrelated to PR #24257. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24257 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @akabiru to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @akabiru, and request a review from @akabiru.
On every commit, set @akabiru as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

akabiru added 8 commits July 15, 2026 19:52
The layout argument is the feature; defaults stay what each surface
always rendered. Only an explicit multiline layout switches exports to
one value per line, which also makes the legacy version layout pin
redundant on this path.
A bare layout keyword directly after an id collapses to the relative
reference form; quoting the keyword keeps it as an attribute name. Both
sides of that contract are now guarded against regex changes.
The display field service spec locks the multi-value type list to the
per-type multiline branches it mirrors, so adding a type to one side
without the other fails a test. The macro component spec pins the
deprecated version attribute mapping, including the explicit multiline
override and the work-package-only gate.
reinterpret_as_relative_embed sits next to relative_embed?, which its
result feeds, and returns the corrected hash instead of mutating its
argument in place. Also threads layout as a keyword through
format_attribute_value like the rest of the call chain.
valueString joins like the sibling multi-line fields so the title
getter returns a string, and the singleline routing branch carries the
same single-view container gate as the branches it sits beside. Spec
now also covers the empty value list.
The undefined state stays meaningful (no author choice), the type now
says so and rules out arbitrary strings.
The export resolver takes semantic references via find_by_display_id;
these cases pin that the layout argument and the legacy version mapping
hold when the work package is referenced by semantic identifier.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional trailing layout argument (singleline / multiline) to attribute value macros so authors can control whether multi-value attributes render inline (comma-separated) or stacked (one per line). This is applied consistently across the markdown/web macro parsing, frontend rendering, and PDF/export macro path, including mapping legacy version to targetVersions with single-line default.

Changes:

  • Extend attribute macro parsing to recognize a reserved :singleline / :multiline layout segment (including relative/id-less forms) and expose it via data-layout.
  • Add frontend rendering support for the singleline layout by routing relevant multi-value field types to a new SingleLineResourcesDisplayField.
  • Apply the same layout option to the PDF/export macro formatter and map legacy version to target_versions / targetVersions behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spec/models/exports/pdf/common/macro_spec.rb Adds PDF/export specs covering layout behavior for multi-value custom fields and target versions (incl. legacy version).
spec/lib/open_project/text_formatting/markdown/attribute_macros_spec.rb Verifies markdown parsing emits data-layout correctly and handles relative/id-less forms.
lib/open_project/text_formatting/matchers/attribute_macros.rb Extends the core attribute macro regex + extraction to parse and propagate the layout argument.
frontend/src/app/shared/components/fields/macros/attribute-value-macro.html Passes the parsed layout into display field rendering options.
frontend/src/app/shared/components/fields/macros/attribute-value-macro.component.ts Reads data-layout, maps legacy versiontargetVersions, and defaults legacy layout to single-line.
frontend/src/app/shared/components/fields/macros/attribute-value-macro.component.spec.ts Unit tests for legacy version mapping and layout defaulting behavior.
frontend/src/app/shared/components/fields/display/field-types/single-line-resources-display-field.module.ts New display field rendering multi-value resources as a full comma-separated single line.
frontend/src/app/shared/components/fields/display/field-types/single-line-resources-display-field.module.spec.ts Unit tests for single-line rendering, title, and empty placeholder behavior.
frontend/src/app/shared/components/fields/display/display-field.service.ts Routes singleline layout + supported multi-value schema types to the new single-line display field.
frontend/src/app/shared/components/fields/display/display-field.service.spec.ts Tests routing logic for singleline/multiline/default layout across supported multi-value schema types.
app/models/work_package/exports/macros/attributes.rb Extends export macro parsing with layout + uses layout to select array separator; maps legacy version.

Comment thread lib/open_project/text_formatting/matchers/attribute_macros.rb Outdated
Comment thread app/models/work_package/exports/macros/attributes.rb Outdated
Without a boundary the layout alternation matched keyword prefixes, so
:multilinefoo applied the multiline layout and left foo as stray text.
A word boundary rejects such tokens while trailing punctuation after a
valid keyword still parses.
@akabiru
akabiru marked this pull request as ready for review July 15, 2026 17:48
@akabiru
akabiru requested review from a team and HDinger July 15, 2026 17:48

@HDinger HDinger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm 👍
I have some general comments:

  • I am missing somewhere the information, that the layout argument will not affect all fields.. I can now write something like this workPackageValue:description:singleline but it basically has no effect. Same wih multiline, it only applies to ceratin field types. I admit that I don't know where the best place for this would be. Maybe in the comments explaining the syntax 🤷
  • When using singleline on a user custom field, the avatars where not shown. Don't know whether this is intendend (or even existing behaviour from the table though)

@akabiru

akabiru commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review @HDinger - there's a followup PR updating the docs that will be reviewed with the docs team https://github.com/opf/openproject/pull/24264/changes

I can now write something like this workPackageValue:description:singleline but it basically has no effect.

I suppose this is ok, no? We can add documentation that user defined layout will take effect only on supported fields.

When using singleline on a user custom field, the avatars where not shown. Don't know whether this is intendend (or even existing behaviour from the table though)

AFAICT- and testing on QA Edge; avatars were never shown from custom fields- in fact it looks broken, at least testing on Edge. In any case I'm happy to look deeper into it.

(Screenshots from current QA Edge)
Screenshot 2026-07-16 at 12 49 29 PM
Screenshot 2026-07-16 at 12 49 21 PM

@HDinger

HDinger commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

When using singleline on a user custom field, the avatars where not shown. Don't know whether this is intendend (or even existing behaviour from the table though)

AFAICT- and testing on QA Edge; avatars were never shown from custom fields- in fact it looks broken, at least testing on Edge. In any case I'm happy to look deeper into it.

(Screenshots from current QA Edge) Screenshot 2026-07-16 at 12 49 29 PM Screenshot 2026-07-16 at 12 49 21 PM

They are working correctly. The example you showed simply had no value set in the field.

Bildschirmfoto 2026-07-16 um 12 57 23 Bildschirmfoto 2026-07-16 um 12 57 28

@brunopagno brunopagno left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me as well. Nice job 👏

@akabiru

akabiru commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

When using singleline on a user custom field, the avatars where not shown. Don't know whether this is intendend (or even existing behaviour from the table though)

AFAICT- and testing on QA Edge; avatars were never shown from custom fields- in fact it looks broken, at least testing on Edge. In any case I'm happy to look deeper into it.
(Screenshots from current QA Edge) Screenshot 2026-07-16 at 12 49 29 PM Screenshot 2026-07-16 at 12 49 21 PM

They are working correctly. The example you showed simply had no value set in the field.
Bildschirmfoto 2026-07-16 um 12 57 23 Bildschirmfoto 2026-07-16 um 12 57 28

Thanks for checking- it worked on my end after a refresh. The values do not update real-time.

The generic single-line field renders plain text, which dropped the
avatars user attributes get in every other view. Route []User to a
dedicated field that uses the principal renderer's inline mode.
@akabiru

akabiru commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

Addressed single line avatar rendering in 929cd31

singleline-user-avatars

@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24257, linked for reference only):

- `rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]`

Treat this as a standalone task, unrelated to PR #24257. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24257 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @akabiru to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @akabiru, and request a review from @akabiru.
On every commit, set @akabiru as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

@akabiru

akabiru commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

@copilot The following spec(s) are flaky in CI (first seen on PR #24257, linked for reference only):

  • rspec ./modules/backlogs/spec/features/inbox_column_spec.rb[1:7:1]

Treat this as a standalone task, unrelated to PR #24257. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24257 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. script/bulk_run_rspec --run-count 10).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @akabiru to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR flaky-spec, assign @akabiru, and request a review from @akabiru.
On every commit, set @akabiru as the sole co-author with a Co-authored-by: trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@akabiru I've opened a new pull request, #24308, to work on those changes. Once the pull request is ready, I'll request review from you.

@akabiru
akabiru merged commit 7ea559d into dev Jul 17, 2026
18 checks passed
@akabiru
akabiru deleted the feature/comms-876-adjust-ckeditor-version-macros-single-line-multi-line-layout-argument-for-attribute-value-macros branch July 17, 2026 05:51
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

5 participants