diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index a71e29ab5d..adb5a41ee6 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -1037,3 +1037,10 @@ a.anchor { height: 30px; } +.search-menu { + padding-top: 2rem; +} + +.search-menu .ui-menu-item { + margin-top: 0.5rem; +} diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 79e02d7da5..bdcbb82ebd 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -80,6 +80,41 @@ function inventreeDocReady() { attachClipboard('.clip-btn'); attachClipboard('.clip-btn', 'modal-about'); // modals attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // version-text + + // Add autocomplete to the search-bar + $("#search-bar" ).autocomplete({ + source: function (request, response) { + $.ajax({ + url: '/api/part/', + data: { search: request.term, limit: 4, offset: 0 }, + success: function (data) { + var transformed = $.map(data.results, function (el) { + return { + label: el.name, + id: el.pk, + thumbnail: el.thumbnail + }; + }); + response(transformed); + }, + error: function () { + response([]); + } + }); + }, + create: function () { + $(this).data('ui-autocomplete')._renderItem = function (ul, item) { + return $('
  • ') + .append('' + imageHoverIcon(item.thumbnail) + item.label + '') + .appendTo(ul); + }; + }, + select: function( event, ui ) { + window.location = '/part/' + ui.item.id + '/'; + }, + minLength: 2, + classes: {'ui-autocomplete': 'dropdown-menu search-menu'}, + }); } function isFileTransfer(transfer) { diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_444444_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_444444_256x240.png index ed8d9135ca..84220b0da1 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_444444_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_444444_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_555555_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_555555_256x240.png index 67648e3e9e..4ac750dd31 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_555555_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_555555_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777620_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777620_256x240.png index f2cc3f0e64..c5f9c9af67 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777620_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777620_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777777_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777777_256x240.png index 6adf699471..c0891d6de7 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777777_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_777777_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_cc0000_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_cc0000_256x240.png index a24cde337d..fdaa36b219 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_cc0000_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_cc0000_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_ffffff_256x240.png b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_ffffff_256x240.png index 6766245740..08e2f14488 100644 Binary files a/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_ffffff_256x240.png and b/InvenTree/InvenTree/static/script/jquery-ui/images/ui-icons_ffffff_256x240.png differ diff --git a/InvenTree/InvenTree/static/script/jquery-ui/index.html b/InvenTree/InvenTree/static/script/jquery-ui/index.html index b5ac7218c6..6bc6bf7980 100644 --- a/InvenTree/InvenTree/static/script/jquery-ui/index.html +++ b/InvenTree/InvenTree/static/script/jquery-ui/index.html @@ -59,6 +59,11 @@

    YOUR COMPONENTS:

    + +

    Autocomplete

    +
    + +
    @@ -248,6 +253,23 @@ + +

    Menu

    + @@ -270,6 +292,33 @@