Skip to content

Feature: Data mapping extension + aligning reference lists#18318

Merged
nielslyngsoe merged 112 commits intov15/devfrom
v15/feature/$type-data-mapper-extension
Feb 20, 2025
Merged

Feature: Data mapping extension + aligning reference lists#18318
nielslyngsoe merged 112 commits intov15/devfrom
v15/feature/$type-data-mapper-extension

Conversation

@madsrasmussen
Copy link
Copy Markdown
Member

@madsrasmussen madsrasmussen commented Feb 13, 2025

Build on top of #18311 - Review this first

This PR implements a fully dynamic approach to listing references in a document/media workspace supporting the polymorphic response from the server.

Until now, the reference lists have had a hardcoded solution with support for document, media, and member entities. With this PR, we use the entityRefItem extension to render a reference based on the entity type in the data.

The reference endpoint returns a "mixed" response, which can consist of multiple entity types. The endpoint doesn't specify the entity type of an entry but only the type of the response model. To prevent a hardcoded solution, the PR introduces a dataMapping extension that can map any data based on an identifier in the data.

Manifest:

 {
  type: 'dataMapping',
  alias: 'Umb.DataMapping.ManagementApi.DocumentReferenceResponse',
  name: 'Document Reference Response Management Api Data Mapping',
  api: () => import('./document-reference-response-model.mapper.js'),
  dataSourceIdentifier: 'Umb.ManagementApi',
  dataModelIdentifier: 'DocumentReferenceResponseModel',
 },

Example:

export class UmbDocumentReferenceResponseManagementApiDataMapping
  extends UmbControllerBase
  implements UmbDataMapping<DocumentReferenceResponseModel, UmbDocumentReferenceModel> {

  async map(data: DocumentReferenceResponseModel): Promise<UmbDocumentReferenceModel> {
    return {
      // map data here
    };
  }
}

export { UmbDocumentReferenceResponseManagementApiDataMapping as api };

@madsrasmussen madsrasmussen marked this pull request as ready for review February 17, 2025 14:10
@madsrasmussen madsrasmussen added release/15.3.0 category/ux User experience category/dx Developer experience labels Feb 17, 2025
@madsrasmussen madsrasmussen changed the title Feature: Data mapper extension + aligning reference lists Feature: Data mapping extension + aligning reference lists Feb 17, 2025
Base automatically changed from v15/feature/display-current-variant-item-name to v15/dev February 18, 2025 18:52
# Conflicts:
#	src/Umbraco.Web.UI.Client/src/packages/documents/documents/item/document-item-ref.element.ts
Comment thread src/Umbraco.Web.UI.Client/src/packages/media/media/item/media-item-ref.element.ts Outdated
Copy link
Copy Markdown
Member

@nielslyngsoe nielslyngsoe left a comment

Choose a reason for hiding this comment

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

@madsrasmussen I just have one thing that I like you to consider and then I'm happy, I have read all the code and tested the various cases.

@nielslyngsoe nielslyngsoe enabled auto-merge (squash) February 18, 2025 20:16
@nielslyngsoe nielslyngsoe merged commit 78554f8 into v15/dev Feb 20, 2025
@nielslyngsoe nielslyngsoe deleted the v15/feature/$type-data-mapper-extension branch February 20, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants