From 9b1c029f7b89ab8ac727750527f9450e93b882b6 Mon Sep 17 00:00:00 2001 From: encimita <55883409+encimita@users.noreply.github.com> Date: Fri, 29 Nov 2024 15:08:24 +0100 Subject: [PATCH] [PowerBI] Decouple addin settings, default "Show zoom bar" to true (#2342) #### Summary The Power BI Embedded control add-in currently supports a bunch of different settings that change the embed experience making it richer and more customizable. These settings are currently controlled with the `SetSettings` add-in function, which takes a bunch of booleans. This is of course not very readable nor very extensible. This PR cleans up the code for these settings by having a different function to set up each setting. It also flips the default for the "Show Status Bar" setting to true; this is for accessibility reasons, as full-page reports might not be accessible or "navigable" without the zoom controls. #### Work Item(s) Fixes [AB#556723](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/556723) --- .../PowerBIManagement/js/PowerBIManagement.js | 47 ++++++++++++++----- .../src/PowerBIManagement.ControlAddin.al | 33 +++++++++++++ .../PowerBIManagement/js/PowerBIManagement.js | 47 ++++++++++++++----- 3 files changed, 105 insertions(+), 22 deletions(-) diff --git a/src/System Application/App/ControlAddIns/Resources/PowerBIManagement/js/PowerBIManagement.js b/src/System Application/App/ControlAddIns/Resources/PowerBIManagement/js/PowerBIManagement.js index 06a3e840aa..2617c632f0 100644 --- a/src/System Application/App/ControlAddIns/Resources/PowerBIManagement/js/PowerBIManagement.js +++ b/src/System Application/App/ControlAddIns/Resources/PowerBIManagement/js/PowerBIManagement.js @@ -16,7 +16,7 @@ var pbiAuthToken = null; var _showBookmarkSelection = false; var _showFilters = false; var _showPageSelection = false; -var _showZoomBar = false; +var _showZoomBar = true; var _forceTransparentBackground = false; var _forceFitToPage = false; var _addBottomPadding = false; @@ -147,6 +147,17 @@ function InitializeFrame(fullpage, ratio) { } } +function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) { + // OBSOLETE + _showBookmarkSelection = showBookmarkSelection; + _showFilters = showFilters; + _showPageSelection = showPageSelection; + _showZoomBar = showZoomBar; + _forceTransparentBackground = forceTransparentBackground; + _addBottomPadding = addBottomPadding; + _forceFitToPage = forceFitToPage; +} + // Exposed Functions function EmbedPowerBIReport(reportLink, reportId, pageName) { @@ -345,14 +356,24 @@ function SetToken(authToken) { pbiAuthToken = authToken; } -function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) { - _showBookmarkSelection = showBookmarkSelection; - _showFilters = showFilters; - _showPageSelection = showPageSelection; - _showZoomBar = showZoomBar; - _forceTransparentBackground = forceTransparentBackground; - _forceFitToPage = forceFitToPage; - _addBottomPadding = addBottomPadding; +function SetBookmarksVisible(visible) { + _showBookmarkSelection = visible; +} + +function SetFiltersVisible(visible) { + _showFilters = visible; +} + +function SetPageSelectionVisible(visible) { + _showPageSelection = visible; +} + +function SetTransparentBackground(transparent) { + _forceTransparentBackground = transparent; +} + +function AddBottomPadding(addPadding) { + _addBottomPadding = addPadding; } // Internal functions @@ -504,14 +525,18 @@ function LogErrorToConsole(operation, error) { } function GetErrorMessage(error) { - if (error && error.message) { - return error.message; + if (error && error.detail && error.detail.detailedMessage) { + return error.detail.detailedMessage; } if (error && error.detail && error.detail.message) { return error.detail.message; } + if (error && error.message) { + return error.message; + } + return error.toString(); } diff --git a/src/System Application/App/ControlAddIns/src/PowerBIManagement.ControlAddin.al b/src/System Application/App/ControlAddIns/src/PowerBIManagement.ControlAddin.al index 0aa30926ce..47da51ef28 100644 --- a/src/System Application/App/ControlAddIns/src/PowerBIManagement.ControlAddin.al +++ b/src/System Application/App/ControlAddIns/src/PowerBIManagement.ControlAddin.al @@ -130,6 +130,37 @@ controladdin PowerBIManagement /// The locale to use, for example "en-us". procedure SetLocale(NewLocale: Text); + /// + /// Controls whether the bookmark selection pane will be visible in the embed experience. Defaults to false. + /// + /// Whether bookmarks should be visible. + procedure SetBookmarksVisible(Visible: Boolean); + + /// + /// Controls whether the filter pane will be visible in the embed experience. Defaults to false. + /// + /// Whether filters should be visible. + procedure SetFiltersVisible(Visible: Boolean); + + /// + /// Controls whether the page selection bar will be visible in the embed experience. Defaults to false. + /// + /// Whether page selection should be visible. + procedure SetPageSelectionVisible(Visible: Boolean); + + /// + /// Controls whether the report background should be set to transparent regardless of the actual color. Defaults to false. + /// + /// Whether the background should be force to transparent. + procedure SetTransparentBackground(Transparent: Boolean); + + /// + /// Controls whether the addin includes a bottom padding that makes it look nicer in some embedded scenarios. Defaults to false. + /// + /// Whether the bottom padding should be added. + procedure AddBottomPadding(AddPadding: Boolean); + +#if not CLEAN26 /// /// Sets the properties for the embed experience /// @@ -140,7 +171,9 @@ controladdin PowerBIManagement ///Forces a transparent background to the embed. ///Forces the Fit To Page behaviour for the embed. ///Controls whether a padding is needed on the bottom of the page (useful in case the embed is the only element displayed on the page). + [Obsolete('Use SetBookmarksVisible, SetFiltersVisible, AddBottomPadding, SetTransparentBackground, and SetPageSelectionVisible instead. The other options are no longer supported.', '26.0')] procedure SetSettings(ShowBookmarkSelection: Boolean; ShowFilters: Boolean; ShowPageSelection: Boolean; ShowZoomBar: Boolean; ForceTransparentBackground: Boolean; ForceFitToPage: Boolean; AddBottomPadding: Boolean); +#endif #if not CLEAN25 /// diff --git a/src/System Application/App/Resources/PowerBIManagement/js/PowerBIManagement.js b/src/System Application/App/Resources/PowerBIManagement/js/PowerBIManagement.js index 06a3e840aa..2617c632f0 100644 --- a/src/System Application/App/Resources/PowerBIManagement/js/PowerBIManagement.js +++ b/src/System Application/App/Resources/PowerBIManagement/js/PowerBIManagement.js @@ -16,7 +16,7 @@ var pbiAuthToken = null; var _showBookmarkSelection = false; var _showFilters = false; var _showPageSelection = false; -var _showZoomBar = false; +var _showZoomBar = true; var _forceTransparentBackground = false; var _forceFitToPage = false; var _addBottomPadding = false; @@ -147,6 +147,17 @@ function InitializeFrame(fullpage, ratio) { } } +function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) { + // OBSOLETE + _showBookmarkSelection = showBookmarkSelection; + _showFilters = showFilters; + _showPageSelection = showPageSelection; + _showZoomBar = showZoomBar; + _forceTransparentBackground = forceTransparentBackground; + _addBottomPadding = addBottomPadding; + _forceFitToPage = forceFitToPage; +} + // Exposed Functions function EmbedPowerBIReport(reportLink, reportId, pageName) { @@ -345,14 +356,24 @@ function SetToken(authToken) { pbiAuthToken = authToken; } -function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) { - _showBookmarkSelection = showBookmarkSelection; - _showFilters = showFilters; - _showPageSelection = showPageSelection; - _showZoomBar = showZoomBar; - _forceTransparentBackground = forceTransparentBackground; - _forceFitToPage = forceFitToPage; - _addBottomPadding = addBottomPadding; +function SetBookmarksVisible(visible) { + _showBookmarkSelection = visible; +} + +function SetFiltersVisible(visible) { + _showFilters = visible; +} + +function SetPageSelectionVisible(visible) { + _showPageSelection = visible; +} + +function SetTransparentBackground(transparent) { + _forceTransparentBackground = transparent; +} + +function AddBottomPadding(addPadding) { + _addBottomPadding = addPadding; } // Internal functions @@ -504,14 +525,18 @@ function LogErrorToConsole(operation, error) { } function GetErrorMessage(error) { - if (error && error.message) { - return error.message; + if (error && error.detail && error.detail.detailedMessage) { + return error.detail.detailedMessage; } if (error && error.detail && error.detail.message) { return error.detail.message; } + if (error && error.message) { + return error.message; + } + return error.toString(); }