Skip to content

Commit

Permalink
Merge pull request #103 from OpenLMIS-Angola/feature/OAM-126-2
Browse files Browse the repository at this point in the history
OAM-126: return quarantined lots on initial fetch, add filter
  • Loading branch information
DominikNoga authored May 29, 2024
2 parents d9aaef3 + 5524ebf commit a57c1c4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/admin-lot-list/admin-lot-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
$stateProvider.state('openlmis.administration.lots', {
showInNavigation: true,
label: 'adminLotList.lots',
// ANGOLASUP-715: Filtering by lot code
url: '/lots?orderableId&expirationDateFrom&expirationDateTo&lotCode&page&size&sort',
// ANGOLASUP-715: Ends here
url: '/lots?orderableId&includeQuarantined&expirationDateFrom&expirationDateTo&lotCode&page&size&sort',
controller: 'LotListController',
templateUrl: 'admin-lot-list/lot-list.html',
controllerAs: 'vm',
accessRights: [ADMINISTRATION_RIGHTS.LOTS_MANAGE],
resolve: {
paginatedLots: function($q, $stateParams, paginationService, lotService) {
if (!$stateParams.includeQuarantined && $stateParams.includeQuarantined !== 'false') {
$stateParams.includeQuarantined = 'true';
}

return paginationService.registerUrl($stateParams, function(stateParams) {
var params = angular.copy(stateParams);

Expand Down
6 changes: 4 additions & 2 deletions src/admin-lot-list/admin-lot-list.routes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ describe('openlmis.administration.lot state', function() {
page: 0,
size: 10,
tradeItemIdIgnored: true,
expirationDateFrom: '1970-01-01'
expirationDateFrom: '1970-01-01',
includeQuarantined: 'true'
});

expect(paginatedLots.length).toEqual(1);
Expand All @@ -139,7 +140,8 @@ describe('openlmis.administration.lot state', function() {
page: 0,
size: 10,
tradeItemIdIgnored: true,
expirationDateTo: '1970-01-01'
expirationDateTo: '1970-01-01',
includeQuarantined: 'true'
});

expect(paginatedLots.length).toEqual(1);
Expand Down
12 changes: 12 additions & 0 deletions src/admin-lot-list/lot-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
*/
vm.orderables = [];

/**
* @ngdoc property
* @propertyOf admin-lot-list.controller:LotListController
* @name includeQuarantined
*
* @description
* Include quarantined lots in the list. By default, quarantined lots are included.
*/
vm.includeQuarantined = undefined;

/**
* @ngdoc property
* @propertyOf admin-lot-list.controller:LotListController
Expand Down Expand Up @@ -116,6 +126,7 @@
vm.search = function() {
var stateParams = angular.copy($stateParams);

stateParams.includeQuarantined = vm.includeQuarantined;
stateParams.orderableId = vm.orderableId;
stateParams.expirationDateFrom = vm.expirationDateFrom;
stateParams.expirationDateTo = vm.expirationDateTo;
Expand All @@ -140,6 +151,7 @@
vm.lots = lots;
vm.orderables = orderables;

vm.includeQuarantined = $stateParams.includeQuarantined;
vm.orderableId = $stateParams.orderableId;
vm.expirationDateFrom = $stateParams.expirationDateFrom;
vm.expirationDateTo = $stateParams.expirationDateTo;
Expand Down
12 changes: 12 additions & 0 deletions src/admin-lot-list/lot-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ <h2>{{'adminLotList.lots' | message}}</h2>
<input type="text" id="lotCode" ng-model="vm.lotCode"/>
</fieldset>
<!-- ANGOLASUP-715: Ends here -->
<fieldset class="form-group">
<label for="includeQuarantined" class="checkbox">
<input
type="checkbox"
id="includeQuarantined"
ng-model="vm.includeQuarantined"
ng-true-value="'true'"
ng-false-value="'false'"
/>
{{:: 'adminLotList.includeQuarantined' | message}}
</label>
</fieldset>
<input type="submit" value="{{'adminLotList.search' | message}}"/>
</form>
<openlmis-table table-config="vm.tableConfig"></openlmis-table>
Expand Down
2 changes: 1 addition & 1 deletion src/admin-lot-list/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"adminLotList.manufacturedDate": "Manufacture Date",
"adminLotList.actions": "Actions",
"adminLotList.edit": "Edit",
"adminLotList.showQuarantined": "Show Quarantined",
"adminLotList.includeQuarantined": "Include Quarantined Lots",
"adminLotList.isQuarantined": "Quarantined"
}

0 comments on commit a57c1c4

Please sign in to comment.