var SELECT2_DELAY = 250; var select2Filters = {}; function setSelect2Filter(type, options) { if (typeof operatorByType === 'undefined') { return } operatorByType[type] = operatorByType[type] || operatorByType['list_optional']; select2Filters[type] = options; }; var originBuildFilterRow = buildFilterRow; buildFilterRow = function (field, operator, values) { originBuildFilterRow(field, operator, values); var options = select2Options(field); if (options) { setSelect2FilterValues(field, options, values); transformToSelect2(field, options); } }; function select2Options(field) { var filter = availableFilters[field]; var options = select2Filters[filter['type']]; if (!options && filter['field_format']) { options = select2Filters[field] } return options; }; function setSelect2FilterValues(field, options, values) { var needAddValues = !rowHasSelectTag(field); if (needAddValues) { addSelectTag(field) } var $select = findSelectTagInRowBy(field); if (options['multiple'] !== false) { $select.attr('multiple', true) } if (needAddValues) { addOptionTags($select, field, values); } }; function addSelectTag(field) { var fieldId = sanitizeToId(field); $('#tr_' + fieldId).find('td.values').append( '' ); }; function addOptionTags($select, field, values) { var filterValues = availableFilters[field]['values']; for (var i = 0; i < filterValues.length; i++) { var filterValue = filterValues[i]; var option = $('