Sha256: 4eb3ed3d2b1b53b24f6533da0c67c100fdfb1dc8d47d9af7682e8c95e5f50b73

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

var oldToggleFilter = window.toggleFilter;

window.toggleFilter = function (field) {
    oldToggleFilter(field);
    return transform_to_select2(field);
};

function formatStateWithAvatar(opt) {
    return $('<span>' + opt.avatar + '&nbsp;' + opt.text + '</span>');
};

var select2Filters = {};

function transform_to_select2(field) {
    field = field.replace('.', '_');
    var filter = select2Filters[field];
    if (filter !== undefined && $('#tr_' + field + ' .values .select2').size() == 0) {
        $('#tr_' + field + ' .toggle-multiselect').hide();
        $('#tr_' + field + ' .values .value').attr('multiple', 'multiple');
        $('#tr_' + field + ' .values .value').select2({
            ajax: {
                url: filter['url'],
                dataType: 'json',
                delay: 250,
                data: function (params) {
                    return {q: params.term};
                },
                processResults: function (data, params) {
                    return {results: data};
                },
                cache: true
            },
            placeholder: ' ',
            minimumInputLength: filter['minimumInputLength'],
            width: filter['width'],
            templateResult: filter['formatState']
        });
    }
};

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine_crm-0.0.37 vendor/assets/javascripts/select2_helpers.js