From 20b6a5c1ff5067b89822f31521554988cda6c662 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 11 Jul 2024 10:52:31 +0200 Subject: [PATCH 1/5] AO-870: Added component to manage integration emails --- .../admin-integration-email-add.controller.js | 138 ++++++++++++++++++ .../admin-integration-email-add.html | 19 +++ .../admin-integration-email-add.module.js | 40 +++++ .../admin-integration-email-add.routes.js | 47 ++++++ .../messages_en.json | 15 ++ ...admin-integration-email-list.controller.js | 86 +++++++++++ ...-integration-email-list.controller.spec.js | 58 ++++++++ .../admin-integration-email-list.html | 30 ++++ .../admin-integration-email-list.module.js | 36 +++++ .../admin-integration-email-list.routes.js | 41 ++++++ .../integration-email-data-builder.spec.js | 60 ++++++++ .../integration-email.service.js | 85 +++++++++++ .../messages_en.json | 13 ++ 13 files changed, 668 insertions(+) create mode 100644 src/admin-integration-email-add/admin-integration-email-add.controller.js create mode 100644 src/admin-integration-email-add/admin-integration-email-add.html create mode 100644 src/admin-integration-email-add/admin-integration-email-add.module.js create mode 100644 src/admin-integration-email-add/admin-integration-email-add.routes.js create mode 100644 src/admin-integration-email-add/messages_en.json create mode 100644 src/admin-integration-email-list/admin-integration-email-list.controller.js create mode 100644 src/admin-integration-email-list/admin-integration-email-list.controller.spec.js create mode 100644 src/admin-integration-email-list/admin-integration-email-list.html create mode 100644 src/admin-integration-email-list/admin-integration-email-list.module.js create mode 100644 src/admin-integration-email-list/admin-integration-email-list.routes.js create mode 100644 src/admin-integration-email-list/integration-email-data-builder.spec.js create mode 100644 src/admin-integration-email-list/integration-email.service.js create mode 100644 src/admin-integration-email-list/messages_en.json diff --git a/src/admin-integration-email-add/admin-integration-email-add.controller.js b/src/admin-integration-email-add/admin-integration-email-add.controller.js new file mode 100644 index 0000000..70f8451 --- /dev/null +++ b/src/admin-integration-email-add/admin-integration-email-add.controller.js @@ -0,0 +1,138 @@ +/* + * 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-integration-email-add.controller:AdminIntegrationEmailAddController + * + * @description + * Controller for integration email add screen. + */ + angular + .module('admin-integration-email-add') + .controller('AdminIntegrationEmailAddController', AdminIntegrationEmailAddController); + + AdminIntegrationEmailAddController.$inject = [ + '$state', 'email', 'FunctionDecorator' + ]; + + function AdminIntegrationEmailAddController($state, email, FunctionDecorator) { + + var vm = this; + + vm.$onInit = onInit; + vm.saveEmail = saveEmail; + vm.goToPreviousState = goToPreviousState; + + /** + * @ngdoc property + * @propertyOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name email + * @type {Object} + * + * @description + * Holds email that will be created. + */ + vm.email = undefined; + + /** + * @ngdoc property + * @propertyOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name successNotificationKey + * @type {String} + * + * @description + * Holds successNotificationKey message. + */ + vm.successNotificationKey = email ? 'AdminIntegrationEmailAdd.save.success' : + 'adminIntegrationEmailAdd.create.success'; + + /** + * @ngdoc property + * @propertyOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name errorNotificationKey + * @type {String} + * + * @description + * Holds errorNotificationKey message. + */ + vm.errorNotificationKey = email ? 'adminIntegrationEmailAdd.save.failure' : + 'adminIntegrationEmailAdd.create.failure'; + + /** + * @ngdoc property + * @propertyOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name modalHeaderKey + * @type {String} + * + * @description + * Holds modalHeaderKey message. + */ + vm.modalHeaderKey = email ? 'adminIntegrationEmailAdd.editEmail' : + 'adminIntegrationEmailAdd.addEmail'; + + /** + * @ngdoc property + * @methodOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name onInit + * + * @description + * Initialization method for AdminIntegrationEmailAddController. + */ + function onInit() { + vm.email = email; + vm.saveEmail = new FunctionDecorator() + .decorateFunction(saveEmail) + .withSuccessNotification(vm.successNotificationKey) + .withErrorNotification(vm.errorNotificationKey) + .withLoading(true) + .getDecoratedFunction(); + console.log('email: ', email); + console.log('successNotificationKey: ', vm.successNotificationKey); + } + + /** + * @ngdoc method + * @methodOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name save + * + * @description + * Saves the email address. + */ + function saveEmail() { + // return new OrderableResource() + // .update(vm.email) + // .then(function() { + // goToPreviousState(); + // }); + } + + /** + * @ngdoc property + * @methodOf admin-integration-email-add.controller:AdminIntegrationEmailAddController + * @name goToPreviousState + * + * @description + * Redirects user to integration email list screen. + */ + function goToPreviousState() { + $state.go('openlmis.administration.adminIntegrationEmailList'); + } + } +})(); diff --git a/src/admin-integration-email-add/admin-integration-email-add.html b/src/admin-integration-email-add/admin-integration-email-add.html new file mode 100644 index 0000000..a803940 --- /dev/null +++ b/src/admin-integration-email-add/admin-integration-email-add.html @@ -0,0 +1,19 @@ + diff --git a/src/admin-integration-email-add/admin-integration-email-add.module.js b/src/admin-integration-email-add/admin-integration-email-add.module.js new file mode 100644 index 0000000..e9ce3d5 --- /dev/null +++ b/src/admin-integration-email-add/admin-integration-email-add.module.js @@ -0,0 +1,40 @@ +/* + * 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-integration-email-add + * + * @description + * Provides a modal for adding new integration emails + */ + angular.module('admin-integration-email-add', [ + 'openlmis-admin', + 'openlmis-rights', + 'openlmis-permissions', + 'openlmis-function-decorator', + 'referencedata-program', + 'openlmis-i18n', + 'ui.router', + 'openlmis-modal', + 'openlmis-templates', + 'openlmis-state-tracker', + 'openlmis-modal-state' + ]); + +})(); diff --git a/src/admin-integration-email-add/admin-integration-email-add.routes.js b/src/admin-integration-email-add/admin-integration-email-add.routes.js new file mode 100644 index 0000000..28b3fce --- /dev/null +++ b/src/admin-integration-email-add/admin-integration-email-add.routes.js @@ -0,0 +1,47 @@ +/* + * 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-integration-email-add') + .config(routes); + + routes.$inject = ['$stateProvider', 'modalStateProvider', 'ADMINISTRATION_RIGHTS']; + + function routes($stateProvider, modalStateProvider, ADMINISTRATION_RIGHTS) { + + modalStateProvider.state('openlmis.administration.adminIntegrationEmailList.add', { + controller: 'AdminIntegrationEmailAddController', + controllerAs: 'vm', + url: '/add/:emailId', + templateUrl: 'admin-integration-email-add/admin-integration-email-add.html', + accessRights: [ + ADMINISTRATION_RIGHTS.USERS_MANAGE + ], + resolve: { + email: function($stateParams, emailList) { + var email = _.findWhere(emailList, { + id: $stateParams.emailId + }); + return email; + } + }, + parentResolves: ['emailList'] + }); + } +})(); diff --git a/src/admin-integration-email-add/messages_en.json b/src/admin-integration-email-add/messages_en.json new file mode 100644 index 0000000..fe24734 --- /dev/null +++ b/src/admin-integration-email-add/messages_en.json @@ -0,0 +1,15 @@ +{ + "adminIntegrationEmailAdd.addEmail": "Add Email", + "adminIntegrationEmailAdd.editEmail": "Edit Email", + "adminIntegrationEmailAdd.active": "Active", + "adminIntegrationEmailAdd.emailName": "Email Name", + "adminIntegrationEmailAdd.save": "Save", + "adminIntegrationEmailAdd.cancel": "Cancel", + "adminIntegrationEmailAdd.createProgram.confirm": "Are you sure you want to save \"${email}\" email?", + "adminIntegrationEmailAdd.createProgram.success": "Email created successfully!", + "adminIntegrationEmailAdd.createProgram.failure": "Email creation failed!", + "adminIntegrationEmailAdd.save.success": "Email saved successfully", + "adminIntegrationEmailAdd.create.success": "Email created successfully", + "adminIntegrationEmailAdd.save.failure": "Failed to save email", + "adminIntegrationEmailAdd.create.failure": "Failed to create emial" +} diff --git a/src/admin-integration-email-list/admin-integration-email-list.controller.js b/src/admin-integration-email-list/admin-integration-email-list.controller.js new file mode 100644 index 0000000..32e4ed9 --- /dev/null +++ b/src/admin-integration-email-list/admin-integration-email-list.controller.js @@ -0,0 +1,86 @@ +/* + * 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-integration-email-list.controller:AdminIntegrationEmailListController + * + * @description + * Controller for managing integration email list. + */ + angular + .module('admin-integration-email-list') + .controller('AdminIntegrationEmailListController', controller); + + controller.$inject = ['$state', 'emailList', 'FunctionDecorator', 'integrationEmailService']; + + function controller($state, emailList, FunctionDecorator, integrationEmailService) { + + var vm = this; + vm.$onInit = onInit; + + vm.removeEmail = new FunctionDecorator() + .decorateFunction(removeEmail) + .withSuccessNotification('adminIntegrationEmailList.emailRemovedSuccessfully') + .withErrorNotification('adminIntegrationEmailList.failedToRemoveEmail') + .withConfirm('adminIntegrationEmailList.confirmToRemoveEmail') + .withLoading(true) + .getDecoratedFunction(); + + /** + * @ngdoc property + * @name emails + * @propertyOf admin-integration-email-list.controller:AdminIntegrationEmailListController + * @type {Array} + * + * @description + * Holds list of all integration emials. + */ + vm.emails = []; + + /** + * @ngdoc method + * @methodOf admin-integration-email-list.controller:AdminIntegrationEmailListController + * @name $onInit + * + * @description + * Initializes controller + */ + function onInit() { + vm.emails = emailList; + } + + /** + * @ngdoc method + * @methodOf admin-integration-email-list.controller:AdminIntegrationEmailListController + * @name removeEmail + * + * @description + * Remove the integration email. + */ + function removeEmail(email) { + console.log('email to remove:', email); + return integrationEmailService.remove(email.id) + .then(function() { + $state.reload(); + }); + } + } + +})(); diff --git a/src/admin-integration-email-list/admin-integration-email-list.controller.spec.js b/src/admin-integration-email-list/admin-integration-email-list.controller.spec.js new file mode 100644 index 0000000..2928290 --- /dev/null +++ b/src/admin-integration-email-list/admin-integration-email-list.controller.spec.js @@ -0,0 +1,58 @@ +/* + * 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('AdminIntegrationEmailListController', function() { + +// var $state, $controller, IntegrationEmailDataBuilder, +// vm, emailList; + +// beforeEach(function() { +// module('admin-integration-email-list'); + +// inject(function($injector) { +// $controller = $injector.get('$controller'); +// $state = $injector.get('$state'); +// this.integrationEmailService = $injector.get('integrationEmailService'); +// IntegrationEmailDataBuilder = $injector.get('IntegrationEmailDataBuilder'); +// }); + +// emailList = [ +// new IntegrationEmailDataBuilder().build() +// ]; + +// vm = $controller('AdminIntegrationEmailListController', { +// emailList: emailList +// }); + +// spyOn($state, 'go').andReturn(); +// }); + +// describe('removeEmail', function() { + +// it('should remove email', function() { +// this.vm.removeEmail(this.emailList[0]); +// this.$rootScope.$apply(); + +// expect(this.OrderableResource.prototype.update).toHaveBeenCalledWith(this.emailList[0].id); +// }); + +// it('should redirect to the list view on success', function() { +// this.vm.removeEmail(this.emailList[0]); +// this.$rootScope.$apply(); + +// expect(this.$state.reload).toHaveBeenCalled(); +// }); +// }); +// }); diff --git a/src/admin-integration-email-list/admin-integration-email-list.html b/src/admin-integration-email-list/admin-integration-email-list.html new file mode 100644 index 0000000..ccb93f6 --- /dev/null +++ b/src/admin-integration-email-list/admin-integration-email-list.html @@ -0,0 +1,30 @@ +

{{'adminIntegrationEmailList.header' | message}}

+
+ + + + + + + + + + + + + + + +
+ {{'adminIntegrationEmailList.noEmails' | message}} +
{{'adminIntegrationEmailList.name' | message}}{{'adminIntegrationEmailList.actions' | message}}
{{email.name}} + + +
+
diff --git a/src/admin-integration-email-list/admin-integration-email-list.module.js b/src/admin-integration-email-list/admin-integration-email-list.module.js new file mode 100644 index 0000000..e207d74 --- /dev/null +++ b/src/admin-integration-email-list/admin-integration-email-list.module.js @@ -0,0 +1,36 @@ +/* + * 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-integration-email-list + * + * @description + * Provides integration emails list screen for administrator. + */ + angular.module('admin-integration-email-list', [ + 'openlmis-admin', + 'referencedata-program', + 'ui.router', + 'openlmis-table', + 'openlmis-i18n', + 'openlmis-rights', + 'openlmis-urls', + 'openlmis-permissions' + ]); +})(); diff --git a/src/admin-integration-email-list/admin-integration-email-list.routes.js b/src/admin-integration-email-list/admin-integration-email-list.routes.js new file mode 100644 index 0000000..02001ac --- /dev/null +++ b/src/admin-integration-email-list/admin-integration-email-list.routes.js @@ -0,0 +1,41 @@ +/* + * 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-integration-email-list').config(routes); + + routes.$inject = ['$stateProvider', 'ADMINISTRATION_RIGHTS']; + + function routes($stateProvider, ADMINISTRATION_RIGHTS) { + + $stateProvider.state('openlmis.administration.adminIntegrationEmailList', { + showInNavigation: true, + label: 'adminIntegrationEmailList.integrationEmails', + url: '/integrationEmails', + controller: 'AdminIntegrationEmailListController', + templateUrl: 'admin-integration-email-list/admin-integration-email-list.html', + controllerAs: 'vm', + accessRights: [ADMINISTRATION_RIGHTS.USERS_MANAGE], + resolve: { + emailList: function(programService) { + return programService.getAll(); + } + } + }); + } +})(); diff --git a/src/admin-integration-email-list/integration-email-data-builder.spec.js b/src/admin-integration-email-list/integration-email-data-builder.spec.js new file mode 100644 index 0000000..8d475f5 --- /dev/null +++ b/src/admin-integration-email-list/integration-email-data-builder.spec.js @@ -0,0 +1,60 @@ +/* + * 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-integration-email-list') +// .factory('IntegrationIntegrationEmailDataBuilder', IntegrationEmailDataBuilder); + +// IntegrationEmailDataBuilder.$inject = ['Email']; + +// function IntegrationEmailDataBuilder(Email) { + +// IntegrationEmailDataBuilder.prototype.build = build; +// IntegrationEmailDataBuilder.prototype.withId = withId; +// IntegrationEmailDataBuilder.prototype.withName = withName; + +// return IntegrationEmailDataBuilder; + +// function IntegrationEmailDataBuilder() { +// IntegrationEmailDataBuilder.instanceNumber = (IntegrationEmailDataBuilder.instanceNumber || 0) + 1; + +// this.id = 'email-id-' + IntegrationEmailDataBuilder.instanceNumber; +// this.name = 'test-' + IntegrationEmailDataBuilder.instanceNumber + '@openlmis.com'; +// } + +// function withName(newName) { +// this.name = newName; +// return this; +// } + +// function withId(newId) { +// this.id = newId; +// return this; +// } + +// function build() { +// return new Email( +// this.id, +// this.name +// ); +// } + +// } + +// })(); diff --git a/src/admin-integration-email-list/integration-email.service.js b/src/admin-integration-email-list/integration-email.service.js new file mode 100644 index 0000000..7e4fc90 --- /dev/null +++ b/src/admin-integration-email-list/integration-email.service.js @@ -0,0 +1,85 @@ +/* + * 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-integration-email-list') + .factory('integrationEmailService', service); + + service.$inject = ['openlmisUrlFactory', '$resource']; + + function service(openlmisUrlFactory, $resource) { + + var resource = $resource(openlmisUrlFactory('/api/integrationEmails'), {}, { + get: { + method: 'GET', + url: openlmisUrlFactory('/api/integrationEmails/:id') + }, + getAll: { + method: 'GET', + url: openlmisUrlFactory('/api/integrationEmails') + }, + add: { + method: 'POST', + url: openlmisUrlFactory('/api/integrationEmails') + }, + edit: { + method: 'PUT', + url: openlmisUrlFactory('/api/integrationEmails/:id') + }, + remove: { + method: 'DELETE', + url: openlmisUrlFactory('/api/integrationEmails/:id') + } + }); + + return { + get: get, + getAll: getAll, + add: add, + edit: edit, + remove: remove + }; + + function getAll(searchParams) { + return resource.getAll(searchParams).$promise; + } + + function get(id) { + return resource.get({ + id: id + }).$promise; + } + + function add(report) { + return resource.add(report).$promise; + } + + function edit(report) { + return resource.edit({ + id: report.id + }, report).$promise; + } + + function remove(id) { + return resource.remove({ + id: id + }).$promise; + } + } +})(); \ No newline at end of file diff --git a/src/admin-integration-email-list/messages_en.json b/src/admin-integration-email-list/messages_en.json new file mode 100644 index 0000000..79b8e1a --- /dev/null +++ b/src/admin-integration-email-list/messages_en.json @@ -0,0 +1,13 @@ +{ + "adminIntegrationEmailList.integrationEmails": "SIGECA Integration Emails", + "adminIntegrationEmailList.header": "SIGECA Integration Emails", + "adminIntegrationEmailList.noEmails": "No emails found", + "adminIntegrationEmailList.name": "Name", + "adminIntegrationEmailList.actions": "Actions", + "adminIntegrationEmailList.edit": "Edit", + "adminIntegrationEmailList.addEmail": "Add email", + "adminIntegrationEmailList.delete": "Delete", + "adminIntegrationEmailList.emailRemovedSuccessfully": "Email removed successfully", + "adminIntegrationEmailList.failedToRemoveEmail": "Failed to remove email", + "adminIntegrationEmailList.confirmToRemoveEmail": "Are you sure you want to remove the emial?" +} From c0a63a6fab97eca9a5a632992cdbe5b3c1d2c619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandra=20Ciesi=C5=84ska?= Date: Mon, 15 Jul 2024 10:52:33 +0200 Subject: [PATCH 2/5] AO-870: added correct url, little corrections --- .../admin-integration-email-add.controller.js | 36 +++++++++++-------- .../admin-integration-email-add.html | 4 +-- .../admin-integration-email-add.module.js | 7 +--- .../admin-integration-email-add.routes.js | 14 +++----- .../messages_en.json | 18 +++++----- ...admin-integration-email-list.controller.js | 11 +++--- .../admin-integration-email-list.html | 4 ++- .../admin-integration-email-list.module.js | 7 ++-- .../admin-integration-email-list.routes.js | 16 +++++++-- .../integration-email.service.js | 20 +++++------ .../messages_en.json | 12 +++---- 11 files changed, 80 insertions(+), 69 deletions(-) diff --git a/src/admin-integration-email-add/admin-integration-email-add.controller.js b/src/admin-integration-email-add/admin-integration-email-add.controller.js index 70f8451..a850fdc 100644 --- a/src/admin-integration-email-add/admin-integration-email-add.controller.js +++ b/src/admin-integration-email-add/admin-integration-email-add.controller.js @@ -29,16 +29,16 @@ .controller('AdminIntegrationEmailAddController', AdminIntegrationEmailAddController); AdminIntegrationEmailAddController.$inject = [ - '$state', 'email', 'FunctionDecorator' + '$state', 'email', 'FunctionDecorator', 'integrationEmailService' ]; - function AdminIntegrationEmailAddController($state, email, FunctionDecorator) { + function AdminIntegrationEmailAddController($state, email, FunctionDecorator, integrationEmailService) { var vm = this; vm.$onInit = onInit; vm.saveEmail = saveEmail; - vm.goToPreviousState = goToPreviousState; + vm.goToEmailList = goToEmailList; /** * @ngdoc property @@ -60,7 +60,7 @@ * @description * Holds successNotificationKey message. */ - vm.successNotificationKey = email ? 'AdminIntegrationEmailAdd.save.success' : + vm.successNotificationKey = email ? 'adminIntegrationEmailAdd.save.success' : 'adminIntegrationEmailAdd.create.success'; /** @@ -101,10 +101,9 @@ .decorateFunction(saveEmail) .withSuccessNotification(vm.successNotificationKey) .withErrorNotification(vm.errorNotificationKey) + .withConfirm('adminIntegrationEmailAdd.confirm') .withLoading(true) .getDecoratedFunction(); - console.log('email: ', email); - console.log('successNotificationKey: ', vm.successNotificationKey); } /** @@ -116,23 +115,32 @@ * Saves the email address. */ function saveEmail() { - // return new OrderableResource() - // .update(vm.email) - // .then(function() { - // goToPreviousState(); - // }); + if (email) { + return integrationEmailService + .update(vm.email) + .then(function() { + vm.goToEmailList(); + }); + } + return integrationEmailService + .add(vm.email) + .then(function() { + vm.goToEmailList(); + }); } /** * @ngdoc property * @methodOf admin-integration-email-add.controller:AdminIntegrationEmailAddController - * @name goToPreviousState + * @name goToEmailList * * @description * Redirects user to integration email list screen. */ - function goToPreviousState() { - $state.go('openlmis.administration.adminIntegrationEmailList'); + function goToEmailList() { + $state.go('openlmis.administration.adminIntegrationEmailList', {}, { + reload: true + }); } } })(); diff --git a/src/admin-integration-email-add/admin-integration-email-add.html b/src/admin-integration-email-add/admin-integration-email-add.html index a803940..ac9df5e 100644 --- a/src/admin-integration-email-add/admin-integration-email-add.html +++ b/src/admin-integration-email-add/admin-integration-email-add.html @@ -7,11 +7,11 @@

{{vm.modalHeaderKey | message}}

diff --git a/src/admin-integration-email-add/admin-integration-email-add.module.js b/src/admin-integration-email-add/admin-integration-email-add.module.js index e9ce3d5..7977ffc 100644 --- a/src/admin-integration-email-add/admin-integration-email-add.module.js +++ b/src/admin-integration-email-add/admin-integration-email-add.module.js @@ -24,17 +24,12 @@ * Provides a modal for adding new integration emails */ angular.module('admin-integration-email-add', [ - 'openlmis-admin', - 'openlmis-rights', - 'openlmis-permissions', 'openlmis-function-decorator', - 'referencedata-program', 'openlmis-i18n', 'ui.router', 'openlmis-modal', - 'openlmis-templates', 'openlmis-state-tracker', - 'openlmis-modal-state' + 'openlmis-pagination' ]); })(); diff --git a/src/admin-integration-email-add/admin-integration-email-add.routes.js b/src/admin-integration-email-add/admin-integration-email-add.routes.js index 28b3fce..2d379ef 100644 --- a/src/admin-integration-email-add/admin-integration-email-add.routes.js +++ b/src/admin-integration-email-add/admin-integration-email-add.routes.js @@ -21,27 +21,23 @@ .module('admin-integration-email-add') .config(routes); - routes.$inject = ['$stateProvider', 'modalStateProvider', 'ADMINISTRATION_RIGHTS']; + routes.$inject = ['$stateProvider', 'modalStateProvider']; - function routes($stateProvider, modalStateProvider, ADMINISTRATION_RIGHTS) { + function routes($stateProvider, modalStateProvider) { modalStateProvider.state('openlmis.administration.adminIntegrationEmailList.add', { controller: 'AdminIntegrationEmailAddController', controllerAs: 'vm', url: '/add/:emailId', templateUrl: 'admin-integration-email-add/admin-integration-email-add.html', - accessRights: [ - ADMINISTRATION_RIGHTS.USERS_MANAGE - ], resolve: { - email: function($stateParams, emailList) { - var email = _.findWhere(emailList, { + email: function($stateParams, emails) { + var email = _.findWhere(emails, { id: $stateParams.emailId }); return email; } - }, - parentResolves: ['emailList'] + } }); } })(); diff --git a/src/admin-integration-email-add/messages_en.json b/src/admin-integration-email-add/messages_en.json index fe24734..bbb5a95 100644 --- a/src/admin-integration-email-add/messages_en.json +++ b/src/admin-integration-email-add/messages_en.json @@ -1,15 +1,13 @@ { - "adminIntegrationEmailAdd.addEmail": "Add Email", - "adminIntegrationEmailAdd.editEmail": "Edit Email", + "adminIntegrationEmailAdd.addEmail": "Add e-mail", + "adminIntegrationEmailAdd.editEmail": "Edit e-mail", "adminIntegrationEmailAdd.active": "Active", - "adminIntegrationEmailAdd.emailName": "Email Name", + "adminIntegrationEmailAdd.emailName": "E-mail Name", "adminIntegrationEmailAdd.save": "Save", "adminIntegrationEmailAdd.cancel": "Cancel", - "adminIntegrationEmailAdd.createProgram.confirm": "Are you sure you want to save \"${email}\" email?", - "adminIntegrationEmailAdd.createProgram.success": "Email created successfully!", - "adminIntegrationEmailAdd.createProgram.failure": "Email creation failed!", - "adminIntegrationEmailAdd.save.success": "Email saved successfully", - "adminIntegrationEmailAdd.create.success": "Email created successfully", - "adminIntegrationEmailAdd.save.failure": "Failed to save email", - "adminIntegrationEmailAdd.create.failure": "Failed to create emial" + "adminIntegrationEmailAdd.confirm": "Are you sure you want to save e-mail?", + "adminIntegrationEmailAdd.save.success": "E-mail saved successfully", + "adminIntegrationEmailAdd.create.success": "E-mail created successfully", + "adminIntegrationEmailAdd.save.failure": "Failed to save e-mail", + "adminIntegrationEmailAdd.create.failure": "Failed to create e-mial" } diff --git a/src/admin-integration-email-list/admin-integration-email-list.controller.js b/src/admin-integration-email-list/admin-integration-email-list.controller.js index 32e4ed9..54c1492 100644 --- a/src/admin-integration-email-list/admin-integration-email-list.controller.js +++ b/src/admin-integration-email-list/admin-integration-email-list.controller.js @@ -28,9 +28,9 @@ .module('admin-integration-email-list') .controller('AdminIntegrationEmailListController', controller); - controller.$inject = ['$state', 'emailList', 'FunctionDecorator', 'integrationEmailService']; + controller.$inject = ['$state', 'emails', 'FunctionDecorator', 'integrationEmailService', '$stateParams']; - function controller($state, emailList, FunctionDecorator, integrationEmailService) { + function controller($state, emails, FunctionDecorator, integrationEmailService, $stateParams) { var vm = this; vm.$onInit = onInit; @@ -63,7 +63,9 @@ * Initializes controller */ function onInit() { - vm.emails = emailList; + vm.emails = emails; + console.log(vm.emails); + console.log($stateParams); } /** @@ -75,8 +77,7 @@ * Remove the integration email. */ function removeEmail(email) { - console.log('email to remove:', email); - return integrationEmailService.remove(email.id) + return integrationEmailService.remove(email.email.id) .then(function() { $state.reload(); }); diff --git a/src/admin-integration-email-list/admin-integration-email-list.html b/src/admin-integration-email-list/admin-integration-email-list.html index ccb93f6..68ee98e 100644 --- a/src/admin-integration-email-list/admin-integration-email-list.html +++ b/src/admin-integration-email-list/admin-integration-email-list.html @@ -15,7 +15,7 @@

{{'adminIntegrationEmailList.header' | message}}

- {{email.name}} + {{email.email}} - + + diff --git a/src/admin-integration-email-list/admin-integration-email-list.html b/src/admin-integration-email-list/admin-integration-email-list.html index 8da4a6d..ccbe08d 100644 --- a/src/admin-integration-email-list/admin-integration-email-list.html +++ b/src/admin-integration-email-list/admin-integration-email-list.html @@ -1,27 +1,27 @@

{{'adminIntegrationEmailList.header' | message}}

- - + + - +
- {{'adminIntegrationEmailList.noEmails' | message}} + {{:: 'adminIntegrationEmailList.noEmails' | message}}
{{'adminIntegrationEmailList.name' | message}}{{'adminIntegrationEmailList.actions' | message}}{{:: 'adminIntegrationEmailList.name' | message}}{{:: 'adminIntegrationEmailList.actions' | message}}
{{email.email}}{{:: email.email}}