2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 13:05:42 +00:00

Feature/icons for PartCategory and StockLocation (#3542)

* Added icon to stock location

- added `icon` field to `stock_stocklocation` model
- added input field to stock location form
- added icon to breadcrumb treeview in header
- added icon to sub-locations table
- added icon to location detail information
- added `STOCK_LOCATION_DEFAULT_ICON` setting as default

* Added icon to part category

- added `icon` field to `part_partcategory` model
- added input field to part category form
- added icon to breadcrumb treeview in header
- added icon to sub-categories table
- added icon to category detail information
- added `PART_CATEGORY_DEFAULT_ICON` setting as default

* Added `blocktrans` to allowed tags in ci check

* fix: style

* Added `endblocktrans` to allowed tags in ci check

* fix: missing `,` in ci check allowed tags script

* Removed blocktrans from js and fixed style
This commit is contained in:
wolflu05
2022-08-16 13:51:55 +02:00
committed by GitHub
parent 1b76828305
commit b9f83eefc8
15 changed files with 111 additions and 5 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2022-08-15 08:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0083_auto_20220731_2357'),
]
operations = [
migrations.AddField(
model_name='partcategory',
name='icon',
field=models.CharField(blank=True, help_text='Icon (optional)', max_length=100, verbose_name='Icon'),
),
]

View File

@ -101,6 +101,13 @@ class PartCategory(MetadataMixin, InvenTreeTree):
default_keywords = models.CharField(null=True, blank=True, max_length=250, verbose_name=_('Default keywords'), help_text=_('Default keywords for parts in this category'))
icon = models.CharField(
blank=True,
max_length=100,
verbose_name=_("Icon"),
help_text=_("Icon (optional)")
)
@staticmethod
def get_api_url():
"""Return the API url associated with the PartCategory model"""

View File

@ -75,6 +75,7 @@ class CategorySerializer(InvenTreeModelSerializer):
'pathstring',
'starred',
'url',
'icon',
]
@ -88,6 +89,7 @@ class CategoryTree(InvenTreeModelSerializer):
'pk',
'name',
'parent',
'icon',
]

View File

@ -1,6 +1,7 @@
{% extends "part/part_app_base.html" %}
{% load static %}
{% load i18n %}
{% load inventree_extras %}
{% block sidebar %}
{% include 'part/category_sidebar.html' %}
@ -12,7 +13,12 @@
{% block heading %}
{% if category %}
{% trans "Part Category" %}: {{ category.name }}
{% trans "Part Category" %}:
{% settings_value "PART_CATEGORY_DEFAULT_ICON" as default_icon %}
{% if category.icon or default_icon %}
<span class="{{ category.icon|default:default_icon }}"></span>
{% endif %}
{{ category.name }}
{% else %}
{% trans "Parts" %}
{% endif %}
@ -288,7 +294,8 @@
node.href = `/part/category/${node.pk}/`;
return node;
}
},
defaultIcon: global_settings.PART_CATEGORY_DEFAULT_ICON,
});
onPanelLoad('subcategories', function() {