mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 03:30:54 +00:00
PUI Template editor (#6541)
* Added first POC for label editor * Added preview item selection * Split code * Fix import * Use liquid lang and added custom tooltips * Auto load first item for preview and add BOM part assembly filter * Make the save&reload action more obvious * Make save optional and use server stored template * Fix icons and inherit model url * Add label/report extra fields to serializer and default templates * Bump api version to v176 * Remove generic and pass template to editor * Added error overlay * Moved default tempaltes in default folder * Only show detail drawer back button if necessary * Rename action dropdown disabled to hidden and add loading disabled to template editor * Fix types * Add icons to editor/preview tabs * Add draggable split pane and make editors use full height * Add SplitButton component * add code editor tag description * fix related model field if empty string * remove debug console.log * move code editor/pdf preview into their own folder * Update api_version.py * add support for multiple editors * fix template editor error handleing while loading/saving code * add documentation for the template editor
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
||||
IconBuildingStore,
|
||||
IconCalendar,
|
||||
IconCalendarStats,
|
||||
IconCategory,
|
||||
IconCheck,
|
||||
IconClipboardList,
|
||||
IconCopy,
|
||||
@ -58,102 +59,105 @@ import {
|
||||
IconX
|
||||
} from '@tabler/icons-react';
|
||||
import { IconFlag } from '@tabler/icons-react';
|
||||
import { IconTruckReturn } from '@tabler/icons-react';
|
||||
import { IconInfoCircle } from '@tabler/icons-react';
|
||||
import { IconCalendarTime } from '@tabler/icons-react';
|
||||
import { TablerIconsProps } from '@tabler/icons-react';
|
||||
import React from 'react';
|
||||
|
||||
const icons: { [key: string]: (props: TablerIconsProps) => React.JSX.Element } =
|
||||
{
|
||||
description: IconInfoCircle,
|
||||
variant_of: IconStatusChange,
|
||||
unallocated_stock: IconPackage,
|
||||
total_in_stock: IconPackages,
|
||||
minimum_stock: IconFlag,
|
||||
allocated_to_build_orders: IconTool,
|
||||
allocated_to_sales_orders: IconTruck,
|
||||
can_build: IconTools,
|
||||
ordering: IconShoppingCart,
|
||||
building: IconTool,
|
||||
category: IconBinaryTree2,
|
||||
IPN: Icon123,
|
||||
revision: IconGitBranch,
|
||||
units: IconRulerMeasure,
|
||||
keywords: IconTag,
|
||||
status: IconInfoCircle,
|
||||
info: IconInfoCircle,
|
||||
details: IconInfoCircle,
|
||||
parameters: IconList,
|
||||
stock: IconPackages,
|
||||
variants: IconVersions,
|
||||
allocations: IconBookmarks,
|
||||
bom: IconListTree,
|
||||
builds: IconTools,
|
||||
used_in: IconStack2,
|
||||
manufacturers: IconBuildingFactory2,
|
||||
suppliers: IconBuilding,
|
||||
customers: IconBuildingStore,
|
||||
purchase_orders: IconShoppingCart,
|
||||
sales_orders: IconTruckDelivery,
|
||||
shipment: IconTruckDelivery,
|
||||
scheduling: IconCalendarStats,
|
||||
test_templates: IconTestPipe,
|
||||
related_parts: IconLayersLinked,
|
||||
attachments: IconPaperclip,
|
||||
notes: IconNotes,
|
||||
photo: IconPhoto,
|
||||
upload: IconFileUpload,
|
||||
reject: IconX,
|
||||
select_image: IconGridDots,
|
||||
delete: IconTrash,
|
||||
const icons = {
|
||||
description: IconInfoCircle,
|
||||
variant_of: IconStatusChange,
|
||||
unallocated_stock: IconPackage,
|
||||
total_in_stock: IconPackages,
|
||||
minimum_stock: IconFlag,
|
||||
allocated_to_build_orders: IconTool,
|
||||
allocated_to_sales_orders: IconTruck,
|
||||
can_build: IconTools,
|
||||
ordering: IconShoppingCart,
|
||||
building: IconTool,
|
||||
category: IconBinaryTree2,
|
||||
IPN: Icon123,
|
||||
revision: IconGitBranch,
|
||||
units: IconRulerMeasure,
|
||||
keywords: IconTag,
|
||||
status: IconInfoCircle,
|
||||
info: IconInfoCircle,
|
||||
details: IconInfoCircle,
|
||||
parameters: IconList,
|
||||
stock: IconPackages,
|
||||
variants: IconVersions,
|
||||
allocations: IconBookmarks,
|
||||
bom: IconListTree,
|
||||
builds: IconTools,
|
||||
used_in: IconStack2,
|
||||
manufacturers: IconBuildingFactory2,
|
||||
suppliers: IconBuilding,
|
||||
customers: IconBuildingStore,
|
||||
purchase_orders: IconShoppingCart,
|
||||
sales_orders: IconTruckDelivery,
|
||||
return_orders: IconTruckReturn,
|
||||
shipment: IconTruckDelivery,
|
||||
scheduling: IconCalendarStats,
|
||||
test_templates: IconTestPipe,
|
||||
related_parts: IconLayersLinked,
|
||||
attachments: IconPaperclip,
|
||||
notes: IconNotes,
|
||||
photo: IconPhoto,
|
||||
upload: IconFileUpload,
|
||||
reject: IconX,
|
||||
select_image: IconGridDots,
|
||||
delete: IconTrash,
|
||||
|
||||
// Part Icons
|
||||
active: IconCheck,
|
||||
template: IconCopy,
|
||||
assembly: IconTool,
|
||||
component: IconGridDots,
|
||||
trackable: IconCornerUpRightDouble,
|
||||
purchaseable: IconShoppingCart,
|
||||
saleable: IconCurrencyDollar,
|
||||
virtual: IconWorldCode,
|
||||
inactive: IconX,
|
||||
part: IconBox,
|
||||
supplier_part: IconPackageImport,
|
||||
// Part Icons
|
||||
active: IconCheck,
|
||||
template: IconCopy,
|
||||
assembly: IconTool,
|
||||
component: IconGridDots,
|
||||
trackable: IconCornerUpRightDouble,
|
||||
purchaseable: IconShoppingCart,
|
||||
saleable: IconCurrencyDollar,
|
||||
virtual: IconWorldCode,
|
||||
inactive: IconX,
|
||||
part: IconBox,
|
||||
supplier_part: IconPackageImport,
|
||||
|
||||
calendar: IconCalendar,
|
||||
external: IconExternalLink,
|
||||
creation_date: IconCalendarTime,
|
||||
location: IconMapPin,
|
||||
default_location: IconMapPinHeart,
|
||||
default_supplier: IconShoppingCartHeart,
|
||||
link: IconLink,
|
||||
responsible: IconUserStar,
|
||||
pricing: IconCurrencyDollar,
|
||||
currency: IconCurrencyDollar,
|
||||
stocktake: IconClipboardList,
|
||||
user: IconUser,
|
||||
group: IconUsersGroup,
|
||||
check: IconCheck,
|
||||
copy: IconCopy,
|
||||
quantity: IconNumbers,
|
||||
progress: IconProgressCheck,
|
||||
reference: IconHash,
|
||||
website: IconWorld,
|
||||
email: IconMail,
|
||||
phone: IconPhone,
|
||||
sitemap: IconSitemap
|
||||
};
|
||||
calendar: IconCalendar,
|
||||
external: IconExternalLink,
|
||||
creation_date: IconCalendarTime,
|
||||
location: IconMapPin,
|
||||
default_location: IconMapPinHeart,
|
||||
default_supplier: IconShoppingCartHeart,
|
||||
link: IconLink,
|
||||
responsible: IconUserStar,
|
||||
pricing: IconCurrencyDollar,
|
||||
currency: IconCurrencyDollar,
|
||||
stocktake: IconClipboardList,
|
||||
user: IconUser,
|
||||
group: IconUsersGroup,
|
||||
check: IconCheck,
|
||||
copy: IconCopy,
|
||||
quantity: IconNumbers,
|
||||
progress: IconProgressCheck,
|
||||
reference: IconHash,
|
||||
website: IconWorld,
|
||||
email: IconMail,
|
||||
phone: IconPhone,
|
||||
sitemap: IconSitemap
|
||||
};
|
||||
|
||||
export type InvenTreeIconType = keyof typeof icons;
|
||||
|
||||
/**
|
||||
* Returns a Tabler Icon for the model field name supplied
|
||||
* @param field string defining field name
|
||||
*/
|
||||
export function GetIcon(field: keyof typeof icons) {
|
||||
export function GetIcon(field: InvenTreeIconType) {
|
||||
return icons[field];
|
||||
}
|
||||
|
||||
type IconProps = {
|
||||
icon: string;
|
||||
icon: InvenTreeIconType;
|
||||
iconProps?: TablerIconsProps;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user