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

This commit is contained in:
CJ Cenizal 2017-02-15 13:19:30 -08:00
parent 9b447c53c1
commit d2483ad4db
4 changed files with 20 additions and 12 deletions

View file

@ -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">

View file

@ -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();
});
@ -57,6 +60,7 @@ export function DashboardListingController($injector, $scope) {
selectedItems = this.pageOfItems.slice(0);
};
this.isFetchingItems = false;
this.items = [];
this.pageOfItems = [];
this.filter = '';
@ -65,7 +69,7 @@ export function DashboardListingController($injector, $scope) {
$scope.$watch(() => this.filter, () => {
deselectAll();
fetchObjects();
fetchItems();
});
/**
@ -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();
})

View file

@ -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">

View file

@ -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 = () => {
@ -58,6 +61,7 @@ export function VisualizeListingController($injector, $scope) {
selectedItems = this.pageOfItems.slice(0);
};
this.isFetchingItems = false;
this.items = [];
this.pageOfItems = [];
this.filter = '';
@ -66,7 +70,7 @@ export function VisualizeListingController($injector, $scope) {
$scope.$watch(() => this.filter, () => {
deselectAll();
fetchObjects();
fetchItems();
});
/**
@ -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();
})