← Back to team overview

dhis2-devs team mailing list archive

Re: custom form in Tracker Capture

 

Dear Channara,

See an example of building a custom form.

*<script>*
* $(document).ready(function(){*
* var scope = getScope('RegistrationController'); //Get scope from
registration controller*
* var orgUnitName = angular.element($("#orgUnitTree .selected")).text(); *
* if(scope.registrationMode === 'REGISTRATION'){*

* scope.$on('teienrolled',function(){*
* console.log("TEI enrolled");*
* });*
* }*
* if(scope.registrationMode === 'PROFILE'){*
* scope.$on('teiupdated',function(){*
* console.log("TEI updated");*
* });*
* } *
* //var myForm = document.querySelector('d2-custom-form');*
* //var $scope = angular.element(myForm).scope();*
* // control birth date and date of consultation*
* // Attribute Birth Date has a uid = A31FfrjPqyp*

* scope.$watch('selectedTei.A31FfrjPqyp',function(newDOBValue,oldDOBValue){*
* if(scope.interacted(scope.outerForm.A31FfrjPqyp) === true){*
* if(newDOBValue >= scope.selectedEnrollment.enrollmentDate){ *
* alert("Date of Birth should not be later than Date of Consultation,
correct the Date of Birth."); *
* scope.$applyAsync(function(){*
* scope.selectedTei.A31FfrjPqyp = ''; //Assign date to null*
* scope.outerForm.$dirty;*
* });*
* //angular.element($('[attributeid="A31FfrjPqyp"]')).focus().select(); *
* }*
* if(scope.selectedEnrollment.incidentDate <
scope.selectedTei.A31FfrjPqyp){ *
* alert("Date of onset of symptoms has to be later than or equal to Date of
Birth , correct the Date of Birth.");*
* scope.$applyAsync(function(){*
* scope.selectedTei.A31FfrjPqyp = '';  //Assign date to null*
* scope.outerForm.$dirty;*
* });*
* }*
* }*
* },true)*
* });*
*</script>*

Alex

On Sun, Oct 9, 2016 at 4:23 PM, channara rin <rin.channara@xxxxxxxxx> wrote:

> Dear alex,
> thank you alot.... :-)
> But could you give example one attribute for me? i don't know how to use
> that script...
>
> On Thu, Oct 6, 2016 at 5:36 PM, Alex Tumwesigye <atumwesigye@xxxxxxxxx>
> wrote:
>
>> Dear Channara,
>>
>> Use angular $watch to watch the models changes.
>>
>>
>> Attribute model is $scope.selectedTei.uid
>> event model is $scope.currentEvent.uid
>>
>> For Jquery,
>> use $(selectedTei.uid).val("Your value").trigger('input');
>>
>> For angular,
>> This $scope.selectedTei.uid will pick your value, however, you will need
>> $watch to watch for changes.
>>
>>  Note uid is the dhis2 11 character identifier.
>>
>> Alex
>>
>> On Thu, Oct 6, 2016 at 12:47 PM, channara rin <rin.channara@xxxxxxxxx>
>> wrote:
>>
>>> Dear all,
>>> do you know any jquery script for tracker capture custom form to catch
>>> require attributes fields and unique attribute field?
>>>
>>> for example, when i edit client's profile in tracker capture. if i do
>>> some things wrong format of attribute fields, when i click update/save. i
>>> didn't see any popup message what i did wrong. but when i look console. i
>>> saw error of jax to use "PUT" on 404 message.
>>>
>>> thank you
>>> channara
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help   : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Alex Tumwesigye
>>
>> Technical Advisor - DHIS2 (Consultant),
>> Ministry of Health/AFENET  | HISP Uganda
>> Kampala
>> Uganda
>> +256 774149 775, + 256 759 800161
>> Skype ID: talexie
>>
>> IT Consultant (Servers, Networks and Security, Health Information Systems
>> - DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant
>>
>>
>> "I don't want to be anything other than what I have been - one tree hill "
>>
>
>


-- 
Alex Tumwesigye

Technical Advisor - DHIS2 (Consultant),
Ministry of Health/AFENET  | HISP Uganda
Kampala
Uganda
+256 774149 775, + 256 759 800161
Skype ID: talexie

IT Consultant (Servers, Networks and Security, Health Information Systems -
DHIS2, Disease Outbreak & Surveillance Systems) & Solar Consultant


"I don't want to be anything other than what I have been - one tree hill "

References