-
-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PUI/Feature] Integrate Part "Default Location" into UX (#5972)
* Add default parts to location page * Fix name strings * Add Stock Transfer modal * Add ApiForm Table field * temp * Add stock transfer form to part, stock item and location * All stock operations for Item, Part, and Location added (except order new) * Add default_location category traversal, and initial PO Line Item Receive form * . * Remove debug values * Added PO line receive form * Add functionality to PO receive extra fields * . * Forgot to bump API version * Add Category Default to details panel * Fix stockItem query count * Fix reviewed issues * . * . * . * Prevent root category from checking parent for default location
- Loading branch information
1 parent
6abd33f
commit 0196dd2
Showing
22 changed files
with
1,785 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { Trans, t } from '@lingui/macro'; | ||
import { Table } from '@mantine/core'; | ||
import { FieldValues, UseControllerReturn } from 'react-hook-form'; | ||
|
||
import { InvenTreeIcon } from '../../../functions/icons'; | ||
import { ApiFormFieldType } from './ApiFormField'; | ||
|
||
export function TableField({ | ||
definition, | ||
fieldName, | ||
control | ||
}: { | ||
definition: ApiFormFieldType; | ||
fieldName: string; | ||
control: UseControllerReturn<FieldValues, any>; | ||
}) { | ||
const { | ||
field, | ||
fieldState: { error } | ||
} = control; | ||
const { value, ref } = field; | ||
|
||
const onRowFieldChange = (idx: number, key: string, value: any) => { | ||
const val = field.value; | ||
val[idx][key] = value; | ||
field.onChange(val); | ||
}; | ||
|
||
const removeRow = (idx: number) => { | ||
const val = field.value; | ||
val.splice(idx, 1); | ||
field.onChange(val); | ||
}; | ||
|
||
return ( | ||
<Table highlightOnHover striped> | ||
<thead> | ||
<tr> | ||
{definition.headers?.map((header) => { | ||
return <th key={header}>{header}</th>; | ||
})} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{value.length > 0 ? ( | ||
value.map((item: any, idx: number) => { | ||
// Table fields require render function | ||
if (!definition.modelRenderer) { | ||
return <tr>{t`modelRenderer entry required for tables`}</tr>; | ||
} | ||
return definition.modelRenderer({ | ||
item: item, | ||
idx: idx, | ||
changeFn: onRowFieldChange, | ||
removeFn: removeRow | ||
}); | ||
}) | ||
) : ( | ||
<tr> | ||
<td | ||
style={{ textAlign: 'center' }} | ||
colSpan={definition.headers?.length} | ||
> | ||
<span | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
gap: '5px' | ||
}} | ||
> | ||
<InvenTreeIcon icon="info" /> | ||
<Trans>No entries available</Trans> | ||
</span> | ||
</td> | ||
</tr> | ||
)} | ||
</tbody> | ||
</Table> | ||
); | ||
} |
Oops, something went wrong.