Skip to content

Commit a34bb9d

Browse files
authored
fix(formbuilder): validation criteria for Select question types DEV-1283 (#6469)
### 📣 Summary Fix UI for the validation criteria of question types Select One and Select Many. ### 💭 Notes It looks like a 10+ year old bug. But that can't be right, right? ### 👀 Preview steps 1. ℹ️ in formbuilder for question type Select One, go to "settings" and then "validation criteria" 2. click "add a condition" 3. 🔴 [on main] UI starts to misbehave, error in console 4. 🟢 [on PR] it works
1 parent c1a69ba commit a34bb9d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

jsapp/xlform/src/mv.validationLogicHelpers.coffee

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,26 @@ module.exports = do ->
4646

4747
class validationLogicHelpers.ValidationLogicHelperContext extends $skipLogicHelpers.SkipLogicHelperContext
4848
use_mode_selector_helper: () ->
49-
if @questionTypeHasNoValidationOperators()
49+
if !@questionTypeHasResponseType()
5050
@use_hand_code_helper()
5151
else
5252
@state = new validationLogicHelpers.ValidationLogicModeSelectorHelper @view_factory, @
5353
@render @destination
5454
return
5555
use_hand_code_helper: () ->
5656
@state = new validationLogicHelpers.ValidationLogicHandCodeHelper(@state.serialize(), @builder, @view_factory, @)
57-
if @questionTypeHasNoValidationOperators()
57+
if !@questionTypeHasResponseType()
5858
@state.button = @view_factory.create_empty()
5959
@render @destination
6060
return
6161

62-
questionTypeHasNoValidationOperators: () ->
62+
questionTypeHasResponseType: () ->
6363
typeId = @helper_factory.current_question.get('type').get('typeId')
6464
# Note: Leszek: seems like a dead code, can't figure out how to setup a test to trigger it.
6565
if !typeId
6666
return console.error('no type id found for question', @helper_factory.current_question)
67-
operators = $skipLogicHelpers.question_types[typeId]?.operators
68-
if !operators
69-
operators = $skipLogicHelpers.question_types['default'].operators
70-
operators.length == operators[0]
67+
question_type = $skipLogicHelpers.question_types[typeId] || $skipLogicHelpers.question_types['default']
68+
return question_type.response_type?
7169

7270
class validationLogicHelpers.ValidationLogicModeSelectorHelper extends $skipLogicHelpers.SkipLogicModeSelectorHelper
7371
constructor: (view_factory, context) ->

jsapp/xlform/src/view.rowDetail.SkipLogic.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ module.exports = do ->
320320
class viewRowDetailSkipLogic.SkipLogicDropDownResponse extends $viewWidgets.DropDown
321321
tagName: 'select'
322322
className: 'skiplogic__responseval'
323+
model: new $viewWidgets.DropDownModel()
323324

324325
attach_to: (target) ->
325326
target.find('.skiplogic__responseval').remove()
@@ -341,15 +342,14 @@ module.exports = do ->
341342
@model.on 'change:cid', handle_model_cid_change
342343
return
343344

344-
constructor: (responses, model) ->
345+
constructor: (responses) ->
345346
super(_.map responses.models, (response) ->
346347
return {
347348
text: response.get('label')
348349
value: response.cid
349350
}
350351
)
351352
@responses = responses
352-
@model = model
353353

354354
###----------------------------------------------------------------------------------------------------------###
355355
#-- Factories.RowDetail.SkipLogic.coffee

0 commit comments

Comments
 (0)