Skip to content

Commit

Permalink
Merge pull request #76 from EyeSeeTea/UpdateDataSetsDirective
Browse files Browse the repository at this point in the history
Issue #75
  • Loading branch information
josemp10 authored Aug 31, 2016
2 parents 3093b52 + 337545f commit 3741ac1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions core/dhis2Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Dhis2Api.factory("commonvariable", function () {
userDirective:"",
users: usersMSF,
healhservicesCodeOUG: "",
refreshDataSets:false,
clearForm:[]
};

Expand Down
4 changes: 2 additions & 2 deletions directives/orgunitgroupsets/orgunitGroupSetsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ Dhis2Api.controller("d2DropdownorgunitgroupsetController", ['$q','$scope','$http

//function to call when change of OU
if ($scope.operation == "show") {
//console.log("Voy a ejecutar esto de la directiva");
$scope.disabled = true;

$scope.disabled = true;
try{
getOrgUnitGroup(commonvariable.OrganisationUnit.id, $scope.uidgroupset).then(function (data) {
$scope.ougName = data.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Dhis2Api.controller("d2ResourcejsondatasetController", ['$scope', '$filter', '$i
$scope.operation = 'show';
$scope.prevOu = undefined;
}

$scope.editOrgUnit = function (datasets) {
try {
commonvariable.OrganisationUnit.dataSets = datasets;
Expand All @@ -56,11 +57,13 @@ Dhis2Api.controller("d2ResourcejsondatasetController", ['$scope', '$filter', '$i
}

$scope.$watch(function () {
if (commonvariable.OrganisationUnit && commonvariable.OrganisationUnit.id != $scope.prevOu) {
if ((commonvariable.OrganisationUnit && commonvariable.OrganisationUnit.id != $scope.prevOu) ||
commonvariable.refreshDataSets) {
$scope.initForm();
$scope.prevOu = commonvariable.OrganisationUnit.id;
$scope.pdatasets = commonvariable.OrganisationUnit.dataSets;
$scope.loadDataSet();
commonvariable.refreshDataSets = false;
//$scope.finddatasetSelected();
}
});
Expand Down
8 changes: 6 additions & 2 deletions modules/HealthService/healthServiceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,12 @@ appConfigProjectMSF.controller('healthServiceController', ["$scope",'$filter',"c

if (commonvariable.orgUnitGroupSet[commonvariable.ouGroupsetId.HealthService].name == "Vaccination") { //Assocate Vacc datasets

commonService.assignVaccinationDataSet(orgUnit);
}
commonService.assignVaccinationDataSet(orgUnit).$promise.then(function(data){

commonvariable.refreshDataSets = true;

});
} else commonvariable.refreshDataSets = true;

});

Expand Down
5 changes: 4 additions & 1 deletion services/commonservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ Dhis2Api.service('commonService', ['$q', 'commonvariable', 'OrgUnitGroupByOrgUni
var promises = [];
var variable = {};

commonvariable.OrganisationUnit.dataSets = [];

angular.forEach(orgUnit.dataSets, function (ds, key){
var deferred = $q.defer();
promises.push(deferred.promise);
Expand All @@ -205,7 +207,7 @@ Dhis2Api.service('commonService', ['$q', 'commonvariable', 'OrgUnitGroupByOrgUni
variable=data;
deferred.resolve(variable);
});
} else deferred.resolve(-1);
} else { commonvariable.OrganisationUnit.dataSets.push(ds); deferred.resolve(-1); }

});

Expand All @@ -226,6 +228,7 @@ Dhis2Api.service('commonService', ['$q', 'commonvariable', 'OrgUnitGroupByOrgUni

if (response.dataSets.length > 0) {
var dataSet = response.dataSets[0];
commonvariable.OrganisationUnit.dataSets.push(dataSet);
DataSetsOrgUnit.POST({ uidorgunit: orgUnit.id, uiddataset: dataSet.id });
}

Expand Down
1 change: 1 addition & 0 deletions services/healthserviceservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Dhis2Api.service('healthserviceService', ['$q', 'commonvariable', 'OrgUnitOrgUni
commonService.deleteOrgUnitGroup(commonvariable.OrganisationUnit.id, commonvariable.ouGroupsetId.HealthServiceType).then(function (data) {

OrgUnitOrgUnitGroups.POST({ uidorgunit: commonvariable.OrganisationUnit.id, uidgroup: commonvariable.orgUnitGroupSet[commonvariable.ouGroupsetId.HealthService].id });
commonvariable.healhservicesCodeOUG = commonvariable.orgUnitGroupSet[commonvariable.ouGroupsetId.HealthService].code;

var sitePrefix = commonvariable.OrganisationUnit.name.slice(0,3);
var healthServiceName = sitePrefix + commonvariable.orgUnitGroupSet[commonvariable.ouGroupsetId.HealthService].name;
Expand Down

0 comments on commit 3741ac1

Please sign in to comment.