<commit_before># coffeelint: disable=camel_case_classes
class App.UiElement.select extends App.UiElement.ApplicationUiElement
  @render: (attributeConfig, params, form = {}) ->
    attribute = $.extend(true, {}, attributeConfig)

    # set multiple option
    if attribute.multiple
      attribute.multiple = 'multiple'
    else
      attribute.multiple = ''

    if form.rejectNonExistentValues
      attribute.rejectNonExistentValues = true

    # add deleted historical options if required
    @addDeletedOptions(attribute, params)

    # build options list based on config
    @getConfigCustomSortOptionList(attribute)

    # build options list based on relation
    @getRelationOptionList(attribute, params)

    # add null selection if needed
    @addNullOption(attribute, params)

    # sort attribute.options
    @sortOptions(attribute, params)

    # find selected/checked item of list
    @selectedOptions(attribute, params)

    # disable item of list
    @disabledOptions(attribute, params)

    # filter attributes
    @filterOption(attribute, params)

    item = $( App.view('generic/select')(attribute: attribute) )

    # bind event listeners
    @bindEventListeners(item, attribute, params)

    # return item
    item

  @bindEventListeners: (item, attribute, params) ->
    if attribute.display_warn
      item.on('change', (e) =>
        @bindWarnDisplayListener(e.target.value, attribute, params, item)
      )

      # initialization for default selection
      @bindWarnDisplayListener(attribute.value, attribute, params, item)

  @bindWarnDisplayListener: (selectedVal, attribute, params, item) ->
    warn_visible = @shouldDisplayWarn(selectedVal, attribute, params)
    @toggleDisplayWarn(warn_visible, attribute, item)

  @shouldDisplayWarn: (selectedVal, attribute, params) ->
    return if !selectedVal
    return if !params

    params[attribute.name + '_is_display_warning'](selectedVal)

  @toggleDisplayWarn: (warn_visible, attribute, item) ->
    if !warn_visible
      item.removeClass('display-warn')
      item.find('.alert--warning').remove()
      return

    item.addClass('display-warn')
    warn_elem = $('<div class="alert alert--warning" role="alert"></div>')
    warn_elem.html(attribute.warn)
    item.append(warn_elem)<commit_msg>Fixes #4309 - TypeError: params[(attribute.name + "_is_display_warning")] is not a function<commit_after># coffeelint: disable=camel_case_classes
class App.UiElement.select extends App.UiElement.ApplicationUiElement
  @render: (attributeConfig, params, form = {}) ->
    attribute = $.extend(true, {}, attributeConfig)

    # set multiple option
    if attribute.multiple
      attribute.multiple = 'multiple'
    else
      attribute.multiple = ''

    if form.rejectNonExistentValues
      attribute.rejectNonExistentValues = true

    # add deleted historical options if required
    @addDeletedOptions(attribute, params)

    # build options list based on config
    @getConfigCustomSortOptionList(attribute)

    # build options list based on relation
    @getRelationOptionList(attribute, params)

    # add null selection if needed
    @addNullOption(attribute, params)

    # sort attribute.options
    @sortOptions(attribute, params)

    # find selected/checked item of list
    @selectedOptions(attribute, params)

    # disable item of list
    @disabledOptions(attribute, params)

    # filter attributes
    @filterOption(attribute, params)

    item = $( App.view('generic/select')(attribute: attribute) )

    # bind event listeners
    @bindEventListeners(item, attribute, params)

    # return item
    item

  @bindEventListeners: (item, attribute, params) ->
    if attribute.display_warn
      item.on('change', (e) =>
        @bindWarnDisplayListener(e.target.value, attribute, params, item)
      )

      # initialization for default selection
      @bindWarnDisplayListener(attribute.value, attribute, params, item)

  @bindWarnDisplayListener: (selectedVal, attribute, params, item) ->
    warn_visible = @shouldDisplayWarn(selectedVal, attribute, params)
    @toggleDisplayWarn(warn_visible, attribute, item)

  @shouldDisplayWarn: (selectedVal, attribute, params) ->
    return if !selectedVal
    return if !params

    params[attribute.name + '_is_display_warning']?(selectedVal)

  @toggleDisplayWarn: (warn_visible, attribute, item) ->
    if !warn_visible
      item.removeClass('display-warn')
      item.find('.alert--warning').remove()
      return

    item.addClass('display-warn')
    warn_elem = $('<div class="alert alert--warning" role="alert"></div>')
    warn_elem.html(attribute.warn)
    item.append(warn_elem)
{'fraction_non_alphanumeric': 0.10403626160155408, 'fraction_numerical': 0.0008633714655730628, 'mean_word_length': 3.8727655099894847, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '677794', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1253, 'n_words': 309}