Skip to content

Commit 588e53e

Browse files
author
Andriy Malish
committed
Merged PR 280202: [Storytelling] - Add report on blur event - lose focus
Add report on blur event - lose focus Two new methods added: - clearVisualsSelection() -- Clears selected not popped out visuals, if flag is passed, all visuals selections will be cleared. - closeAllOverlays() -- Closes all open PBI overlays (context menus, tooltips...)
1 parent e7638e9 commit 588e53e

File tree

4 files changed

+167
-3
lines changed

4 files changed

+167
-3
lines changed

dist/powerbi-client.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,35 @@ declare module "report" {
16141614
* @param zoomLevel zoom level to set
16151615
*/
16161616
setZoom(zoomLevel: number): Promise<void>;
1617+
/**
1618+
* Closes all open context menus and tooltips.
1619+
*
1620+
* ```javascript
1621+
* report.closeAllOverlays()
1622+
* .then(() => {
1623+
* ...
1624+
* });
1625+
* ```
1626+
*
1627+
* @returns {Promise<void>}
1628+
*/
1629+
closeAllOverlays(): Promise<void>;
1630+
/**
1631+
* Clears selected not popped out visuals, if flag is passed, all visuals selections will be cleared.
1632+
*
1633+
* ```javascript
1634+
* report.clearSelectedVisuals()
1635+
* .then(() => {
1636+
* ...
1637+
* });
1638+
* ```
1639+
*
1640+
* @param {Boolean} [clearPopOutState=false]
1641+
* If false / undefined visuals selection will not be cleared if one of visuals
1642+
* is in popped out state (in focus, show as table, spotlight...)
1643+
* @returns {Promise<void>}
1644+
*/
1645+
clearSelectedVisuals(clearPopOutState?: boolean): Promise<void>;
16171646
}
16181647
}
16191648
declare module "create" {

dist/powerbi.js

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11121,8 +11121,84 @@ var Report = /** @class */ (function (_super) {
1112111121
});
1112211122
});
1112311123
};
11124+
/**
11125+
* Closes all open context menus and tooltips.
11126+
*
11127+
* ```javascript
11128+
* report.closeAllOverlays()
11129+
* .then(() => {
11130+
* ...
11131+
* });
11132+
* ```
11133+
*
11134+
* @returns {Promise<void>}
11135+
*/
11136+
Report.prototype.closeAllOverlays = function () {
11137+
return __awaiter(this, void 0, void 0, function () {
11138+
var response, error_1;
11139+
return __generator(this, function (_a) {
11140+
switch (_a.label) {
11141+
case 0:
11142+
if ((0, util_1.isRDLEmbed)(this.config.embedUrl)) {
11143+
return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)];
11144+
}
11145+
_a.label = 1;
11146+
case 1:
11147+
_a.trys.push([1, 3, , 4]);
11148+
return [4 /*yield*/, this.service.hpm.post('/report/closeAllOverlays', null, { uid: this.config.uniqueId }, this.iframe.contentWindow)];
11149+
case 2:
11150+
response = _a.sent();
11151+
return [2 /*return*/, response.body];
11152+
case 3:
11153+
error_1 = _a.sent();
11154+
return [2 /*return*/, Promise.reject(error_1)];
11155+
case 4: return [2 /*return*/];
11156+
}
11157+
});
11158+
});
11159+
};
11160+
/**
11161+
* Clears selected not popped out visuals, if flag is passed, all visuals selections will be cleared.
11162+
*
11163+
* ```javascript
11164+
* report.clearSelectedVisuals()
11165+
* .then(() => {
11166+
* ...
11167+
* });
11168+
* ```
11169+
*
11170+
* @param {Boolean} [clearPopOutState=false]
11171+
* If false / undefined visuals selection will not be cleared if one of visuals
11172+
* is in popped out state (in focus, show as table, spotlight...)
11173+
* @returns {Promise<void>}
11174+
*/
11175+
Report.prototype.clearSelectedVisuals = function (clearPopOutState) {
11176+
return __awaiter(this, void 0, void 0, function () {
11177+
var response, error_2;
11178+
return __generator(this, function (_a) {
11179+
switch (_a.label) {
11180+
case 0:
11181+
clearPopOutState = clearPopOutState === true;
11182+
if ((0, util_1.isRDLEmbed)(this.config.embedUrl)) {
11183+
return [2 /*return*/, Promise.reject(errors_1.APINotSupportedForRDLError)];
11184+
}
11185+
_a.label = 1;
11186+
case 1:
11187+
_a.trys.push([1, 3, , 4]);
11188+
return [4 /*yield*/, this.service.hpm.post("/report/clearSelectedVisuals/".concat(clearPopOutState.toString()), null, { uid: this.config.uniqueId }, this.iframe.contentWindow)];
11189+
case 2:
11190+
response = _a.sent();
11191+
return [2 /*return*/, response.body];
11192+
case 3:
11193+
error_2 = _a.sent();
11194+
return [2 /*return*/, Promise.reject(error_2)];
11195+
case 4: return [2 /*return*/];
11196+
}
11197+
});
11198+
});
11199+
};
1112411200
/** @hidden */
11125-
Report.allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered", "swipeStart", "swipeEnd", "bookmarkApplied", "dataHyperlinkClicked", "visualRendered", "visualClicked", "selectionChanged", "renderingStarted"];
11201+
Report.allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered", "swipeStart", "swipeEnd", "bookmarkApplied", "dataHyperlinkClicked", "visualRendered", "visualClicked", "selectionChanged", "renderingStarted", "blur"];
1112611202
/** @hidden */
1112711203
Report.reportIdAttribute = 'powerbi-report-id';
1112811204
/** @hidden */

dist/powerbi.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/report.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface IReportNode {
6464
*/
6565
export class Report extends Embed implements IReportNode, IFilterable {
6666
/** @hidden */
67-
static allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered", "swipeStart", "swipeEnd", "bookmarkApplied", "dataHyperlinkClicked", "visualRendered", "visualClicked", "selectionChanged", "renderingStarted"];
67+
static allowedEvents = ["filtersApplied", "pageChanged", "commandTriggered", "swipeStart", "swipeEnd", "bookmarkApplied", "dataHyperlinkClicked", "visualRendered", "visualClicked", "selectionChanged", "renderingStarted", "blur"];
6868
/** @hidden */
6969
static reportIdAttribute = 'powerbi-report-id';
7070
/** @hidden */
@@ -1177,4 +1177,63 @@ export class Report extends Embed implements IReportNode, IFilterable {
11771177
async setZoom(zoomLevel: number): Promise<void> {
11781178
await this.updateSettings({ zoomLevel: zoomLevel });
11791179
}
1180+
1181+
/**
1182+
* Closes all open context menus and tooltips.
1183+
*
1184+
* ```javascript
1185+
* report.closeAllOverlays()
1186+
* .then(() => {
1187+
* ...
1188+
* });
1189+
* ```
1190+
*
1191+
* @returns {Promise<void>}
1192+
*/
1193+
async closeAllOverlays(): Promise<void> {
1194+
if (isRDLEmbed(this.config.embedUrl)) {
1195+
return Promise.reject(APINotSupportedForRDLError);
1196+
}
1197+
1198+
try {
1199+
const response = await this.service.hpm.post<void>('/report/closeAllOverlays', null, { uid: this.config.uniqueId }, this.iframe.contentWindow);
1200+
return response.body;
1201+
} catch (error) {
1202+
return Promise.reject(error);
1203+
}
1204+
}
1205+
1206+
/**
1207+
* Clears selected not popped out visuals, if flag is passed, all visuals selections will be cleared.
1208+
*
1209+
* ```javascript
1210+
* report.clearSelectedVisuals()
1211+
* .then(() => {
1212+
* ...
1213+
* });
1214+
* ```
1215+
*
1216+
* @param {Boolean} [clearPopOutState=false]
1217+
* If false / undefined visuals selection will not be cleared if one of visuals
1218+
* is in popped out state (in focus, show as table, spotlight...)
1219+
* @returns {Promise<void>}
1220+
*/
1221+
async clearSelectedVisuals(clearPopOutState?: boolean): Promise<void> {
1222+
clearPopOutState = clearPopOutState === true;
1223+
if (isRDLEmbed(this.config.embedUrl)) {
1224+
return Promise.reject(APINotSupportedForRDLError);
1225+
}
1226+
1227+
try {
1228+
const response = await this.service.hpm.post<void>(
1229+
`/report/clearSelectedVisuals/${clearPopOutState.toString()}`,
1230+
null,
1231+
{ uid: this.config.uniqueId },
1232+
this.iframe.contentWindow
1233+
);
1234+
return response.body;
1235+
} catch (error) {
1236+
return Promise.reject(error);
1237+
}
1238+
}
11801239
}

0 commit comments

Comments
 (0)