From 4c4df194faca9640c37c0430c9f22d0aa399b57b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 00:29:16 +1000 Subject: [PATCH 1/2] BOM table improvements - Add part image - Replace button text with icons - Fix bug in BOM download --- InvenTree/static/css/inventree.css | 4 ++++ InvenTree/static/script/inventree/bom.js | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/InvenTree/static/css/inventree.css b/InvenTree/static/css/inventree.css index 50d10547e1..752885145d 100644 --- a/InvenTree/static/css/inventree.css +++ b/InvenTree/static/css/inventree.css @@ -6,6 +6,10 @@ font-size: 20px; } +.glyphicon-small { + font-size: 14px; +} + .starred-part { color: #ffcc00; } diff --git a/InvenTree/static/script/inventree/bom.js b/InvenTree/static/script/inventree/bom.js index b96ae49050..e88e617945 100644 --- a/InvenTree/static/script/inventree/bom.js +++ b/InvenTree/static/script/inventree/bom.js @@ -42,6 +42,8 @@ function downloadBom(options = {}) { modalSetContent(modal, content); + modalEnable(modal, true); + $(modal).on('click', '#modal-form-submit', function() { $(modal).modal('hide'); @@ -91,7 +93,7 @@ function loadBomTable(table, options) { title: 'Part', sortable: true, formatter: function(value, row, index, field) { - return renderLink(value.name, value.url); + return imageHoverIcon(value.image_url) + renderLink(value.name, value.url); } } ); @@ -127,8 +129,8 @@ function loadBomTable(table, options) { if (options.editable) { cols.push({ formatter: function(value, row, index, field) { - var bEdit = ""; - var bDelt = ""; + var bEdit = ""; + var bDelt = ""; return "
" + bEdit + bDelt + "
"; } From 94ad378b9df645f4ebf9bc6df6b37b9ee5b3ac6c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 9 May 2019 00:39:51 +1000 Subject: [PATCH 2/2] Part and company images return the 'no image found' image if they do not have an image --- InvenTree/company/models.py | 3 ++- InvenTree/part/models.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py index bb86230b70..bbc081f78d 100644 --- a/InvenTree/company/models.py +++ b/InvenTree/company/models.py @@ -10,6 +10,7 @@ import os from django.db import models from django.urls import reverse from django.conf import settings +from django.contrib.staticfiles.templatetags.staticfiles import static def rename_company_image(instance, filename): @@ -85,7 +86,7 @@ class Company(models.Model): if self.image: return os.path.join(settings.MEDIA_URL, str(self.image.url)) else: - return '' + return static('/img/blank_image.png') @property def part_count(self): diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 3bca8cd445..293d1f194e 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -19,6 +19,7 @@ from django.conf import settings from django.db import models from django.core.validators import MinValueValidator +from django.contrib.staticfiles.templatetags.staticfiles import static from django.contrib.auth.models import User from django.db.models.signals import pre_delete from django.dispatch import receiver @@ -130,7 +131,7 @@ class Part(models.Model): if self.image: return os.path.join(settings.MEDIA_URL, str(self.image.url)) else: - return '' + return static('/img/blank_image.png') # Short name of the part name = models.CharField(max_length=100, unique=True, blank=False, help_text='Part name (must be unique)')