Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO-870: Create a UI module to manage mailing list for facility syncho report #151

Merged
merged 5 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 src/admin-integration-email-add/admin-integration-email-add.html
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>
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'
]);

})();
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;
}
}
});
}
})();
13 changes: 13 additions & 0 deletions src/admin-integration-email-add/messages_en.json
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"
}
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 src/admin-integration-email-list/admin-integration-email-list.html
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>
Loading
Loading