2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 05:46:34 +00:00

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);
}
},
{