-
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.
ANGOLASUP-859: Add whole functionality to embedded report categories.
- Loading branch information
mdulko
committed
Jun 5, 2024
1 parent
4517ce8
commit 4d3400b
Showing
16 changed files
with
507 additions
and
13 deletions.
There are no files selected for viewing
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
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
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,7 @@ | ||
{ | ||
"adminEmbeddedReportCategoryAdd.title": "Add Embedded Report Category", | ||
"adminEmbeddedReportCategoryAdd.name": "Name", | ||
"adminEmbeddedReportCategoryAdd.add": "Add", | ||
"adminEmbeddedReportCategoryAdd.cancel": "Cancel", | ||
"adminEmbeddedReportCategoryAdd.fieldRequired": "This field is required" | ||
} |
82 changes: 82 additions & 0 deletions
82
src/report-embedded-category-add/report-embedded-category-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,82 @@ | ||
/* | ||
* 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 report-embedded-category-add.controller:ReportEmbeddedCategoryAddController | ||
* | ||
* @description | ||
* Allows user to add new embedded report category | ||
*/ | ||
angular | ||
.module('report-embedded-category-add') | ||
.controller('ReportEmbeddedCategoryAddController', ReportEmbeddedCategoryAddController); | ||
|
||
ReportEmbeddedCategoryAddController.$inject = ['reportEmbeddedService', 'loadingModalService', '$state']; | ||
|
||
function ReportEmbeddedCategoryAddController(reportEmbeddedService, loadingModalService, $state) { | ||
var vm = this; | ||
|
||
vm.goBack = goBack; | ||
vm.add = add; | ||
vm.validateField = validateField; | ||
vm.invalidFields = new Set(); | ||
vm.category = {}; | ||
|
||
function add() { | ||
loadingModalService.open(); | ||
|
||
if (validateAddReport()) { | ||
reportEmbeddedService.addReportCategory(vm.category) | ||
.then(function() { | ||
$state.go('openlmis.administration.embeddedReportsCategoriesList', {}, { | ||
reload: true | ||
}); | ||
}); | ||
} else { | ||
loadingModalService.close(); | ||
} | ||
} | ||
|
||
function goBack() { | ||
window.history.back(); | ||
} | ||
|
||
function validateAddReport() { | ||
var fieldsToValidate = ['name']; | ||
fieldsToValidate.forEach(function(fieldName) { | ||
validateField(vm.category[fieldName], fieldName); | ||
}); | ||
|
||
return vm.invalidFields.size === 0; | ||
} | ||
|
||
function isNotEmpty(value) { | ||
return !!value; | ||
} | ||
|
||
function validateField(value, fieldName) { | ||
var isValid = isNotEmpty(value); | ||
|
||
if (vm.invalidFields.has(fieldName) && isValid) { | ||
vm.invalidFields.delete(fieldName); | ||
} else if (!isValid) { | ||
vm.invalidFields.add(fieldName); | ||
} | ||
} | ||
} | ||
})(); |
42 changes: 42 additions & 0 deletions
42
src/report-embedded-category-add/report-embedded-category-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,42 @@ | ||
<div class="modal" role="dialog" aria-hidden="true"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h2>{{:: 'adminEmbeddedReportCategoryAdd.title' | message}}</h2> | ||
</div> | ||
<div class="modal-body"> | ||
<form id="addReport"> | ||
<fieldset class="form-group"> | ||
<label for="name" class="is-required" | ||
>{{:: 'adminEmbeddedReportCategoryAdd.name' | message}}</label | ||
> | ||
<div | ||
class="input-control" | ||
ng-class="{'is-invalid': vm.invalidFields.has('name')}" | ||
> | ||
<input | ||
type="text" | ||
id="name" | ||
style="width: 100%" | ||
ng-model="vm.category.name" | ||
ng-change="vm.validateField(vm.category.name, 'name')" | ||
required | ||
/> | ||
</div> | ||
<ul class="openlmis-invalid" ng-if="vm.invalidFields.has('name')"> | ||
<li>{{'adminEmbeddedReportCategoryAdd.fieldRequired' | message}}</li> | ||
</ul> | ||
</fieldset> | ||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button id="cancel" ng-click="vm.goBack()"> | ||
{{:: 'adminEmbeddedReportCategoryAdd.cancel' | message}} | ||
</button> | ||
<button class="primary" ng-click="vm.add()"> | ||
{{:: 'adminEmbeddedReportCategoryAdd.add' | message}} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
34 changes: 34 additions & 0 deletions
34
src/report-embedded-category-add/report-embedded-category-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,34 @@ | ||
/* | ||
* 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 report-embedded-category-add | ||
* | ||
* @description | ||
* Responsible for add reports screen. | ||
*/ | ||
angular.module('report-embedded-category-add', [ | ||
'ngResource', | ||
'openlmis-i18n', | ||
'openlmis-rights', | ||
'openlmis-urls', | ||
'openlmis-permissions', | ||
'openlmis-pagination', | ||
'ui.router' | ||
]); | ||
})(); |
34 changes: 34 additions & 0 deletions
34
src/report-embedded-category-add/report-embedded-category-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,34 @@ | ||
/* | ||
* 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('report-embedded-category-add') | ||
.config(routes); | ||
|
||
routes.$inject = ['$stateProvider', 'modalStateProvider']; | ||
|
||
function routes($stateProvider, modalStateProvider) { | ||
modalStateProvider.state('openlmis.administration.embeddedReportsCategoriesList.add', { | ||
url: '/add', | ||
label: 'adminEmbeddedReportCategoryAdd.title', | ||
controller: 'ReportEmbeddedCategoryAddController', | ||
controllerAs: 'vm', | ||
templateUrl: 'report-embedded-category-add/report-embedded-category-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,17 @@ | ||
{ | ||
"reportEmbeddedCategoriesList.navRoute": "Embedded Report Categories", | ||
"reportEmbeddedCategoriesList.pageHeader": "Embedded Report Categories", | ||
"reportEmbeddedCategoriesList.noEmbeddedReport": "No Embedded Report Categories found.", | ||
"reportEmbeddedCategoriesList.filter.name": "Name", | ||
"reportEmbeddedCategoriesList.column.name": "Name", | ||
"reportEmbeddedCategoriesList.column.category": "Category", | ||
"reportEmbeddedCategoriesList.column.enabled": "Enabled", | ||
"reportEmbeddedCategoriesList.column.actions": "Actions", | ||
"reportEmbeddedCategoriesList.action.edit": "Edit", | ||
"reportEmbeddedCategoriesList.action.delete": "Delete", | ||
"reportEmbeddedCategoriesList.addEmbeddedReport": "Add Category", | ||
"reportEmbeddedCategoriesList.deleteReport.question": "Are you sure you want to remove ${categoryName} category?", | ||
"reportEmbeddedCategoriesList.delete": "Delete", | ||
"reportEmbeddedCategoriesList.deleteReport.success": "Embedded report category deleted successfully", | ||
"reportEmbeddedCategoriesList.deleteReport.fail": "Failed to delete embedded report category" | ||
} |
Oops, something went wrong.