Skip to content

fix(edit-content): show content type icon in relationship field table#35285

Merged
oidacra merged 5 commits intomainfrom
issue-35258-missing-content-type-icon-in-relationships-field-t
Apr 10, 2026
Merged

fix(edit-content): show content type icon in relationship field table#35285
oidacra merged 5 commits intomainfrom
issue-35258-missing-content-type-icon-in-relationships-field-t

Conversation

@oidacra
Copy link
Copy Markdown
Member

@oidacra oidacra commented Apr 10, 2026

Summary

  • Show thumbnail/icon for all relationship items when at least one item has a title image, matching the existing content picker dialog behavior
  • Items without images display the content type icon as a placeholder instead of an empty space
  • Added showThumbnail computed signal to the store with unit tests

Closes #35258

Changes

File Change
dot-relationship-field.component.html Replace per-item hasTitleImage check with store-level showThumbnail signal; increase gap between thumbnail and title
relationship-field.store.ts Add showThumbnail computed: data.some(item => item.hasTitleImage)
relationship-field.store.spec.ts Add 3 tests for showThumbnail (no images, mixed images, empty data)

Acceptance Criteria

  • When at least one relationship item has a title image, all rows show the thumbnail area (real image or content type icon placeholder)
  • When no relationship items have title images, only text is shown (no thumbnail area)
  • Fallback to content type icon when hasTitleImage is false (handled by dot-contentlet-thumbnail web component)
  • When a new relationship is added, the thumbnail renders immediately
  • When rows are reordered via drag-and-drop, icons stay with their respective rows
  • Unit tests cover the showThumbnail computed signal

Test Plan

  • Open a content item with a Relationships field pointing to a content type with image fields (e.g., Pages). Verify: items with images show the thumbnail, items without show the content type icon placeholder
  • Open a content item with a Relationships field pointing to a content type without image fields (e.g., Authors). Verify: only text titles are shown, no thumbnail area
  • Add a new relationship via the content picker. Verify the icon/image appears immediately
  • Reorder rows via drag-and-drop. Verify icons stay with their rows

Visual Changes

CleanShot 2026-04-10 at 11 47 48@2x

Note

Low Risk
Low risk UI/state change limited to relationship field rendering; main risk is minor visual/layout regressions due to new computed showThumbnail condition.

Overview
Updates the relationship field table so the title column renders the thumbnail/icon area for all rows whenever any item in the relationship has a title image, rather than deciding per-row, matching picker behavior.

Adds a store-level computed signal showThumbnail (treating hasTitleImage as boolean or string) with new unit tests to cover mixed/empty data scenarios, and slightly increases spacing between thumbnail and title.

Reviewed by Cursor Bugbot for commit 420ef09. Bugbot is set up for automated code reviews on this repo. Configure here.

This PR fixes: #35258

…items have images

Show thumbnail/icon for all relationship items when at least one item
has a title image, matching the existing content picker dialog behavior.
Items without images show the content type icon as placeholder.

Closes #35258
@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 10, 2026

Claude finished @oidacra's task in 1m 16s —— View job


Review

  • Read changed files
  • Analyze and post findings

Three things worth a second look:

1. The as unknown cast is a symptom, not a fix

relationship-field.store.ts:107

(item.hasTitleImage as unknown) === 'true'

This cast is needed because DotCMSContentlet.hasTitleImage is typed as boolean, but the API returns a string. Fixing the cast at the call site means every future comparison against 'true'/'false' will need the same workaround. The right fix is to update the model type to boolean | string. As written, this silently works but will silently break if another caller forgets the cast. Fix this →

2. showThumbnail is scoped to all data, not the current page

The computed runs over state.data() (all items), not paginatedData(). This means: if 12 items span 2 pages and only page-2 items have images, page-1 rows will still show the thumbnail column. That's almost certainly the right call (consistent layout across pages — avoids column jumping during pagination), but it's a non-obvious consequence that's not mentioned in comments or tested explicitly. A comment in the computed would clarify intent.

3. Tests use as unknown as boolean to simulate API strings

relationship-field.store.spec.ts:422,432

hasTitleImage: 'true' as unknown as boolean

This works, but it's a test-only workaround for the same model type issue in point 1. If the model type is fixed, these casts go away naturally and the tests become cleaner.


Otherwise the change is clean. The copilot-flagged string coercion bug was correctly handled with explicit === true || === 'true' guards, the template migration from per-row to store-level is correct, and the three new test cases cover the meaningful branches.

@claude
Copy link
Copy Markdown
Contributor

claude bot commented Apr 10, 2026

Rollback Safety Analysis complete. Label added: AI: Safe To Rollback. All changes are pure frontend Angular (HTML template, signal store, unit tests) with no database, ES mapping, API contract, or OSGi changes. Safe to rollback.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Edit Content Relationships field table to render a consistent thumbnail/icon area across rows when at least one related item has a title image, using a store-level computed signal to drive the UI.

Changes:

  • Added a showThumbnail computed signal in the relationship field store to decide when to render the thumbnail/icon area.
  • Updated the relationship table template to use showThumbnail instead of a per-row hasTitleImage check (and adjusted spacing).
  • Added unit tests validating showThumbnail behavior for empty data, no images, and mixed images.

Reviewed changes

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

File Description
core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.ts Adds showThumbnail computed signal based on whether any item has a title image.
core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/store/relationship-field.store.spec.ts Adds unit tests for showThumbnail.
core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/components/dot-relationship-field/dot-relationship-field.component.html Uses store-level showThumbnail to render thumbnails/icons for all rows when enabled.
Comments suppressed due to low confidence (1)

core-web/libs/edit-content/src/lib/fields/dot-edit-content-relationship-field/components/dot-relationship-field/dot-relationship-field.component.html:126

  • This change gates rendering of the thumbnail/icon area on store.showThumbnail(). That means for relationships where no items have a title image, the table will show no icon column at all (text only). The linked issue’s acceptance criteria calls for an icon column on every row with a generic fallback when the icon is unavailable; if that’s still the requirement, this conditional rendering won’t satisfy it.
                            <div class="flex items-center gap-3">
                                @if (showThumbnail) {
                                    <div
                                        class="w-20 h-14 flex-shrink-0 rounded-md overflow-hidden bg-gray-100">
                                        <dot-contentlet-thumbnail
                                            [iconSize]="'24px'"
                                            [contentlet]="item"
                                            [playableVideo]="false"
                                            data-testId="contentlet-thumbnail" />
                                    </div>
                                }
                                <p class="truncate">{{ item.title }}</p>

@oidacra oidacra enabled auto-merge April 10, 2026 16:00
oidacra added 4 commits April 10, 2026 12:00
Some API endpoints return hasTitleImage as a string ('true'/'false')
instead of a boolean. Use explicit equality checks to avoid treating
the string 'false' as truthy, matching dot-contentlet-thumbnail logic.
…ationship field store

The production build fails with TS2367 because hasTitleImage is typed as
boolean but was also compared against the string 'true'.
@oidacra oidacra added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 1007280 Apr 10, 2026
28 checks passed
@oidacra oidacra deleted the issue-35258-missing-content-type-icon-in-relationships-field-t branch April 10, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Missing content type icon in Relationships field table (new Edit Content view)

3 participants