diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 668c241294..d697b401e7 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -21,6 +21,7 @@ class CompanyList(generics.ListCreateAPIView): filter_backends = [ DjangoFilterBackend, filters.SearchFilter, + filters.OrderingFilter, ] filter_fields = [ diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index 7e746bf9d0..82655557e6 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -1,30 +1,31 @@ {% extends "base.html" %} +{% load static %} + {% block content %}

Companies

+
+
+ + + + +

-TODO - Filtering! (customer / supplier / search) -
- -
+
+ + {% endblock %} \ No newline at end of file diff --git a/InvenTree/static/script/filter_company.js b/InvenTree/static/script/filter_company.js new file mode 100644 index 0000000000..8b36847680 --- /dev/null +++ b/InvenTree/static/script/filter_company.js @@ -0,0 +1,72 @@ +var keyDelay = 0; + +var delay = (function(){ + return function(callback, ms){ + clearTimeout(keyDelay); + keyDelay = setTimeout(callback, ms); + }; +})(); + + +function add_company(company){ + + var text = "
  • "; + + text += ""; + text += company.name + ""; + + if (company.description){ + text += " - " + company.description; + } + + text += "
  • "; + + $("#company-list").append(text); +} + + +function filter(text){ + + $.ajax( + { + url: "/api/company/", + success: function(result) { + $("#company-list").empty(); + $.each(result.results, function(i, company){ + add_company(company); + }) + }, + data: { + 'search': text, + } + } + ); +} + +$(document).ready(function(){ + $("#company-filter").keyup(function(e) { + + if (e.keyCode == 27){ // Escape key + clearTimeout(keyDelay); + $("#company-filter").val(''); + filter(''); + } + else { + + var value = $(this).val().toLowerCase(); + + delay(function() { + filter(value); + }, 500); + } + }); + + $("#clear-filter").click(function(){ + clearTimeout(keyDelay); + $("#company-filter").val(''); + filter(''); + }); + + // Initially load the list with all values + filter(''); +}); \ No newline at end of file diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 3151fd1477..34c5753488 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -16,12 +16,19 @@ + + + +{% block head %} + +{% endblock %} + {% block title %} InvenTree