Skip to content
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

fix: Added support for missing 'showClearButton', 'showMessages', and 'liveMode' properties in FilterBar building block generation. #2953

Merged
merged 3 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-chicken-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-ux/fe-fpm-writer': patch
---

Added support for 'showClearButton', 'showMessages', and 'liveMode' properties in FilterBar building block generation.
18 changes: 18 additions & 0 deletions packages/fe-fpm-writer/src/building-block/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ export interface FilterBar extends BuildingBlock {
* This event is fired when the Go button is pressed or after a condition change.
*/
search?: string;
/**
* If true, the search is triggered automatically when a filter value is changed.
*
* @default false
*/
liveMode?: boolean;
/**
* Handles the visibility of the 'Clear' button on the FilterBar.
*
* @default false
*/
showClearButton?: boolean;
/**
* Displays possible errors during the search in a message box.
*
* @default true
*/
showMessages?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
metaPath="<%- data.metaPath %>"<% } %><% if (data.contextPath) { %>
contextPath="<%- data.contextPath %>"<% } %><% if (data.search) { %>
search="<%- data.search %>"<% } %><% if (data.filterChanged) { %>
filterChanged="<%- data.filterChanged %>"<% } %>
filterChanged="<%- data.filterChanged %>"<% } %><% if (data.liveMode !== undefined) { %>
liveMode="<%- data.liveMode %>"<% } %><% if (data.showClearButton !== undefined) { %>
showClearButton="<%- data.showClearButton %>"<% } %><% if (data.showMessages !== undefined) { %>
showMessages="<%- data.showMessages %>"<% } %>
/>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Object {
}
`;

exports[`Building Blocks FilterBar properties: filterbar-properties 1`] = `
"<mvc:View xmlns:core=\\"sap.ui.core\\" xmlns:mvc=\\"sap.ui.core.mvc\\" xmlns=\\"sap.m\\" xmlns:html=\\"http://www.w3.org/1999/xhtml\\" controllerName=\\"com.test.myApp.ext.main.Main\\" xmlns:macros=\\"sap.fe.macros\\">
<Page title=\\"Main\\">
<content>
<macros:FilterBar id=\\"testFilterBar\\" search=\\"onSearch\\" filterChanged=\\"onFilterChanged\\" liveMode=\\"true\\" showClearButton=\\"false\\" showMessages=\\"true\\"/>
</content>
</Page>
</mvc:View>"
`;

exports[`Building Blocks Generate with just ID and xml view without macros namespace generate chart building block: generate-chart-with-id-no-macros-ns 1`] = `
Object {
"generate-chart-with-id-no-macros-ns/webapp/ext/main/Main.view.xml": Object {
Expand Down
28 changes: 28 additions & 0 deletions packages/fe-fpm-writer/test/unit/building-block.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,34 @@ describe('Building Blocks', () => {
expect(testFS.read(join(basePath, xmlViewFilePath))).toMatchSnapshot();
});

test('FilterBar properties', async () => {
const aggregationPath = `/mvc:View/*[local-name()='Page']/*[local-name()='content']`;
const basePath = join(__dirname, 'sample/building-block/filterbar-properties');
const testXmlViewFilePath = join(basePath, xmlViewFilePath);
fs.write(join(basePath, manifestFilePath), JSON.stringify(testManifestContent));
fs.write(testXmlViewFilePath, testXmlViewContent);

await generateBuildingBlock<FilterBar>(
basePath,
{
viewOrFragmentPath: xmlViewFilePath,
aggregationPath: aggregationPath,
buildingBlockData: {
id: 'testFilterBar',
buildingBlockType: BuildingBlockType.FilterBar,
filterChanged: 'onFilterChanged',
search: 'onSearch',
liveMode: true,
showClearButton: false,
showMessages: true
}
},
fs
);
expect(fs.read(testXmlViewFilePath)).toMatchSnapshot('filterbar-properties');
await writeFilesForDebugging(fs);
});

describe('Generate with just ID and xml view without macros namespace', () => {
const testInput = [
{
Expand Down
Loading