From 1998dabe9b3406c694f38b9e1d7105192136618b Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 15 Aug 2021 21:47:37 +1000 Subject: [PATCH] Small tweaks here and there --- .../templates/js/translated/attachment.js | 27 +++++++++++++++++-- InvenTree/templates/js/translated/bom.js | 2 +- InvenTree/templates/js/translated/part.js | 2 +- InvenTree/templates/js/translated/stock.js | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/translated/attachment.js b/InvenTree/templates/js/translated/attachment.js index 4b9d522a59..bffe3d9995 100644 --- a/InvenTree/templates/js/translated/attachment.js +++ b/InvenTree/templates/js/translated/attachment.js @@ -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 = ` ${filename}`; + + return renderLink(html, value); } }, { diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 34a6206ac9..37a3eb23b0 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -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) { diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index bf9b5f316f..93fb7066a4 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -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`); } } ]; diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index f489b45948..d722f3bff8 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -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 = '';