generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Add global detection for XML Templating #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...es/linter/projects/com.ui5.troublesome.app/webapp/controller/TemplatingMain.controller.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| sap.ui.define(["./BaseController"], function (BaseController) { | ||
| "use strict"; | ||
|
|
||
| const TemplatingMainController = BaseController.extend("com.ui5.troublesome.app.controller.TemplatingMain", { | ||
| }); | ||
| return TemplatingMainController; | ||
| }); |
26 changes: 26 additions & 0 deletions
26
test/fixtures/linter/projects/com.ui5.troublesome.app/webapp/view/TemplatingMain.view.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <mvc:View | ||
| controllerName="com.ui5.troublesome.app.controller.TemplatingMain" | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core" | ||
| xmlns:layout="sap.ui.layout" | ||
| xmlns:mvc="sap.ui.core.mvc" | ||
| xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"> | ||
| <layout:VerticalLayout class="sapUiSmallMarginBottom"> | ||
| <template:alias name=".formatParts" value="com.ui5.troublesome.app.helpers.Helper.formatParts"> | ||
| <template:alias name=".id" value="com.ui5.troublesome.app.helpers.Helper.id"> | ||
| <template:with path="meta>/" var="fieldGroup"> | ||
| <template:with path="meta>entityType" helper="sap.ui.model.odata.AnnotationHelper.gotoEntityType" var="entityType"> | ||
| <template:if test="{entityType>com.sap.vocabularies.UI.v1.LineItem}"> | ||
| <Table headerText="Items" includeItemInSelection="true" mode="SingleSelectMaster" | ||
| selectionChange="onSelectionChange" items="{:= '{path:\'/' + ${meta>name} + '\', length: 5}' }"> | ||
| <template:with path="entityType>com.sap.vocabularies.UI.v1.LineItem" var="target"> | ||
| <core:Fragment fragmentName="com.ui5.troublesome.app.view.TemplatingTable" type="XML"/> | ||
| </template:with> | ||
| </Table> | ||
| </template:if> | ||
| </template:with> | ||
| </template:with> | ||
| </template:alias> | ||
| </template:alias> | ||
| </layout:VerticalLayout> | ||
| </mvc:View> |
56 changes: 56 additions & 0 deletions
56
...fixtures/linter/projects/com.ui5.troublesome.app/webapp/view/TemplatingTable.fragment.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <core:FragmentDefinition | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core" | ||
| xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"> | ||
| <columns> | ||
| <template:repeat list="{target>}" var="field"> | ||
| <template:if test="{field>Value}"> | ||
| <Column> | ||
| <Text text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/> | ||
| </Column> | ||
| </template:if> | ||
| <template:if test="{field>Action}"> | ||
| <Column demandPopin="true" minScreenWidth="1800px" popinDisplay="WithoutHeader"> | ||
| <Text text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"/> | ||
| </Column> | ||
| </template:if> | ||
| </template:repeat> | ||
| </columns> | ||
| <ColumnListItem> | ||
| <template:repeat list="{target>}" var="field"> | ||
| <template:if test="{field>Value}"> | ||
| <template:if test="{field>Target}"> | ||
| <template:then> | ||
| <template:with path="field>Target" helper="sap.ui.model.odata.AnnotationHelper.resolvePath" var="entityType"> | ||
| <Link text="{path: 'field>Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" press="onDetailsPressed"> | ||
| <dependents> | ||
| <template:with path="entityType>com.sap.vocabularies.UI.v1.HeaderInfo" var="headerInfo"> | ||
| <Popover binding="{path: 'field>Target', formatter: 'sap.ui.model.odata.AnnotationHelper.getNavigationPath'}" | ||
| title="{path: 'headerInfo>Title/Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}"> | ||
| </Popover> | ||
| </template:with> | ||
| </dependents> | ||
| </Link> | ||
| </template:with> | ||
| </template:then> | ||
| <template:else> | ||
| <Text text="{path: 'field>Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" /> | ||
| </template:else> | ||
| </template:if> | ||
| </template:if> | ||
| <template:if test="{field>Action}"> | ||
| <template:with path="field>Action" helper="sap.ui.model.odata.AnnotationHelper.gotoFunctionImport" var="function"> | ||
| <template:if test="{function>com.sap.vocabularies.Common.v1.IsActionCritical}"> | ||
| <template:then> | ||
| <Button text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" | ||
| icon="{= ${function>com.sap.vocabularies.Common.v1.IsActionCritical/Bool} !== 'false' ? 'sap-icon://notification' : ''}" /> | ||
| </template:then> | ||
| <template:else> | ||
| <Button text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" /> | ||
| </template:else> | ||
| </template:if> | ||
| </template:with> | ||
| </template:if> | ||
| </template:repeat> | ||
| </ColumnListItem> | ||
| </core:FragmentDefinition> |
40 changes: 40 additions & 0 deletions
40
test/fixtures/linter/rules/NoGlobals/XMLTemplatingV2.view.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <mvc:View | ||
| controllerName="sap.ui.core.sample.ViewTemplate.scenario.Detail" | ||
| template:require="{AH: 'sap/ui/model/odata/AnnotationHelper', | ||
| Helper: 'sap/ui/core/sample/ViewTemplate/scenario/Helper'}" | ||
| xmlns="sap.m" | ||
| xmlns:core="sap.ui.core" | ||
| xmlns:layout="sap.ui.layout" | ||
| xmlns:mvc="sap.ui.core.mvc" | ||
| xmlns:template="http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1"> | ||
|
|
||
| <!-- Global access of value function --> | ||
| <template:alias name="gotoEntityType" value="Helper.gotoEntityType"> | ||
|
|
||
| <!-- Global access of value function --> | ||
| <template:alias name=".formatParts" value="sap.ui.core.sample.ViewTemplate.scenario.Helper.formatParts"> | ||
|
|
||
| <!-- Negative test: Access via local name --> | ||
| <template:alias name=".id" value="Helper.id"> | ||
|
|
||
| <!-- Global access of helper function --> | ||
| <template:with path="meta>entityType" helper="sap.ui.model.odata.AnnotationHelper.gotoEntityType" var="entityType"> | ||
|
|
||
| <!-- Negative test: Access via local alias name --> | ||
| <template:with path="meta>entityType" helper="gotoEntityType" var="entityType2"> | ||
|
|
||
| <template:if test="{entityType>com.sap.vocabularies.UI.v1.LineItem}"> | ||
| <Table headerText="Items" includeItemInSelection="true" mode="SingleSelectMaster" | ||
| selectionChange="onSelectionChange" items="{:= '{path:\'/' + ${meta>name} + '\', length: 5}' }"> | ||
| <template:with path="entityType>com.sap.vocabularies.UI.v1.LineItem" var="target"> | ||
| <core:Fragment fragmentName="sap.ui.core.sample.ViewTemplate.scenario.Table" type="XML"/> | ||
| </template:with> | ||
| </Table> | ||
| </template:if> | ||
|
|
||
| </template:with> | ||
| </template:with> | ||
| </template:alias> | ||
| </template:alias> | ||
| </template:alias> | ||
| </mvc:View> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KlattG please review this new message