Small tweaks here and there

This commit is contained in:
Oliver 2021-08-15 21:47:37 +10:00
parent 4061693522
commit 1998dabe9b
4 changed files with 28 additions and 5 deletions

View File

@ -42,9 +42,32 @@ function loadAttachmentTable(url, options) {
title: '{% trans "File" %}',
formatter: function(value, row) {
var split = value.split('/');
var icon = 'fa-file-alt';
return renderLink(split[split.length - 1], value);
var fn = value.toLowerCase();
if (fn.endsWith('.pdf')) {
icon = 'fa-file-pdf';
} else if (fn.endsWith('.xls') || fn.endsWith('.xlsx')) {
icon = 'fa-file-excel';
} else if (fn.endsWith('.doc') || fn.endsWith('.docx')) {
icon = 'fa-file-word';
} else {
var images = ['.png', '.jpg', '.bmp', '.gif', '.svg', '.tif'];
images.forEach(function (suffix) {
if (fn.endsWith(suffix)) {
icon = 'fa-file-image';
}
});
}
var split = value.split('/');
var filename = split[split.length - 1];
var html = `<span class='fas ${icon}'></span> ${filename}`;
return renderLink(html, value);
}
},
{

View File

@ -252,7 +252,7 @@ function loadBomTable(table, options) {
sortable: true,
formatter: function(value, row, index, field) {
var url = `/part/${row.sub_part_detail.pk}/stock/`;
var url = `/part/${row.sub_part_detail.pk}/?display=stock`;
var text = value;
if (value == null || value <= 0) {

View File

@ -500,7 +500,7 @@ function loadPartVariantTable(table, partId, options={}) {
field: 'in_stock',
title: '{% trans "Stock" %}',
formatter: function(value, row) {
return renderLink(value, `/part/${row.pk}/stock/`);
return renderLink(value, `/part/${row.pk}/?display=stock`);
}
}
];

View File

@ -1066,7 +1066,7 @@ function loadStockTable(table, options) {
return '-';
}
var link = `/supplier-part/${row.supplier_part}/stock/`;
var link = `/supplier-part/${row.supplier_part}/?display=stock`;
var text = '';