diff --git a/InvenTree/InvenTree/static/script/inventree/company.js b/InvenTree/InvenTree/static/script/inventree/company.js
new file mode 100644
index 0000000000..f007ed8c14
--- /dev/null
+++ b/InvenTree/InvenTree/static/script/inventree/company.js
@@ -0,0 +1,82 @@
+
+function loadCompanyTable(table, url, options={}) {
+ /*
+ * Load company listing data into specified table.
+ *
+ * Args:
+ * - table: Table element on the page
+ * - url: Base URL for the API query
+ * - options: table options.
+ */
+
+ // Query parameters
+ var params = options.params || {};
+
+ var filters = loadTableFilters("company");
+
+ for (var key in params) {
+ filters[key] = params[key];
+ }
+
+ setupFilterList("company", $(table));
+
+ $(table).inventreeTable({
+ url: url,
+ method: 'get',
+ queryParams: filters,
+ groupBy: false,
+ formatNoMatches: function() { return "No company information found"; },
+ columns: [
+ {
+ field: 'pk',
+ title: 'ID',
+ visible: false,
+ },
+ {
+ field: 'name',
+ title: 'Company',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ var html = imageHoverIcon(row.image) + renderLink(value, row.url);
+
+ if (row.is_customer) {
+ html += ``;
+ }
+
+ if (row.is_manufacturer) {
+ html += ``;
+ }
+
+ if (row.is_supplier) {
+ html += ``;
+ }
+
+ return html;
+ }
+ },
+ {
+ field: 'description',
+ title: 'Description',
+ sortable: true,
+ },
+ {
+ field: 'website',
+ title: 'Website',
+ formatter: function(value, row, index, field) {
+ if (value) {
+ return renderLink(value, value);
+ }
+ return '';
+ }
+ },
+ {
+ field: 'part_count',
+ title: 'Parts',
+ sortable: true,
+ formatter: function(value, row, index, field) {
+ return renderLink(value, row.url + 'parts/');
+ }
+ },
+ ],
+ });
+}
diff --git a/InvenTree/InvenTree/static/script/inventree/filters.js b/InvenTree/InvenTree/static/script/inventree/filters.js
index f59645bf8a..818cf747c7 100644
--- a/InvenTree/InvenTree/static/script/inventree/filters.js
+++ b/InvenTree/InvenTree/static/script/inventree/filters.js
@@ -17,6 +17,7 @@ function defaultFilters() {
stock: "cascade=1",
build: "",
parts: "cascade=1",
+ company: "",
};
}
diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html
index 2bdc936db8..245e357489 100644
--- a/InvenTree/company/templates/company/index.html
+++ b/InvenTree/company/templates/company/index.html
@@ -33,61 +33,9 @@ InvenTree | {% trans "Supplier List" %}
});
});
- $("#company-table").inventreeTable({
- formatNoMatches: function() { return "No company information found"; },
- columns: [
- {
- field: 'pk',
- title: '{% trans "ID" %}',
- visible: false,
- },
- {
- field: 'name',
- title: '{% trans "Supplier" %}',
- sortable: true,
- formatter: function(value, row, index, field) {
- var html = imageHoverIcon(row.image) + renderLink(value, row.url);
-
- if (row.is_customer) {
- html += ``;
- }
-
- if (row.is_manufacturer) {
- html += ``;
- }
-
- if (row.is_supplier) {
- html += ``;
- }
-
- return html;
- }
- },
- {
- field: 'description',
- title: '{% trans "Description" %}',
- sortable: true,
- },
- {
- field: 'website',
- title: '{% trans "Website" %}',
- formatter: function(value, row, index, field) {
- if (value) {
- return renderLink(value, value);
- }
- return '';
- }
- },
- {
- field: 'part_count',
- title: '{% trans "Parts" %}',
- sortable: true,
- formatter: function(value, row, index, field) {
- return renderLink(value, row.url + 'parts/');
- }
- },
- ],
- url: "{% url 'api-company-list' %}"
- });
+ loadCompanyTable("#company-table", "{% url 'api-company-list' %}",
+ {
+ }
+ );
{% endblock %}
\ No newline at end of file
diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html
index 987e1872f2..3cae9fd37b 100644
--- a/InvenTree/templates/base.html
+++ b/InvenTree/templates/base.html
@@ -108,6 +108,7 @@ InvenTree
+