-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hai 750 #254
base: master
Are you sure you want to change the base?
Hai 750 #254
Changes from 2 commits
37d0234
0dd3689
4f86ea8
79945bc
f0c6620
ba41ab8
6f1e189
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,4 +393,88 @@ function updateLastCheckboxRequired(containerSelector) { | |
|
||
// Add the updateLastCheckboxRequired function to the beforeSubmit array to call it before form submission. | ||
beforeSubmit.push(updateLastCheckbox); | ||
} | ||
|
||
usePatientAddressAsContactAddress(); | ||
|
||
function usePatientAddressAsContactAddress(){ | ||
jq(document).ready(function() { | ||
|
||
// change the ckeckbox message based on the languade | ||
var message=''; | ||
var url = window.location.href; | ||
var urlParams = new URLSearchParams(new URL(url).search); | ||
var langParam = urlParams.get('lang'); | ||
message=langParam === 'fr'? "Utilisez l'adresse du patient ?":"Use the patient address ?" | ||
|
||
//target the div containing the contact address | ||
const divElement = jq('#contactQuestionLabel div'); | ||
|
||
//creating a check, to be checked if clinician wants to use patient address as contact one | ||
const checkboxElement = jq("<input>", { | ||
type: "checkbox", | ||
id: "question_address", | ||
name: "question_address" | ||
}); | ||
|
||
//Creating a label to show the checkbox title | ||
const labelElement = jq("<label>", { | ||
for: "question_address", | ||
text: message | ||
}); | ||
|
||
//creating a break line to push other elements a litle bit down | ||
const brElement = $("<br>"); | ||
divElement.prepend(checkboxElement, labelElement, brElement); | ||
|
||
// checkbox event occurs here | ||
jq('#question_address').on('change', function() { | ||
if (this.checked) { | ||
//disable other input if the want to use the patient address as contact address | ||
isInputDisabled(true); | ||
// get and set the new address detail from patient to contact | ||
getPatienAddressInfo(); | ||
|
||
} else { | ||
//Enable the inputs to put value manually | ||
isInputDisabled(false); | ||
clearInputValue(); | ||
} | ||
}); | ||
}); | ||
|
||
} | ||
|
||
function getPatienAddressInfo(){ | ||
|
||
//creating an array to store patient adress | ||
var valuesArray = []; | ||
var manualEntryAddress; | ||
jq("#personAddressQuestion div input[type='text']").each(function() { | ||
valuesArray.push(jq(this).val()); | ||
}); | ||
manualEntryAddress=$("#personAddressQuestion div input[type='text']:last").val() | ||
jq("#contactQuestionLabel div input[type='text']:last").val(manualEntryAddress); | ||
|
||
|
||
// target the contact address input and set the new value | ||
jq("#contactQuestionLabel div input[type='text']").each(function(index) { | ||
if (index < valuesArray.length) { | ||
jq(this).val(valuesArray[index]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a line: " jq(this).data('legalValues', [ valuesArray[index] ])" which I think needs to happen for the entry to be considered "valid" (see my overall comments). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added focused class to the autocomplete when the checkbox is checked. I hoped that would help. it stil does not save in DB |
||
//No need to show this error if value presents | ||
jq("#contactQuestionLabel .field-error").val(''); | ||
} | ||
}); | ||
} | ||
|
||
function isInputDisabled(value){ | ||
jq("#contactQuestionLabel div input[type='text']").each(function() { | ||
jq(this).prop("disabled", value); | ||
}); | ||
} | ||
function clearInputValue(){ | ||
jq("#contactQuestionLabel div input[type='text']").each(function(index) { | ||
jq(this).val(''); | ||
}); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try removing this line? I think disabling the inputs result it in not getting saved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean @mogoodrich line 434?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly @Dutervil