mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Add translation layer for order.js
This commit is contained in:
@ -106,7 +106,6 @@ InvenTree
|
||||
<script type='text/javascript' src="{% static 'script/inventree/filters.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/tables.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>
|
||||
@ -114,6 +113,7 @@ InvenTree
|
||||
<script type='text/javascript' src="{% url 'part.js' %}"></script>
|
||||
<script type='text/javascript' src="{% url 'stock.js' %}"></script>
|
||||
<script type='text/javascript' src="{% url 'build.js' %}"></script>
|
||||
<script type='text/javascript' src="{% url 'order.js' %}"></script>
|
||||
|
||||
<script type='text/javascript' src="{% static 'fontawesome/js/solid.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'fontawesome/js/brands.js' %}"></script>
|
||||
|
257
InvenTree/templates/js/order.js
Normal file
257
InvenTree/templates/js/order.js
Normal file
@ -0,0 +1,257 @@
|
||||
{% load i18n %}
|
||||
|
||||
function removeOrderRowFromOrderWizard(e) {
|
||||
/* Remove a part selection from an order form. */
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var row = $(src).attr('row');
|
||||
|
||||
$('#' + row).remove();
|
||||
}
|
||||
|
||||
function newSupplierPartFromOrderWizard(e) {
|
||||
/* Create a new supplier part directly from an order form.
|
||||
* Launches a secondary modal and (if successful),
|
||||
* back-populates the selected row.
|
||||
*/
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var part = $(src).attr('part-id');
|
||||
|
||||
launchModalForm("/supplier-part/new/", {
|
||||
modal: '#modal-form-secondary',
|
||||
data: {
|
||||
part: part,
|
||||
},
|
||||
success: function(response) {
|
||||
/* A new supplier part has been created! */
|
||||
|
||||
var dropdown = '#id_supplier_part_' + part;
|
||||
|
||||
var option = new Option(response.text, response.pk, true, true);
|
||||
|
||||
$('#modal-form').find(dropdown).append(option).trigger('change');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function newPurchaseOrderFromOrderWizard(e) {
|
||||
/* Create a new purchase order directly from an order form.
|
||||
* Launches a secondary modal and (if successful),
|
||||
* back-fills the newly created purchase order.
|
||||
*/
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var supplier = $(src).attr('supplier-id');
|
||||
|
||||
launchModalForm("/order/purchase-order/new/", {
|
||||
modal: '#modal-form-secondary',
|
||||
data: {
|
||||
supplier: supplier,
|
||||
},
|
||||
success: function(response) {
|
||||
/* A new purchase order has been created! */
|
||||
|
||||
var dropdown = '#id-purchase-order-' + supplier;
|
||||
|
||||
var option = new Option(response.text, response.pk, true, true);
|
||||
|
||||
$('#modal-form').find(dropdown).append(option).trigger('change');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function editPurchaseOrderLineItem(e) {
|
||||
|
||||
/* Edit a purchase order line item in a modal form.
|
||||
*/
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var url = $(src).attr('url');
|
||||
|
||||
launchModalForm(url, {
|
||||
reload: true,
|
||||
});
|
||||
}
|
||||
|
||||
function removePurchaseOrderLineItem(e) {
|
||||
|
||||
/* Delete a purchase order line item in a modal form
|
||||
*/
|
||||
|
||||
e = e || window.event;
|
||||
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var url = $(src).attr('url');
|
||||
|
||||
launchModalForm(url, {
|
||||
reload: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function loadPurchaseOrderTable(table, options) {
|
||||
/* Create a purchase-order table */
|
||||
|
||||
options.params = options.params || {};
|
||||
|
||||
options.params['supplier_detail'] = true;
|
||||
|
||||
var filters = loadTableFilters("purchaseorder");
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
}
|
||||
|
||||
setupFilterList("purchaseorder", $(table));
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url,
|
||||
queryParams: filters,
|
||||
groupBy: false,
|
||||
original: options.params,
|
||||
formatNoMatches: function() { return "{% trans "No purchase orders found" %}"; },
|
||||
columns: [
|
||||
{
|
||||
field: 'pk',
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'reference',
|
||||
title: '{% trans "Purchase Order" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, `/order/purchase-order/${row.pk}/`);
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'supplier_detail',
|
||||
title: '{% trans "Supplier" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return imageHoverIcon(row.supplier_detail.image) + renderLink(row.supplier_detail.name, `/company/${row.supplier}/purchase-orders/`);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'supplier_reference',
|
||||
title: '{% trans "Supplier Reference" %}',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'description',
|
||||
title: '{% trans "Description" %}',
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'status',
|
||||
title: '{% trans "Status" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return purchaseOrderStatusDisplay(row.status, row.status_text);
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'creation_date',
|
||||
title: '{% trans "Date" %}',
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'line_items',
|
||||
title: '{% trans "Items" %}'
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
function loadSalesOrderTable(table, options) {
|
||||
|
||||
options.params = options.params || {};
|
||||
options.params['customer_detail'] = true;
|
||||
|
||||
var filters = loadTableFilters("salesorder");
|
||||
|
||||
for (var key in options.params) {
|
||||
filters[key] = options.params[key];
|
||||
}
|
||||
|
||||
setupFilterList("salesorder", $(table));
|
||||
|
||||
$(table).inventreeTable({
|
||||
url: options.url,
|
||||
queryParams: filters,
|
||||
groupBy: false,
|
||||
original: options.params,
|
||||
formatNoMatches: function() { return "{% trans "No sales orders found" %}"; },
|
||||
columns: [
|
||||
{
|
||||
field: 'pk',
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'reference',
|
||||
title: '{% trans "Sales Order" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, `/order/sales-order/${row.pk}/`);
|
||||
},
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'customer_detail',
|
||||
title: '{% trans "Customer" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return imageHoverIcon(row.customer_detail.image) + renderLink(row.customer_detail.name, `/company/${row.customer}/sales-orders/`);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'customer_reference',
|
||||
title: '{% trans "Customer Reference" %}',
|
||||
sotrable: true,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'description',
|
||||
title: '{% trans "Description" %}',
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'status',
|
||||
title: '{% trans "Status" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return salesOrderStatusDisplay(row.status, row.status_text);
|
||||
}
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'creation_date',
|
||||
title: '{% trans "Creation Date" %}',
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'shipment_date',
|
||||
title: "{% trans "Shipment Date" %}",
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'line_items',
|
||||
title: '{% trans "Items" %}'
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user