Skip to content

[Version: 3.13.1] Empty facet displayed for inline attachment annotated with @UI.Hidden #473

Description

@TiborAdk

Describe the bug
Annotating an inline attachment with @UI.Hidden reuslts in an empty facet beeing displayed on the object page instead of the facet beeing hidden as well.

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 empty facet
  attachment     : Attachment @UI.Hidden;
  // Required to trigger UI enhancement for attachments due to a different bug.
  attachments    : Composition of many Attachments @UI.Hidden;
}

annotate Invoices with @(
  UI.LineItem: [ {Value: attachment_filename}],
  UI.Facets  : [] // Required for plugin to add facets
)

(Note: the attachments composition is only required to add the facet for the inline attachment. see: #470 )

  1. Expose the entity through a service definition
service AccountinService {
  @odata.draft.enabled
  entity Invoices as projection on my.Invoices;
}
  1. Start development preview with cds watch
  2. Open Fiori preview for AccountingService.Invoices
  3. Create a new entity to open the object page
  4. The objec page shows an empty facet with title "Attachment"

Likey caused by:

// lib/plugin.js

336  facets.push({
337    $Type: "UI.ReferenceFacet",
338      ID: `${prefix}_attachment`,
339      Target: fieldGroupKey,
340      Label: label,
341  })

Possible solution:

  • Copy @UI.Hidden from content element to fact.
// lib/plugin.js

336  facets.push({
337    $Type: "UI.ReferenceFacet",
338      ID: `${prefix}_attachment`,
339      Target: fieldGroupKey,
340      Label: label,
341      "@UI.Hidden": contentElement["@UI.Hidden"],
342  })

Expected behavior

When using @UI.Hidden with an inline attachment, the facet should inherit the content of the annotation, and should be hidden as well.

The facets for inline attachments should behave like the facets for attachment compositions.

Screenshots

Empty facet:

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