<commit_before>define [
    'underscore'
    'backbone'
    'marionette'
    './base'
], (_, Backbone, Marionette, base) ->

    class SelectionCollection extends Backbone.Collection
        model: Backbone.Model

        parse: (response) ->
            return response.values

    class SelectionListItem extends Marionette.ItemView
        template: ->

        tagName: 'option'

        modelEvents: ->
            'change:selected': 'render'

        onRender: ->
            @$el.text(@model.get('label'))
            @$el.attr('value', @model.get('value'))
            @$el.attr('selected', @model.get('selected'))

    # Renders a dropdown of items allowing for selection of a single item
    # from the list.
    class SingleSelectionList extends Marionette.CompositeView
        className: 'selection-list'

        itemView: SelectionListItem

        itemViewOptions: (model, index) ->
            model: model

        itemViewContainer: '.items'

        template: 'controls/select/list'

        ui:
            items: '.items'

        events:
            'change .items': 'onSelectionChange'

        collectionEvents:
            'sync': 'onCollectionSync'

        constructor: (options={}) ->
            @bindContext(options.context)
            super(options)

        initialize: (options) ->
            @options.emptyValueLabel = options.emptyValueLable or '---'

            if not @collection
                @collection = new SelectionCollection
                @collection.url = => @model.links.values

            @collection.fetch()

        onCollectionSync: ->
            @collection.add(
                {label: @options.emptyValueLabel, value: ''},<commit_msg>Fix redundant assignment of emptyValueLabel<commit_after>define [
    'underscore'
    'backbone'
    'marionette'
    './base'
], (_, Backbone, Marionette, base) ->

    class SelectionCollection extends Backbone.Collection
        model: Backbone.Model

        parse: (response) ->
            return response.values

    class SelectionListItem extends Marionette.ItemView
        template: ->

        tagName: 'option'

        modelEvents: ->
            'change:selected': 'render'

        onRender: ->
            @$el.text(@model.get('label'))
            @$el.attr('value', @model.get('value'))
            @$el.attr('selected', @model.get('selected'))

    # Renders a dropdown of items allowing for selection of a single item
    # from the list.
    class SingleSelectionList extends Marionette.CompositeView
        className: 'selection-list'

        itemView: SelectionListItem

        itemViewOptions: (model, index) ->
            model: model

        itemViewContainer: '.items'

        template: 'controls/select/list'

        ui:
            items: '.items'

        events:
            'change .items': 'onSelectionChange'

        collectionEvents:
            'sync': 'onCollectionSync'

        constructor: (options={}) ->
            @bindContext(options.context)
            super(options)

        initialize: (options) ->
            if not @collection
                @collection = new SelectionCollection
                @collection.url = => @model.links.values

            @collection.fetch()

        onCollectionSync: ->
            @collection.add(
                {label: @options.emptyValueLabel or '---', value: ''},
{'fraction_non_alphanumeric': 0.1130952380952381, 'fraction_numerical': 0.0, 'mean_word_length': 1.9405074365704287, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '519647', 'n_tokens_mistral': 892, 'n_tokens_neox': 838, 'n_words': 200}