Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(Invetory): adding loading indicator into the inventory list #1991

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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