Skip to content

Commit

Permalink
new content demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mfinholt committed Aug 14, 2020
1 parent 73f153b commit 0bb2a49
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 1 deletion.
28 changes: 27 additions & 1 deletion content-sets/case-module/case-type-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"templateCaseEventListItemPrimary": "<span>${caseEventDefinition.name}</span>",
"templateCaseEventListItemSecondary": "${caseEvent.scheduledDay ? `Scheduled: ${moment(caseEvent.scheduledDay, 'YYYY-MM-DD').format('DD/MM/YYYY')}, ` : ''} Status: ${caseEvent.complete ? 'Complete' : 'Incomplete'}",
"templateEventFormListItemIcon": "",
"templateEventFormListItemPrimary": "<span>${eventFormDefinition.name}</span>",
"templateEventFormListItemPrimary": "<span>${eventForm?.data?.title ? eventForm.data.title : eventFormDefinition.name}</span>",
"templateEventFormListItemSecondary": "Status: ${!eventForm.complete ? 'Incomplete' : 'Complete'}",
"templateBreadcrumbText": "${caseService.getVariable('participant_id') ? ` ${caseService.getVariable('participant_id')}` : ` ${caseService.case._id.substring(0,6)}`}",
"startFormOnOpen": {
Expand Down Expand Up @@ -271,6 +271,32 @@
"repeatable": false
}
]
},
{
"id": "dynamic-form-instance-creation",
"name": "Fruit Labs creates optional lab results forms",
"repeatable": true,
"required": false,
"eventFormDefinitions": [
{
"id": "ef-dynamic-form-instance-creation--form-1",
"formId": "dynamic-form-instance-creation--form-1",
"forCaseRole": "role-1",
"name": "Fruit Labs",
"autoPopulate": true,
"required": true,
"repeatable": false
},
{
"id": "ef-dynamic-form-instance-creation--form-2",
"formId": "dynamic-form-instance-creation--form-2",
"forCaseRole": "role-1",
"name": "Fruit Lab Result",
"autoPopulate": false,
"required": false,
"repeatable": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<tangy-form id="dynamic-form-instance-creation--form-1" title="Form submit creates multiple instances of follow-up form"

on-submit="
debugger
if(getValue('fruit_tests').includes('1') && getValue('apple_result_received')[0] === '0'){
var resultForm = caseService.createEventForm(T.case.caseEvent.id, 'ef-dynamic-form-instance-creation--form-2', window.participant.id);
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'title', 'Fruit Lab Result - Apple');
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'resultType', 'apple');
caseService.markEventFormRequired(T.case.caseEvent.id, resultForm.id);
}
if(getValue('fruit_tests').includes('2') && getValue('tangerine_result_received')[0] === '0'){
var resultForm = caseService.createEventForm(T.case.caseEvent.id, 'ef-dynamic-form-instance-creation--form-2', window.participant.id);
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'title', 'Fruit Lab Result - Tangerine');
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'resultType', 'tangerine');
caseService.markEventFormRequired(T.case.caseEvent.id, resultForm.id);
}
if(getValue('fruit_tests').includes('3') && getValue('kiwi_result_received')[0] === '0'){
var resultForm = caseService.createEventForm(T.case.caseEvent.id, 'ef-dynamic-form-instance-creation--form-2', window.participant.id);
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'title', 'Fruit Lab Result - Kiwi');
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'resultType', 'kiwi');
caseService.markEventFormRequired(T.case.caseEvent.id, resultForm.id);
}
if(getValue('fruit_tests').includes('4') && getValue('tomato_result_received')[0] === '0'){
var resultForm = caseService.createEventForm(T.case.caseEvent.id, 'ef-dynamic-form-instance-creation--form-2', window.participant.id);
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'title', 'Fruit Lab Result - Tomato');
caseService.setEventFormData(T.case.caseEvent.id, resultForm.id, 'resultType', 'tomato');
caseService.markEventFormRequired(T.case.caseEvent.id, resultForm.id);
}
"

>
<tangy-form-item id="item1"
on-change="
"
>


<tangy-checkboxes
name="fruit_tests"
label="What fruits did you test today?"
>
<option value="1">Apple</option>
<option value="2">Tangerine</option>
<option value="3">Kiwi</option>
<option value="4">Tomato</option>
</tangy-checkboxes>


<tangy-radio-buttons name="apple_result_received" show-if="getValue('fruit_tests').includes('1')" required="" question-number="2" label="Did you receive the results for your Apple test?" hint-text="" error-text="" warn-text="" class="" style="">

<option value="1">Yes</option>

<option value="0">No</option>

</tangy-radio-buttons>

<tangy-input type="text" show-if="getValue('apple_result_received') === '1'" inner-label="" name="apple_result" required="" question-number="3" label="Enter your Apple results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>


<tangy-radio-buttons name="tangerine_result_received" show-if="getValue('fruit_tests').includes('2')" required="" question-number="4" label="Did you receive the results for your Tangerine test?" hint-text="" error-text="" warn-text="" class="" style="">

<option value="1">Yes</option>

<option value="0">No</option>

</tangy-radio-buttons>

<tangy-input type="text" show-if="getValue('tangerine_result_received') === '1'" inner-label="" name="tangerine_result" required="" question-number="5" label="Enter your Tangerine results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>



<tangy-radio-buttons name="kiwi_result_received" show-if="getValue('fruit_tests').includes('3')" required="" question-number="6" label="Did you receive the results for your Kiwi test?" hint-text="" error-text="" warn-text="" class="" style="">

<option value="1">Yes</option>

<option value="0">No</option>

</tangy-radio-buttons>

<tangy-input type="text" show-if="getValue('kiwi_result_received') === '1'" inner-label="" name="kiwi_result" required="" question-number="7" label="Enter your Kiwi results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>


<tangy-radio-buttons name="tomato_result_received" show-if="getValue('fruit_tests').includes('4')" required="" question-number="8" label="Did you receive the results for your Tomato test?" hint-text="" error-text="" warn-text="" class="" style="">

<option value="1">Yes</option>

<option value="0">No</option>

</tangy-radio-buttons>

<tangy-input type="text" show-if="getValue('tomato_result_received') === '1'" inner-label="" name="tomato_result" required="" question-number="9" label="Enter your Tomato results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>


</tangy-form-item>
</tangy-form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<tangy-form id="dynamic-form-instance-creation--form-2" title="Follow-up form instance"

on-submit="
debugger
"

>
<tangy-form-item id="item1" on-change="debugger">


<tangy-input type="text" allowed-pattern="" show-if="(window.eventForm.data?.resultType === 'apple') && getValue('isCored') === true" inner-label="" name="apple_result" required="" question-number="3" label="Enter your Apple results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>

<tangy-input type="text" allowed-pattern="" show-if="window.eventForm.data?.resultType === 'tangerine'" inner-label="" name="tangerine_result" required="" question-number="5" label="Enter your Tangerine results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>

<tangy-input type="text" allowed-pattern="" show-if="window.eventForm.data?.resultType === 'kiwi'" inner-label="" name="kiwi_result" required="" question-number="7" label="Enter your Kiwi results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>

<tangy-input type="text" allowed-pattern="" show-if="window.eventForm.data?.resultType === 'tomato'" inner-label="" name="tomato_result" required="" question-number="9" label="Enter your Tomato results" hint-text="" error-text="" warn-text="" class="" style=""></tangy-input>

</tangy-form-item>
</tangy-form>
58 changes: 58 additions & 0 deletions content-sets/case-module/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -525,5 +525,63 @@
"push": true,
"pull": true
}
},
{
"id" : "dynamic-form-instance-creation--form-1",
"src" : "./assets/dynamic-form-instance-creation--form-1/form.html",
"description" : "Fruit Labs",
"listed" : false,
"title" : "Fruit Labs",
"icon" : "assignment",
"type" : "form",
"templates": [],
"searchSettings" : {
"shouldIndex" : false,
"primaryTemplate" : "",
"secondaryTemplate" : "",
"variablesToIndex" : [
]
},
"customSyncSettings": {
"enabled": false,
"push": false,
"pull": false,
"excludeIncomplete":false
},
"couchdbSyncSettings": {
"enabled": true,
"filterByLocation": true,
"push": true,
"pull": true
}
},
{
"id" : "dynamic-form-instance-creation--form-2",
"src" : "./assets/dynamic-form-instance-creation--form-2/form.html",
"description" : "Fruit Lab Result",
"listed" : false,
"title" : "Fruit Lab Result",
"icon" : "assignment",
"type" : "form",
"templates": [],
"searchSettings" : {
"shouldIndex" : false,
"primaryTemplate" : "",
"secondaryTemplate" : "",
"variablesToIndex" : [
]
},
"customSyncSettings": {
"enabled": false,
"push": false,
"pull": false,
"excludeIncomplete":false
},
"couchdbSyncSettings": {
"enabled": true,
"filterByLocation": true,
"push": true,
"pull": true
}
}
]

0 comments on commit 0bb2a49

Please sign in to comment.