diff --git a/demo/v2-demo/live_showcases/insight_to_action/showcase_insight_to_action.js b/demo/v2-demo/live_showcases/insight_to_action/showcase_insight_to_action.js index bbbb61d2..519df4e7 100644 --- a/demo/v2-demo/live_showcases/insight_to_action/showcase_insight_to_action.js +++ b/demo/v2-demo/live_showcases/insight_to_action/showcase_insight_to_action.js @@ -118,18 +118,18 @@ function embedInsightsToActionReport() { .then(function (pages) { // Retrieve active page. - let activePage = pages.find(function(page) { + let activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; // Get page's visuals activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - let visual = visuals.find(function(visual) { + let visual = visuals.filter(function(visual) { return visual.name === tableVisualName; - }); + })[0]; // Exports visual data visual.exportData(models.ExportDataType.Underlying).then(handleExportData); @@ -191,7 +191,10 @@ function parseData(data) { // Filter the table's data - removing the 'filterValues' columns function filterTable(filterValues, table) { for (let i = 0; i < filterValues.length; i++) { - valueIndex = table[0].findIndex(function(value) { return value === filterValues[i] }); + valueIndex = table[0].indexOf( + table[0].filter(function(value) { return value === filterValues[i] })[0] + ); + for (let j = 0; j < table.length; j++) { table[j].splice(valueIndex, 1); } diff --git a/demo/v2-demo/scripts/codesamples.js b/demo/v2-demo/scripts/codesamples.js index 4a40fb0e..7c769b6c 100644 --- a/demo/v2-demo/scripts/codesamples.js +++ b/demo/v2-demo/scripts/codesamples.js @@ -1565,9 +1565,9 @@ function _Page_GetFilters() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getFilters() .then(function (filters) { @@ -1593,9 +1593,9 @@ function _Page_GetVisuals() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { @@ -1642,9 +1642,9 @@ function _Page_SetFilters() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.setFilters([filter]) .then(function () { @@ -1670,9 +1670,9 @@ function _Page_RemoveFilters() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.removeFilters() .then(function () { @@ -2187,16 +2187,16 @@ function _Visual_GetSlicer() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive; - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var slicer = visuals.find(function(visual) { + var slicer = visuals.filter(function(visual) { return visual.type == "slicer" && visual.name == "4d55baaa5eddde4cdf90"; - }); + })[0]; // Get the slicer state which contains the slicer filter. slicer.getSlicerState() @@ -2249,16 +2249,16 @@ function _Visual_SetSlicer() { report.getPages() .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive; - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var slicer = visuals.find(function(visual) { + var slicer = visuals.filter(function(visual) { return visual.type == "slicer" && visual.name == "4d55baaa5eddde4cdf90"; - }); + })[0]; // Set the slicer state which contains the slicer filters. slicer.setSlicerState({ filters: [filter]}) @@ -2308,17 +2308,17 @@ function _Visual_SetFilters() { .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var visual = visuals.find(function(visual) { + var visual = visuals.filter(function(visual) { return visual.name == "VisualContainer4"; - }); + })[0]; // Set the filter for the visual. // Pay attention that setFilters receives an array. @@ -2351,17 +2351,17 @@ function _Visual_GetFilters() { .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var visual = visuals.find(function(visual) { + var visual = visuals.filter(function(visual) { return visual.name == "VisualContainer4"; - }); + })[0]; visual.getFilters() .then(function (filters) { @@ -2392,17 +2392,17 @@ function _Visual_RemoveFilters() { .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var visual = visuals.find(function(visual) { + var visual = visuals.filter(function(visual) { return visual.name == "VisualContainer4"; - }); + })[0]; visual.removeFilters() .then(function () { @@ -2436,17 +2436,17 @@ function _Visual_ExportData_Summarized() { .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var visual = visuals.find(function(visual) { + var visual = visuals.filter(function(visual) { return visual.name == "VisualContainer4"; - }); + })[0]; // Exports visual data visual.exportData(models.ExportDataType.Summarized) @@ -2481,17 +2481,17 @@ function _Visual_ExportData_Underlying() { .then(function (pages) { // Retrieve active page. - var activePage = pages.find(function(page) { + var activePage = pages.filter(function(page) { return page.isActive - }); + })[0]; activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. - var visual = visuals.find(function(visual) { + var visual = visuals.filter(function(visual) { return visual.name == "VisualContainer4"; - }); + })[0]; // Exports visual data visual.exportData(models.ExportDataType.Underlying) diff --git a/demo/v2-demo/scripts/session_utils.js b/demo/v2-demo/scripts/session_utils.js index 73766b2e..5618cf67 100644 --- a/demo/v2-demo/scripts/session_utils.js +++ b/demo/v2-demo/scripts/session_utils.js @@ -182,7 +182,7 @@ function FetchUrlIntoSession(url, updateCurrentToken) { { let embedContainerId = getEmbedContainerID(capitalizeFirstLetter(embedConfig.type)); - let embedContainer = powerbi.embeds.find(function(embedElement) {return (embedElement.element.id == embedContainerId)}); + let embedContainer = powerbi.embeds.filter(function(embedElement) { return embedElement.element.id === embedContainerId; })[0]; if (embedContainer) { embedContainer.setAccessToken(embedConfig.embedToken.token);