forked from FITER1/community-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FBR-75 Refactor the creation of a center and added the ability to edit an existing center (#9) Co-authored-by: Leonardo Hildt <[email protected]> * FBR-102 Como líder de Agencia, quiero crear uno o mas grupos (#10) Co-authored-by: Leonardo Hildt <[email protected]> * FBR-102 - Fix edition of Portfolio (#11) Co-authored-by: Leonardo Hildt <[email protected]> * FBR-101 - Necesito trasladar grupos a otro centro (#12) Co-authored-by: Leonardo Hildt <[email protected]> * FBR-101 Fix parameter validation (#13) Co-authored-by: Leonardo Hildt <[email protected]> --------- Co-authored-by: Leonardo Hildt <[email protected]>
- Loading branch information
1 parent
abbdf0c
commit e929e39
Showing
18 changed files
with
892 additions
and
57 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
56 changes: 56 additions & 0 deletions
56
app/scripts/controllers/organization/CreateCenterGroupController.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,56 @@ | ||
(function (module) { | ||
mifosX.controllers = _.extend(module, { | ||
CreateCenterGroupController: function (scope, routeParams, resourceFactory, location, dateFilter) { | ||
scope.formData = {}; | ||
scope.parentOfficesOptions = []; | ||
scope.responsibleUserOptions = []; | ||
scope.statusOptions = []; | ||
scope.portfolioCenterOptions = []; | ||
scope.tf = "HH:mm"; | ||
let portfolioId = routeParams.portfolioId | ||
let portfolioCenterId = routeParams.portfolioCenterId; | ||
|
||
resourceFactory.portfolioCenterByCurrentUserResource.get({portfolioId:portfolioId},function(data) | ||
{ | ||
scope.portfolioCenterOptions = data; | ||
}); | ||
|
||
resourceFactory.centerGroupTemplateResource.get({portfolioCenterId:portfolioCenterId}, function (data) { | ||
scope.parentOfficesOptions = data.parentOfficesOptions; | ||
scope.responsibleUserOptions = data.responsibleUserOptions; | ||
scope.statusOptions = data.statusOptions; | ||
scope.formData = { | ||
portfolioCenterId: parseInt(portfolioCenterId), | ||
portfolioId: parseInt(portfolioId) | ||
} | ||
}); | ||
|
||
scope.submit = function () { | ||
// remove extra fields from form data | ||
delete this.formData.parentName; | ||
delete this.formData.status; | ||
delete this.formData.responsibleUserName; | ||
delete this.formData.portfolioId; | ||
|
||
this.formData.locale = scope.optlang.code; | ||
this.formData.dateFormat = scope.df; | ||
|
||
this.formData.formationDate = dateFilter(scope.formData.formationDate, scope.df); | ||
|
||
if (scope.formData.meetingStartTime) { | ||
this.formData.meetingStartTime = dateFilter(scope.formData.meetingStartTime, scope.tf); | ||
} | ||
if (scope.formData.meetingEndTime) { | ||
this.formData.meetingEndTime = dateFilter(scope.formData.meetingEndTime, scope.tf); | ||
} | ||
|
||
resourceFactory.centerGroupResource.save({'portfolioId': portfolioId, 'portfolioCenterId': portfolioCenterId}, this.formData, function (data) { | ||
location.path('/viewcentergroups/' + portfolioId + "/" + portfolioCenterId); | ||
}); | ||
}; | ||
} | ||
}); | ||
mifosX.ng.application.controller('CreateCenterGroupController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', mifosX.controllers.CreateCenterGroupController]).run(function ($log) { | ||
$log.info("CreateCenterGroupController initialized"); | ||
}); | ||
}(mifosX.controllers || {})); |
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
73 changes: 73 additions & 0 deletions
73
app/scripts/controllers/organization/EditCenterGroupController.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,73 @@ | ||
(function (module) { | ||
mifosX.controllers = _.extend(module, { | ||
EditCenterGroupController: function (scope, routeParams, resourceFactory, location, dateFilter) { | ||
scope.formData = {}; | ||
scope.parentOfficesOptions = []; | ||
scope.responsibleUserOptions = []; | ||
scope.statusOptions = []; | ||
scope.portfolioCenterOptions = []; | ||
scope.tf = "HH:mm"; | ||
let portfolioId = routeParams.portfolioId | ||
let portfolioCenterId = routeParams.portfolioCenterId; | ||
let centerGroupId = routeParams.centerGroupId; | ||
|
||
resourceFactory.centerGroupTemplateResource.get({portfolioCenterId:portfolioCenterId}, function (data) { | ||
scope.parentOfficesOptions = data.parentOfficesOptions; | ||
scope.responsibleUserOptions = data.responsibleUserOptions; | ||
scope.statusOptions = data.statusOptions; | ||
}); | ||
|
||
resourceFactory.portfolioCenterByCurrentUserResource.get({portfolioId:portfolioId}, function (data) { | ||
scope.portfolioCenterOptions = data; | ||
}); | ||
|
||
resourceFactory.centerGroupResource.get({portfolioCenterId: portfolioCenterId, centerGroupId:centerGroupId}, function (data) { | ||
scope.formData = data; | ||
scope.formData.statusId = data.status.id; | ||
scope.formData.portfolioId = parseInt(portfolioId); | ||
|
||
if (data.formationDate) { | ||
let formationDate = dateFilter(data.formationDate, scope.df); | ||
scope.formData.formationDate = new Date(formationDate); | ||
} | ||
|
||
var date = new Date(); | ||
if (data.meetingStartTime) { | ||
scope.formData.meetingStartTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), data.meetingStartTime[0], data.meetingStartTime[1], 0); | ||
} | ||
|
||
if (data.meetingEndTime) { | ||
scope.formData.meetingEndTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), data.meetingEndTime[0], data.meetingEndTime[1], 0); | ||
} | ||
}); | ||
|
||
scope.submit = function () { | ||
// remove extra fields from form data | ||
delete this.formData.parentName; | ||
delete this.formData.status; | ||
delete this.formData.portfolioCenterName; | ||
delete this.formData.responsibleUserName; | ||
delete this.formData.portfolioId; | ||
|
||
this.formData.locale = scope.optlang.code; | ||
this.formData.dateFormat = scope.df; | ||
|
||
this.formData.formationDate = dateFilter(scope.formData.formationDate, scope.df); | ||
|
||
if (scope.formData.meetingStartTime) { | ||
this.formData.meetingStartTime = dateFilter(scope.formData.meetingStartTime, scope.tf); | ||
} | ||
if (scope.formData.meetingEndTime) { | ||
this.formData.meetingEndTime = dateFilter(scope.formData.meetingEndTime, scope.tf); | ||
} | ||
|
||
resourceFactory.centerGroupResource.update({'portfolioCenterId':portfolioCenterId, 'centerGroupId': centerGroupId}, this.formData, function (data) { | ||
location.path('/viewcentergroups/' + portfolioId + "/" + portfolioCenterId); | ||
}); | ||
}; | ||
} | ||
}); | ||
mifosX.ng.application.controller('EditCenterGroupController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', mifosX.controllers.EditCenterGroupController]).run(function ($log) { | ||
$log.info("EditCenterGroupController initialized"); | ||
}); | ||
}(mifosX.controllers || {})); |
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
88 changes: 88 additions & 0 deletions
88
app/scripts/controllers/organization/TransferCenterGroupController.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 @@ | ||
(function (module) { | ||
mifosX.controllers = _.extend(module, { | ||
TransferCenterGroupController: function (scope, resourceFactory, route, location, routeParams, $uibModal, dateFilter) { | ||
scope.centersAvailability = []; | ||
scope.tf = "HH:mm"; | ||
let portfolioId = routeParams.portfolioId | ||
let portfolioCenterId = routeParams.portfolioCenterId; | ||
let centerGroupId = routeParams.centerGroupId; | ||
scope.centerData = {}; | ||
|
||
resourceFactory.centerGroupResource.get({portfolioCenterId: portfolioCenterId, centerGroupId:centerGroupId}, function (data) { | ||
scope.centerGroup = data; | ||
|
||
var date = new Date(); | ||
if (data.meetingStartTime) { | ||
scope.centerGroup.meetingStartTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), data.meetingStartTime[0], data.meetingStartTime[1], 0); | ||
} | ||
|
||
if (data.meetingEndTime) { | ||
scope.centerGroup.meetingEndTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), data.meetingEndTime[0], data.meetingEndTime[1], 0); | ||
} | ||
}); | ||
|
||
resourceFactory.portfolioAllCentersAvailabilityResource.get({portfolioId: portfolioId}, function (data) { | ||
let date = new Date(); | ||
for (var i = 0; i < data.length; i++) { | ||
let centerId = data[i].portfolioCenterId; | ||
let centerName = data[i].portfolioCenterName; | ||
let centerTimes = data[i].availableMeetingTimes; | ||
|
||
if (portfolioCenterId != centerId) { | ||
// iterate over available meetings times | ||
for (var j = 0; j < centerTimes.length; j++) { | ||
let meetingTimes = centerTimes[j]; | ||
let availableMeetingStartTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), meetingTimes.meetingStartTime[0], meetingTimes.meetingStartTime[1], 0); | ||
let availableMeetingEndTime = new Date(date.getFullYear(), date.getMonth(), date.getDay(), meetingTimes.meetingEndTime[0], meetingTimes.meetingEndTime[1], 0); | ||
scope.centersAvailability.push({portfolioCenterId: centerId, portfolioCenterName: centerName, meetingStartTime: availableMeetingStartTime, meetingEndTime: availableMeetingEndTime}) | ||
} | ||
} | ||
} | ||
}); | ||
|
||
scope.transferGroup = function (portfolioCenterId, meetingStartTime, meetingEndTime) { | ||
scope.centerData.newPortfolioCenterId = portfolioCenterId; | ||
scope.centerData.meetingStartTime = meetingStartTime; | ||
scope.centerData.meetingEndTime = meetingEndTime; | ||
|
||
$uibModal.open({ | ||
templateUrl: 'transferGroupToCenter.html', | ||
controller: TransferGroupCtrl | ||
}); | ||
} | ||
|
||
var TransferGroupCtrl = function ($scope, $uibModalInstance) { | ||
$scope.transfer = function () { | ||
|
||
if (scope.centerData.meetingStartTime) { | ||
scope.centerData.meetingStartTime = dateFilter(scope.centerData.meetingStartTime, scope.tf); | ||
} | ||
if (scope.centerData.meetingEndTime) { | ||
scope.centerData.meetingEndTime = dateFilter(scope.centerData.meetingEndTime, scope.tf); | ||
} | ||
|
||
resourceFactory.transferCenterGroupResource.transfer({'portfolioCenterId':portfolioCenterId, 'centerGroupId': centerGroupId}, scope.centerData, function (data) { | ||
$uibModalInstance.close('transfer'); | ||
location.path('/viewcentergroups/' + portfolioId + "/" + portfolioCenterId); | ||
}); | ||
}; | ||
$scope.cancel = function () { | ||
$uibModalInstance.dismiss('cancel'); | ||
}; | ||
}; | ||
|
||
scope.submit = function () { | ||
this.formData.locale = scope.optlang.code; | ||
this.formData.dateFormat = scope.df; | ||
this.formData.newPortfolioCenterId = scope.newPortfolioCenterId; | ||
|
||
resourceFactory.transferCenterGroupResource.transfer({'portfolioCenterId':portfolioCenterId, 'centerGroupId': centerGroupId}, this.formData, function (data) { | ||
location.path('/viewcentergroups/' + portfolioId + "/" + portfolioCenterId); | ||
}); | ||
}; | ||
} | ||
}); | ||
mifosX.ng.application.controller('TransferCenterGroupController', ['$scope', 'ResourceFactory', '$route', '$location', '$routeParams', '$uibModal', 'dateFilter', mifosX.controllers.TransferCenterGroupController]).run(function ($log) { | ||
$log.info("TransferCenterGroupController initialized"); | ||
}); | ||
}(mifosX.controllers || {})); |
Oops, something went wrong.