Skip to content

Commit

Permalink
fix(Inventory): adding loading indicator into the inventory list (#1991)
Browse files Browse the repository at this point in the history
* Fix(Invetory): adding loading indicator into the inventory list
* fixing the exception message, closes #1918

* using promise's structure before setting loading state to false
  • Loading branch information
jeremielodi authored and jniles committed Aug 17, 2017
1 parent 5bf9d92 commit 360b68a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 10 additions & 4 deletions client/src/modules/inventory/list/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<li role="separator" class="divider"></li>
<li role="menuitem">
<a ng-href="/reports/inventory/items/?params={{ InventoryCtrl.parameters }}&lang={{ InventoryCtrl.lang }}"
<a ng-href="/reports/inventory/items/?params={{ InventoryCtrl.parameters }}&lang={{ InventoryCtrl.lang }}"
download="{{ 'INVENTORY.PRICE_LIST_REPORT' | translate }}">
<span class="fa fa-file-pdf-o"></span> <span translate>DOWNLOADS.PDF</span>
</a>
Expand All @@ -57,7 +57,7 @@
data-method="filter">
<i class="fa fa-filter"></i>
</button>

<a
class="btn btn-default text-capitalize"
ui-sref="inventory.create"
Expand All @@ -72,7 +72,7 @@
id="research">
<i class="fa fa-search"></i> <span translate>FORM.BUTTONS.SEARCH</span>
</button>
</div>
</div>
</div>

</div>
Expand All @@ -86,7 +86,6 @@
</bh-filters>
</div>


<!-- grid content -->
<div class="flex-content">
<div class="container-fluid">
Expand All @@ -99,6 +98,13 @@
ui-grid-exporter
ui-grid-auto-resize
ui-grid-resize-columns>

<bh-grid-loading-indicator
loading-state="InventoryCtrl.loading"
empty-state="InventoryCtrl.gridOptions.data.length === 0"
error-state="InventoryCtrl.hasError">
</bh-grid-loading-indicator>

</div>
</div>
</div>
16 changes: 15 additions & 1 deletion client/src/modules/inventory/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function InventoryListController($translate, Inventory, Notify, uiGridConstants,
vm.gridOptions = {};
vm.gridApi = {};

vm.loading = true;


// grid default options
columnDefs = [
{ field : 'code',
Expand Down Expand Up @@ -138,20 +141,31 @@ function InventoryListController($translate, Inventory, Notify, uiGridConstants,
}

function runResearch(params) {

if (params) {
search.assignFilters(params);
vm.latestViewFilters = search.latestViewFilters();
vm.hasCustomFilters = search.hasCustomFilters();
vm.parameters = JSON.stringify(params);
}

vm.loading = true;
vm.hasError = false;

Inventory.read(null, params)
.then(function (rows) {
vm.gridOptions.data = rows;
})
.catch(Notify.handleError);
.catch(function (exception) {
vm.hasError = true;
Notify.handleError(exception);
})
.finally(function () {
vm.loading = false; // this will execute after the data is downloaded.
});
}


// research and filter data in Inventory List
function research() {
Inventory.openSearchModal()
Expand Down

0 comments on commit 360b68a

Please sign in to comment.