Skip to content

[Version: 3.13.1] No UI enhancement for inline attachments without attachment compositions #470

Description

@TiborAdk

Describe the bug

When using an inline attachment (Attachment) with an entity, and no Attachments composiotion is used elsewhere in the application, the object page of the entity is not enhanced with the facet for an inline attachemt.

(lcoal development using cds watch, likely not limited to local development)

To Reproduce
Steps to reproduce the behavior:

  1. Create an entity with an inline attachment.
using {cuid} from '@sap/cds/common';
using {Attachment, Attachments} from '@cap-js/attachments';

namespace sample

entity Invoices : cuid {
  documentNumber : String;
  // annotation causes file upload to fail
  attachment     : Attachment;
  // Uncomment to trigger UI enhancement for attachments
  // attachments    : Composition of many Attachments;
}

annotate Invoices with @(
  UI.LineItem: [
    {Value: attachment_filename},
    {Value: attachment_mimeType}
  ],
  UI.Facets  : [] // Required for plugin to add facets
)
  1. Expose the entity through a service definition
service AccountinService {
  @odata.draft.enabled
  entity Invoices as projection on my.Invoices;
}
  1. Start development preview (cds watch)
  2. Open Fiori preview for AccountingService.Invoices
  3. Create a new entity to open the object page
  4. UI Facet for inline attachment is not added to the object page

Uncommenting the attachments field leads to both facets for inline and compostion being added.

This is likey caused by the following line in unfoldModel (lib/plugin.js) only checking for sap.attachments.Attachments and not sap.attachments.Attachment as well:

if (!("sap.attachments.Attachments" in csn.definitions)) return

Expected behavior

When using a single inline attachment without another attachments composition in the application, the UI facet for the inline attachments should be added.

Screenshots

Missing facet:
Image

Expected state:
Image

Customer Info
Company: TUM project with SAP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions