Skip to content

Commit

Permalink
Merge pull request #178 from OpenLMIS-Angola/ANGOLASUP-918
Browse files Browse the repository at this point in the history
ANGOLASUP-918: product name filter added on requisition page
  • Loading branch information
saleksandra authored Sep 4, 2024
2 parents 467f919 + d81339e commit 7eb048a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

service.$inject = [
'$q', 'programService', 'authorizationService', 'facilityService', 'currentUserService',
'permissionService'
'permissionService', 'loadingModalService'
];

function service($q, programService, authorizationService, facilityService, currentUserService,
permissionService) {
permissionService, loadingModalService) {

var modulesWithRights = {},
facilities = [],
Expand Down Expand Up @@ -162,7 +162,7 @@
*/
function loadData(moduleName) {
var userId = authorizationService.getUser().user_id;

loadingModalService.open();
return $q.all([
facilityService.getFacilitiesWithoutWards(),
programService.getUserPrograms(userId),
Expand All @@ -178,6 +178,7 @@

var currentUserDetails = responses[3];
homeFacility = getFacilityById(currentUserDetails.homeFacilityId);
loadingModalService.close();
});
}

Expand Down
10 changes: 10 additions & 0 deletions src/requisition-view-tab/_requisition-view-tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
flex-direction: row-reverse;
}

.toolbar {
display: flex;
flex-direction: row;
align-items: center !important;

.requisition-indicator {
margin-left: auto;
}
}

.hide-line-item {
@extend button.danger;
@include icon-only('remove');
Expand Down
3 changes: 3 additions & 0 deletions src/requisition-view-tab/messages_en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"requisitionPatientsViewTab.filterPlaceholder": "Filter by product name"
}
16 changes: 15 additions & 1 deletion src/requisition-view-tab/requisition-view-tab.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,16 @@
*/
vm.columns = undefined;

vm.orderableFilterProperties = {
name: undefined
};

vm.filteredItems = undefined;

function onInit() {
vm.lineItems = lineItems;
vm.items = items;
vm.filteredItems = lineItems;
vm.requisition = requisition;
vm.columns = columns;
vm.userCanEdit = canAuthorize || canSubmit || canUnskipRequisitionItemWhenApproving;
Expand Down Expand Up @@ -198,7 +205,7 @@
*
* @description
* Caches given requisition in the local storage.
*
*
* @return {Promise} the promise resolved after adding requisition to the local storage
*/
function cacheRequisition() {
Expand Down Expand Up @@ -384,6 +391,13 @@
return vm.requisition.requisitionLineItems.filter(isSkippedFullSupply).length;
}

vm.filterByOrderableParams = function() {
vm.filteredItems = vm.lineItems.filter(function(item) {
return item.orderable.fullProductName.toLowerCase()
.includes(vm.orderableFilterProperties.name.toLowerCase());
});
};

function getNoProductsMessage() {
return fullSupply ?
'requisitionViewTab.noFullSupplyProducts' :
Expand Down
7 changes: 6 additions & 1 deletion src/requisition-view-tab/requisition-view-tab.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<div class="view-tab openlmis-table-container">
<h4 ng-show="vm.showSkipControls">{{'requisitionViewTab.skip' | message}}</h4>

<ul ng-show="vm.showSkipControls">
<li><a ng-click="vm.requisition.skipAllFullSupplyLineItems()">{{'requisitionViewTab.all' | message}}</a></li>
<li><a ng-click="vm.requisition.unskipAllFullSupplyLineItems()">{{'requisitionViewTab.none' | message}}</a></li>
</ul>
<span ng-if="vm.showAddFullSupplyProductControls">
{{ vm.skippedFullSupplyProductCountMessage() }}
</span>
<div class="productNameFilter">
<input type="text" placeholder="{{ 'requisitionPatientsViewTab.filterPlaceholder' | message}}"
ng-model="vm.orderableFilterProperties.name" ng-change="vm.filterByOrderableParams()">
</div>
<button class="add" ng-if="vm.showAddFullSupplyProductsButton" ng-click="vm.addFullSupplyProducts()" >{{'requisitionViewTab.addProduct' | message}}</button>
<button class="add" ng-if="vm.showAddNonFullSupplyProductsButton" ng-click="vm.addNonFullSupplyProducts()" >{{'requisitionViewTab.addProduct' | message}}</button>
<button class="add" ng-if="vm.showUnskipFullSupplyProductsButton" ng-click="vm.unskipFullSupplyProducts()" >{{'requisitionViewTab.addProduct' | message}}</button>
Expand Down Expand Up @@ -43,7 +48,7 @@ <h4 ng-show="vm.showSkipControls">{{'requisitionViewTab.skip' | message}}</h4>
</tbody>
</table>
<openlmis-pagination
list="vm.lineItems"
list="vm.filteredItems"
paged-list="vm.items"
pagination-id="vm.paginationId"
on-page-change="vm.cacheRequisition"/>
Expand Down

0 comments on commit 7eb048a

Please sign in to comment.