Skip to content
5 changes: 5 additions & 0 deletions .changeset/fresh-weeks-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/eslint-plugin-fiori-tools': patch
---

Update sap-no-data-field-intent-based-navigation rule documentation with information on semantic link navigation.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,57 @@ Using `UI.DataFieldForIntentBasedNavigation` or `UI.DataFieldWithIntentBasedNavi
</Annotation>
```

#### Correct: Semantic Link or Smart Link Navigation Is Used
### Correct: Semantic Link or Smart Link Navigation Is Used Using `Common.SemanticObject` on the Entity Property

The `sap.ui.comp.navpopover.SmartLink` control provides a popover with navigation links to related applications, for example, more detailed information about customer data.
For more information about this control, see the [API Reference](https://ui5.sap.com/#/api/sap.ui.comp.navpopover.SmartLink) and the [samples](https://ui5.sap.com/#/entity/sap.ui.comp.navpopover.SmartLink).
Annotate the entity property, for example,`CustomerId`, with the `Common.SemanticObject` annotation before using it in a `UI.LineItem` or `UI.FieldGroup`. SAP Fiori elements automatically detects this and renders the field as a semantic link.

#### Step 1: Annotate the Entity Property:

```xml
<!-- Applied to the actual OData property, NOT inside DataField -->
<Annotation Term="Common.SemanticObject" String="Customer" Target="YourEntityType/CustomerId"/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we set Target on Annotation?
Shouldn't we write the following?

<Annotations Target="YourEntityType/CustomerId">
    <Annotation Term="Common.SemanticObject" String="Customer"/>
</Annotations>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @hitesh-parmar can you help with Marco's question?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe Marco is right, I don't remember an example where Term and Target are on the same level. I think annotation LSP should show an error/warning in this case.

```

#### Step 2: Reference the Property in Your UI Annotations:
Note: No navigation annotation is needed.

For a table column using the `UI.LineItem` annotation:

```xml
<Annotation Term="UI.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="CustomerId"/>
<PropertyValue Property="Label" String="Customer"/>
<!-- Semantic Link rendered automatically due to Common.SemanticObject on CustomerId property -->
</Record>
</Collection>
</Annotation>
```

For a form field using the `UI.FieldGroup` annotation:

```xml
<Annotation Term="UI.FieldGroup" Qualifier="GeneralInformation">
<Record Type="UI.FieldGroupType">
<PropertyValue Property="Data">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="CustomerId"/>
<PropertyValue Property="Label" String="Customer"/>
<!-- Semantic Link rendered automatically due to Common.SemanticObject on CustomerId property -->
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
```

## Bug Report

If you encounter an issue with this rule, please open a [GitHub issue](https://github.com/SAP/open-ux-tools/issues).

## Further Reading

- [UI5 UI Adaptation Documentation: Smart Link](https://ui5.sap.com/#/topic/f638884d0d624ad8a243f4005f8e9972)
- [Semantic Link Implementation in SAP Fiori Elements](https://ui5.sap.com/#/topic/c18ada4bc56e427a9a2df2d1898f28a5)
- [Smart Link and Navigation Intents](https://ui5.sap.com/#/topic/d782acf8bfd74107ad6a04f0361c5f62)
Loading