-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO-870: Create a UI module to manage mailing list for facility syncho…
… report (#151) * AO-870: Added component to manage integration emails * AO-870: added correct url, little corrections * wip * AO-870: Changed url * AO-870: Added one-time bindings --------- Co-authored-by: Jan <[email protected]>
- Loading branch information
1 parent
aefa68f
commit fa4fcd3
Showing
11 changed files
with
561 additions
and
0 deletions.
There are no files selected for viewing
148 changes: 148 additions & 0 deletions
148
src/admin-integration-email-add/admin-integration-email-add.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* | ||
* 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 [email protected]. | ||
*/ | ||
|
||
(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', '$stateParams', 'email', 'FunctionDecorator', 'integrationEmailService' | ||
]; | ||
|
||
function AdminIntegrationEmailAddController($state, $stateParams, email, FunctionDecorator, | ||
integrationEmailService) { | ||
|
||
var vm = this; | ||
|
||
vm.$onInit = onInit; | ||
vm.saveEmail = saveEmail; | ||
vm.goToEmailList = goToEmailList; | ||
|
||
/** | ||
* @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) | ||
.withConfirm('adminIntegrationEmailAdd.confirm') | ||
.withLoading(true) | ||
.getDecoratedFunction(); | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf admin-integration-email-add.controller:AdminIntegrationEmailAddController | ||
* @name save | ||
* | ||
* @description | ||
* Saves the email address. | ||
*/ | ||
function saveEmail() { | ||
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 goToEmailList | ||
* | ||
* @description | ||
* Redirects user to integration email list screen. | ||
*/ | ||
function goToEmailList() { | ||
var stateParams = angular.copy($stateParams); | ||
$state.go('openlmis.administration.adminIntegrationEmailList', stateParams, { | ||
reload: true | ||
}); | ||
} | ||
} | ||
})(); |
19 changes: 19 additions & 0 deletions
19
src/admin-integration-email-add/admin-integration-email-add.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="modal" role="dialog" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h1>{{:: vm.modalHeaderKey | message}}</h1> | ||
</div> | ||
<div class="modal-body"> | ||
<form id="admin-integration-email-add-form" ng-submit="vm.saveEmail()"> | ||
<label for="code">{{:: 'adminIntegrationEmailAdd.emailName' | message}}</label> | ||
<input id="code" class="form-control" ng-model="vm.email.email" required/> | ||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button id="cancel" ng-click="vm.goToEmailList()">{{:: 'adminIntegrationEmailAdd.cancel' | message}}</button> | ||
<button class="primary" type="submit" form="admin-integration-email-add-form">{{:: 'adminIntegrationEmailAdd.save' | message}}</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
35 changes: 35 additions & 0 deletions
35
src/admin-integration-email-add/admin-integration-email-add.module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 [email protected]. | ||
*/ | ||
|
||
(function() { | ||
|
||
'use strict'; | ||
|
||
/** | ||
* @module admin-integration-email-add | ||
* | ||
* @description | ||
* Provides a modal for adding new integration emails | ||
*/ | ||
angular.module('admin-integration-email-add', [ | ||
'openlmis-function-decorator', | ||
'openlmis-i18n', | ||
'ui.router', | ||
'openlmis-modal', | ||
'openlmis-state-tracker', | ||
'openlmis-pagination' | ||
]); | ||
|
||
})(); |
43 changes: 43 additions & 0 deletions
43
src/admin-integration-email-add/admin-integration-email-add.routes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 [email protected]. | ||
*/ | ||
|
||
(function() { | ||
|
||
'use strict'; | ||
|
||
angular | ||
.module('admin-integration-email-add') | ||
.config(routes); | ||
|
||
routes.$inject = ['$stateProvider', 'modalStateProvider']; | ||
|
||
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', | ||
resolve: { | ||
email: function($stateParams, emails) { | ||
var email = _.findWhere(emails, { | ||
id: $stateParams.emailId | ||
}); | ||
return email; | ||
} | ||
} | ||
}); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"adminIntegrationEmailAdd.addEmail": "Add e-mail", | ||
"adminIntegrationEmailAdd.editEmail": "Edit e-mail", | ||
"adminIntegrationEmailAdd.active": "Active", | ||
"adminIntegrationEmailAdd.emailName": "E-mail Name", | ||
"adminIntegrationEmailAdd.save": "Save", | ||
"adminIntegrationEmailAdd.cancel": "Cancel", | ||
"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" | ||
} |
88 changes: 88 additions & 0 deletions
88
src/admin-integration-email-list/admin-integration-email-list.controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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 [email protected]. | ||
*/ | ||
|
||
(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', '$stateParams', 'emails', 'FunctionDecorator', 'integrationEmailService']; | ||
|
||
function controller($state, $stateParams, emails, 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 = undefined; | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf admin-integration-email-list.controller:AdminIntegrationEmailListController | ||
* @name $onInit | ||
* | ||
* @description | ||
* Initializes controller | ||
*/ | ||
function onInit() { | ||
vm.emails = emails; | ||
} | ||
|
||
/** | ||
* @ngdoc method | ||
* @methodOf admin-integration-email-list.controller:AdminIntegrationEmailListController | ||
* @name removeEmail | ||
* | ||
* @description | ||
* Remove the integration email. | ||
*/ | ||
function removeEmail(email) { | ||
return integrationEmailService.remove(email.email.id) | ||
.then(function() { | ||
var stateParams = angular.copy($stateParams); | ||
$state.go('openlmis.administration.adminIntegrationEmailList', stateParams, { | ||
reload: true | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
})(); |
31 changes: 31 additions & 0 deletions
31
src/admin-integration-email-list/admin-integration-email-list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<h2>{{'adminIntegrationEmailList.header' | message}}</h2> | ||
<section class="openlmis-table-container"> | ||
<button id="add-email" class="add" ui-sref="openlmis.administration.adminIntegrationEmailList.add"> | ||
{{:: 'adminIntegrationEmailList.addEmail' | message}} | ||
</button> | ||
<table> | ||
<caption ng-if="vm.emails.length === 0"> | ||
{{:: 'adminIntegrationEmailList.noEmails' | message}} | ||
</caption> | ||
<thead> | ||
<tr> | ||
<th>{{:: 'adminIntegrationEmailList.name' | message}}</th> | ||
<th>{{:: 'adminIntegrationEmailList.actions' | message}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="email in vm.emails"> | ||
<td>{{:: email.email}}</td> | ||
<td> | ||
<button class="primary" ui-sref="openlmis.administration.adminIntegrationEmailList.add({emailId: email.id})"> | ||
{{:: 'adminIntegrationEmailList.edit' | message}} | ||
</button> | ||
<button class="danger" ng-click="vm.removeEmail({email})"> | ||
{{:: 'adminOrderableEdit.remove' | message}} | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<openlmis-pagination/> | ||
</section> |
Oops, something went wrong.