Skip to content

Commit

Permalink
Merge pull request #35108 from dimagi/ml/broadcast-bug
Browse files Browse the repository at this point in the history
Filename broadcast bug fix 2
  • Loading branch information
minhaminha authored Sep 17, 2024
2 parents 6d13acb + a32b5b1 commit a4afa7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ hqDefine("cloudcare/js/form_entry/entries", [
FileEntry.prototype.constructor = EntrySingleAnswer;
FileEntry.prototype.onPreProcess = function (newValue) {
var self = this;
if (newValue === "" && self.question.filename()) {
if (newValue === "" && self.question.filename) {
self.question.hasAnswered = true;
self.fileNameDisplay(self.question.filename());
} else if (newValue !== constants.NO_ANSWER && newValue !== "") {
Expand Down
19 changes: 15 additions & 4 deletions corehq/apps/cloudcare/static/cloudcare/js/form_entry/form_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,24 @@ hqDefine("cloudcare/js/form_entry/form_ui", [
element.serverError(null);
}

if (allChildren) {
for (let i = 0; i < allChildren.length; i++) {
if (allChildren[i].control >= constants.CONTROL_IMAGE_CHOOSE) {
allChildren[i].filename = element.answer();
const inputControl = [constants.CONTROL_IMAGE_CHOOSE, constants.CONTROL_LABEL,
constants.CONTROL_AUDIO_CAPTURE, constants.CONTROL_VIDEO_CAPTURE];

let findChildAndSetFilename = function (children) {
for (let child of children) {
if (child.children && child.children.length > 0) {
findChildAndSetFilename(child.children);
} else if (inputControl.includes(child.control) && element.binding() === child.binding &&
element.ix() === child.ix && element.answer()) {
child.filename = element.answer();
return;
}
}
};
if (allChildren && allChildren.length > 0) {
findChildAndSetFilename(allChildren);
}

response.children = allChildren;
self.fromJS(response);
}
Expand Down

0 comments on commit a4afa7c

Please sign in to comment.