[COMMS-876] Single-line/multi-line layout argument for attribute value macros#24257
Conversation
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy 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. |
704c960 to
b29661a
Compare
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.
b29661a to
efe27bf
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy 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. |
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.
There was a problem hiding this comment.
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/:multilinelayout segment (including relative/id-less forms) and expose it viadata-layout. - Add frontend rendering support for the
singlelinelayout by routing relevant multi-value field types to a newSingleLineResourcesDisplayField. - Apply the same layout option to the PDF/export macro formatter and map legacy
versiontotarget_versions/targetVersionsbehavior.
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 version → targetVersions, 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. |
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.
|
Caution The provided work package version does not match the core version Details:
Please make sure that:
|
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:singlelineor:multiline, multi-line being the default) so authors can choose.data-layoutversionattribute mapped to the single-line behaviourCkEditor render
PDF Export