mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
More translations for part.js and stock.js
This commit is contained in:
parent
b1a642918c
commit
24a816e9a2
@ -1,59 +0,0 @@
|
||||
/* Part API functions
|
||||
* Requires api.js to be loaded first
|
||||
*/
|
||||
|
||||
function toggleStar(options) {
|
||||
/* Toggle the 'starred' status of a part.
|
||||
* Performs AJAX queries and updates the display on the button.
|
||||
*
|
||||
* options:
|
||||
* - button: ID of the button (default = '#part-star-icon')
|
||||
* - part: pk of the part object
|
||||
* - user: pk of the user
|
||||
*/
|
||||
|
||||
var url = '/api/part/star/';
|
||||
|
||||
inventreeGet(
|
||||
url,
|
||||
{
|
||||
part: options.part,
|
||||
user: options.user,
|
||||
},
|
||||
{
|
||||
success: function(response) {
|
||||
if (response.length == 0) {
|
||||
// Zero length response = star does not exist
|
||||
// So let's add one!
|
||||
inventreePut(
|
||||
url,
|
||||
{
|
||||
part: options.part,
|
||||
user: options.user,
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
success: function(response, status) {
|
||||
$(options.button).addClass('icon-yellow');
|
||||
},
|
||||
}
|
||||
);
|
||||
} else {
|
||||
var pk = response[0].pk;
|
||||
// There IS a star (delete it!)
|
||||
inventreePut(
|
||||
url + pk + "/",
|
||||
{
|
||||
},
|
||||
{
|
||||
method: 'DELETE',
|
||||
success: function(response, status) {
|
||||
$(options.button).removeClass('icon-yellow');
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
/* Stock API functions
|
||||
* Requires api.js to be loaded first
|
||||
*/
|
||||
|
||||
/* Functions for interacting with stock management forms
|
||||
*/
|
||||
|
||||
function removeStockRow(e) {
|
||||
// Remove a selected row from a stock modal form
|
||||
|
||||
e = e || window.event;
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var row = $(src).attr('row');
|
||||
|
||||
$('#' + row).remove();
|
||||
}
|
||||
|
||||
function loadStockTrackingTable(table, options) {
|
||||
|
||||
var cols = [
|
||||
{
|
||||
field: 'pk',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'date',
|
||||
title: 'Date',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var m = moment(value);
|
||||
if (m.isValid()) {
|
||||
var html = m.format('dddd MMMM Do YYYY'); // + '<br>' + m.format('h:mm a');
|
||||
return html;
|
||||
}
|
||||
|
||||
return 'N/A';
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// If enabled, provide a link to the referenced StockItem
|
||||
if (options.partColumn) {
|
||||
cols.push({
|
||||
field: 'item',
|
||||
title: 'Stock Item',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value.part_name, value.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Stock transaction description
|
||||
cols.push({
|
||||
field: 'title',
|
||||
title: 'Description',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var html = "<b>" + value + "</b>";
|
||||
|
||||
if (row.notes) {
|
||||
html += "<br><i>" + row.notes + "</i>";
|
||||
}
|
||||
|
||||
if (row.link) {
|
||||
html += "<br><a href='" + row.link + "'>" + row.link + "</a>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
cols.push({
|
||||
field: 'quantity',
|
||||
title: 'Quantity',
|
||||
formatter: function(value, row, index, field) {
|
||||
return parseFloat(value);
|
||||
},
|
||||
});
|
||||
|
||||
cols.push({
|
||||
sortable: true,
|
||||
field: 'user',
|
||||
title: 'User',
|
||||
formatter: function(value, row, index, field) {
|
||||
if (value)
|
||||
{
|
||||
// TODO - Format the user's first and last names
|
||||
return value.username;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "No user information";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cols.push({
|
||||
sortable: false,
|
||||
formatter: function(value, row, index, field) {
|
||||
// Manually created entries can be edited or deleted
|
||||
if (!row.system) {
|
||||
var bEdit = "<button title='Edit tracking entry' class='btn btn-entry-edit btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/edit/'><span class='fas fa-edit'/></button>";
|
||||
var bDel = "<button title='Delete tracking entry' class='btn btn-entry-delete btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/delete/'><span class='fas fa-trash-alt icon-red'/></button>";
|
||||
|
||||
return "<div class='btn-group' role='group'>" + bEdit + bDel + "</div>";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
table.inventreeTable({
|
||||
method: 'get',
|
||||
queryParams: options.params,
|
||||
columns: cols,
|
||||
url: options.url,
|
||||
});
|
||||
|
||||
if (options.buttons) {
|
||||
linkButtonsToSelection(table, options.buttons);
|
||||
}
|
||||
|
||||
table.on('click', '.btn-entry-edit', function() {
|
||||
var button = $(this);
|
||||
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
||||
table.on('click', '.btn-entry-delete', function() {
|
||||
var button = $(this);
|
||||
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
}
|
@ -102,12 +102,10 @@ InvenTree
|
||||
|
||||
<script type='text/javascript' src="{% static 'script/inventree/inventree.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/api.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/part.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/bom.js' %}"></script>
|
||||
<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/build.js' %}"></script>
|
||||
<script type='text/javascript' src="{% static 'script/inventree/stock.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>
|
||||
|
@ -1,5 +1,65 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* Part API functions
|
||||
* Requires api.js to be loaded first
|
||||
*/
|
||||
|
||||
function toggleStar(options) {
|
||||
/* Toggle the 'starred' status of a part.
|
||||
* Performs AJAX queries and updates the display on the button.
|
||||
*
|
||||
* options:
|
||||
* - button: ID of the button (default = '#part-star-icon')
|
||||
* - part: pk of the part object
|
||||
* - user: pk of the user
|
||||
*/
|
||||
|
||||
var url = '/api/part/star/';
|
||||
|
||||
inventreeGet(
|
||||
url,
|
||||
{
|
||||
part: options.part,
|
||||
user: options.user,
|
||||
},
|
||||
{
|
||||
success: function(response) {
|
||||
if (response.length == 0) {
|
||||
// Zero length response = star does not exist
|
||||
// So let's add one!
|
||||
inventreePut(
|
||||
url,
|
||||
{
|
||||
part: options.part,
|
||||
user: options.user,
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
success: function(response, status) {
|
||||
$(options.button).addClass('icon-yellow');
|
||||
},
|
||||
}
|
||||
);
|
||||
} else {
|
||||
var pk = response[0].pk;
|
||||
// There IS a star (delete it!)
|
||||
inventreePut(
|
||||
url + pk + "/",
|
||||
{
|
||||
},
|
||||
{
|
||||
method: 'DELETE',
|
||||
success: function(response, status) {
|
||||
$(options.button).removeClass('icon-yellow');
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function loadPartTable(table, url, options={}) {
|
||||
/* Load part listing data into specified table.
|
||||
*
|
||||
|
@ -1,5 +1,23 @@
|
||||
{% load i18n %}
|
||||
|
||||
/* Stock API functions
|
||||
* Requires api.js to be loaded first
|
||||
*/
|
||||
|
||||
/* Functions for interacting with stock management forms
|
||||
*/
|
||||
|
||||
function removeStockRow(e) {
|
||||
// Remove a selected row from a stock modal form
|
||||
|
||||
e = e || window.event;
|
||||
var src = e.target || e.srcElement;
|
||||
|
||||
var row = $(src).attr('row');
|
||||
|
||||
$('#' + row).remove();
|
||||
}
|
||||
|
||||
function loadStockTable(table, options) {
|
||||
/* Load data into a stock table with adjustable options.
|
||||
* Fetches data (via AJAX) and loads into a bootstrap table.
|
||||
@ -358,3 +376,126 @@ function loadStockTable(table, options) {
|
||||
stockAdjustment('delete');
|
||||
});
|
||||
}
|
||||
|
||||
function loadStockTrackingTable(table, options) {
|
||||
|
||||
var cols = [
|
||||
{
|
||||
field: 'pk',
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
field: 'date',
|
||||
title: '{% trans "Date" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var m = moment(value);
|
||||
if (m.isValid()) {
|
||||
var html = m.format('dddd MMMM Do YYYY'); // + '<br>' + m.format('h:mm a');
|
||||
return html;
|
||||
}
|
||||
|
||||
return 'N/A';
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// If enabled, provide a link to the referenced StockItem
|
||||
if (options.partColumn) {
|
||||
cols.push({
|
||||
field: 'item',
|
||||
title: '{% trans "Stock Item" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value.part_name, value.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Stock transaction description
|
||||
cols.push({
|
||||
field: 'title',
|
||||
title: '{% trans "Description" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var html = "<b>" + value + "</b>";
|
||||
|
||||
if (row.notes) {
|
||||
html += "<br><i>" + row.notes + "</i>";
|
||||
}
|
||||
|
||||
if (row.link) {
|
||||
html += "<br><a href='" + row.link + "'>" + row.link + "</a>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
});
|
||||
|
||||
cols.push({
|
||||
field: 'quantity',
|
||||
title: '{% trans "Quantity" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return parseFloat(value);
|
||||
},
|
||||
});
|
||||
|
||||
cols.push({
|
||||
sortable: true,
|
||||
field: 'user',
|
||||
title: '{% trans "User" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
if (value)
|
||||
{
|
||||
// TODO - Format the user's first and last names
|
||||
return value.username;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "{% trans "No user information" %}";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cols.push({
|
||||
sortable: false,
|
||||
formatter: function(value, row, index, field) {
|
||||
// Manually created entries can be edited or deleted
|
||||
if (!row.system) {
|
||||
var bEdit = "<button title='Edit tracking entry' class='btn btn-entry-edit btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/edit/'><span class='fas fa-edit'/></button>";
|
||||
var bDel = "<button title='Delete tracking entry' class='btn btn-entry-delete btn-default btn-glyph' type='button' url='/stock/track/" + row.pk + "/delete/'><span class='fas fa-trash-alt icon-red'/></button>";
|
||||
|
||||
return "<div class='btn-group' role='group'>" + bEdit + bDel + "</div>";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
table.inventreeTable({
|
||||
method: 'get',
|
||||
queryParams: options.params,
|
||||
columns: cols,
|
||||
url: options.url,
|
||||
});
|
||||
|
||||
if (options.buttons) {
|
||||
linkButtonsToSelection(table, options.buttons);
|
||||
}
|
||||
|
||||
table.on('click', '.btn-entry-edit', function() {
|
||||
var button = $(this);
|
||||
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
|
||||
table.on('click', '.btn-entry-delete', function() {
|
||||
var button = $(this);
|
||||
|
||||
launchModalForm(button.attr('url'), {
|
||||
reload: true,
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user