@inventreedb/ui 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (555) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/dist/.vite/manifest.json +43 -0
  4. package/dist/enums/ApiEndpoints.d.ts +179 -0
  5. package/dist/enums/ApiEndpoints.js +184 -0
  6. package/dist/enums/ApiEndpoints.js.map +1 -0
  7. package/dist/enums/ModelType.d.ts +35 -0
  8. package/dist/enums/ModelType.js +40 -0
  9. package/dist/enums/ModelType.js.map +1 -0
  10. package/dist/enums/Roles.d.ts +18 -0
  11. package/dist/functions/Api.d.ts +11 -0
  12. package/dist/functions/Api.js +27 -0
  13. package/dist/functions/Api.js.map +1 -0
  14. package/dist/functions/Plugins.d.ts +2 -0
  15. package/dist/functions/Plugins.js +23 -0
  16. package/dist/functions/Plugins.js.map +1 -0
  17. package/dist/index.d.ts +6 -0
  18. package/dist/index.js +13 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/types/Auth.d.ts +51 -0
  21. package/dist/types/Core.d.ts +10 -0
  22. package/dist/types/Filters.d.ts +56 -0
  23. package/dist/types/Forms.d.ts +159 -0
  24. package/dist/types/Modals.d.ts +15 -0
  25. package/dist/types/Plugins.d.ts +58 -0
  26. package/dist/types/Plugins.js +5 -0
  27. package/dist/types/Plugins.js.map +1 -0
  28. package/dist/types/Server.d.ts +7 -0
  29. package/dist/types/Settings.d.ts +48 -0
  30. package/dist/types/Tables.d.ts +34 -0
  31. package/dist/types/User.d.ts +55 -0
  32. package/package.json +9 -1
  33. package/.babelrc +0 -8
  34. package/.linguirc +0 -55
  35. package/index.html +0 -15
  36. package/netlify.toml +0 -22
  37. package/playwright/global-setup.ts +0 -45
  38. package/playwright.config.ts +0 -99
  39. package/src/App.tsx +0 -35
  40. package/src/assets/inventree.svg +0 -1
  41. package/src/components/Boundary.tsx +0 -43
  42. package/src/components/SplashScreen.tsx +0 -35
  43. package/src/components/barcodes/BarcodeCameraInput.tsx +0 -207
  44. package/src/components/barcodes/BarcodeInput.tsx +0 -127
  45. package/src/components/barcodes/BarcodeKeyboardInput.tsx +0 -50
  46. package/src/components/barcodes/BarcodeScanDialog.tsx +0 -101
  47. package/src/components/barcodes/BarcodeScanItem.tsx +0 -23
  48. package/src/components/barcodes/QRCode.tsx +0 -211
  49. package/src/components/buttons/ActionButton.tsx +0 -61
  50. package/src/components/buttons/AddItemButton.tsx +0 -10
  51. package/src/components/buttons/AdminButton.tsx +0 -91
  52. package/src/components/buttons/ButtonMenu.tsx +0 -33
  53. package/src/components/buttons/CopyButton.tsx +0 -52
  54. package/src/components/buttons/PrimaryActionButton.tsx +0 -40
  55. package/src/components/buttons/PrintingActions.tsx +0 -191
  56. package/src/components/buttons/RemoveRowButton.tsx +0 -22
  57. package/src/components/buttons/SSOButton.tsx +0 -53
  58. package/src/components/buttons/ScanButton.tsx +0 -27
  59. package/src/components/buttons/SegmentedIconControl.tsx +0 -51
  60. package/src/components/buttons/SplitButton.css.ts +0 -19
  61. package/src/components/buttons/SplitButton.tsx +0 -111
  62. package/src/components/buttons/SpotlightButton.tsx +0 -22
  63. package/src/components/buttons/StarredToggleButton.tsx +0 -62
  64. package/src/components/buttons/YesNoButton.tsx +0 -42
  65. package/src/components/calendar/Calendar.tsx +0 -193
  66. package/src/components/calendar/OrderCalendar.tsx +0 -209
  67. package/src/components/charts/colors.tsx +0 -12
  68. package/src/components/charts/tooltipFormatter.tsx +0 -12
  69. package/src/components/dashboard/DashboardLayout.tsx +0 -327
  70. package/src/components/dashboard/DashboardMenu.tsx +0 -136
  71. package/src/components/dashboard/DashboardWidget.tsx +0 -82
  72. package/src/components/dashboard/DashboardWidgetDrawer.tsx +0 -130
  73. package/src/components/dashboard/DashboardWidgetLibrary.tsx +0 -189
  74. package/src/components/dashboard/widgets/ColorToggleWidget.tsx +0 -28
  75. package/src/components/dashboard/widgets/GetStartedWidget.tsx +0 -19
  76. package/src/components/dashboard/widgets/LanguageSelectWidget.tsx +0 -28
  77. package/src/components/dashboard/widgets/NewsWidget.tsx +0 -143
  78. package/src/components/dashboard/widgets/QueryCountDashboardWidget.tsx +0 -134
  79. package/src/components/details/Details.tsx +0 -514
  80. package/src/components/details/DetailsBadge.tsx +0 -20
  81. package/src/components/details/DetailsImage.tsx +0 -462
  82. package/src/components/details/ItemDetails.tsx +0 -17
  83. package/src/components/editors/NotesEditor.tsx +0 -232
  84. package/src/components/editors/TemplateEditor/CodeEditor/CodeEditor.tsx +0 -158
  85. package/src/components/editors/TemplateEditor/CodeEditor/index.tsx +0 -12
  86. package/src/components/editors/TemplateEditor/PdfPreview/PdfPreview.tsx +0 -90
  87. package/src/components/editors/TemplateEditor/PdfPreview/index.tsx +0 -12
  88. package/src/components/editors/TemplateEditor/TemplateEditor.tsx +0 -425
  89. package/src/components/editors/TemplateEditor/index.tsx +0 -3
  90. package/src/components/errors/ClientError.tsx +0 -28
  91. package/src/components/errors/GenericErrorPage.tsx +0 -73
  92. package/src/components/errors/NotAuthenticated.tsx +0 -12
  93. package/src/components/errors/NotFound.tsx +0 -12
  94. package/src/components/errors/PermissionDenied.tsx +0 -12
  95. package/src/components/errors/ServerError.tsx +0 -13
  96. package/src/components/forms/ApiForm.tsx +0 -718
  97. package/src/components/forms/AuthFormOptions.tsx +0 -39
  98. package/src/components/forms/AuthenticationForm.tsx +0 -332
  99. package/src/components/forms/HostOptionsForm.tsx +0 -96
  100. package/src/components/forms/InstanceOptions.tsx +0 -178
  101. package/src/components/forms/StandaloneField.tsx +0 -55
  102. package/src/components/forms/fields/ApiFormField.tsx +0 -281
  103. package/src/components/forms/fields/ChoiceField.tsx +0 -86
  104. package/src/components/forms/fields/DateField.tsx +0 -79
  105. package/src/components/forms/fields/DependentField.tsx +0 -91
  106. package/src/components/forms/fields/IconField.tsx +0 -353
  107. package/src/components/forms/fields/NestedObjectField.tsx +0 -45
  108. package/src/components/forms/fields/RelatedModelField.tsx +0 -339
  109. package/src/components/forms/fields/TableField.tsx +0 -275
  110. package/src/components/forms/fields/TextField.tsx +0 -81
  111. package/src/components/images/ApiImage.tsx +0 -35
  112. package/src/components/images/Thumbnail.tsx +0 -52
  113. package/src/components/importer/ImportDataSelector.tsx +0 -433
  114. package/src/components/importer/ImporterColumnSelector.tsx +0 -244
  115. package/src/components/importer/ImporterDrawer.tsx +0 -173
  116. package/src/components/importer/ImporterImportProgress.tsx +0 -45
  117. package/src/components/items/ActionDropdown.tsx +0 -290
  118. package/src/components/items/ApiIcon.css.ts +0 -13
  119. package/src/components/items/ApiIcon.tsx +0 -32
  120. package/src/components/items/AttachmentLink.tsx +0 -79
  121. package/src/components/items/ColorToggle.tsx +0 -34
  122. package/src/components/items/DashboardItem.tsx +0 -33
  123. package/src/components/items/DocInfo.tsx +0 -20
  124. package/src/components/items/DocTooltip.tsx +0 -98
  125. package/src/components/items/ErrorItem.tsx +0 -17
  126. package/src/components/items/Expand.tsx +0 -14
  127. package/src/components/items/GettingStartedCarousel.css.ts +0 -30
  128. package/src/components/items/GettingStartedCarousel.tsx +0 -49
  129. package/src/components/items/InfoItem.tsx +0 -64
  130. package/src/components/items/InvenTreeLogo.tsx +0 -24
  131. package/src/components/items/LanguageSelect.tsx +0 -43
  132. package/src/components/items/LanguageToggle.tsx +0 -37
  133. package/src/components/items/MenuLinks.tsx +0 -113
  134. package/src/components/items/OnlyStaff.tsx +0 -10
  135. package/src/components/items/ProgressBar.tsx +0 -45
  136. package/src/components/items/StylishText.tsx +0 -59
  137. package/src/components/items/TitleWithDoc.tsx +0 -26
  138. package/src/components/items/UnavailableIndicator.tsx +0 -5
  139. package/src/components/items/inventree.svg +0 -1
  140. package/src/components/modals/AboutInvenTreeModal.tsx +0 -203
  141. package/src/components/modals/LicenseModal.tsx +0 -116
  142. package/src/components/modals/QrModal.tsx +0 -21
  143. package/src/components/modals/ServerInfoModal.tsx +0 -136
  144. package/src/components/nav/Alerts.tsx +0 -130
  145. package/src/components/nav/BreadcrumbList.tsx +0 -84
  146. package/src/components/nav/DetailDrawer.css.ts +0 -6
  147. package/src/components/nav/DetailDrawer.tsx +0 -105
  148. package/src/components/nav/Footer.tsx +0 -11
  149. package/src/components/nav/Header.tsx +0 -226
  150. package/src/components/nav/InstanceDetail.tsx +0 -46
  151. package/src/components/nav/Layout.tsx +0 -85
  152. package/src/components/nav/MainMenu.tsx +0 -101
  153. package/src/components/nav/NavHoverMenu.tsx +0 -15
  154. package/src/components/nav/NavigationDrawer.tsx +0 -230
  155. package/src/components/nav/NavigationTree.tsx +0 -210
  156. package/src/components/nav/NotificationDrawer.tsx +0 -231
  157. package/src/components/nav/PageDetail.tsx +0 -171
  158. package/src/components/nav/PageTitle.tsx +0 -53
  159. package/src/components/nav/SearchDrawer.tsx +0 -598
  160. package/src/components/nav/SettingsHeader.tsx +0 -50
  161. package/src/components/panels/AttachmentPanel.tsx +0 -27
  162. package/src/components/panels/NotesPanel.tsx +0 -36
  163. package/src/components/panels/Panel.tsx +0 -15
  164. package/src/components/panels/PanelGroup.css.ts +0 -10
  165. package/src/components/panels/PanelGroup.tsx +0 -292
  166. package/src/components/plugins/LocateItemButton.tsx +0 -94
  167. package/src/components/plugins/PluginContext.tsx +0 -67
  168. package/src/components/plugins/PluginDrawer.tsx +0 -156
  169. package/src/components/plugins/PluginInterface.tsx +0 -34
  170. package/src/components/plugins/PluginPanel.tsx +0 -37
  171. package/src/components/plugins/PluginSettingsPanel.tsx +0 -34
  172. package/src/components/plugins/PluginSource.tsx +0 -48
  173. package/src/components/plugins/PluginUIFeature.tsx +0 -174
  174. package/src/components/plugins/PluginUIFeatureTypes.ts +0 -78
  175. package/src/components/plugins/RemoteComponent.tsx +0 -137
  176. package/src/components/render/Build.tsx +0 -54
  177. package/src/components/render/Company.tsx +0 -114
  178. package/src/components/render/Generic.tsx +0 -49
  179. package/src/components/render/Instance.tsx +0 -240
  180. package/src/components/render/InstanceFromUrl.tsx +0 -33
  181. package/src/components/render/ModelType.tsx +0 -293
  182. package/src/components/render/Order.tsx +0 -124
  183. package/src/components/render/Part.tsx +0 -109
  184. package/src/components/render/Plugin.tsx +0 -21
  185. package/src/components/render/Report.tsx +0 -29
  186. package/src/components/render/StatusRenderer.tsx +0 -178
  187. package/src/components/render/Stock.tsx +0 -84
  188. package/src/components/render/User.tsx +0 -42
  189. package/src/components/settings/FactCollection.tsx +0 -31
  190. package/src/components/settings/FactItem.tsx +0 -17
  191. package/src/components/settings/SettingItem.tsx +0 -176
  192. package/src/components/settings/SettingList.tsx +0 -217
  193. package/src/components/wizards/OrderPartsWizard.tsx +0 -473
  194. package/src/components/wizards/WizardDrawer.tsx +0 -188
  195. package/src/contexts/ApiContext.tsx +0 -31
  196. package/src/contexts/LanguageContext.tsx +0 -155
  197. package/src/contexts/ThemeContext.tsx +0 -58
  198. package/src/contexts/colorSchema.tsx +0 -67
  199. package/src/defaults/actions.tsx +0 -87
  200. package/src/defaults/backendMappings.tsx +0 -32
  201. package/src/defaults/defaultHostList.tsx +0 -4
  202. package/src/defaults/defaults.tsx +0 -38
  203. package/src/defaults/formatters.tsx +0 -176
  204. package/src/defaults/links.tsx +0 -193
  205. package/src/defaults/templates.tsx +0 -53
  206. package/src/forms/BomForms.tsx +0 -26
  207. package/src/forms/BuildForms.tsx +0 -615
  208. package/src/forms/CommonForms.tsx +0 -89
  209. package/src/forms/CompanyForms.tsx +0 -133
  210. package/src/forms/ImporterForms.tsx +0 -20
  211. package/src/forms/PartForms.tsx +0 -281
  212. package/src/forms/PurchaseOrderForms.tsx +0 -779
  213. package/src/forms/ReturnOrderForms.tsx +0 -263
  214. package/src/forms/SalesOrderForms.tsx +0 -408
  215. package/src/forms/StockForms.tsx +0 -1296
  216. package/src/forms/selectionListFields.tsx +0 -120
  217. package/src/functions/api.tsx +0 -61
  218. package/src/functions/auth.tsx +0 -574
  219. package/src/functions/conversion.tsx +0 -42
  220. package/src/functions/events.tsx +0 -6
  221. package/src/functions/forms.tsx +0 -173
  222. package/src/functions/icons.tsx +0 -294
  223. package/src/functions/loading.tsx +0 -29
  224. package/src/functions/navigation.tsx +0 -20
  225. package/src/functions/notifications.tsx +0 -101
  226. package/src/functions/tables.tsx +0 -26
  227. package/src/functions/uid.tsx +0 -15
  228. package/src/functions/urls.tsx +0 -58
  229. package/src/hooks/UseCalendar.tsx +0 -178
  230. package/src/hooks/UseDashboardItems.tsx +0 -118
  231. package/src/hooks/UseDataExport.tsx +0 -125
  232. package/src/hooks/UseDataOutput.tsx +0 -109
  233. package/src/hooks/UseFilter.tsx +0 -67
  234. package/src/hooks/UseFilterSet.tsx +0 -24
  235. package/src/hooks/UseForm.tsx +0 -161
  236. package/src/hooks/UseGenerator.tsx +0 -92
  237. package/src/hooks/UseImportSession.tsx +0 -139
  238. package/src/hooks/UseInstance.tsx +0 -137
  239. package/src/hooks/UseInstanceName.tsx +0 -14
  240. package/src/hooks/UseModal.tsx +0 -38
  241. package/src/hooks/UsePlaceholder.tsx +0 -66
  242. package/src/hooks/UsePluginPanels.tsx +0 -123
  243. package/src/hooks/UsePluginUIFeature.tsx +0 -95
  244. package/src/hooks/UsePlugins.tsx +0 -45
  245. package/src/hooks/UseSelectedRows.tsx +0 -37
  246. package/src/hooks/UseStatusCodes.tsx +0 -50
  247. package/src/hooks/UseTable.tsx +0 -145
  248. package/src/hooks/UseWizard.tsx +0 -133
  249. package/src/locales/ar/messages.d.ts +0 -4
  250. package/src/locales/ar/messages.po +0 -10695
  251. package/src/locales/ar/messages.ts +0 -1
  252. package/src/locales/bg/messages.d.ts +0 -4
  253. package/src/locales/bg/messages.po +0 -10695
  254. package/src/locales/bg/messages.ts +0 -1
  255. package/src/locales/cs/messages.d.ts +0 -4
  256. package/src/locales/cs/messages.po +0 -10695
  257. package/src/locales/cs/messages.ts +0 -1
  258. package/src/locales/da/messages.d.ts +0 -4
  259. package/src/locales/da/messages.po +0 -10695
  260. package/src/locales/da/messages.ts +0 -1
  261. package/src/locales/de/messages.d.ts +0 -4
  262. package/src/locales/de/messages.po +0 -10695
  263. package/src/locales/de/messages.ts +0 -1
  264. package/src/locales/el/messages.d.ts +0 -4
  265. package/src/locales/el/messages.po +0 -10695
  266. package/src/locales/el/messages.ts +0 -1
  267. package/src/locales/en/messages.d.ts +0 -4
  268. package/src/locales/en/messages.po +0 -10689
  269. package/src/locales/en/messages.ts +0 -1
  270. package/src/locales/es/messages.d.ts +0 -4
  271. package/src/locales/es/messages.po +0 -10695
  272. package/src/locales/es/messages.ts +0 -1
  273. package/src/locales/es_MX/messages.d.ts +0 -4
  274. package/src/locales/es_MX/messages.po +0 -10695
  275. package/src/locales/es_MX/messages.ts +0 -1
  276. package/src/locales/et/messages.d.ts +0 -4
  277. package/src/locales/et/messages.po +0 -10695
  278. package/src/locales/et/messages.ts +0 -1
  279. package/src/locales/fa/messages.d.ts +0 -4
  280. package/src/locales/fa/messages.po +0 -10695
  281. package/src/locales/fa/messages.ts +0 -1
  282. package/src/locales/fi/messages.d.ts +0 -4
  283. package/src/locales/fi/messages.po +0 -10695
  284. package/src/locales/fi/messages.ts +0 -1
  285. package/src/locales/fr/messages.d.ts +0 -4
  286. package/src/locales/fr/messages.po +0 -10695
  287. package/src/locales/fr/messages.ts +0 -1
  288. package/src/locales/he/messages.d.ts +0 -4
  289. package/src/locales/he/messages.po +0 -10695
  290. package/src/locales/he/messages.ts +0 -1
  291. package/src/locales/hi/messages.d.ts +0 -4
  292. package/src/locales/hi/messages.po +0 -10695
  293. package/src/locales/hi/messages.ts +0 -1
  294. package/src/locales/hu/messages.d.ts +0 -4
  295. package/src/locales/hu/messages.po +0 -10695
  296. package/src/locales/hu/messages.ts +0 -1
  297. package/src/locales/id/messages.po +0 -10695
  298. package/src/locales/it/messages.d.ts +0 -4
  299. package/src/locales/it/messages.po +0 -10695
  300. package/src/locales/it/messages.ts +0 -1
  301. package/src/locales/ja/messages.d.ts +0 -4
  302. package/src/locales/ja/messages.po +0 -10695
  303. package/src/locales/ja/messages.ts +0 -1
  304. package/src/locales/ko/messages.d.ts +0 -4
  305. package/src/locales/ko/messages.po +0 -10695
  306. package/src/locales/ko/messages.ts +0 -1
  307. package/src/locales/lt/messages.d.ts +0 -4
  308. package/src/locales/lt/messages.po +0 -10695
  309. package/src/locales/lt/messages.ts +0 -1
  310. package/src/locales/lv/messages.d.ts +0 -4
  311. package/src/locales/lv/messages.po +0 -10695
  312. package/src/locales/lv/messages.ts +0 -1
  313. package/src/locales/nl/messages.d.ts +0 -4
  314. package/src/locales/nl/messages.po +0 -10695
  315. package/src/locales/nl/messages.ts +0 -1
  316. package/src/locales/no/messages.d.ts +0 -4
  317. package/src/locales/no/messages.po +0 -10695
  318. package/src/locales/no/messages.ts +0 -1
  319. package/src/locales/pl/messages.d.ts +0 -4
  320. package/src/locales/pl/messages.po +0 -10695
  321. package/src/locales/pl/messages.ts +0 -1
  322. package/src/locales/pseudo-LOCALE/messages.d.ts +0 -4
  323. package/src/locales/pseudo-LOCALE/messages.po +0 -8003
  324. package/src/locales/pseudo-LOCALE/messages.ts +0 -1
  325. package/src/locales/pt/messages.d.ts +0 -4
  326. package/src/locales/pt/messages.po +0 -10696
  327. package/src/locales/pt/messages.ts +0 -1
  328. package/src/locales/pt_BR/messages.d.ts +0 -4
  329. package/src/locales/pt_BR/messages.po +0 -10695
  330. package/src/locales/pt_BR/messages.ts +0 -1
  331. package/src/locales/ro/messages.po +0 -10695
  332. package/src/locales/ro/messages.ts +0 -1
  333. package/src/locales/ru/messages.d.ts +0 -4
  334. package/src/locales/ru/messages.po +0 -10695
  335. package/src/locales/ru/messages.ts +0 -1
  336. package/src/locales/sk/messages.d.ts +0 -4
  337. package/src/locales/sk/messages.po +0 -10695
  338. package/src/locales/sk/messages.ts +0 -1
  339. package/src/locales/sl/messages.d.ts +0 -4
  340. package/src/locales/sl/messages.po +0 -10695
  341. package/src/locales/sl/messages.ts +0 -1
  342. package/src/locales/sr/messages.d.ts +0 -4
  343. package/src/locales/sr/messages.po +0 -10695
  344. package/src/locales/sr/messages.ts +0 -1
  345. package/src/locales/sv/messages.d.ts +0 -4
  346. package/src/locales/sv/messages.po +0 -10695
  347. package/src/locales/sv/messages.ts +0 -1
  348. package/src/locales/th/messages.d.ts +0 -4
  349. package/src/locales/th/messages.po +0 -10695
  350. package/src/locales/th/messages.ts +0 -1
  351. package/src/locales/tr/messages.d.ts +0 -4
  352. package/src/locales/tr/messages.po +0 -10695
  353. package/src/locales/tr/messages.ts +0 -1
  354. package/src/locales/uk/messages.d.ts +0 -3
  355. package/src/locales/uk/messages.po +0 -10695
  356. package/src/locales/uk/messages.ts +0 -1
  357. package/src/locales/vi/messages.d.ts +0 -4
  358. package/src/locales/vi/messages.po +0 -10695
  359. package/src/locales/vi/messages.ts +0 -1
  360. package/src/locales/zh_Hans/messages.d.ts +0 -4
  361. package/src/locales/zh_Hans/messages.po +0 -10695
  362. package/src/locales/zh_Hans/messages.ts +0 -1
  363. package/src/locales/zh_Hant/messages.d.ts +0 -4
  364. package/src/locales/zh_Hant/messages.po +0 -10695
  365. package/src/locales/zh_Hant/messages.ts +0 -1
  366. package/src/main.css.ts +0 -148
  367. package/src/main.tsx +0 -123
  368. package/src/pages/Auth/ChangePassword.tsx +0 -84
  369. package/src/pages/Auth/Layout.tsx +0 -74
  370. package/src/pages/Auth/LoggedIn.tsx +0 -21
  371. package/src/pages/Auth/Login.tsx +0 -133
  372. package/src/pages/Auth/Logout.tsx +0 -16
  373. package/src/pages/Auth/MFA.tsx +0 -36
  374. package/src/pages/Auth/MFASetup.tsx +0 -38
  375. package/src/pages/Auth/Register.tsx +0 -28
  376. package/src/pages/Auth/Reset.tsx +0 -30
  377. package/src/pages/Auth/ResetPassword.tsx +0 -48
  378. package/src/pages/Auth/VerifyEmail.tsx +0 -34
  379. package/src/pages/ErrorPage.tsx +0 -26
  380. package/src/pages/Index/Home.tsx +0 -12
  381. package/src/pages/Index/Scan.tsx +0 -258
  382. package/src/pages/Index/Settings/AccountSettings/AccountDetailPanel.tsx +0 -162
  383. package/src/pages/Index/Settings/AccountSettings/QrRegistrationForm.tsx +0 -38
  384. package/src/pages/Index/Settings/AccountSettings/SecurityContent.tsx +0 -713
  385. package/src/pages/Index/Settings/AccountSettings/UserPanel.tsx +0 -24
  386. package/src/pages/Index/Settings/AccountSettings/UserThemePanel.tsx +0 -207
  387. package/src/pages/Index/Settings/AccountSettings/useConfirm.tsx +0 -117
  388. package/src/pages/Index/Settings/AdminCenter/CurrencyManagementPanel.tsx +0 -111
  389. package/src/pages/Index/Settings/AdminCenter/Index.tsx +0 -251
  390. package/src/pages/Index/Settings/AdminCenter/LabelTemplatePanel.tsx +0 -23
  391. package/src/pages/Index/Settings/AdminCenter/MachineManagementPanel.tsx +0 -110
  392. package/src/pages/Index/Settings/AdminCenter/PartParameterPanel.tsx +0 -29
  393. package/src/pages/Index/Settings/AdminCenter/PluginManagementPanel.tsx +0 -84
  394. package/src/pages/Index/Settings/AdminCenter/ReportTemplatePanel.tsx +0 -38
  395. package/src/pages/Index/Settings/AdminCenter/StocktakePanel.tsx +0 -31
  396. package/src/pages/Index/Settings/AdminCenter/TaskManagementPanel.tsx +0 -73
  397. package/src/pages/Index/Settings/AdminCenter/UnitManagementPanel.tsx +0 -74
  398. package/src/pages/Index/Settings/AdminCenter/UserManagementPanel.tsx +0 -49
  399. package/src/pages/Index/Settings/SystemSettings.tsx +0 -339
  400. package/src/pages/Index/Settings/UserSettings.tsx +0 -143
  401. package/src/pages/Notifications.tsx +0 -134
  402. package/src/pages/build/BuildDetail.tsx +0 -579
  403. package/src/pages/build/BuildIndex.tsx +0 -100
  404. package/src/pages/company/CompanyDetail.tsx +0 -352
  405. package/src/pages/company/CustomerDetail.tsx +0 -13
  406. package/src/pages/company/ManufacturerDetail.tsx +0 -13
  407. package/src/pages/company/ManufacturerPartDetail.tsx +0 -307
  408. package/src/pages/company/SupplierDetail.tsx +0 -13
  409. package/src/pages/company/SupplierPartDetail.tsx +0 -433
  410. package/src/pages/core/CoreIndex.tsx +0 -50
  411. package/src/pages/core/GroupDetail.tsx +0 -97
  412. package/src/pages/core/UserDetail.tsx +0 -193
  413. package/src/pages/part/CategoryDetail.tsx +0 -369
  414. package/src/pages/part/PartAllocationPanel.tsx +0 -40
  415. package/src/pages/part/PartDetail.tsx +0 -1071
  416. package/src/pages/part/PartPricingPanel.tsx +0 -155
  417. package/src/pages/part/PartSchedulingDetail.tsx +0 -315
  418. package/src/pages/part/PartStocktakeDetail.tsx +0 -285
  419. package/src/pages/part/PartSupplierDetail.tsx +0 -31
  420. package/src/pages/part/pricing/BomPricingPanel.tsx +0 -269
  421. package/src/pages/part/pricing/PriceBreakPanel.tsx +0 -182
  422. package/src/pages/part/pricing/PricingOverviewPanel.tsx +0 -338
  423. package/src/pages/part/pricing/PricingPanel.tsx +0 -82
  424. package/src/pages/part/pricing/PurchaseHistoryPanel.tsx +0 -134
  425. package/src/pages/part/pricing/SaleHistoryPanel.tsx +0 -95
  426. package/src/pages/part/pricing/SupplierPricingPanel.tsx +0 -80
  427. package/src/pages/part/pricing/VariantPricingPanel.tsx +0 -112
  428. package/src/pages/purchasing/PurchaseOrderDetail.tsx +0 -547
  429. package/src/pages/purchasing/PurchasingIndex.tsx +0 -131
  430. package/src/pages/sales/ReturnOrderDetail.tsx +0 -529
  431. package/src/pages/sales/SalesIndex.tsx +0 -148
  432. package/src/pages/sales/SalesOrderDetail.tsx +0 -593
  433. package/src/pages/sales/SalesOrderShipmentDetail.tsx +0 -385
  434. package/src/pages/stock/LocationDetail.tsx +0 -413
  435. package/src/pages/stock/StockDetail.tsx +0 -951
  436. package/src/router.tsx +0 -213
  437. package/src/states/ApiState.tsx +0 -85
  438. package/src/states/IconState.tsx +0 -94
  439. package/src/states/LocalState.tsx +0 -181
  440. package/src/states/SettingsState.tsx +0 -206
  441. package/src/states/StatusState.tsx +0 -55
  442. package/src/states/UserState.tsx +0 -202
  443. package/src/states/states.tsx +0 -69
  444. package/src/tables/Column.tsx +0 -29
  445. package/src/tables/ColumnRenderers.tsx +0 -320
  446. package/src/tables/ColumnSelect.tsx +0 -39
  447. package/src/tables/Filter.tsx +0 -297
  448. package/src/tables/FilterSelectDrawer.tsx +0 -358
  449. package/src/tables/InvenTreeTable.tsx +0 -750
  450. package/src/tables/InvenTreeTableHeader.tsx +0 -257
  451. package/src/tables/RowActions.tsx +0 -176
  452. package/src/tables/RowExpansionIcon.tsx +0 -16
  453. package/src/tables/Search.tsx +0 -42
  454. package/src/tables/TableHoverCard.tsx +0 -91
  455. package/src/tables/bom/BomTable.tsx +0 -590
  456. package/src/tables/bom/UsedInTable.tsx +0 -114
  457. package/src/tables/build/BuildAllocatedStockTable.tsx +0 -233
  458. package/src/tables/build/BuildLineTable.tsx +0 -800
  459. package/src/tables/build/BuildOrderTable.tsx +0 -226
  460. package/src/tables/build/BuildOrderTestTable.tsx +0 -265
  461. package/src/tables/build/BuildOutputTable.tsx +0 -599
  462. package/src/tables/company/AddressTable.tsx +0 -211
  463. package/src/tables/company/CompanyTable.tsx +0 -176
  464. package/src/tables/company/ContactTable.tsx +0 -182
  465. package/src/tables/core/UserTable.tsx +0 -88
  466. package/src/tables/general/AttachmentTable.tsx +0 -404
  467. package/src/tables/general/BarcodeScanTable.tsx +0 -124
  468. package/src/tables/general/ExtraLineItemTable.tsx +0 -174
  469. package/src/tables/machine/MachineListTable.tsx +0 -634
  470. package/src/tables/machine/MachineTypeTable.tsx +0 -395
  471. package/src/tables/notifications/NotificationTable.tsx +0 -60
  472. package/src/tables/part/ParametricPartTable.tsx +0 -297
  473. package/src/tables/part/PartBuildAllocationsTable.tsx +0 -128
  474. package/src/tables/part/PartCategoryTable.tsx +0 -208
  475. package/src/tables/part/PartCategoryTemplateTable.tsx +0 -157
  476. package/src/tables/part/PartParameterTable.tsx +0 -226
  477. package/src/tables/part/PartParameterTemplateTable.tsx +0 -168
  478. package/src/tables/part/PartPurchaseOrdersTable.tsx +0 -163
  479. package/src/tables/part/PartSalesAllocationsTable.tsx +0 -130
  480. package/src/tables/part/PartTable.tsx +0 -423
  481. package/src/tables/part/PartTestTemplateTable.tsx +0 -290
  482. package/src/tables/part/PartThumbTable.tsx +0 -230
  483. package/src/tables/part/PartVariantTable.tsx +0 -52
  484. package/src/tables/part/RelatedPartTable.tsx +0 -182
  485. package/src/tables/part/SelectionListTable.tsx +0 -134
  486. package/src/tables/plugin/PluginErrorTable.tsx +0 -58
  487. package/src/tables/plugin/PluginListTable.tsx +0 -440
  488. package/src/tables/purchasing/ManufacturerPartParameterTable.tsx +0 -136
  489. package/src/tables/purchasing/ManufacturerPartTable.tsx +0 -158
  490. package/src/tables/purchasing/PurchaseOrderLineItemTable.tsx +0 -424
  491. package/src/tables/purchasing/PurchaseOrderTable.tsx +0 -193
  492. package/src/tables/purchasing/SupplierPartTable.tsx +0 -281
  493. package/src/tables/purchasing/SupplierPriceBreakTable.tsx +0 -222
  494. package/src/tables/sales/ReturnOrderLineItemTable.tsx +0 -271
  495. package/src/tables/sales/ReturnOrderTable.tsx +0 -201
  496. package/src/tables/sales/SalesOrderAllocationTable.tsx +0 -330
  497. package/src/tables/sales/SalesOrderLineItemTable.tsx +0 -508
  498. package/src/tables/sales/SalesOrderShipmentTable.tsx +0 -225
  499. package/src/tables/sales/SalesOrderTable.tsx +0 -212
  500. package/src/tables/settings/ApiTokenTable.tsx +0 -203
  501. package/src/tables/settings/BarcodeScanHistoryTable.tsx +0 -281
  502. package/src/tables/settings/CustomStateTable.tsx +0 -226
  503. package/src/tables/settings/CustomUnitsTable.tsx +0 -125
  504. package/src/tables/settings/ErrorTable.tsx +0 -170
  505. package/src/tables/settings/ExportSessionTable.tsx +0 -60
  506. package/src/tables/settings/FailedTasksTable.tsx +0 -103
  507. package/src/tables/settings/GroupTable.tsx +0 -240
  508. package/src/tables/settings/ImportSessionTable.tsx +0 -175
  509. package/src/tables/settings/PendingTasksTable.tsx +0 -63
  510. package/src/tables/settings/ProjectCodeTable.tsx +0 -115
  511. package/src/tables/settings/ScheduledTasksTable.tsx +0 -62
  512. package/src/tables/settings/StocktakeReportTable.tsx +0 -111
  513. package/src/tables/settings/TemplateTable.tsx +0 -404
  514. package/src/tables/settings/UserTable.tsx +0 -329
  515. package/src/tables/stock/InstalledItemsTable.tsx +0 -146
  516. package/src/tables/stock/LocationTypesTable.tsx +0 -132
  517. package/src/tables/stock/StockItemTable.tsx +0 -707
  518. package/src/tables/stock/StockItemTestResultTable.tsx +0 -487
  519. package/src/tables/stock/StockLocationTable.tsx +0 -208
  520. package/src/tables/stock/StockTrackingTable.tsx +0 -244
  521. package/src/theme.ts +0 -5
  522. package/src/views/DesktopAppView.tsx +0 -28
  523. package/src/views/MainView.tsx +0 -38
  524. package/src/views/MobileAppView.tsx +0 -43
  525. package/tests/baseFixtures.ts +0 -93
  526. package/tests/defaults.ts +0 -18
  527. package/tests/helpers.ts +0 -122
  528. package/tests/login.ts +0 -97
  529. package/tests/pages/pui_build.spec.ts +0 -373
  530. package/tests/pages/pui_company.spec.ts +0 -40
  531. package/tests/pages/pui_core.spec.ts +0 -26
  532. package/tests/pages/pui_dashboard.spec.ts +0 -64
  533. package/tests/pages/pui_part.spec.ts +0 -413
  534. package/tests/pages/pui_purchase_order.spec.ts +0 -388
  535. package/tests/pages/pui_sales_order.spec.ts +0 -224
  536. package/tests/pages/pui_scan.spec.ts +0 -114
  537. package/tests/pages/pui_stock.spec.ts +0 -259
  538. package/tests/pui_exporting.spec.ts +0 -124
  539. package/tests/pui_forms.spec.ts +0 -131
  540. package/tests/pui_general.spec.ts +0 -60
  541. package/tests/pui_login.spec.ts +0 -74
  542. package/tests/pui_modals.spec.ts +0 -144
  543. package/tests/pui_plugins.spec.ts +0 -216
  544. package/tests/pui_printing.spec.ts +0 -149
  545. package/tests/pui_settings.spec.ts +0 -285
  546. package/tests/pui_tables.spec.ts +0 -65
  547. package/tests/settings/selectionList.spec.ts +0 -103
  548. package/tests/settings.ts +0 -54
  549. package/tsconfig.json +0 -25
  550. package/tsconfig.lib.json +0 -13
  551. package/tsconfig.node.json +0 -11
  552. package/vite-env.d.ts +0 -11
  553. package/vite.config.ts +0 -98
  554. package/vite.lib.config.ts +0 -50
  555. /package/{public → dist}/inventree.svg +0 -0
@@ -1,1296 +0,0 @@
1
- import { t } from '@lingui/core/macro';
2
- import { Flex, Group, Skeleton, Stack, Table, Text } from '@mantine/core';
3
- import { useDisclosure } from '@mantine/hooks';
4
- import { modals } from '@mantine/modals';
5
- import {
6
- IconCalendarExclamation,
7
- IconCoins,
8
- IconCurrencyDollar,
9
- IconLink,
10
- IconPackage,
11
- IconUsersGroup
12
- } from '@tabler/icons-react';
13
- import { useQuery, useSuspenseQuery } from '@tanstack/react-query';
14
- import { Suspense, useEffect, useMemo, useState } from 'react';
15
-
16
- import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
17
- import { ModelType } from '@lib/enums/ModelType';
18
- import dayjs from 'dayjs';
19
- import { api } from '../App';
20
- import { ActionButton } from '../components/buttons/ActionButton';
21
- import RemoveRowButton from '../components/buttons/RemoveRowButton';
22
- import { StandaloneField } from '../components/forms/StandaloneField';
23
-
24
- import { apiUrl } from '@lib/functions/Api';
25
- import type {
26
- ApiFormAdjustFilterType,
27
- ApiFormFieldChoice,
28
- ApiFormFieldSet,
29
- ApiFormModalProps
30
- } from '@lib/types/Forms';
31
- import {
32
- TableFieldExtraRow,
33
- type TableFieldRowProps
34
- } from '../components/forms/fields/TableField';
35
- import { Thumbnail } from '../components/images/Thumbnail';
36
- import { StylishText } from '../components/items/StylishText';
37
- import { StatusRenderer } from '../components/render/StatusRenderer';
38
- import { InvenTreeIcon } from '../functions/icons';
39
- import { useCreateApiFormModal, useDeleteApiFormModal } from '../hooks/UseForm';
40
- import {
41
- useBatchCodeGenerator,
42
- useSerialNumberGenerator
43
- } from '../hooks/UseGenerator';
44
- import { useSerialNumberPlaceholder } from '../hooks/UsePlaceholder';
45
- import { useGlobalSettingsState } from '../states/SettingsState';
46
- import { StatusFilterOptions } from '../tables/Filter';
47
-
48
- /**
49
- * Construct a set of fields for creating / editing a StockItem instance
50
- */
51
- export function useStockFields({
52
- partId,
53
- stockItem,
54
- create = false
55
- }: {
56
- partId?: number;
57
- stockItem?: any;
58
- create: boolean;
59
- }): ApiFormFieldSet {
60
- const globalSettings = useGlobalSettingsState();
61
-
62
- // Keep track of the "part" instance
63
- const [partInstance, setPartInstance] = useState<any>({});
64
-
65
- const [supplierPart, setSupplierPart] = useState<number | null>(null);
66
-
67
- const [nextBatchCode, setNextBatchCode] = useState<string>('');
68
- const [nextSerialNumber, setNextSerialNumber] = useState<string>('');
69
-
70
- const [expiryDate, setExpiryDate] = useState<string | null>(null);
71
-
72
- const batchGenerator = useBatchCodeGenerator((value: any) => {
73
- if (value) {
74
- setNextBatchCode(`${t`Next batch code`}: ${value}`);
75
- } else {
76
- setNextBatchCode('');
77
- }
78
- });
79
-
80
- const serialGenerator = useSerialNumberGenerator((value: any) => {
81
- if (value) {
82
- setNextSerialNumber(`${t`Next serial number`}: ${value}`);
83
- } else {
84
- setNextSerialNumber('');
85
- }
86
- });
87
-
88
- useEffect(() => {
89
- if (partInstance?.pk) {
90
- // Update the generators whenever the part ID changes
91
- batchGenerator.update({ part: partInstance.pk });
92
- serialGenerator.update({ part: partInstance.pk });
93
- }
94
- }, [partInstance.pk]);
95
-
96
- return useMemo(() => {
97
- const fields: ApiFormFieldSet = {
98
- part: {
99
- value: partInstance.pk,
100
- disabled: !create,
101
- filters: {
102
- active: create ? true : undefined
103
- },
104
- onValueChange: (value, record) => {
105
- // Update the tracked part instance
106
- setPartInstance(record);
107
-
108
- // Clear the 'supplier_part' field if the part is changed
109
- setSupplierPart(null);
110
-
111
- // Adjust the 'expiry date' for the stock item
112
- const expiry_days = record?.default_expiry ?? 0;
113
-
114
- if (expiry_days && expiry_days > 0) {
115
- // Adjust the expiry date based on the part default expiry
116
- setExpiryDate(
117
- dayjs().add(expiry_days, 'days').format('YYYY-MM-DD')
118
- );
119
- }
120
- }
121
- },
122
- supplier_part: {
123
- hidden: partInstance?.purchaseable == false,
124
- value: supplierPart,
125
- onValueChange: (value) => {
126
- setSupplierPart(value);
127
- },
128
- filters: {
129
- part_detail: true,
130
- supplier_detail: true,
131
- part: partId
132
- },
133
- adjustFilters: (adjust: ApiFormAdjustFilterType) => {
134
- if (adjust.data.part) {
135
- adjust.filters['part'] = adjust.data.part;
136
- }
137
-
138
- return adjust.filters;
139
- }
140
- },
141
- use_pack_size: {
142
- hidden: !create,
143
- description: t`Add given quantity as packs instead of individual items`
144
- },
145
- location: {
146
- // Cannot adjust location for existing stock items
147
- hidden: !create,
148
- onValueChange: (value) => {
149
- batchGenerator.update({ location: value });
150
- },
151
- filters: {
152
- structural: false
153
- }
154
- },
155
- quantity: {
156
- hidden: !create,
157
- description: t`Enter initial quantity for this stock item`,
158
- onValueChange: (value) => {
159
- batchGenerator.update({ quantity: value });
160
- }
161
- },
162
- serial_numbers: {
163
- field_type: 'string',
164
- label: t`Serial Numbers`,
165
- disabled: partInstance?.trackable == false,
166
- description: t`Enter serial numbers for new stock (or leave blank)`,
167
- required: false,
168
- hidden: !create,
169
- placeholder: nextSerialNumber
170
- },
171
- serial: {
172
- hidden:
173
- create ||
174
- partInstance.trackable == false ||
175
- (stockItem?.quantity != undefined && stockItem?.quantity != 1)
176
- },
177
- batch: {
178
- placeholder: nextBatchCode
179
- },
180
- status_custom_key: {
181
- label: t`Stock Status`
182
- },
183
- expiry_date: {
184
- icon: <IconCalendarExclamation />,
185
- hidden: !globalSettings.isSet('STOCK_ENABLE_EXPIRY'),
186
- value: expiryDate,
187
- onValueChange: (value) => {
188
- setExpiryDate(value);
189
- }
190
- },
191
- purchase_price: {
192
- icon: <IconCurrencyDollar />
193
- },
194
- purchase_price_currency: {
195
- icon: <IconCoins />
196
- },
197
- packaging: {
198
- icon: <IconPackage />
199
- },
200
- link: {
201
- icon: <IconLink />
202
- },
203
- owner: {
204
- icon: <IconUsersGroup />
205
- },
206
- delete_on_deplete: {}
207
- };
208
-
209
- // Remove the expiry date field if it is not enabled
210
- if (!globalSettings.isSet('STOCK_ENABLE_EXPIRY')) {
211
- delete fields.expiry_date;
212
- }
213
-
214
- return fields;
215
- }, [
216
- stockItem,
217
- expiryDate,
218
- partInstance,
219
- partId,
220
- globalSettings,
221
- supplierPart,
222
- nextSerialNumber,
223
- nextBatchCode,
224
- create
225
- ]);
226
- }
227
-
228
- /**
229
- * Launch a form to create a new StockItem instance
230
- */
231
- export function useCreateStockItem() {
232
- const fields = useStockFields({ create: true });
233
-
234
- return useCreateApiFormModal({
235
- url: ApiEndpoints.stock_item_list,
236
- fields: fields,
237
- title: t`Add Stock Item`
238
- });
239
- }
240
-
241
- /**
242
- * Form set for manually removing (uninstalling) a StockItem from an existing StockItem
243
- */
244
- export function useStockItemUninstallFields(): ApiFormFieldSet {
245
- return useMemo(() => {
246
- return {
247
- location: {
248
- filters: {
249
- structural: false
250
- }
251
- },
252
- note: {}
253
- };
254
- }, []);
255
- }
256
-
257
- /**
258
- * Form set for manually installing a StockItem into an existing StockItem
259
- */
260
- export function useStockItemInstallFields({
261
- stockItem
262
- }: {
263
- stockItem: any;
264
- }): ApiFormFieldSet {
265
- const globalSettings = useGlobalSettingsState();
266
-
267
- const [selectedPart, setSelectedPart] = useState<number | null>(null);
268
-
269
- useEffect(() => {
270
- setSelectedPart(null);
271
- }, [stockItem]);
272
-
273
- return useMemo(() => {
274
- // Note: The 'part' field is not a part of the API endpoint, so we construct it manually
275
- return {
276
- part: {
277
- field_type: 'related field',
278
- required: true,
279
- exclude: true,
280
- label: t`Part`,
281
- description: t`Select the part to install`,
282
- model: ModelType.part,
283
- api_url: apiUrl(ApiEndpoints.part_list),
284
- onValueChange: (value) => {
285
- setSelectedPart(value);
286
- },
287
- filters: {
288
- trackable: true,
289
- in_bom_for: globalSettings.isSet('STOCK_ENFORCE_BOM_INSTALLATION')
290
- ? stockItem.part
291
- : undefined
292
- }
293
- },
294
- stock_item: {
295
- disabled: !selectedPart,
296
- filters: {
297
- part_detail: true,
298
- in_stock: true,
299
- available: true,
300
- tracked: true,
301
- part: selectedPart ? selectedPart : undefined
302
- }
303
- },
304
- quantity: {},
305
- note: {}
306
- };
307
- }, [globalSettings, selectedPart, stockItem]);
308
- }
309
-
310
- /**
311
- * Form set for serializing an existing StockItem
312
- */
313
- export function useStockItemSerializeFields({
314
- partId,
315
- trackable
316
- }: {
317
- partId: number;
318
- trackable: boolean;
319
- }) {
320
- const snPlaceholder = useSerialNumberPlaceholder({
321
- partId: partId,
322
- key: 'stock-item-serialize',
323
- enabled: trackable
324
- });
325
-
326
- return useMemo(() => {
327
- return {
328
- quantity: {},
329
- serial_numbers: {
330
- placeholder: snPlaceholder
331
- },
332
- destination: {}
333
- };
334
- }, [snPlaceholder]);
335
- }
336
-
337
- function StockItemDefaultMove({
338
- stockItem,
339
- value
340
- }: Readonly<{
341
- stockItem: any;
342
- value: any;
343
- }>) {
344
- const { data } = useSuspenseQuery({
345
- queryKey: [
346
- 'location',
347
- stockItem.part_detail?.default_location ??
348
- stockItem.part_detail?.category_default_location
349
- ],
350
- queryFn: async () => {
351
- const url = apiUrl(
352
- ApiEndpoints.stock_location_list,
353
- stockItem.part_detail?.default_location ??
354
- stockItem.part_detail?.category_default_location
355
- );
356
-
357
- return api
358
- .get(url)
359
- .then((response) => {
360
- switch (response.status) {
361
- case 200:
362
- return response.data;
363
- default:
364
- return null;
365
- }
366
- })
367
- .catch(() => {
368
- return null;
369
- });
370
- }
371
- });
372
-
373
- return (
374
- <Flex gap='sm' justify='space-evenly' align='center'>
375
- <Flex gap='sm' direction='column' align='center'>
376
- <Text>
377
- {value} x {stockItem.part_detail.name}
378
- </Text>
379
- <Thumbnail
380
- src={stockItem.part_detail.thumbnail}
381
- size={80}
382
- align='center'
383
- />
384
- </Flex>
385
- <Flex direction='column' gap='sm' align='center'>
386
- <Text>{stockItem.location_detail?.pathstring ?? '-'}</Text>
387
- <InvenTreeIcon icon='arrow_down' />
388
- <Suspense fallback={<Skeleton width='150px' />}>
389
- <Text>{data?.pathstring}</Text>
390
- </Suspense>
391
- </Flex>
392
- </Flex>
393
- );
394
- }
395
-
396
- function moveToDefault(
397
- stockItem: any,
398
- value: StockItemQuantity,
399
- refresh: () => void
400
- ) {
401
- modals.openConfirmModal({
402
- title: <StylishText>{t`Confirm Stock Transfer`}</StylishText>,
403
- children: <StockItemDefaultMove stockItem={stockItem} value={value} />,
404
- onConfirm: () => {
405
- if (
406
- stockItem.location === stockItem.part_detail?.default_location ||
407
- stockItem.location === stockItem.part_detail?.category_default_location
408
- ) {
409
- return;
410
- }
411
- api
412
- .post(apiUrl(ApiEndpoints.stock_transfer), {
413
- items: [
414
- {
415
- pk: stockItem.pk,
416
- quantity: value,
417
- batch: stockItem.batch,
418
- status: stockItem.status
419
- }
420
- ],
421
- location:
422
- stockItem.part_detail?.default_location ??
423
- stockItem.part_detail?.category_default_location
424
- })
425
- .then((response) => {
426
- refresh();
427
- return response.data;
428
- })
429
- .catch(() => {
430
- return null;
431
- });
432
- }
433
- });
434
- }
435
-
436
- type StockAdjustmentItemWithRecord = {
437
- obj: any;
438
- } & StockAdjustmentItem;
439
-
440
- type TableFieldRefreshFn = (idx: number) => void;
441
- type TableFieldChangeFn = (idx: number, key: string, value: any) => void;
442
-
443
- type StockRow = {
444
- item: StockAdjustmentItemWithRecord;
445
- idx: number;
446
- changeFn: TableFieldChangeFn;
447
- removeFn: TableFieldRefreshFn;
448
- };
449
-
450
- function StockOperationsRow({
451
- props,
452
- transfer = false,
453
- changeStatus = false,
454
- add = false,
455
- setMax = false,
456
- merge = false,
457
- record
458
- }: {
459
- props: TableFieldRowProps;
460
- transfer?: boolean;
461
- changeStatus?: boolean;
462
- add?: boolean;
463
- setMax?: boolean;
464
- merge?: boolean;
465
- record?: any;
466
- }) {
467
- const statusOptions: ApiFormFieldChoice[] = useMemo(() => {
468
- return (
469
- StatusFilterOptions(ModelType.stockitem)()?.map((choice) => {
470
- return {
471
- value: choice.value,
472
- display_name: choice.label
473
- };
474
- }) ?? []
475
- );
476
- }, []);
477
-
478
- const [quantity, setQuantity] = useState<StockItemQuantity>(
479
- add ? 0 : (props.item?.quantity ?? 0)
480
- );
481
-
482
- const [status, setStatus] = useState<number | undefined>(undefined);
483
-
484
- const removeAndRefresh = () => {
485
- props.removeFn(props.idx);
486
- };
487
-
488
- const [packagingOpen, packagingHandlers] = useDisclosure(false, {
489
- onOpen: () => {
490
- if (transfer) {
491
- props.changeFn(props.idx, 'packaging', record?.packaging || undefined);
492
- }
493
- },
494
- onClose: () => {
495
- if (transfer) {
496
- props.changeFn(props.idx, 'packaging', undefined);
497
- }
498
- }
499
- });
500
-
501
- const [statusOpen, statusHandlers] = useDisclosure(false, {
502
- onOpen: () => {
503
- setStatus(record?.status_custom_key || record?.status || undefined);
504
- props.changeFn(props.idx, 'status', record?.status || undefined);
505
- },
506
- onClose: () => {
507
- setStatus(undefined);
508
- props.changeFn(props.idx, 'status', undefined);
509
- }
510
- });
511
-
512
- const stockString: string = useMemo(() => {
513
- if (!record) {
514
- return '-';
515
- }
516
-
517
- if (!record.serial) {
518
- return `${record.quantity}`;
519
- } else {
520
- return `#${record.serial}`;
521
- }
522
- }, [record]);
523
-
524
- return !record ? (
525
- <div>{t`Loading...`}</div>
526
- ) : (
527
- <>
528
- <Table.Tr>
529
- <Table.Td>
530
- <Stack gap='xs'>
531
- <Flex gap='sm' align='center'>
532
- <Thumbnail
533
- size={40}
534
- src={record.part_detail?.thumbnail}
535
- align='center'
536
- />
537
- <div>{record.part_detail?.name}</div>
538
- </Flex>
539
- {props.rowErrors?.pk?.message && (
540
- <Text c='red' size='xs'>
541
- {props.rowErrors.pk.message}
542
- </Text>
543
- )}
544
- </Stack>
545
- </Table.Td>
546
- <Table.Td>
547
- {record.location ? record.location_detail?.pathstring : '-'}
548
- </Table.Td>
549
- <Table.Td>{record.batch ? record.batch : '-'}</Table.Td>
550
- <Table.Td>
551
- <Group grow justify='space-between' wrap='nowrap'>
552
- <Text>{stockString}</Text>
553
- <StatusRenderer
554
- status={record.status_custom_key}
555
- type={ModelType.stockitem}
556
- />
557
- </Group>
558
- </Table.Td>
559
- {!merge && (
560
- <Table.Td>
561
- <StandaloneField
562
- fieldName='quantity'
563
- fieldDefinition={{
564
- field_type: 'number',
565
- value: quantity,
566
- onValueChange: (value: any) => {
567
- setQuantity(value);
568
- props.changeFn(props.idx, 'quantity', value);
569
- }
570
- }}
571
- error={props.rowErrors?.quantity?.message}
572
- />
573
- </Table.Td>
574
- )}
575
- <Table.Td>
576
- <Flex gap='3px'>
577
- {transfer && (
578
- <ActionButton
579
- onClick={() =>
580
- moveToDefault(record, props.item.quantity, removeAndRefresh)
581
- }
582
- icon={<InvenTreeIcon icon='default_location' />}
583
- tooltip={t`Move to default location`}
584
- tooltipAlignment='top'
585
- disabled={
586
- !record.part_detail?.default_location &&
587
- !record.part_detail?.category_default_location
588
- }
589
- />
590
- )}
591
- {changeStatus && (
592
- <ActionButton
593
- size='sm'
594
- icon={<InvenTreeIcon icon='status' />}
595
- tooltip={t`Change Status`}
596
- onClick={() => statusHandlers.toggle()}
597
- variant={statusOpen ? 'filled' : 'transparent'}
598
- />
599
- )}
600
- {transfer && (
601
- <ActionButton
602
- size='sm'
603
- icon={<InvenTreeIcon icon='packaging' />}
604
- tooltip={t`Adjust Packaging`}
605
- onClick={() => packagingHandlers.toggle()}
606
- variant={packagingOpen ? 'filled' : 'transparent'}
607
- />
608
- )}
609
- <RemoveRowButton onClick={() => props.removeFn(props.idx)} />
610
- </Flex>
611
- </Table.Td>
612
- </Table.Tr>
613
- {changeStatus && (
614
- <TableFieldExtraRow
615
- visible={statusOpen}
616
- onValueChange={(value: any) => {
617
- setStatus(value);
618
- props.changeFn(props.idx, 'status', value || undefined);
619
- }}
620
- fieldName='status'
621
- fieldDefinition={{
622
- field_type: 'choice',
623
- label: t`Status`,
624
- choices: statusOptions,
625
- value: status
626
- }}
627
- defaultValue={status}
628
- />
629
- )}
630
- {transfer && (
631
- <TableFieldExtraRow
632
- visible={transfer && packagingOpen}
633
- onValueChange={(value: any) => {
634
- props.changeFn(props.idx, 'packaging', value || undefined);
635
- }}
636
- fieldName='packaging'
637
- fieldDefinition={{
638
- field_type: 'string',
639
- label: t`Packaging`
640
- }}
641
- defaultValue={record.packaging}
642
- />
643
- )}
644
- </>
645
- );
646
- }
647
-
648
- type StockItemQuantity = number | '' | undefined;
649
-
650
- type StockAdjustmentItem = {
651
- pk: number;
652
- quantity: StockItemQuantity;
653
- batch?: string;
654
- status?: number | '' | null;
655
- packaging?: string;
656
- };
657
-
658
- function mapAdjustmentItems(items: any[]) {
659
- const mappedItems: StockAdjustmentItemWithRecord[] = items.map((elem) => {
660
- return {
661
- pk: elem.pk,
662
- quantity: elem.quantity,
663
- batch: elem.batch || undefined,
664
- status: elem.status || undefined,
665
- packaging: elem.packaging || undefined,
666
- obj: elem
667
- };
668
- });
669
-
670
- return mappedItems;
671
- }
672
-
673
- function stockTransferFields(items: any[]): ApiFormFieldSet {
674
- if (!items) {
675
- return {};
676
- }
677
-
678
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
679
-
680
- const fields: ApiFormFieldSet = {
681
- items: {
682
- field_type: 'table',
683
- value: mapAdjustmentItems(items),
684
- modelRenderer: (row: TableFieldRowProps) => {
685
- const record = records[row.item.pk];
686
-
687
- return (
688
- <StockOperationsRow
689
- props={row}
690
- transfer
691
- changeStatus
692
- setMax
693
- key={record.pk}
694
- record={record}
695
- />
696
- );
697
- },
698
- headers: [
699
- { title: t`Part` },
700
- { title: t`Location` },
701
- { title: t`Batch` },
702
- { title: t`Stock` },
703
- { title: t`Move`, style: { width: '200px' } },
704
- { title: t`Actions` }
705
- ]
706
- },
707
- location: {
708
- filters: {
709
- structural: false
710
- }
711
- },
712
- notes: {}
713
- };
714
- return fields;
715
- }
716
-
717
- function stockRemoveFields(items: any[]): ApiFormFieldSet {
718
- if (!items) {
719
- return {};
720
- }
721
-
722
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
723
-
724
- const fields: ApiFormFieldSet = {
725
- items: {
726
- field_type: 'table',
727
- value: mapAdjustmentItems(items),
728
- modelRenderer: (row: TableFieldRowProps) => {
729
- const record = records[row.item.pk];
730
-
731
- return (
732
- <StockOperationsRow
733
- props={row}
734
- setMax
735
- changeStatus
736
- add
737
- key={record.pk}
738
- record={record}
739
- />
740
- );
741
- },
742
- headers: [
743
- { title: t`Part` },
744
- { title: t`Location` },
745
- { title: t`Batch` },
746
- { title: t`In Stock` },
747
- { title: t`Remove`, style: { width: '200px' } },
748
- { title: t`Actions` }
749
- ]
750
- },
751
- notes: {}
752
- };
753
-
754
- return fields;
755
- }
756
-
757
- function stockAddFields(items: any[]): ApiFormFieldSet {
758
- if (!items) {
759
- return {};
760
- }
761
-
762
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
763
-
764
- const fields: ApiFormFieldSet = {
765
- items: {
766
- field_type: 'table',
767
- value: mapAdjustmentItems(items),
768
- modelRenderer: (row: TableFieldRowProps) => {
769
- const record = records[row.item.pk];
770
-
771
- return (
772
- <StockOperationsRow
773
- changeStatus
774
- props={row}
775
- add
776
- key={record.pk}
777
- record={record}
778
- />
779
- );
780
- },
781
- headers: [
782
- { title: t`Part` },
783
- { title: t`Location` },
784
- { title: t`Batch` },
785
- { title: t`In Stock` },
786
- { title: t`Add`, style: { width: '200px' } },
787
- { title: t`Actions` }
788
- ]
789
- },
790
- notes: {}
791
- };
792
-
793
- return fields;
794
- }
795
-
796
- function stockCountFields(items: any[]): ApiFormFieldSet {
797
- if (!items) {
798
- return {};
799
- }
800
-
801
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
802
-
803
- const fields: ApiFormFieldSet = {
804
- items: {
805
- field_type: 'table',
806
- value: mapAdjustmentItems(items),
807
- modelRenderer: (row: TableFieldRowProps) => {
808
- return (
809
- <StockOperationsRow
810
- props={row}
811
- changeStatus
812
- key={row.item.pk}
813
- record={records[row.item.pk]}
814
- />
815
- );
816
- },
817
- headers: [
818
- { title: t`Part` },
819
- { title: t`Location` },
820
- { title: t`Batch` },
821
- { title: t`In Stock` },
822
- { title: t`Count`, style: { width: '200px' } },
823
- { title: t`Actions` }
824
- ]
825
- },
826
- notes: {}
827
- };
828
-
829
- return fields;
830
- }
831
-
832
- function stockChangeStatusFields(items: any[]): ApiFormFieldSet {
833
- if (!items) {
834
- return {};
835
- }
836
-
837
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
838
-
839
- const fields: ApiFormFieldSet = {
840
- items: {
841
- field_type: 'table',
842
- value: items.map((elem) => {
843
- return elem.pk;
844
- }),
845
- modelRenderer: (row: TableFieldRowProps) => {
846
- return (
847
- <StockOperationsRow
848
- props={row}
849
- key={row.item}
850
- merge
851
- record={records[row.item]}
852
- />
853
- );
854
- },
855
- headers: [
856
- { title: t`Part` },
857
- { title: t`Location` },
858
- { title: t`Batch` },
859
- { title: t`In Stock` },
860
- { title: '', style: { width: '50px' } }
861
- ]
862
- },
863
- status: {},
864
- note: {}
865
- };
866
-
867
- return fields;
868
- }
869
-
870
- function stockMergeFields(items: any[]): ApiFormFieldSet {
871
- if (!items) {
872
- return {};
873
- }
874
-
875
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
876
-
877
- const fields: ApiFormFieldSet = {
878
- items: {
879
- field_type: 'table',
880
- value: items.map((elem) => {
881
- return {
882
- item: elem.pk,
883
- obj: elem
884
- };
885
- }),
886
- modelRenderer: (row: TableFieldRowProps) => {
887
- return (
888
- <StockOperationsRow
889
- props={row}
890
- key={row.item.item}
891
- merge
892
- changeStatus
893
- record={records[row.item.item]}
894
- />
895
- );
896
- },
897
- headers: [
898
- { title: t`Part` },
899
- { title: t`Location` },
900
- { title: t`Batch` },
901
- { title: t`In Stock` },
902
- { title: t`Actions` }
903
- ]
904
- },
905
- location: {
906
- default: items[0]?.part_detail.default_location,
907
- filters: {
908
- structural: false
909
- }
910
- },
911
- notes: {},
912
- allow_mismatched_suppliers: {},
913
- allow_mismatched_status: {}
914
- };
915
-
916
- return fields;
917
- }
918
-
919
- function stockAssignFields(items: any[]): ApiFormFieldSet {
920
- if (!items) {
921
- return {};
922
- }
923
-
924
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
925
-
926
- const fields: ApiFormFieldSet = {
927
- items: {
928
- field_type: 'table',
929
- value: items.map((elem) => {
930
- return {
931
- item: elem.pk,
932
- obj: elem
933
- };
934
- }),
935
- modelRenderer: (row: TableFieldRowProps) => {
936
- return (
937
- <StockOperationsRow
938
- props={row}
939
- key={row.item.item}
940
- merge
941
- record={records[row.item.item]}
942
- />
943
- );
944
- },
945
- headers: [
946
- { title: t`Part` },
947
- { title: t`Location` },
948
- { title: t`Batch` },
949
- { title: t`In Stock` },
950
- { title: '', style: { width: '50px' } }
951
- ]
952
- },
953
- customer: {
954
- filters: {
955
- is_customer: true
956
- }
957
- },
958
- notes: {}
959
- };
960
-
961
- return fields;
962
- }
963
-
964
- function stockDeleteFields(items: any[]): ApiFormFieldSet {
965
- if (!items) {
966
- return {};
967
- }
968
-
969
- const records = Object.fromEntries(items.map((item) => [item.pk, item]));
970
-
971
- const fields: ApiFormFieldSet = {
972
- items: {
973
- field_type: 'table',
974
- value: items.map((elem) => {
975
- return elem.pk;
976
- }),
977
- modelRenderer: (row: TableFieldRowProps) => {
978
- const record = records[row.item];
979
-
980
- return (
981
- <StockOperationsRow
982
- props={row}
983
- key={record.pk}
984
- merge
985
- record={record}
986
- />
987
- );
988
- },
989
- headers: [
990
- { title: t`Part` },
991
- { title: t`Location` },
992
- { title: t`Batch` },
993
- { title: t`In Stock` },
994
- { title: '', style: { width: '50px' } }
995
- ]
996
- }
997
- };
998
-
999
- return fields;
1000
- }
1001
-
1002
- type apiModalFunc = (props: ApiFormModalProps) => {
1003
- open: () => void;
1004
- close: () => void;
1005
- toggle: () => void;
1006
- modal: JSX.Element;
1007
- };
1008
-
1009
- function stockOperationModal({
1010
- items,
1011
- pk,
1012
- model,
1013
- refresh,
1014
- fieldGenerator,
1015
- endpoint,
1016
- filters,
1017
- title,
1018
- successMessage,
1019
- modalFunc = useCreateApiFormModal
1020
- }: {
1021
- items?: object;
1022
- pk?: number;
1023
- filters?: any;
1024
- model: ModelType | string;
1025
- refresh: () => void;
1026
- fieldGenerator: (items: any[]) => ApiFormFieldSet;
1027
- endpoint: ApiEndpoints;
1028
- title: string;
1029
- successMessage?: string;
1030
- modalFunc?: apiModalFunc;
1031
- }) {
1032
- const baseParams: any = {
1033
- part_detail: true,
1034
- location_detail: true,
1035
- cascade: false
1036
- };
1037
-
1038
- const params = useMemo(() => {
1039
- const query_params: any = {
1040
- ...baseParams,
1041
- ...(filters ?? {})
1042
- };
1043
-
1044
- query_params[model] =
1045
- pk === undefined && model === 'location' ? 'null' : pk;
1046
-
1047
- return query_params;
1048
- }, [baseParams, filters, model, pk]);
1049
-
1050
- const { data } = useQuery({
1051
- queryKey: ['stockitems', model, pk, items, params],
1052
- queryFn: async () => {
1053
- if (items) {
1054
- return Array.isArray(items) ? items : [items];
1055
- }
1056
- const url = apiUrl(ApiEndpoints.stock_item_list);
1057
-
1058
- return api
1059
- .get(url, {
1060
- params: params
1061
- })
1062
- .then((response) => {
1063
- if (response.status === 200) {
1064
- return response.data;
1065
- }
1066
- })
1067
- .catch(() => {
1068
- return null;
1069
- });
1070
- }
1071
- });
1072
-
1073
- const fields = useMemo(() => {
1074
- return fieldGenerator(data);
1075
- }, [data]);
1076
-
1077
- return modalFunc({
1078
- url: endpoint,
1079
- fields: fields,
1080
- title: title,
1081
- size: '80%',
1082
- successMessage: successMessage,
1083
- onFormSuccess: () => refresh()
1084
- });
1085
- }
1086
-
1087
- export type StockOperationProps = {
1088
- items?: any[];
1089
- pk?: number;
1090
- filters?: any;
1091
- model: ModelType.stockitem | 'location' | ModelType.part;
1092
- refresh: () => void;
1093
- };
1094
-
1095
- export function useAddStockItem(props: StockOperationProps) {
1096
- return stockOperationModal({
1097
- ...props,
1098
- fieldGenerator: stockAddFields,
1099
- endpoint: ApiEndpoints.stock_add,
1100
- title: t`Add Stock`,
1101
- successMessage: t`Stock added`
1102
- });
1103
- }
1104
-
1105
- export function useRemoveStockItem(props: StockOperationProps) {
1106
- return stockOperationModal({
1107
- ...props,
1108
- fieldGenerator: stockRemoveFields,
1109
- endpoint: ApiEndpoints.stock_remove,
1110
- title: t`Remove Stock`,
1111
- successMessage: t`Stock removed`
1112
- });
1113
- }
1114
-
1115
- export function useTransferStockItem(props: StockOperationProps) {
1116
- return stockOperationModal({
1117
- ...props,
1118
- fieldGenerator: stockTransferFields,
1119
- endpoint: ApiEndpoints.stock_transfer,
1120
- title: t`Transfer Stock`,
1121
- successMessage: t`Stock transferred`
1122
- });
1123
- }
1124
-
1125
- export function useCountStockItem(props: StockOperationProps) {
1126
- return stockOperationModal({
1127
- ...props,
1128
- fieldGenerator: stockCountFields,
1129
- endpoint: ApiEndpoints.stock_count,
1130
- title: t`Count Stock`,
1131
- successMessage: t`Stock counted`
1132
- });
1133
- }
1134
-
1135
- export function useChangeStockStatus(props: StockOperationProps) {
1136
- return stockOperationModal({
1137
- ...props,
1138
- fieldGenerator: stockChangeStatusFields,
1139
- endpoint: ApiEndpoints.stock_change_status,
1140
- title: t`Change Stock Status`,
1141
- successMessage: t`Stock status changed`
1142
- });
1143
- }
1144
-
1145
- export function useMergeStockItem(props: StockOperationProps) {
1146
- return stockOperationModal({
1147
- ...props,
1148
- fieldGenerator: stockMergeFields,
1149
- endpoint: ApiEndpoints.stock_merge,
1150
- title: t`Merge Stock`,
1151
- successMessage: t`Stock merged`
1152
- });
1153
- }
1154
-
1155
- export function useAssignStockItem(props: StockOperationProps) {
1156
- // Filter items - only allow 'salable' items
1157
- const items = useMemo(() => {
1158
- return props.items?.filter((item) => item?.part_detail?.salable);
1159
- }, [props.items]);
1160
-
1161
- return stockOperationModal({
1162
- ...props,
1163
- items: items,
1164
- fieldGenerator: stockAssignFields,
1165
- endpoint: ApiEndpoints.stock_assign,
1166
- title: t`Assign Stock to Customer`,
1167
- successMessage: t`Stock assigned to customer`
1168
- });
1169
- }
1170
-
1171
- export function useDeleteStockItem(props: StockOperationProps) {
1172
- return stockOperationModal({
1173
- ...props,
1174
- fieldGenerator: stockDeleteFields,
1175
- endpoint: ApiEndpoints.stock_item_list,
1176
- modalFunc: useDeleteApiFormModal,
1177
- title: t`Delete Stock Items`,
1178
- successMessage: t`Stock deleted`
1179
- });
1180
- }
1181
-
1182
- export function stockLocationFields(): ApiFormFieldSet {
1183
- const fields: ApiFormFieldSet = {
1184
- parent: {
1185
- description: t`Parent stock location`,
1186
- required: false
1187
- },
1188
- name: {},
1189
- description: {},
1190
- structural: {},
1191
- external: {},
1192
- custom_icon: {
1193
- field_type: 'icon'
1194
- },
1195
- location_type: {}
1196
- };
1197
-
1198
- return fields;
1199
- }
1200
-
1201
- // Construct a set of fields for
1202
- export function useTestResultFields({
1203
- partId,
1204
- itemId,
1205
- templateId,
1206
- editing = false,
1207
- editTemplate = false
1208
- }: {
1209
- partId: number;
1210
- itemId: number;
1211
- templateId: number | undefined;
1212
- editing?: boolean;
1213
- editTemplate?: boolean;
1214
- }): ApiFormFieldSet {
1215
- // Valid field choices
1216
- const [choices, setChoices] = useState<any[]>([]);
1217
-
1218
- // Field type for the "value" input
1219
- const [fieldType, setFieldType] = useState<'string' | 'choice'>('string');
1220
-
1221
- const settings = useGlobalSettingsState();
1222
-
1223
- const includeTestStation = useMemo(
1224
- () => settings.isSet('TEST_STATION_DATA'),
1225
- [settings]
1226
- );
1227
-
1228
- return useMemo(() => {
1229
- const fields: ApiFormFieldSet = {
1230
- stock_item: {
1231
- value: itemId,
1232
- hidden: true
1233
- },
1234
- template: {
1235
- disabled: !editTemplate && !!templateId,
1236
- filters: {
1237
- include_inherited: true,
1238
- part: partId
1239
- },
1240
- onValueChange: (value: any, record: any) => {
1241
- // Adjust the type of the "value" field based on the selected template
1242
- if (record?.choices) {
1243
- const _choices: string[] = record.choices.split(',');
1244
-
1245
- if (_choices.length > 0) {
1246
- setChoices(
1247
- _choices.map((choice) => {
1248
- return {
1249
- label: choice.trim(),
1250
- value: choice.trim()
1251
- };
1252
- })
1253
- );
1254
- setFieldType('choice');
1255
- } else {
1256
- setChoices([]);
1257
- setFieldType('string');
1258
- }
1259
- }
1260
- }
1261
- },
1262
- result: {},
1263
- value: {
1264
- field_type: fieldType,
1265
- choices: fieldType === 'choice' ? choices : undefined
1266
- },
1267
- attachment: {},
1268
- notes: {},
1269
- started_datetime: {
1270
- hidden: !includeTestStation
1271
- },
1272
- finished_datetime: {
1273
- hidden: !includeTestStation
1274
- },
1275
- test_station: {
1276
- hidden: !includeTestStation
1277
- }
1278
- };
1279
-
1280
- if (editing) {
1281
- // Prevent changing uploaded attachments
1282
- delete fields.attachment;
1283
- }
1284
-
1285
- return fields;
1286
- }, [
1287
- choices,
1288
- editing,
1289
- editTemplate,
1290
- fieldType,
1291
- partId,
1292
- itemId,
1293
- templateId,
1294
- includeTestStation
1295
- ]);
1296
- }