Closed broncha closed 5 years ago
Hi Rajesh, Making expressions be a kind of fake answer seems to cause a lot of weirdness. e.g.
exports.isQuestion = (item) ->
return item._type? and (item._type.match(/Question$/) or item._type in ["TextColumn", "Calculation"] )
There might be side-effects for considering a non-question to be a question. What about creating a new render function for expressions rather than modifying renderAnswer?
I thought of
exports.isExpressionQuestion = (item) ->
return item._type? and item._type in ["TextColumn", "Calculation"]
This would mean we duplicate the logic for renderQuestion
too
since we are doing
if formUtils.isQuestion(item)
return @renderQuestion(item, dataId)
We do need the question(header) to be rendered as it is being rendered right now. Also, this is just in the display component, would it have such side effects? This change is just required so it is visible in web and in pdf
Right. The logic to display an expression is much simpler than to display a normal question, and that includes the renderQuestion logic (doesn't have associated data or value, etc). I'd go with the approach of a separate renderExpression, since it's really not a question and there could be all sorts of impacts in other places to extend the definition of question. I'd call it "isExpression" rather than isExpressionQuestion to make the difference clear.
all done
I see you did formUtils.d.ts, but don't forget formDesign.d.ts!
Looks good to me!
@grassick I am not comfortable with the changes. Please review. This is related to https://github.com/mWater/mwater-form-designer/issues/187