Skip to content

Commit

Permalink
Merge pull request #101 from OpenLMIS-Angola/feature/OAM-127-2
Browse files Browse the repository at this point in the history
OAM-127: show quarantined by default, add checkbox to hide quarantined
  • Loading branch information
DominikNoga authored May 27, 2024
2 parents c059873 + f6c5767 commit d7e7c5f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/admin-orderable-list/admin-orderable-list.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$stateProvider.state('openlmis.administration.orderables', {
showInNavigation: true,
label: 'adminOrderableList.products',
url: '/orderables?code&name&description&program&page&size&sort',
url: '/orderables?code&includeQuarantined&name&description&program&page&size&sort',
controller: 'OrderableListController',
templateUrl: 'admin-orderable-list/orderable-list.html',
controllerAs: 'vm',
Expand All @@ -40,8 +40,12 @@
return new ProgramResource().query();
},
orderables: function(paginationService, OrderableResource, $stateParams) {
return paginationService.registerUrl($stateParams, function(stateParams) {
return new OrderableResource().query(stateParams);
return paginationService.registerUrl($stateParams, function() {
if (!$stateParams.includeQuarantined && $stateParams.includeQuarantined !== 'false') {
$stateParams.includeQuarantined = 'true';
}

return new OrderableResource().query($stateParams);
});
},
canAdd: function(authorizationService, permissionService, ADMINISTRATION_RIGHTS) {
Expand Down
2 changes: 1 addition & 1 deletion src/admin-orderable-list/messages_en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"adminOrderableList.export": "Export",
"adminOrderableList.showQuarantined": "Show Quarantined",
"adminOrderableList.includeQuarantined": "Include Quarantined Products",
"adminOrderableList.isQuarantined": "Quarantined"
}
12 changes: 12 additions & 0 deletions src/admin-orderable-list/orderable-list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
*/
vm.programs = undefined;

/**
* @ngdoc property
* @propertyOf admin-orderable-list.controller:OrderableListController
* @name includeQuarantined
*
* @description
* Contains flag for including quarantined orderables. By default, quarantined products are listed.
*/
vm.includeQuarantined = undefined;

/**
* @ngdoc property
* @propertyOf admin-orderable-list.controller:OrderableListController
Expand Down Expand Up @@ -118,6 +128,7 @@
vm.code = $stateParams.code;
vm.name = $stateParams.name;
vm.program = $stateParams.program;
vm.includeQuarantined = $stateParams.includeQuarantined;

vm.canAdd = canAdd;
vm.tableConfig = getTableConfig();
Expand All @@ -137,6 +148,7 @@
stateParams.code = vm.code;
stateParams.name = vm.name;
stateParams.program = vm.program;
stateParams.includeQuarantined = vm.includeQuarantined;

$state.go('openlmis.administration.orderables', stateParams, {
reload: true
Expand Down
6 changes: 6 additions & 0 deletions src/admin-orderable-list/orderable-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ <h2>{{'adminOrderableList.products' | message}}</h2>
ng-model="vm.program">
</select>
</fieldset>
<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'" />
{{:: 'adminOrderableList.includeQuarantined' | message}}
</label>
</fieldset>
<input type="submit" value="{{'adminOrderableList.search' | message}}"/>
</form>
<openlmis-table table-config="vm.tableConfig"></openlmis-table>
Expand Down

0 comments on commit d7e7c5f

Please sign in to comment.