← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17610: bug fix - directive not updating custom form when program stage is changed

 

------------------------------------------------------------
revno: 17610
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-11-28 18:14:38 +0100
message:
  bug fix - directive not updating custom form when program stage is changed
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/custom-form.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/custom-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/custom-form.html	2014-07-13 13:08:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/custom-form.html	2014-11-28 17:14:38 +0000
@@ -1,1 +1,1 @@
-<d2-custom-form custom-form-type="PROGRAM_STAGE" custom-form-object="currentStage"></d2-custom-form>
\ No newline at end of file
+<d2-custom-form custom-form="customForm"></d2-custom-form>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-10-22 15:36:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-11-28 17:14:38 +0000
@@ -9,6 +9,7 @@
                 ModalService,
                 DialogService,
                 CurrentSelection,
+                CustomFormService,
                 TranslationService) {
 
     TranslationService.translate();
@@ -304,7 +305,7 @@
             $scope.programStageDataElements[prStDe.dataElement.id] = prStDe; 
         }); 
 
-        $scope.customForm = $scope.currentStage.dataEntryForm ? $scope.currentStage.dataEntryForm.htmlCode : null; 
+        $scope.customForm = CustomFormService.getForProgramStage($scope.currentStage);
         $scope.displayCustomForm = $scope.customForm ? true:false;
 
         $scope.allowProvidedElsewhereExists = false;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js	2014-11-03 11:11:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js	2014-11-28 17:14:38 +0000
@@ -34,19 +34,14 @@
     };
 })
 
-.directive('d2CustomForm', function($compile, $parse, CustomFormService) {
+.directive('d2CustomForm', function($compile) {
     return{ 
         restrict: 'E',
-        link: function(scope, elm, attrs){   
-            
-            var customFormType = attrs.customFormType;
-            var customFormObject = $parse(attrs.customFormObject)(scope);
-            
-            if(customFormType === 'PROGRAM_STAGE'){                
-                var customForm = CustomFormService.getForProgramStage(customFormObject);  
-                elm.html(customForm ? customForm : '');
-                $compile(elm.contents())(scope);     
-            }
+        link: function(scope, elm, attrs){            
+            scope.$watch('customForm', function(){
+                elm.html(scope.customForm);
+                $compile(elm.contents())(scope);
+            });
         }
     };
 })