mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Make Tree Path searchable (#7786)
* make tree searchable by pathstring * fix related model field colors in dark mode * remove unused import --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
66d1c77d19
commit
32db71cabb
@ -43,7 +43,6 @@ from InvenTree.mixins import (
|
|||||||
from InvenTree.permissions import RolePermission
|
from InvenTree.permissions import RolePermission
|
||||||
from InvenTree.serializers import EmptySerializer
|
from InvenTree.serializers import EmptySerializer
|
||||||
from order.status_codes import PurchaseOrderStatusGroups, SalesOrderStatusGroups
|
from order.status_codes import PurchaseOrderStatusGroups, SalesOrderStatusGroups
|
||||||
from part.admin import PartCategoryResource, PartResource
|
|
||||||
from stock.models import StockLocation
|
from stock.models import StockLocation
|
||||||
|
|
||||||
from . import serializers as part_serializers
|
from . import serializers as part_serializers
|
||||||
@ -245,7 +244,7 @@ class CategoryList(CategoryMixin, DataExportViewMixin, ListCreateAPI):
|
|||||||
# Use hierarchical ordering by default
|
# Use hierarchical ordering by default
|
||||||
ordering = ['tree_id', 'lft', 'name']
|
ordering = ['tree_id', 'lft', 'name']
|
||||||
|
|
||||||
search_fields = ['name', 'description']
|
search_fields = ['name', 'description', 'pathstring']
|
||||||
|
|
||||||
|
|
||||||
class CategoryDetail(CategoryMixin, CustomRetrieveUpdateDestroyAPI):
|
class CategoryDetail(CategoryMixin, CustomRetrieveUpdateDestroyAPI):
|
||||||
|
@ -418,7 +418,7 @@ class StockLocationList(DataExportViewMixin, ListCreateAPI):
|
|||||||
|
|
||||||
filter_backends = SEARCH_ORDER_FILTER
|
filter_backends = SEARCH_ORDER_FILTER
|
||||||
|
|
||||||
search_fields = ['name', 'description', 'tags__name', 'tags__slug']
|
search_fields = ['name', 'description', 'pathstring', 'tags__name', 'tags__slug']
|
||||||
|
|
||||||
ordering_fields = ['name', 'pathstring', 'items', 'level', 'tree_id', 'lft']
|
ordering_fields = ['name', 'pathstring', 'items', 'level', 'tree_id', 'lft']
|
||||||
|
|
||||||
|
@ -236,25 +236,23 @@ export function RelatedModelField({
|
|||||||
// Field doesn't follow Mantine theming
|
// Field doesn't follow Mantine theming
|
||||||
// Define color theme to pass to field based on Mantine theme
|
// Define color theme to pass to field based on Mantine theme
|
||||||
const theme = useMantineTheme();
|
const theme = useMantineTheme();
|
||||||
|
|
||||||
const colorschema = vars.colors.primaryColors;
|
|
||||||
const { colorScheme } = useMantineColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const colors = useMemo(() => {
|
const colors = useMemo(() => {
|
||||||
let colors: any;
|
let colors: any;
|
||||||
if (colorScheme === 'dark') {
|
if (colorScheme === 'dark') {
|
||||||
colors = {
|
colors = {
|
||||||
neutral0: colorschema[6],
|
neutral0: vars.colors.dark[6],
|
||||||
neutral5: colorschema[4],
|
neutral5: vars.colors.dark[4],
|
||||||
neutral10: colorschema[4],
|
neutral10: vars.colors.dark[4],
|
||||||
neutral20: colorschema[4],
|
neutral20: vars.colors.dark[4],
|
||||||
neutral30: colorschema[3],
|
neutral30: vars.colors.dark[3],
|
||||||
neutral40: colorschema[2],
|
neutral40: vars.colors.dark[2],
|
||||||
neutral50: colorschema[1],
|
neutral50: vars.colors.dark[1],
|
||||||
neutral60: colorschema[0],
|
neutral60: vars.colors.dark[0],
|
||||||
neutral70: colorschema[0],
|
neutral70: vars.colors.dark[0],
|
||||||
neutral80: colorschema[0],
|
neutral80: vars.colors.dark[0],
|
||||||
neutral90: colorschema[0],
|
neutral90: vars.colors.dark[0],
|
||||||
primary: vars.colors.primaryColors[7],
|
primary: vars.colors.primaryColors[7],
|
||||||
primary25: vars.colors.primaryColors[6],
|
primary25: vars.colors.primaryColors[6],
|
||||||
primary50: vars.colors.primaryColors[5],
|
primary50: vars.colors.primaryColors[5],
|
||||||
|
@ -157,7 +157,8 @@ export function RenderInlineModel({
|
|||||||
labels,
|
labels,
|
||||||
url,
|
url,
|
||||||
navigate,
|
navigate,
|
||||||
showSecondary = true
|
showSecondary = true,
|
||||||
|
tooltip
|
||||||
}: {
|
}: {
|
||||||
primary: string;
|
primary: string;
|
||||||
secondary?: string;
|
secondary?: string;
|
||||||
@ -168,6 +169,7 @@ export function RenderInlineModel({
|
|||||||
labels?: string[];
|
labels?: string[];
|
||||||
url?: string;
|
url?: string;
|
||||||
navigate?: any;
|
navigate?: any;
|
||||||
|
tooltip?: string;
|
||||||
}): ReactNode {
|
}): ReactNode {
|
||||||
// TODO: Handle labels
|
// TODO: Handle labels
|
||||||
|
|
||||||
@ -181,7 +183,7 @@ export function RenderInlineModel({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group gap="xs" justify="space-between" wrap="nowrap">
|
<Group gap="xs" justify="space-between" wrap="nowrap" title={tooltip}>
|
||||||
<Group gap="xs" justify="left" wrap="nowrap">
|
<Group gap="xs" justify="left" wrap="nowrap">
|
||||||
{prefix}
|
{prefix}
|
||||||
{image && <Thumbnail src={image} size={18} />}
|
{image && <Thumbnail src={image} size={18} />}
|
||||||
|
@ -56,13 +56,18 @@ export function RenderPartCategory(
|
|||||||
props: Readonly<InstanceRenderInterface>
|
props: Readonly<InstanceRenderInterface>
|
||||||
): ReactNode {
|
): ReactNode {
|
||||||
const { instance } = props;
|
const { instance } = props;
|
||||||
const lvl = '-'.repeat(instance.level || 0);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RenderInlineModel
|
<RenderInlineModel
|
||||||
{...props}
|
{...props}
|
||||||
prefix={instance.icon && <ApiIcon name={instance.icon} />}
|
tooltip={instance.pathstring}
|
||||||
primary={`${lvl} ${instance.name}`}
|
prefix={
|
||||||
|
<>
|
||||||
|
<div style={{ width: 10 * (instance.level || 0) }}></div>
|
||||||
|
{instance.icon && <ApiIcon name={instance.icon} />}
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
primary={instance.name}
|
||||||
secondary={instance.description}
|
secondary={instance.description}
|
||||||
url={
|
url={
|
||||||
props.link
|
props.link
|
||||||
|
@ -17,7 +17,13 @@ export function RenderStockLocation(
|
|||||||
return (
|
return (
|
||||||
<RenderInlineModel
|
<RenderInlineModel
|
||||||
{...props}
|
{...props}
|
||||||
prefix={instance.icon && <ApiIcon name={instance.icon} />}
|
tooltip={instance.pathstring}
|
||||||
|
prefix={
|
||||||
|
<>
|
||||||
|
<div style={{ width: 10 * (instance.level || 0) }}></div>
|
||||||
|
{instance.icon && <ApiIcon name={instance.icon} />}
|
||||||
|
</>
|
||||||
|
}
|
||||||
primary={instance.name}
|
primary={instance.name}
|
||||||
secondary={instance.description}
|
secondary={instance.description}
|
||||||
url={
|
url={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user