diff --git a/src/admin-lot-edit/admin-lot-edit.controller.js b/src/admin-lot-edit/admin-lot-edit.controller.js deleted file mode 100644 index a76b28e..0000000 --- a/src/admin-lot-edit/admin-lot-edit.controller.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach - * - * This program is free software: you can redistribute it and/or modify it under the terms - * of the GNU Affero General Public License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - *   - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  - * See the GNU Affero General Public License for more details. You should have received a copy of - * the GNU Affero General Public License along with this program. If not, see - * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  - */ - -(function() { - - 'use strict'; - - /** - * @ngdoc controller - * @name admin-lot-edit.controller:LotEditController - * - * @description - * Provides methods for Edit Lot modal. - */ - angular - .module('admin-lot-edit') - .controller('LotEditController', LotEditController); - - LotEditController.$inject = [ - '$state', - 'loadingModalService', - 'notificationService', - 'confirmService', - 'stateTrackerService', - 'LotResource', - 'lot' - ]; - - function LotEditController( - $state, - loadingModalService, - notificationService, - confirmService, - stateTrackerService, - LotResource, - lot - ) { - var vm = this; - - vm.$onInit = onInit; - vm.editLot = editLot; - vm.goToPreviousState = stateTrackerService.goToPreviousState; - - /** - * @ngdoc property - * @methodOf admin-lot-edit.controller:LotEditController - * @name lot - * @type {Object} - * - * @description - * Current lot - */ - vm.lot = undefined; - - /** - * @ngdoc property - * @methodOf admin-lot-edit.controller:LotEditController - * @name lotResource - * @type {LotResource} - * - * @description - */ - vm.lotResource = undefined; - - /** - * @ngdoc method - * @methodOf admin-lot-edit.controller:LotEditController - * @name $onInit - * - * @description - * Method that is executed on initiating LotEditController. - */ - function onInit() { - vm.lot = lot; - vm.lotResource = new LotResource(); - } - - /** - * @ngdoc property - * @methodOf admin-lot-edit.controller:LotEditController - * @name editLot - * - * @description - */ - function editLot() { - console.log(vm.lot); - confirmService.confirm('adminLotEdit.save.confirmationQuestion', 'adminLotEdit.save') - .then(function() { - loadingModalService.open(); - - vm.lotResource.update(vm.lot).then(function() { - notificationService.success('adminLotEdit.save.success'); - loadingModalService.close(); - stateTrackerService.goToPreviousState(); - }) - .catch(function() { - loadingModalService.close(); - notificationService.error('adminLotEdit.save.failure'); - }); - }); - } - } -})(); \ No newline at end of file diff --git a/src/admin-lot-edit/admin-lot-edit.controller.spec.js b/src/admin-lot-edit/admin-lot-edit.controller.spec.js deleted file mode 100644 index 2dccaab..0000000 --- a/src/admin-lot-edit/admin-lot-edit.controller.spec.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach - * - * This program is free software: you can redistribute it and/or modify it under the terms - * of the GNU Affero General Public License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - *   - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  - * See the GNU Affero General Public License for more details. You should have received a copy of - * the GNU Affero General Public License along with this program. If not, see - * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  - */ - -describe('LotEditController', function() { - - beforeEach(function() { - module('admin-lot-edit'); - - inject(function($injector) { - this.$controller = $injector.get('$controller'); - this.$state = $injector.get('$state'); - this.$rootScope = $injector.get('$rootScope'); - this.$q = $injector.get('$q'); - this.confirmService = $injector.get('confirmService'); - this.loadingModalService = $injector.get('loadingModalService'); - this.notificationService = $injector.get('notificationService'); - - this.LotDataBuilder = $injector.get('LotDataBuilder'); - this.LotResource = $injector.get('LotResource'); - }); - - this.defaultLot = new this.LotDataBuilder().build(); - - spyOn(this.loadingModalService, 'open'); - spyOn(this.loadingModalService, 'close'); - - spyOn(this.notificationService, 'success'); - spyOn(this.notificationService, 'error'); - - this.vm = this.$controller('LotEditController', { - loadingModalService: this.loadingModalService, - notificationService: this.notificationService, - confirmService: this.confirmService, - LotResource: this.LotResource, - lot: this.defaultLot - }); - - this.vm.$onInit(); - }); - - describe('onInit', function() { - - it('should expose editLot method', function() { - expect(typeof this.vm.editLot).toBe('function'); - - }); - - it('should expose lot', function() { - expect(this.vm.lot).toEqual(this.defaultLot); - }); - }); - - describe('editLot', function() { - - it('should not perform update if user does not confirm', function() { - this.confirmDeferred = this.$q.defer(); - spyOn(this.confirmService, 'confirm').andReturn(this.confirmDeferred.promise); - - this.vm.editLot(); - - this.confirmDeferred.reject(); - this.$rootScope.$apply(); - - expect(this.confirmService.confirm).toHaveBeenCalledWith( - 'adminLotEdit.save.confirmationQuestion', - 'adminLotEdit.save' - ); - }); - - it('should update when user confirms', function() { - this.confirmDeferred = this.$q.defer(); - this.updateResultDeferred = this.$q.defer(); - - spyOn(this.confirmService, 'confirm').andReturn(this.confirmDeferred.promise); - spyOn(this.vm.lotResource, 'update').andReturn(this.updateResultDeferred.promise); - - this.vm.editLot(); - - this.confirmDeferred.resolve(); - this.updateResultDeferred.resolve(); - this.$rootScope.$apply(); - - expect(this.confirmService.confirm).toHaveBeenCalledWith( - 'adminLotEdit.save.confirmationQuestion', - 'adminLotEdit.save' - ); - - expect(this.vm.lotResource.update).toHaveBeenCalled(); - expect(this.notificationService.success).toHaveBeenCalledWith('adminLotEdit.save.success'); - }); - - it('should show error message on failure', function() { - this.confirmDeferred = this.$q.defer(); - this.updateResultDeferred = this.$q.defer(); - - spyOn(this.confirmService, 'confirm').andReturn(this.confirmDeferred.promise); - spyOn(this.vm.lotResource, 'update').andReturn(this.updateResultDeferred.promise); - - this.vm.editLot(); - - this.confirmDeferred.resolve(); - this.updateResultDeferred.reject(); - this.$rootScope.$apply(); - - expect(this.confirmService.confirm).toHaveBeenCalledWith( - 'adminLotEdit.save.confirmationQuestion', - 'adminLotEdit.save' - ); - - expect(this.vm.lotResource.update).toHaveBeenCalled(); - expect(this.notificationService.error).toHaveBeenCalledWith('adminLotEdit.save.failure'); - }); - }); -}); diff --git a/src/admin-lot-edit/admin-lot-edit.module.js b/src/admin-lot-edit/admin-lot-edit.module.js deleted file mode 100644 index d11d5bd..0000000 --- a/src/admin-lot-edit/admin-lot-edit.module.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach - * - * This program is free software: you can redistribute it and/or modify it under the terms - * of the GNU Affero General Public License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - *   - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  - * See the GNU Affero General Public License for more details. You should have received a copy of - * the GNU Affero General Public License along with this program. If not, see - * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  - */ - -(function() { - - 'use strict'; - - /** - * @module admin-lot-edit - * - * @description - * Provides lot edit modal. - */ - angular.module('admin-lot-edit', [ - 'openlmis-modal', - 'openlmis-templates', - 'openlmis-modal-state', - 'openlmis-state-tracker', - 'openlmis-rights', - 'referencedata-lot' - ]); - -})(); \ No newline at end of file diff --git a/src/admin-lot-edit/admin-lot-edit.routes.js b/src/admin-lot-edit/admin-lot-edit.routes.js deleted file mode 100644 index a96a645..0000000 --- a/src/admin-lot-edit/admin-lot-edit.routes.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This program is part of the OpenLMIS logistics management information system platform software. - * Copyright © 2017 VillageReach - * - * This program is free software: you can redistribute it and/or modify it under the terms - * of the GNU Affero General Public License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - *   - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  - * See the GNU Affero General Public License for more details. You should have received a copy of - * the GNU Affero General Public License along with this program. If not, see - * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org.  - */ - -(function() { - - 'use strict'; - - angular.module('admin-lot-edit').config(routes); - - routes.$inject = ['modalStateProvider', 'ADMINISTRATION_RIGHTS']; - - function routes(modalStateProvider, ADMINISTRATION_RIGHTS) { - modalStateProvider.state('openlmis.administration.lots.edit', { - controller: 'LotEditController', - controllerAs: 'vm', - templateUrl: 'admin-lot-edit/lot-edit.html', - url: '/edit/:lotId', - accessRights: [ADMINISTRATION_RIGHTS.LOTS_MANAGE], - resolve: { - lot: function($stateParams, alertService, stateTrackerService, LotResource) { - return new LotResource().get($stateParams.lotId) - .then(function(response) { - return response; - }) - .catch(function() { - alertService.error('adminLotsEdit.lotNotFound'); - stateTrackerService.goToPreviousState(); - }); - } - }, - parentResolves: [] - }); - } -})(); \ No newline at end of file diff --git a/src/admin-lot-edit/lot-edit.html b/src/admin-lot-edit/lot-edit.html index 27254f3..648b3f4 100644 --- a/src/admin-lot-edit/lot-edit.html +++ b/src/admin-lot-edit/lot-edit.html @@ -38,4 +38,4 @@

{{'adminLotEdit.editLot.title' | message:({lot: vm.lot.lotCode})}}

- \ No newline at end of file + diff --git a/src/admin-lot-edit/messages_en.json b/src/admin-lot-edit/messages_en.json index acaa07f..b330b3a 100644 --- a/src/admin-lot-edit/messages_en.json +++ b/src/admin-lot-edit/messages_en.json @@ -11,4 +11,4 @@ "adminLotEdit.save.success": "Lot saved successfully", "adminLotEdit.save.failure": "Failed to save lot", "adminLotEdit.quarantined": "Quarantined" -} \ No newline at end of file +} diff --git a/src/admin-lot-list/admin-lot-list.routes.js b/src/admin-lot-list/admin-lot-list.routes.js index 4c7fd26..874fd9a 100644 --- a/src/admin-lot-list/admin-lot-list.routes.js +++ b/src/admin-lot-list/admin-lot-list.routes.js @@ -27,7 +27,7 @@ showInNavigation: true, label: 'adminLotList.lots', // ANGOLASUP-715: Filtering by lot code - url: '/lots?orderableId&quarantined&expirationDateFrom&expirationDateTo&lotCode&page&size&sort', + url: '/lots?orderableId&expirationDateFrom&expirationDateTo&lotCode&page&size&sort', // ANGOLASUP-715: Ends here controller: 'LotListController', templateUrl: 'admin-lot-list/lot-list.html', @@ -35,12 +35,8 @@ accessRights: [ADMINISTRATION_RIGHTS.LOTS_MANAGE], resolve: { paginatedLots: function($q, $stateParams, paginationService, lotService) { - return paginationService.registerUrl($stateParams, function() { - if ($stateParams.quarantined === undefined) { - $stateParams.quarantined = 'true'; - } - - var params = angular.copy($stateParams); + return paginationService.registerUrl($stateParams, function(stateParams) { + var params = angular.copy(stateParams); params.tradeItemIdIgnored = true; @@ -68,6 +64,7 @@ ? noProductMsg : orderable.fullProductName, lotCode: lot.lotCode, + quarantined: lot.quarantined, expirationDate: lot.expirationDate, manufacturedDate: lot.manufactureDate, id: lot.id diff --git a/src/admin-lot-list/lot-list.controller.js b/src/admin-lot-list/lot-list.controller.js index 29af70f..01ba439 100644 --- a/src/admin-lot-list/lot-list.controller.js +++ b/src/admin-lot-list/lot-list.controller.js @@ -97,17 +97,6 @@ vm.lotCode = null; // ANGOLASUP-715: Ends here - /** - * @ngdoc property - * @propertyOf admin-lot-list.controller:LotListController - * @name showQuarantined - * @type {String} - * - * @description - * Indicates if quarantined lots should be visible - */ - vm.showQuarantined = undefined; - /** * @ngdoc property * @propertyOf admin-lot-list.controller:LotListController @@ -130,7 +119,6 @@ stateParams.orderableId = vm.orderableId; stateParams.expirationDateFrom = vm.expirationDateFrom; stateParams.expirationDateTo = vm.expirationDateTo; - stateParams.quarantined = vm.showQuarantined; // ANGOLASUP-715: Filtering by lot code stateParams.lotCode = vm.lotCode; // ANGOLASUP-715: Ends here @@ -152,7 +140,6 @@ vm.lots = lots; vm.orderables = orderables; - vm.showQuarantined = $stateParams.quarantined; vm.orderableId = $stateParams.orderableId; vm.expirationDateFrom = $stateParams.expirationDateFrom; vm.expirationDateTo = $stateParams.expirationDateTo; @@ -193,8 +180,9 @@ header: 'adminLotList.isQuarantined', propertyPath: 'quarantined', sortable: false, - //TODO: Icon should appear if quarantined is true - template: '' + template: function(lot) { + return ''; + } } ], actions: { diff --git a/src/admin-lot-list/lot-list.html b/src/admin-lot-list/lot-list.html index 7833a42..307cc57 100644 --- a/src/admin-lot-list/lot-list.html +++ b/src/admin-lot-list/lot-list.html @@ -1,12 +1,6 @@

{{'adminLotList.lots' | message}}

-
- -