Skip to content

Commit

Permalink
Merge pull request #96 from EyeSeeTea/lastbugfixing
Browse files Browse the repository at this point in the history
Lastbugfixing
  • Loading branch information
josemp10 authored Feb 17, 2017
2 parents f443bc7 + acd6793 commit 68a4b7b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 14 deletions.
32 changes: 30 additions & 2 deletions core/dhis2Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,13 @@ Dhis2Api.factory("DataSets", ['$resource', 'commonvariable', function ($resource
return $resource(commonvariable.url + "dataSets/:uid",
{
uid: '@uid',
fields: 'name,id,code,periodType,dataElements,organisationUnits'
fields: ':all'
//fields: 'name,id,code,periodType,dataElements,organisationUnits'
},
{ Get:{method:"GET"},
Post: { method: "POST" },
Put: { method: "PUT" }
Put: { method: "PUT" },
Patch: {method: "PATCH"}
});
}]);

Expand Down Expand Up @@ -330,6 +332,32 @@ Dhis2Api.factory("DataSetsOrgUnit",['$resource','commonvariable', function ($res
DELETE: {method: "DELETE"}});
}]);

Dhis2Api.factory("UserRoles", ['$resource', 'commonvariable', function ($resource, commonvariable) {

return $resource(commonvariable.url + "userRoles/:uid",
{
uid: '@uid'
},
{ Get:{method:"GET"},
Post: { method: "POST" },
Put: { method: "PUT" },
Patch: {method: "PATCH"}
});
}]);


Dhis2Api.factory("DataSetUserRole",['$resource','commonvariable', function ($resource,commonvariable) {

return $resource(commonvariable.url+"userRoles/:uiduserrole/dataSets/:uiddataset",
{
uiduserrole:'@uiduserrole',
uiddataset: '@uiddataset'
},
{ POST: { method: "POST"},
GET: {method: "GET"},
DELETE: {method: "DELETE"}});
}]);

Dhis2Api.factory("OrganisationUnitChildren",['$resource','commonvariable', function ($resource,commonvariable) {
return $resource(commonvariable.url+"organisationUnits/:uid",
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ Dhis2Api.controller("d2ResourcejsondatasetController", ['$scope', '$filter', '$i
}
$scope.editHealtServiceDataset = function () {
angular.forEach($scope.datasetforsave, function (dvalue,dkey) {
DataSets.Put({ uid: dvalue.id }, dvalue)

if (dvalue.code != "DS_DEM"){
DataSets.Put({ uid: dvalue.id }, dvalue)
.$promise.then(function (data) {

if (data.response.status == "SUCCESS") {
Expand All @@ -87,6 +89,7 @@ Dhis2Api.controller("d2ResourcejsondatasetController", ['$scope', '$filter', '$i
$scope.messages.push({ type: "danger", text: $translate('DATASET_NOSAVED') });
}
});
}

});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Dhis2Api.directive('d2Resourcejsonvaccination', function(){
}
});

Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter', '$interval', "commonvariable", "loadjsonresource", "DataElements", "DataSets", "OrgUnit", "validatorService", "Section", "$q",
function ($scope, $filter, $interval, commonvariable, loadjsonresource, DataElements, DataSets, OrgUnit, validatorService, Section, $q) {
Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter', '$interval', "commonvariable", "loadjsonresource", "DataElements", "DataSets", "OrgUnit", "validatorService", "Section", "$q", "UserRoles", "DataSetUserRole",
function ($scope, $filter, $interval, commonvariable, loadjsonresource, DataElements, DataSets, OrgUnit, validatorService, Section, $q, UserRoles, DataSetUserRole) {
$scope.style=[];
var $translate = $filter('translate');

Expand Down Expand Up @@ -86,13 +86,14 @@ Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter',

$scope.GetChildrenOU = function () {
$scope.childOU = [];
OrgUnit.get({ id: commonvariable.OrganisationUnit.id, includeDescendants: true, fields: 'name,id,level,closedDate', filter: 'level:eq:' + commonvariable.level.HealthService })
OrgUnit.get({ id: commonvariable.OrganisationUnit.id, includeDescendants: true, fields: 'name,id,level,closedDate,organisationUnitGroups', filter: 'level:eq:' + commonvariable.level.HealthService })
.$promise.then(function (childOU) {
angular.forEach(childOU.organisationUnits, function (ou, key) {
if(ou.id!=commonvariable.OrganisationUnit.id && ou.closedDate==undefined){
$scope.childOU.push({ id: ou.id });
}

if(ou.id!=commonvariable.OrganisationUnit.id && ou.closedDate==undefined)
angular.forEach(ou.organisationUnitGroups, function (oug, key){
if (oug.code=="OUG_HSV_VAC")
$scope.childOU.push({ id: ou.id });
});
});

});
Expand Down Expand Up @@ -219,6 +220,7 @@ Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter',
$scope.dataSetDescription = ""
commonvariable.PeriodSelected = [];
commonvariable.DataElementSelected = [];
$scope.checkingDEGroup();
};

///get if there exist a Dataset for this Mission.
Expand All @@ -242,6 +244,18 @@ Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter',
$scope.CreateDatasetVaccination = true;
});
}

$scope.assignUserRoles = function (uidDataSet) {

UserRoles.Get({}).$promise.then (function(data){

angular.forEach(data.userRoles, function(userRole, key) {
DataSetUserRole.POST({uiduserrole:userRole.id,uiddataset:uidDataSet});
});

});

}

//
$scope.saveDatasetVaccination = function () {
Expand Down Expand Up @@ -272,6 +286,7 @@ Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter',
.$promise.then(function (data) {
if (data.response.status == "SUCCESS") {
$scope.dataSetUid = data.response.lastImported;
$scope.assignUserRoles(data.response.lastImported);
$scope.createSectionsToDataSet().then(function(data){
$scope.dhisSectionsToRemove=$scope.dhisSections;
$scope.dhisSections=[];
Expand Down Expand Up @@ -364,7 +379,7 @@ Dhis2Api.controller("d2ResourcejsonvaccinationController", ['$scope', '$filter',

$scope.GetDataelement=function(codes){
$scope.ListnameDataelement=[];
DataElements.Get({filter:'code:in:['+codes+"]"})
DataElements.Get({paging:'no',filter:'code:in:'+codes})
.$promise.then(function(response){
angular.forEach(response.dataElements, function(dvalue,dkey){
$scope.ListnameDataelement[dvalue.code] = { id: dvalue.id, name: dvalue.name };
Expand Down
5 changes: 2 additions & 3 deletions services/projectservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Dhis2Api.service('projectService', ['$q', 'commonvariable', 'User', 'OrgUnitOrgU
if (orgUnit.level == commonvariable.level.HealthSite || orgUnit.level == commonvariable.level.HealthService) {

var textToUpdate = "OU_" + commonvariable.ouDirectiveCode.slice(2, 7);
var newCode = textToUpdate + orgUnit.code.slice(7);
var newCode = textToUpdate + orgUnit.code.slice(8);

OrgUnit.PATCH({id:orgUnit.id},{code:newCode}).$promise.then(function(data){
defered.resolve(data);
Expand Down Expand Up @@ -241,11 +241,10 @@ Dhis2Api.service('projectService', ['$q', 'commonvariable', 'User', 'OrgUnitOrgU
var defered = $q.defer();
var promise = defered.promise;
var projectEdited = false;
OrgUnit.PATCH({id:idOu},editOu).$promise.then(function(data){

if (data.response.status=="SUCCESS") {

//projectEdited=true;
//asign OU selected
commonvariable.EditOrganisationUnit = commonvariable.OrganisationUnit;
Expand Down

0 comments on commit 68a4b7b

Please sign in to comment.