mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Company table now in separate javascript file
This commit is contained in:
parent
f427ee4754
commit
95354f09da
82
InvenTree/InvenTree/static/script/inventree/company.js
Normal file
82
InvenTree/InvenTree/static/script/inventree/company.js
Normal file
@ -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 += `<span title='Customer' class='fas fa-user label-right'></span>`;
|
||||
}
|
||||
|
||||
if (row.is_manufacturer) {
|
||||
html += `<span title='Manufacturer' class='fas fa-industry label-right'></span>`;
|
||||
}
|
||||
|
||||
if (row.is_supplier) {
|
||||
html += `<span title='Supplier' class='fas fa-building label-right'></span>`;
|
||||
}
|
||||
|
||||
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/');
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
@ -17,6 +17,7 @@ function defaultFilters() {
|
||||
stock: "cascade=1",
|
||||
build: "",
|
||||
parts: "cascade=1",
|
||||
company: "",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -33,61 +33,9 @@ InvenTree | {% trans "Supplier List" %}
|
||||
});
|
||||
});
|
||||
|
||||
$("#company-table").inventreeTable({
|
||||
formatNoMatches: function() { return "No company information found"; },
|
||||
columns: [
|
||||
loadCompanyTable("#company-table", "{% url 'api-company-list' %}",
|
||||
{
|
||||
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 += `<span title='Customer' class='fas fa-user label-right'></span>`;
|
||||
}
|
||||
|
||||
if (row.is_manufacturer) {
|
||||
html += `<span title='Manufacturer' class='fas fa-industry label-right'></span>`;
|
||||
}
|
||||
|
||||
if (row.is_supplier) {
|
||||
html += `<span title='Supplier' class='fas fa-building label-right'></span>`;
|
||||
}
|
||||
|
||||
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' %}"
|
||||
});
|
||||
);
|
||||
|
||||
{% endblock %}
|
@ -108,6 +108,7 @@ InvenTree
|
||||
<script type='text/javascript' src="{% static 'script/inventree/build.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/modals.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/order.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/company.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/notification.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/sidenav.js' %}"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user