-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
Filename broadcast bug fix 2 #35108
Filename broadcast bug fix 2 #35108
Changes from 2 commits
de4dbfc
74b766d
3bf0501
3990539
f85775a
f708664
a32b5b1
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
'use strict'; | ||
hqDefine("cloudcare/js/form_entry/form_ui", [ | ||
'jquery', | ||
'knockout', | ||
|
@@ -691,13 +691,21 @@ | |
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(); | ||
var findChildAndSetFilename = function (children) { | ||
for (var i = 0; i < children.length; i++) { | ||
Jtang-1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var child = children[i]; | ||
if (child.children && child.children.length > 0) { | ||
findChildAndSetFilename(child.children); | ||
} else if (child.control >= constants.CONTROL_IMAGE_CHOOSE) { | ||
Jtang-1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
child.filename = element.answer(); | ||
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 realize i'm not completely understanding this. Does 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. Yep as far as I can tell element does represent a single question. And thanks for bringing up the concern - I did some testing and found that there is a pretty convoluted edge case where if you have 2 input questions of the same type AND one them is broadcasting their filename to a text question AND they're all (2 input questions and a text question) contained in the same question tile AND the input question that's not broadcasting is placed before the the broadcasting question, then it'll assign the filename to the wrong input question. I tried a bunch of different variations of this format but this is strangely the only instance where it doesn't work as you'd expect. 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'll see if there's something obvious I missed that can more assuredly pick out the right child to assign the filename to 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. Just added a check that will only assign filename to input questions that match the broadcast style (or lack thereof) of the question you just answered. Testing locally seems to work fine (questions without any style at all don't need this - this is specifically for input questions within the same question tile block that needs updating frequently like when there's a conditionally visible question) but I'm going to ask QA to have another look at it. 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 see, there's still a part i'm confused on. Is this the appearance attribute this work is related to? So Is what you're doing checking that the 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. Yep that's the broadcasting logic I'm dealing with. Element in this case is representing the input question and needs the filename to properly populate the text next to the upload button (this resolved the previous bug we had where having it broadcast to a hidden question in the same question tile would wipe the uploaded file the first time). I'm not sure what you mean by 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. hmm ok the only part i'm still not understanding is, if there are multiple input questions broadcasting (such that they each have a broadcast appearance attribute), would this conditional incorrectly match to all of them? 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. theoretically I think so... but that would mean there would have to be two or more input questions broadcasting to one or more receiving text questions present in a single question tile (basically all in a row) which doesn't make sense to do in a form. 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. Actually I'm not even sure you can have more than broadcasting/receiving pair in a question tile? In any case, I think the best fix for this (assigning filename based on question/child id) is a bit out of scope for this relatively small issue since it'll probably require additional formplayer changes too. How would you feel about keeping track of this as a backlog item to revisit in the future? |
||
break; | ||
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. nit: i think we can just return here? |
||
} | ||
} | ||
}; | ||
if (allChildren && allChildren.length > 0) { | ||
findChildAndSetFilename(allChildren); | ||
} | ||
|
||
response.children = allChildren; | ||
self.fromJS(response); | ||
} | ||
|
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.
lets use
const
andlet
where possible.