Skip to content

Commit

Permalink
fix(review): Integrate review comments and clean the code
Browse files Browse the repository at this point in the history
The bhGridLoadingIndicator has been updated to support 3 types of message (loading, error, empty)
  • Loading branch information
DedrickEnc committed Oct 24, 2017
1 parent f789a2c commit 02fc1ac
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/src/i18n/en/stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"DETAILS" : "Details",
"DOCUMENT" : "Document",
"DONATION" : "Donation",
"EMPTY" : "No stock found",
"EMPTY" : "You do not have any stock in your depot",
"ENTRY" : "Stock Entry",
"ENTRY_DATE" : "Entry Date",
"ENTRY_DOCUMENT" : "Entry Document",
Expand Down
2 changes: 1 addition & 1 deletion client/src/i18n/fr/stock.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"DETAILS" : "Details",
"DOCUMENT" : "Document",
"DONATION" : "Donation",
"EMPTY" : "Pas de stock trouvé",
"EMPTY" : "Vous n'avez aucun stock dans votre depot",
"ENTRY" : "Entrée de stock",
"ENTRY_DATE" : "Date d'entrée",
"ENTRY_DOCUMENT" : "Document d'entrée",
Expand Down
10 changes: 6 additions & 4 deletions client/src/js/components/bhGridLoadingIndicator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
angular.module('bhima.components')
.component('bhGridLoadingIndicator', {
bindings : {
loadingState : '<',
emptyState : '<',
errorState : '<',
messageState : '<?',
loadingState : '<',
loadingStateMessage : '@?',
emptyState : '<',
emptyStateMessage : '@?',
errorState : '<',
errorStateMessage : '@?',
},
templateUrl : 'modules/templates/bhGridLoadingIndicator.tmpl.html',
});
10 changes: 5 additions & 5 deletions client/src/modules/stock/exit/exit.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="flex-content">
<div class="container-fluid">

<form name="StockForm" bh-submit="StockCtrl.submit(StockForm)" novalidate>
<form name="StockExitForm" bh-submit="StockCtrl.submit(StockExitForm)" novalidate>
<!-- destination -->
<div class="row">
<bh-stock-entry-exit-type
Expand All @@ -58,7 +58,7 @@

<!-- note -->
<div class="form-group"
ng-class="{ 'has-error' : StockForm.$submitted && StockForm.description.$invalid }">
ng-class="{ 'has-error' : StockExitForm.$submitted && StockExitForm.description.$invalid }">
<label class="control-label">
<span translate>FORM.LABELS.DESCRIPTION</span>
</label>
Expand All @@ -70,7 +70,7 @@
ng-maxlength="StockCtrl.maxLength"
required>
</textarea>
<div class="help-block" ng-messages="StockForm.description.$error" ng-show="StockForm.$submitted">
<div class="help-block" ng-messages="StockExitForm.description.$error" ng-show="StockExitForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
Expand Down Expand Up @@ -122,15 +122,15 @@
loading-state="StockCtrl.loading"
empty-state="StockCtrl.selectableInventories.length === 0"
error-state="StockCtrl.hasError"
message-state="StockCtrl.message">
empty-state-message="STOCK.EMPTY">
</bh-grid-loading-indicator>
</div>

<!-- footer -->
<div class="row" style="margin-top: 5px;">
<div class="col-xs-6 col-xs-offset-6">
<div class="text-right">
<button class="btn btn-default" ng-click="StockCtrl.suspend(StockForm)" type="button" translate>
<button class="btn btn-default" ng-click="StockCtrl.suspend(StockExitForm)" type="button" translate>
FORM.BUTTONS.SUSPEND
</button>

Expand Down
2 changes: 0 additions & 2 deletions client/src/modules/stock/exit/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ function StockExitController(
// setting params for grid loading state
vm.loading = true;
vm.hasError = false;
vm.message = 'STOCK.EMPTY';

vm.movement = {
date: new Date(),
Expand All @@ -178,7 +177,6 @@ function StockExitController(
}

function loadInventories(depot) {
// var givenDepot = depot || vm.depot;
setupStock();
Stock.inventories.read(null, { depot_uuid: depot.uuid })
.then(function (inventories) {
Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/templates/bhGridLoadingIndicator.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<!-- indicate that the grid is loading -->
<div class="msg" ng-show="$ctrl.loadingState">
<span><span class="fa fa-circle-o-notch fa-spin"></span> <span translate>TABLE.COLUMNS.LOADING</span></span>
<span><span class="fa fa-circle-o-notch fa-spin"></span> <span translate>{{ $ctrl.loadingStateMessage || 'TABLE.COLUMNS.LOADING' }}</span></span>
</div>

<!-- indicate that there is no data for the requested query -->
<div class="msg" ng-show="!$ctrl.loadingState && $ctrl.emptyState">
<span class="text-info">
<span class="fa fa-info-circle"></span> <span translate>{{ $ctrl.messageState || 'TABLE.COLUMNS.EMPTY' }}</span>
<span class="fa fa-info-circle"></span> <span translate>{{ $ctrl.emptyStateMessage || 'TABLE.COLUMNS.EMPTY' }}</span>
</span>
</div>
</div>
Expand All @@ -17,7 +17,7 @@
<!-- indicate that some error occurred -->
<div class="msg" ng-show="$ctrl.errorState">
<span class="text-danger">
<span class="fa fa-warning"></span> <span translate>ERRORS.UNKNOWN</span>
<span class="fa fa-warning"></span> <span translate>{{ $ctrl.errorStateMessage || 'ERRORS.UNKNOWN' }}</span>
</span>
</div>
</div>

0 comments on commit 02fc1ac

Please sign in to comment.