mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 05:05:42 +00:00 
			
		
		
		
	[PUI] Update part duplicate forms (#7575)
- Enable copying of part details when duplicating a part - Update forms
This commit is contained in:
		| @@ -57,7 +57,9 @@ export function usePartFields({ | ||||
|       fields.initial_stock = { | ||||
|         icon: <IconPackages />, | ||||
|         children: { | ||||
|           quantity: {}, | ||||
|           quantity: { | ||||
|             value: 0 | ||||
|           }, | ||||
|           location: {} | ||||
|         } | ||||
|       }; | ||||
|   | ||||
| @@ -34,6 +34,7 @@ import { DetailsImage } from '../../components/details/DetailsImage'; | ||||
| import { ItemDetailsGrid } from '../../components/details/ItemDetails'; | ||||
| import { PartIcons } from '../../components/details/PartIcons'; | ||||
| import NotesEditor from '../../components/editors/NotesEditor'; | ||||
| import { ApiFormFieldSet } from '../../components/forms/fields/ApiFormField'; | ||||
| import { Thumbnail } from '../../components/images/Thumbnail'; | ||||
| import { | ||||
|   ActionDropdown, | ||||
| @@ -718,12 +719,34 @@ export default function PartDetail() { | ||||
|     onFormSuccess: refreshInstance | ||||
|   }); | ||||
|  | ||||
|   const createPartFields = usePartFields({ create: true }); | ||||
|  | ||||
|   const duplicatePartFields: ApiFormFieldSet = useMemo(() => { | ||||
|     return { | ||||
|       ...createPartFields, | ||||
|       duplicate: { | ||||
|         children: { | ||||
|           part: { | ||||
|             value: part.pk, | ||||
|             hidden: true | ||||
|           }, | ||||
|           copy_image: {}, | ||||
|           copy_bom: {}, | ||||
|           copy_notes: {}, | ||||
|           copy_parameters: {} | ||||
|         } | ||||
|       } | ||||
|     }; | ||||
|   }, [createPartFields, part]); | ||||
|  | ||||
|   const duplicatePart = useCreateApiFormModal({ | ||||
|     url: ApiEndpoints.part_list, | ||||
|     title: t`Add Part`, | ||||
|     fields: partFields, | ||||
|     fields: duplicatePartFields, | ||||
|     initialData: { | ||||
|       ...part | ||||
|       ...part, | ||||
|       active: true, | ||||
|       locked: false | ||||
|     }, | ||||
|     follow: true, | ||||
|     modelType: ModelType.part | ||||
|   | ||||
		Reference in New Issue
	
	Block a user