<commit_before>{% block double_list_widget %}
<script type="text/javascript" src="{{ asset('bundles/admingeneratorgenerator/javascripts/double_list.js') }}"></script>
<div class="double_list">
    <div style="float: left">
        <div class="double_list_label">{% trans from "Admingenerator" %}double_list.unselected{% endtrans %}</div>
        <select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][unselected]" multiple="true" id="{{ form.get("id") }}_unselected" class="double_list_select-unselected">
        {% for choice in choices %}
            {% if choice is not selectedchoice(value) %}
                <option value="{{ choice.value }}">{{ choice.label }}</option>
            {% endif %}
        {% endfor %}
        </select>
    </div>
    <div style="float: left; margin-top: 2em">
         <a href="#" onclick="sfDoubleList.move('{{ form.get("id") }}_unselected','{{ form.get("id") }}_selected'); return false;">
            <img src="{{ asset('bundles/admingeneratorgenerator/images/next.png') }}" alt="unassociate" />
         </a>
         <br />
         <a href="#" onclick="sfDoubleList.move('{{ form.get("id") }}_selected','{{ form.get("id") }}_unselected'); return false;">
            <img src="{{ asset('bundles/admingeneratorgenerator/images/previous.png') }}" alt="associate" />
         </a>
    </div>
    <div style="float: left">
         <div class="double_list_label">{% trans from "Admingenerator" %}double_list.selected{% endtrans %}</div>
         <select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][]" multiple="true" id="{{ form.get("id") }}_selected" {% if (form.vars.required) %}required="required" {% endif %}class="double_list_select-selected">
         {% for choice in choices %}
            {% if choice is selectedchoice(value) %}
                <option value="{{ choice.value }}">{{ choice.label }}</option>
            {% endif %}
         {% endfor %}
         </select>
    </div>
    <br style="clear: both" />
    <script type="text/javascript">
        sfDoubleList.init(document.getElementById('{{ form.get("id") }}_selected'), 'double_list_select');
    </script>
</div>
{% endblock %}
{% block doctrine_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}
{% block doctrine_odm_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}
{% block propel_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}

{% block datepicker_range_widget %}
    <div {{ block('widget_container_attributes') }}>
        {% for child in form %}
            {{ form_widget(child) }}
        {% endfor %}
    </div>    
{% endblock %}

{% block datepicker_widget %}
    <div class="{% if prepend_label %}input-prepend {% endif %}input-append">
        {% if prepend_label %}<span class="add-on span2">{{ label|trans({}, 'Admingenerator') }}</span>{% endif %}
        <input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
        <span class="add-on"><i class="icon-calendar"></i></span>
    </div>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#{{ id }}').datepicker({
              format: '{{ format|lower }}',
              language: '{{ app.request.locale }}',
              weekStart: {{ weekstart }},
            });
        });
    </script>
{% endblock %}
    
{% macro datasource(object, builder) %}
{% autoescape -%}
    {% for key,property in builder %}
      {%- if loop.first %}{{ '{' }}{% endif -%}
          {{ '"' ~ key ~ '": "' ~ attribute(object, property) ~ '"' }}
          {%- if not loop.last %}{{ ', ' }}{% endif -%}
      {%- if loop.last %}{{ '}' }}{% endif -%}
    {% endfor %}
{%- endautoescape %}
{% endmacro %}
    
{% block entity_picker_widget %}
{% spaceless %}
    <input type="text" id="{{ id ~ '_typeahead' }}" data-source="
      {%- for choice in choices -%}
        {%- if loop.first %}{{ '[' }}{% endif -%}
            {{ _self.datasource(choice.data, builder) }}
        {%- if not loop.last %}{{ ',' }}{% else %}{{ ']' }}{% endif -%}
      {%- endfor -%}" {% if placeholder %}placeholder="{{ placeholder|trans({}, 'Admingenerator') }}"{% endif %}/>
    <input type="hidden" {{ block('widget_attributes') }} />
    
    <script type="text/javascript">
        $(document).ready(function() {
            $('#{{ id ~ '_typeahead' }}').typeahead({
              source: function() {
                  return this.$element.data('source'); 
              },
              matcher: function (item) {
                  return ~{{ matcher }}.toLowerCase().indexOf(this.query.toLowerCase());
              },
              sorter: function (items) {
                  var beginswith = []
                    , caseSensitive = []
                    , caseInsensitive = []
                    , item

                  while (item = items.shift()) {
                    if (!{{ matcher }}.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
                    else if (~{{ matcher }}.indexOf(this.query)) caseSensitive.push(item)
                    else caseInsensitive.push(item)
                  }

                  return beginswith.concat(caseSensitive, caseInsensitive)
              },
              highlighter: function (item) {
                  var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
                  return {{ matcher }}.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
                      return '<strong>' + match + '</strong>'
                  });
              },<commit_msg>Excluding already chosen entities from EntityPicker's query result. (fix for Collection of EntityPicker)<commit_after>{% block double_list_widget %}
<script type="text/javascript" src="{{ asset('bundles/admingeneratorgenerator/javascripts/double_list.js') }}"></script>
<div class="double_list">
    <div style="float: left">
        <div class="double_list_label">{% trans from "Admingenerator" %}double_list.unselected{% endtrans %}</div>
        <select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][unselected]" multiple="true" id="{{ form.get("id") }}_unselected" class="double_list_select-unselected">
        {% for choice in choices %}
            {% if choice is not selectedchoice(value) %}
                <option value="{{ choice.value }}">{{ choice.label }}</option>
            {% endif %}
        {% endfor %}
        </select>
    </div>
    <div style="float: left; margin-top: 2em">
         <a href="#" onclick="sfDoubleList.move('{{ form.get("id") }}_unselected','{{ form.get("id") }}_selected'); return false;">
            <img src="{{ asset('bundles/admingeneratorgenerator/images/next.png') }}" alt="unassociate" />
         </a>
         <br />
         <a href="#" onclick="sfDoubleList.move('{{ form.get("id") }}_selected','{{ form.get("id") }}_unselected'); return false;">
            <img src="{{ asset('bundles/admingeneratorgenerator/images/previous.png') }}" alt="associate" />
         </a>
    </div>
    <div style="float: left">
         <div class="double_list_label">{% trans from "Admingenerator" %}double_list.selected{% endtrans %}</div>
         <select name="{{ form.getParent().get('id') }}[{{ form.get("name") }}][]" multiple="true" id="{{ form.get("id") }}_selected" {% if (form.vars.required) %}required="required" {% endif %}class="double_list_select-selected">
         {% for choice in choices %}
            {% if choice is selectedchoice(value) %}
                <option value="{{ choice.value }}">{{ choice.label }}</option>
            {% endif %}
         {% endfor %}
         </select>
    </div>
    <br style="clear: both" />
    <script type="text/javascript">
        sfDoubleList.init(document.getElementById('{{ form.get("id") }}_selected'), 'double_list_select');
    </script>
</div>
{% endblock %}
{% block doctrine_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}
{% block doctrine_odm_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}
{% block propel_double_list_widget %}
    {{- block('double_list_widget') -}}
{% endblock %}

{% block datepicker_range_widget %}
    <div {{ block('widget_container_attributes') }}>
        {% for child in form %}
            {{ form_widget(child) }}
        {% endfor %}
    </div>    
{% endblock %}

{% block datepicker_widget %}
    <div class="{% if prepend_label %}input-prepend {% endif %}input-append">
        {% if prepend_label %}<span class="add-on span2">{{ label|trans({}, 'Admingenerator') }}</span>{% endif %}
        <input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
        <span class="add-on"><i class="icon-calendar"></i></span>
    </div>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#{{ id }}').datepicker({
              format: '{{ format|lower }}',
              language: '{{ app.request.locale }}',
              weekStart: {{ weekstart }},
            });
        });
    </script>
{% endblock %}
    
{% macro datasource(object, builder) %}
{% autoescape -%}
    {% for key,property in builder %}
      {%- if loop.first %}{{ '{' }}{% endif -%}
          {{ '"' ~ key ~ '": "' ~ attribute(object, property) ~ '"' }}
          {%- if not loop.last %}{{ ', ' }}{% endif -%}
      {%- if loop.last %}{{ '}' }}{% endif -%}
    {% endfor %}
{%- endautoescape %}
{% endmacro %}
    
{% block entity_picker_widget %}
{% spaceless %}
    <input type="text" id="{{ id ~ '_typeahead' }}" data-source="
      {%- for choice in choices -%}
        {%- if loop.first %}{{ '[' }}{% endif -%}
            {{ _self.datasource(choice.data, builder) }}
        {%- if not loop.last %}{{ ',' }}{% else %}{{ ']' }}{% endif -%}
      {%- endfor -%}" {% if placeholder %}placeholder="{{ placeholder|trans({}, 'Admingenerator') }}"{% endif %}/>
    <input type="hidden" {{ block('widget_attributes') }} />
    
    <script type="text/javascript">
        $(document).ready(function() {
            $('#{{ id ~ '_typeahead' }}').typeahead({
              source: function() {
                  var data = this.$element.data('source'); 
                  
                  {% if form.parent.vars.prototype is defined %}
                    return $(data).filter(function(index, item) {
                        var values = [];
                        var hiddens = $('#{{ form.parent.vars.id }}').find('input[type="hidden"]');
                        
                        hiddens.each(function(i,e){
                          values.push($(e).val());
                        });
                        
                        return ($.inArray({{ identifier }}, values) > -1) ? false : true;
                    });
                  {% else %}
                    return data;
                  {% endif %}
              },
              matcher: function (item) {
                  return ~{{ matcher }}.toLowerCase().indexOf(this.query.toLowerCase());
              },
              sorter: function (items) {
                  var beginswith = []
                    , caseSensitive = []
                    , caseInsensitive = []
                    , item

                  while (item = items.shift()) {
                    if (!{{ matcher }}.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
                    else if (~{{ matcher }}.indexOf(this.query)) caseSensitive.push(item)
                    else caseInsensitive.push(item)
                  }

                  return beginswith.concat(caseSensitive, caseInsensitive)
              },
              highlighter: function (item) {
                  var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
                  return {{ matcher }}.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
                      return '<strong>' + match + '</strong>'
                  });
              },
{'fraction_non_alphanumeric': 0.20245500539105912, 'fraction_numerical': 0.0005805755992369577, 'mean_word_length': 2.242269427265394, 'pattern_counts': {'":': 2, '<': 103, '<?xml version=': 0, '>': 104, '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': '2475725', 'n_tokens_mistral': 3697, 'n_tokens_neox': 3420, 'n_words': 687}