4ce6119be7
https://github.com/user-attachments/assets/3a444937-0290-4505-85e1-64b7b713bc3b - [x] Analyze the existing `FieldWidgetRelationCard` and `FieldWidgetMorphRelationCard` components - [x] Review existing patterns for "More" buttons (found `IconChevronDown` pattern) - [x] Create a reusable `FieldWidgetShowMoreButton` component for the "More (X)" button - [x] Update `FieldWidgetRelationCard` to show max 5 items initially with progressive loading - [x] Update `FieldWidgetMorphRelationCard` to show max 5 items initially with progressive loading - [x] Add Storybook story with play function to test progressive loading for regular relations - [x] Verify changes visually in Storybook (all tests pass) - [x] Run code review (no issues found) - [x] Run CodeQL security check (no code changes for CodeQL to analyze) - [x] Address PR review feedback: - [x] Move constants to separate files (`FieldWidgetRelationCardInitialVisibleItems.ts` and `FieldWidgetRelationCardLoadMoreIncrement.ts`) - [x] Add translation for "More (X)" string using `t` macro from `@lingui/core/macro` ## Summary This PR adds progressive loading functionality to the FIELD widget with CARD display mode: 1. **New Component**: Created `FieldWidgetShowMoreButton` - A styled button component that displays "More (X)" with a chevron icon, showing the remaining count of hidden items. 2. **Updated Components**: - `FieldWidgetRelationCard`: Now displays max 5 relation cards initially, with a "More (X)" button that loads 5 more items on each click - `FieldWidgetMorphRelationCard`: Same progressive loading behavior for morph relations 3. **Constants**: Moved to separate files following codebase conventions: - `FIELD_WIDGET_RELATION_CARD_INITIAL_VISIBLE_ITEMS` (5) - `FIELD_WIDGET_RELATION_CARD_LOAD_MORE_INCREMENT` (5) 4. **Storybook Story**: Added `OneToManyRelationCardWidgetWithProgressiveLoading` story with play function that tests: - Initial display of 5 items - "More (7)" button visibility - Loading additional items on click - Button disappearing when all items are shown <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[RPL] Allow users to progressively load relations in FIELD widget with CARD display mode</issue_title> > <issue_description>## Current state > > The FIELD widget should display max 5 relations in CARD display mode. > > ## Goal > > Display a "More (12)" button. Clicking on this button loads 5 more items. After a click, "More (12)" becomes "More (7)". > > <img width="1334" height="712" alt="Image" src="https://github.com/user-attachments/assets/e801cca2-af99-4d87-8ce2-0c639775b0b1" /> > > ## Technical input > > `FieldWidgetRelationCard` already loads all the relations and maps over each one of them. Create a state that's updated when clicking on the More button, slicing the relations to display. > > ## Acceptance criteria > > - Must work for relations and morph relations in _card_ display mode > - Create stories to assert it works properly (with play function to actually test the components)</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes twentyhq/core-team-issues#2063 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Devessier <29370468+Devessier@users.noreply.github.com> Co-authored-by: Baptiste Devessier <baptiste@devessier.fr>