Sha256: 786a4e374c513f67dffdcb6b4d2ac0d9f269f8c8dbc76712d1fecee8bd05f67c

Contents?: true

Size: 904 Bytes

Versions: 8

Compression:

Stored size: 904 Bytes

Contents

$.fn.userAutocomplete = function () {
  'use strict';

  function formatUser(user) {
    return Select2.util.escapeMarkup(user.email);
  }

  this.select2({
    minimumInputLength: 1,
    multiple: true,
    initSelection: function (element, callback) {
      $.get(Spree.routes.user_search, {
        ids: element.val()
      }, function (data) {
        callback(data.users);
      });
    },
    ajax: {
      url: Spree.routes.user_search,
      datatype: 'json',
      params: { "headers": { "X-Spree-Token": Spree.api_key } },
      data: function (term) {
        return {
          q: term,
          token: Spree.api_key
        };
      },
      results: function (data) {
        return {
          results: data.users
        };
      }
    },
    formatResult: formatUser,
    formatSelection: formatUser
  });
};

$(document).ready(function () {
  $('.user_picker').userAutocomplete();
});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solidus_backend-1.2.3 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.4 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.7 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.6 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.2.2 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.2.1 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.1.3 app/assets/javascripts/spree/backend/user_picker.js
solidus_backend-1.0.5 app/assets/javascripts/spree/backend/user_picker.js