Skip to content

Commit

Permalink
Add isFetchingItems flag to disable the PromptForItems when fetching …
Browse files Browse the repository at this point in the history
…items in Visualize and Dashboard listing tables.

Backports PR #10381

**Commit 1:**
Add isFetchingItems flag to disable the PromptForItems when fetching items in Visualize and Dashboard listing tables.

* Original sha: d2483ad
* Authored by CJ Cenizal <cj@cenizal.com> on 2017-02-15T21:19:30Z
  • Loading branch information
elastic-jasper committed Feb 16, 2017
1 parent af881ea commit 152b0b2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<!-- PromptForItems -->
<div
class="kuiPanel kuiPanel--centered kuiPanel--withHeader"
ng-if="!listingController.items.length && !listingController.filter"
ng-if="!listingController.isFetchingItems && !listingController.items.length && !listingController.filter"
>
<div class="kuiPromptForItems">
<div class="kuiPromptForItems__message">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ export function DashboardListingController($injector, $scope) {
this.pageOfItems = limitTo(this.items, this.pager.pageSize, this.pager.startIndex);
};

const fetchObjects = () => {
const fetchItems = () => {
this.isFetchingItems = true;

dashboardService.find(this.filter)
.then(result => {
this.isFetchingItems = false;
this.items = result.hits;
calculateItemsOnPage();
});
Expand All @@ -57,6 +60,7 @@ export function DashboardListingController($injector, $scope) {
selectedItems = this.pageOfItems.slice(0);
};

this.isFetchingItems = false;
this.items = [];
this.pageOfItems = [];
this.filter = '';
Expand All @@ -65,7 +69,7 @@ export function DashboardListingController($injector, $scope) {

$scope.$watch(() => this.filter, () => {
deselectAll();
fetchObjects();
fetchItems();
});

/**
Expand Down Expand Up @@ -115,7 +119,7 @@ export function DashboardListingController($injector, $scope) {
const selectedIds = selectedItems.map(item => item.id);

dashboardService.delete(selectedIds)
.then(fetchObjects)
.then(fetchItems)
.then(() => {
deselectAll();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<!-- PromptForItems -->
<div
class="kuiPanel kuiPanel--centered kuiPanel--withHeader"
ng-if="!listingController.items.length && !listingController.filter"
ng-if="!listingController.isFetchingItems && !listingController.items.length && !listingController.filter"
>
<div class="kuiPromptForItems">
<div class="kuiPromptForItems__message">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ export function VisualizeListingController($injector, $scope) {
this.pageOfItems = limitTo(this.items, this.pager.pageSize, this.pager.startIndex);
};

const fetchObjects = () => {
const fetchItems = () => {
this.isFetchingItems = true;

visualizationService.find(this.filter)
.then(result => {
this.items = result.hits;
calculateItemsOnPage();
});
.then(result => {
this.isFetchingItems = false;
this.items = result.hits;
calculateItemsOnPage();
});
};

const deselectAll = () => {
Expand All @@ -58,6 +61,7 @@ export function VisualizeListingController($injector, $scope) {
selectedItems = this.pageOfItems.slice(0);
};

this.isFetchingItems = false;
this.items = [];
this.pageOfItems = [];
this.filter = '';
Expand All @@ -66,7 +70,7 @@ export function VisualizeListingController($injector, $scope) {

$scope.$watch(() => this.filter, () => {
deselectAll();
fetchObjects();
fetchItems();
});

/**
Expand Down Expand Up @@ -145,7 +149,7 @@ export function VisualizeListingController($injector, $scope) {
const selectedIds = selectedItems.map(item => item.id);

visualizationService.delete(selectedIds)
.then(fetchObjects)
.then(fetchItems)
.then(() => {
deselectAll();
})
Expand Down

0 comments on commit 152b0b2

Please sign in to comment.