@seedtactics/insight-client 17.0.1-beta.15 → 17.0.1-beta.16

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.
@@ -31,7 +31,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
31
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
32
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
33
  */
34
- import { ListItem, ListItemButton, Paper } from "@mui/material";
34
+ import { Alert, AlertTitle, ListItem, ListItemButton, Paper } from "@mui/material";
35
35
  import { List } from "@mui/material";
36
36
  import { ListItemIcon } from "@mui/material";
37
37
  import { ListSubheader } from "@mui/material";
@@ -39,6 +39,11 @@ import { ListItemText } from "@mui/material";
39
39
  import { Typography } from "@mui/material";
40
40
  import { Build as BuildIcon, ShoppingBasket, Directions as DirectionsIcon, StarRate as StarIcon, InsertChart as ChartIcon, Extension as ExtensionIcon, Info as InfoIcon, Opacity as OpacityIcon, Memory as MemoryIcon, CalendarViewMonth, Paid as SalesIcon, } from "@mui/icons-material";
41
41
  import { RouteLocation } from "./routes.js";
42
+ import { useAtomValue } from "jotai";
43
+ import { LazySeq } from "@seedtactics/immutable-collections";
44
+ import { currentStatus } from "../cell-status/current-status.js";
45
+ import { errorLoadingLast30 } from "../network/websocket.js";
46
+ import { errorLoadingSpecificMonthData } from "../network/load-specific-month.js";
42
47
  export const defaultChooseModes = [
43
48
  { type: "Subheader", caption: "Shop Floor" },
44
49
  {
@@ -130,12 +135,19 @@ export const defaultChooseModes = [
130
135
  },
131
136
  ];
132
137
  export function ChooseMode(p) {
138
+ const status = useAtomValue(currentStatus);
139
+ const recentError = useAtomValue(errorLoadingLast30);
140
+ const monthError = useAtomValue(errorLoadingSpecificMonthData);
141
+ const errors = LazySeq.of([...status.alarms, recentError, monthError])
142
+ .filter((error) => error !== null && error.length > 0)
143
+ .distinct()
144
+ .toRArray();
133
145
  const navList = (_jsx(Paper, { children: _jsx(List, { component: "nav", dense: true, children: (p.modes ?? defaultChooseModes).map((mode, idx) => mode.type === "Subheader" ? (_jsx(ListSubheader, { children: mode.caption }, idx)) : (_jsx(ListItem, { children: _jsxs(ListItemButton, { onClick: () => p.setRoute(mode.route), children: [_jsx(ListItemIcon, { children: mode.icon }), _jsx(ListItemText, { children: mode.label })] }) }, idx))) }) }));
134
- return (_jsx("main", { style: { display: "flex", justifyContent: "center" }, children: _jsxs("div", { children: [_jsxs("div", { style: { textAlign: "center" }, children: [_jsx(Typography, { variant: "h4", style: { marginTop: "2em" }, children: "Select user and computer location" }), _jsxs(Typography, { variant: "caption", style: {
146
+ return (_jsx("main", { style: { display: "flex", justifyContent: "center" }, children: _jsxs("div", { style: { maxWidth: "50em", padding: "0 1em" }, children: [_jsxs("div", { style: { textAlign: "center" }, children: [_jsx(Typography, { variant: "h4", style: { marginTop: "2em" }, children: "Select user and computer location" }), _jsxs(Typography, { variant: "caption", style: {
135
147
  marginBottom: "2em",
136
148
  maxWidth: "30em",
137
149
  marginLeft: "auto",
138
150
  marginRight: "auto",
139
- }, children: ["We recommend that after selecting one of the following modes, you bookmark the page and visit it directly.", _jsx("a", { href: "https://fms-insight.seedtactics.com/docs/client-dashboard.html", children: "Learn More" })] })] }), navList] }) }));
151
+ }, children: ["We recommend that after selecting one of the following modes, you bookmark the page and visit it directly.", _jsx("a", { href: "https://fms-insight.seedtactics.com/docs/client-dashboard.html", children: "Learn More" })] })] }), errors.length > 0 ? (_jsxs(Alert, { severity: "error", sx: { margin: "1em 0" }, children: [_jsx(AlertTitle, { children: "FMS Insight errors" }), errors.map((error) => (_jsx("p", { children: error }, error)))] })) : undefined, navList] }) }));
140
152
  }
141
153
  export default ChooseMode;
@@ -38,11 +38,13 @@ import { Tooltip } from "@mui/material";
38
38
  import { errorLoadingLast30, websocketReconnecting } from "../network/websocket.js";
39
39
  import { errorLoadingSpecificMonthData, loadingSpecificMonthData, } from "../network/load-specific-month.js";
40
40
  import { useAtomValue } from "jotai";
41
+ import { currentRoute, RouteLocation } from "./routes.js";
41
42
  export const LoadingIcon = memo(function LoadingIcon() {
42
43
  const websocketLoading = useAtomValue(websocketReconnecting);
43
44
  const specificMonthLoading = useAtomValue(loadingSpecificMonthData);
44
45
  const last30Error = useAtomValue(errorLoadingLast30);
45
46
  const specificMonthError = useAtomValue(errorLoadingSpecificMonthData);
47
+ const errorsInline = useAtomValue(currentRoute).route === RouteLocation.ChooseMode;
46
48
  const [dialogOpen, setDialogOpen] = useState(false);
47
- return (_jsxs(_Fragment, { children: [last30Error != null || specificMonthError != null ? (_jsx(Tooltip, { title: "Error", children: _jsx(IconButton, { onClick: () => setDialogOpen(true), size: "large", children: _jsx(ErrorIcon, {}) }) })) : undefined, websocketLoading || specificMonthLoading ? (_jsx(Tooltip, { title: "Loading", children: _jsx(CircularProgress, { "data-testid": "loading-icon", color: "secondary" }) })) : undefined, _jsxs(Dialog, { open: dialogOpen, onClose: () => setDialogOpen(false), children: [_jsx(DialogTitle, { children: "Error" }), _jsxs(DialogContent, { children: [last30Error !== null ? _jsx("p", { children: last30Error }) : undefined, specificMonthError !== null ? _jsx("p", { children: specificMonthError }) : undefined] }), _jsx(DialogActions, { children: _jsx(Button, { onClick: () => setDialogOpen(false), children: "Close" }) })] })] }));
49
+ return (_jsxs(_Fragment, { children: [!errorsInline && (last30Error != null || specificMonthError != null) ? (_jsx(Tooltip, { title: "Error", children: _jsx(IconButton, { "aria-label": "Error", onClick: () => setDialogOpen(true), size: "large", children: _jsx(ErrorIcon, {}) }) })) : undefined, websocketLoading || specificMonthLoading ? (_jsx(Tooltip, { title: "Loading", children: _jsx(CircularProgress, { "data-testid": "loading-icon", color: "secondary" }) })) : undefined, _jsxs(Dialog, { open: dialogOpen && !errorsInline, onClose: () => setDialogOpen(false), children: [_jsx(DialogTitle, { children: "Error" }), _jsxs(DialogContent, { children: [last30Error !== null ? _jsx("p", { children: last30Error }) : undefined, specificMonthError !== null ? _jsx("p", { children: specificMonthError }) : undefined] }), _jsx(DialogActions, { children: _jsx(Button, { onClick: () => setDialogOpen(false), children: "Close" }) })] })] }));
48
50
  });
@@ -1,9 +1,12 @@
1
+ import { type ReactNode } from "react";
1
2
  import * as api from "../../network/api.js";
2
3
  import { MatCardFontSize } from "./Material.js";
3
4
  interface BasketLoadStationWorkflowProps {
4
5
  readonly basket: Readonly<api.IBasketStatus>;
5
6
  readonly material: ReadonlyArray<Readonly<api.IInProcessMaterial>>;
6
7
  readonly fsize: MatCardFontSize;
8
+ readonly title: ReactNode;
9
+ readonly elapsed: ReactNode;
7
10
  }
8
- export declare function BasketLoadStationWorkflow({ basket, material, fsize, }: BasketLoadStationWorkflowProps): import("react").JSX.Element;
11
+ export declare function BasketLoadStationWorkflow({ basket, material, fsize, title, elapsed, }: BasketLoadStationWorkflowProps): import("react").JSX.Element;
9
12
  export {};
@@ -125,21 +125,10 @@ function stationWork(material, basket) {
125
125
  work: { workId: tagged[0].workId, ready: true, confirmEmpty: false, awaitingSlots: [] },
126
126
  };
127
127
  }
128
- function loadingInstruction(mat) {
129
- if (mat.location.type === api.LocType.InBasket &&
130
- mat.location.basketId === mat.action.loadToBasketId &&
131
- mat.location.basketSlot === mat.action.loadToBasketSlot) {
132
- return "Unload, re-plate, and reload this slot";
133
- }
134
- if (mat.location.type === api.LocType.InQueue && mat.location.currentQueue) {
135
- return `Load from ${mat.location.currentQueue}`;
136
- }
137
- return "Load from raw material";
138
- }
139
- function SlotMaterial({ material, fsize, }) {
140
- return material.map((mat) => (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.Material, material: mat }, children: _jsx(InProcMaterial, { mat: mat, fsize: fsize }) }, mat.materialID)));
128
+ function SlotMaterial({ material, basketId, fsize, }) {
129
+ return material.map((mat) => (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.Material, material: mat }, children: _jsx(InProcMaterial, { mat: mat, displayActionForSingleBasket: basketId, fsize: fsize }) }, mat.materialID)));
141
130
  }
142
- export function BasketLoadStationWorkflow({ basket, material, fsize, }) {
131
+ export function BasketLoadStationWorkflow({ basket, material, fsize, title, elapsed, }) {
143
132
  const [submission, setSubmission] = useState();
144
133
  const workState = useMemo(() => stationWork(material, basket), [basket, material]);
145
134
  const blockedReason = basket.loadStationWork?.confirmationBlockedReason?.trim();
@@ -191,23 +180,58 @@ export function BasketLoadStationWorkflow({ basket, material, fsize, }) {
191
180
  submissionState === "submitting" ||
192
181
  submissionState === "accepted" ||
193
182
  submissionState === "conflict";
194
- return (_jsxs(Stack, { spacing: 2, sx: { mt: 2 }, children: [_jsx(Typography, { variant: "h6", children: "Basket slots" }), _jsx(Box, { sx: {
183
+ // Confirm sits in the header so it is visible without scrolling. Slots are drawn like pallet
184
+ // faces: stacked regions holding their material side by side. All material in a slot moves
185
+ // together.
186
+ return (_jsxs("div", { children: [_jsxs(Box, { sx: {
195
187
  display: "grid",
196
- gridTemplateColumns: "repeat(auto-fit, minmax(15em, 1fr))",
197
- gap: 2,
198
- }, children: slots.map((slot) => {
188
+ gridTemplateColumns: "1fr auto auto",
189
+ alignItems: "center",
190
+ columnGap: 4,
191
+ }, children: [title, _jsx(Box, { children: work ? (_jsx(Button, { variant: "contained", color: "secondary", size: "large", disabled: submissionDisabled, onClick: () => void submit(), children: "Confirm" })) : null }), _jsx(Box, { sx: { justifySelf: "flex-end" }, children: elapsed })] }), _jsxs(Stack, { spacing: 2, sx: { ml: "4em", mr: "4em", mt: 2 }, children: [work?.confirmEmpty && work.ready && (_jsxs(Typography, { children: ["Confirm basket ", basket.basketId, " is empty."] })), instructionWarning && _jsx(Alert, { severity: "warning", children: instructionWarning }), work && !work.ready && (_jsx(Alert, { severity: "info", children: blockedReason ||
192
+ (work.awaitingSlots.length > 0
193
+ ? `Waiting for material for slots ${work.awaitingSlots.map(basketSlotLabel).join(", ")}.`
194
+ : "Basket work is not ready for confirmation.") })), !work && workState.type === "inconsistent" ? (_jsx(Alert, { severity: "warning", children: "Basket work is inconsistent. Wait for refreshed material actions before confirming." })) : null, submissionState === "accepted" ? (_jsx(Alert, { severity: "success", children: "Confirmation accepted. Waiting for refreshed work." })) : submissionState === "conflict" ? (_jsx(Alert, { severity: "warning", children: "Basket work changed before confirmation. Review the refreshed slots and try again." })) : submissionState === "error" ? (_jsx(Alert, { severity: "error", children: "Unable to confirm basket work. No work was assumed complete." })) : null] }), _jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.BasketZone, basketId: basket.basketId }, children: slots.map((slot, idx) => {
199
195
  const slotMaterial = materialBySlot.get(slot) ?? [];
200
- const loads = loadsBySlot.get(slot) ?? [];
201
196
  const isUnknown = basket.unknownSlots?.includes(slot) === true;
202
- return (_jsx(MoveMaterialArrowNode, { kind: {
203
- type: MoveMaterialNodeKindType.BasketSlotZone,
204
- basketId: basket.basketId,
205
- slot,
206
- }, children: _jsxs(Box, { component: "section", "data-testid": `basket-load-station-slot-${slot}`, sx: { border: "1px solid", borderColor: "text.primary", p: 2 }, children: [_jsxs(Typography, { variant: "h6", children: ["Slot ", basketSlotLabel(slot)] }), loads.length > 0 &&
207
- slotMaterial.some((mat) => mat.action.type === api.ActionType.UnloadToInProcess ||
208
- mat.action.type === api.ActionType.UnloadToCompletedMaterial) && (_jsx(Typography, { children: "Unload the current material before preparing the replacement." })), slotMaterial.length > 0 ? (_jsx(SlotMaterial, { material: slotMaterial, fsize: fsize })) : (_jsx(Typography, { color: isUnknown ? "warning.main" : "text.secondary", children: isUnknown ? "Unknown" : "Empty" })), loads.map((mat, index) => (_jsxs(Box, { sx: { mt: 1 }, children: [_jsx(Typography, { children: loadingInstruction(mat) }), _jsxs(Typography, { variant: "body2", color: "text.secondary", children: [mat.partName, " \u00B7 Process ", mat.action.processAfterLoad ?? mat.process] })] }, `${mat.jobUnique}-${mat.process}-${index}`)))] }) }, slot));
209
- }) }), work?.confirmEmpty && _jsxs(Typography, { children: ["Confirm basket ", basket.basketId, " is empty."] }), instructionWarning && _jsx(Alert, { severity: "warning", children: instructionWarning }), work && !work.ready && (_jsx(Alert, { severity: "info", children: blockedReason ||
210
- (work.awaitingSlots.length > 0
211
- ? `Waiting for material for slots ${work.awaitingSlots.map(basketSlotLabel).join(", ")}.`
212
- : "Basket work is not ready for confirmation.") })), work ? (_jsx(Box, { sx: { display: "flex", justifyContent: "flex-end" }, children: _jsx(Button, { variant: "contained", disabled: submissionDisabled, onClick: () => void submit(), children: "Confirm" }) })) : workState.type === "inconsistent" ? (_jsx(Alert, { severity: "warning", children: "Basket work is inconsistent. Wait for refreshed material actions before confirming." })) : null, submissionState === "accepted" ? (_jsx(Alert, { severity: "success", children: "Confirmation accepted. Waiting for refreshed work." })) : submissionState === "conflict" ? (_jsx(Alert, { severity: "warning", children: "Basket work changed before confirmation. Review the refreshed slots and try again." })) : submissionState === "error" ? (_jsx(Alert, { severity: "error", children: "Unable to confirm basket work. No work was assumed complete." })) : null] }));
197
+ const targetContents = LazySeq.of(slotMaterial)
198
+ .filter((mat) => mat.action.type !== api.ActionType.UnloadToInProcess &&
199
+ mat.action.type !== api.ActionType.UnloadToCompletedMaterial)
200
+ .concat(loadsBySlot.get(slot) ?? [])
201
+ .map((mat) => {
202
+ const process = mat.action.type === api.ActionType.LoadingToBasket
203
+ ? mat.action.processAfterLoad
204
+ : mat.process;
205
+ return `${mat.partName}${process !== undefined ? ` proc ${process}` : ""}`;
206
+ })
207
+ .distinctBy((label) => label)
208
+ .toRArray();
209
+ const targetEmpty = work?.confirmEmpty ||
210
+ (!isUnknown && (slotMaterial.length > 0 || basket.emptySlots?.includes(slot) === true));
211
+ const target = work && !work.awaitingSlots.includes(slot)
212
+ ? targetContents.length > 0
213
+ ? `Fill with ${targetContents.join(", ")}`
214
+ : targetEmpty
215
+ ? "Leave empty"
216
+ : undefined
217
+ : undefined;
218
+ return (_jsxs(Box, { component: "section", "data-testid": `basket-load-station-slot-${slot}`, sx: { borderTop: idx !== 0 ? "1px solid black" : undefined, py: 3 }, children: [_jsxs(Box, { sx: {
219
+ display: "flex",
220
+ justifyContent: "center",
221
+ alignItems: "center",
222
+ flexWrap: "wrap",
223
+ columnGap: 1,
224
+ color: "text.secondary",
225
+ mb: 2,
226
+ }, children: [_jsxs(Typography, { variant: "h6", sx: { color: "text.primary" }, children: ["Slot ", basketSlotLabel(slot)] }), target && (_jsxs(Box, { component: "span", sx: { display: "inline-flex", alignItems: "center", gap: 1 }, children: [_jsx(Typography, { component: "span", variant: "body2", color: "inherit", "aria-hidden": true, children: "\u00B7" }), _jsx(Typography, { component: "span", variant: "body2", color: "inherit", children: target })] }))] }), _jsx(Box, { sx: { ml: "4em", mr: "4em" }, children: _jsx(MoveMaterialArrowNode, { kind: {
227
+ type: MoveMaterialNodeKindType.BasketSlotZone,
228
+ basketId: basket.basketId,
229
+ slot,
230
+ }, children: _jsx(Box, { sx: {
231
+ display: "flex",
232
+ flexWrap: "wrap",
233
+ justifyContent: "space-around",
234
+ minHeight: "4em",
235
+ }, children: slotMaterial.length > 0 ? (_jsx(SlotMaterial, { material: slotMaterial, basketId: basket.basketId, fsize: fsize })) : isUnknown ? (_jsx(Typography, { color: "warning.main", children: "Unknown" })) : null }) }) })] }, slot));
236
+ }) })] }));
213
237
  }
@@ -60,7 +60,7 @@ import { addHours } from "date-fns";
60
60
  import { PromptForQueue } from "./QueuesAddMaterial.js";
61
61
  import { useAtomValue, useSetAtom } from "jotai";
62
62
  import { PrintLabelButton } from "./PrintedLabel.js";
63
- import { hideNonLoadingMaterialOnLoadStation } from "../../data/queue-material.js";
63
+ import { groupInterchangeableMaterial, hideNonLoadingMaterialOnLoadStation, } from "../../data/queue-material.js";
64
64
  import { basketDisplayName, loadStationDisplayName } from "../../cell-status/station-cycles.js";
65
65
  import { canAddOrMoveMaterialToQueue } from "../../data/material-operation-policy.js";
66
66
  import { BasketLoadStationWorkflow } from "./BasketLoadStationWork.js";
@@ -316,6 +316,15 @@ function selectLoadStationAndQueueProps(loadNum, queues, curSt, hideNonLoading)
316
316
  .toRArray().length
317
317
  : 0;
318
318
  const layoutCount = Math.max(matCount, activeBasketSlotCount);
319
+ // Basket slots are rows of material side by side, so the widest slot must fit across the screen
320
+ const widestBasketSlot = activeBasket
321
+ ? (LazySeq.of(curSt.material)
322
+ .filter((mat) => mat.location.type === api.LocType.InBasket &&
323
+ mat.location.basketId === activeBasket.basketId)
324
+ .groupBy((mat) => mat.location.basketSlot ?? 0)
325
+ .map(([, mats]) => mats.length)
326
+ .maxBy((n) => n) ?? 0)
327
+ : 0;
319
328
  return {
320
329
  pallet: pal,
321
330
  activeBasket,
@@ -325,7 +334,7 @@ function selectLoadStationAndQueueProps(loadNum, queues, curSt, hideNonLoading)
325
334
  queues: sortedQueueMat,
326
335
  baskets: sortedBasketMat,
327
336
  elapsedLoadingTime,
328
- fsize: layoutCount <= 2 ? "x-large" : layoutCount <= 6 ? "large" : "normal",
337
+ fsize: layoutCount > 6 || widestBasketSlot >= 3 ? "normal" : layoutCount <= 2 ? "x-large" : "large",
329
338
  };
330
339
  }
331
340
  function MultiInstructionButton({ loadData }) {
@@ -399,15 +408,7 @@ function PalletFace({ data, faceNum }) {
399
408
  if (!face)
400
409
  return null;
401
410
  if (data.activeBasket && !data.pallet) {
402
- return (_jsxs("div", { "data-testid": "load-station-active-basket", children: [faceNum === 1 ? (_jsxs(Box, { sx: {
403
- display: "grid",
404
- gridTemplateColumns: "1fr auto",
405
- }, children: [_jsxs(Typography, { variant: "h4", children: [basketName, " ", data.activeBasket.basketId] }), _jsx(Box, { sx: {
406
- justifySelf: "flex-end",
407
- }, children: _jsx(ElapsedLoadTime, { elapsedLoadTime: data.elapsedLoadingTime }) })] })) : null, _jsx(Box, { sx: { ml: "4em", mr: "4em" }, children: _jsx(MoveMaterialArrowNode, { kind: {
408
- type: MoveMaterialNodeKindType.BasketZone,
409
- basketId: data.activeBasket.basketId,
410
- }, children: _jsx(BasketLoadStationWorkflow, { basket: data.activeBasket, material: data.allMaterial, fsize: data.fsize }) }) })] }));
411
+ return (_jsx("div", { "data-testid": "load-station-active-basket", children: _jsx(BasketLoadStationWorkflow, { basket: data.activeBasket, material: data.allMaterial, fsize: data.fsize, title: _jsxs(Typography, { variant: "h4", children: [basketName, " ", data.activeBasket.basketId] }), elapsed: _jsx(ElapsedLoadTime, { elapsedLoadTime: data.elapsedLoadingTime }) }) }));
411
412
  }
412
413
  if (!data.pallet)
413
414
  return null;
@@ -424,24 +425,31 @@ function PalletFace({ data, faceNum }) {
424
425
  }, children: _jsx(Typography, { variant: "h6", children: data.pallet.faceNames?.[faceNum - 1] ?? `Face ${faceNum}` }) })) : undefined, _jsx(Box, { sx: {
425
426
  ml: "4em",
426
427
  mr: "4em",
427
- }, children: _jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.PalletFaceZone, face: faceNum }, children: _jsx(Box, { sx: {
428
+ }, children: _jsx(MoveMaterialArrowNode, { kind: {
429
+ type: MoveMaterialNodeKindType.PalletFaceZone,
430
+ palletNum: data.pallet.palletNum,
431
+ face: faceNum,
432
+ }, children: _jsx(Box, { sx: {
428
433
  display: "flex",
429
434
  flexWrap: "wrap",
430
435
  justifyContent: "space-around",
431
436
  }, children: face.map((m, idx) => (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.Material, material: m }, children: _jsx(InProcMaterial, { mat: m, fsize: data.fsize }) }, idx))) }) }) })] }));
432
437
  }
433
438
  function MaterialRegion({ data, mat, }) {
434
- return (_jsxs("div", { children: [mat.label !== "" ? _jsx(Typography, { variant: "h4", children: mat.label }) : null, mat.material.mats.map((m, matIdx) => (_jsx(MoveMaterialArrowNode, { kind: {
435
- type: MoveMaterialNodeKindType.Material,
436
- material: m,
437
- identifier: m.materialID < 0
438
- ? `raw-${mat.isFree ? "free" : "queue"}-${mat.label}-${matIdx}`
439
- : undefined,
440
- }, children: mat.isFree || mat.sortable === false ? (_jsx(InProcMaterial, { mat: m, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, fsize: data.fsize, showRawMaterial: true, showJobComment: true })) : (_jsx(SortableInProcMaterial, { mat: m, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, shake: m.action.type === api.ActionType.Loading &&
441
- m.action.loadOntoPalletNum === data.pallet?.palletNum, fsize: m.action.type === api.ActionType.Loading &&
442
- m.action.loadOntoPalletNum === data.pallet?.palletNum
443
- ? data.fsize
444
- : undefined, showRawMaterial: true, showJobComment: true })) }, matIdx))), mat.material.hiddenCnt > 0 ? (_jsxs(Typography, { variant: "body2", color: "textSecondary", sx: {
439
+ return (_jsxs("div", { children: [mat.label !== "" ? _jsx(Typography, { variant: "h4", children: mat.label }) : null, (mat.isFree
440
+ ? groupInterchangeableMaterial(mat.material.mats, (m) => m.process === 0)
441
+ : mat.material.mats.map((m) => [m])).map((group, matIdx) => {
442
+ const m = group[0];
443
+ return (_jsx(MoveMaterialArrowNode, { kind: {
444
+ type: MoveMaterialNodeKindType.Material,
445
+ material: m,
446
+ identifier: m.materialID < 0
447
+ ? `raw-${mat.isFree ? "free" : "queue"}-${mat.label}-${matIdx}`
448
+ : undefined,
449
+ }, children: mat.isFree || mat.sortable === false ? (_jsx(InProcMaterial, { mat: m, materialCount: group.length, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, displayActionForSingleBasket: data.activeBasket?.basketId, fsize: data.fsize, showRawMaterial: true, showJobComment: true })) : (_jsx(SortableInProcMaterial, { mat: m, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, displayActionForSingleBasket: data.activeBasket?.basketId, shake: isLoadingToDisplayedTarget(m, data.pallet, data.activeBasket), fsize: isLoadingToDisplayedTarget(m, data.pallet, data.activeBasket)
450
+ ? data.fsize
451
+ : undefined, showRawMaterial: true, showJobComment: true })) }, matIdx));
452
+ }), mat.material.hiddenCnt > 0 ? (_jsxs(Typography, { variant: "body2", color: "textSecondary", sx: {
445
453
  textAlign: "center",
446
454
  mt: "0.5em",
447
455
  }, children: ["+", mat.material.hiddenCnt, " hidden"] })) : null] }));
@@ -452,15 +460,15 @@ function BasketRegion({ data, label, baskets, }) {
452
460
  pt: idx === 0 ? undefined : "1em",
453
461
  }, children: [_jsx(Typography, { variant: "h6", sx: {
454
462
  mb: "0.5em",
455
- }, children: basket.label }), _jsx(MoveMaterialArrowNode, { kind: {
463
+ }, children: basket.label }), _jsxs(MoveMaterialArrowNode, { kind: {
456
464
  type: MoveMaterialNodeKindType.BasketZone,
457
465
  basketId: basket.basketId,
458
- }, children: _jsx(MaterialRegion, { data: data, mat: {
459
- label: "",
460
- material: basket.material,
461
- isFree: false,
462
- sortable: false,
463
- } }) })] }, basket.basketId)))] }));
466
+ }, children: [basket.empty && _jsx(Typography, { color: "textSecondary", children: "Empty" }), _jsx(MaterialRegion, { data: data, mat: {
467
+ label: "",
468
+ material: basket.material,
469
+ isFree: false,
470
+ sortable: false,
471
+ } })] })] }, basket.basketId)))] }));
464
472
  }
465
473
  function MaterialColumn({ data, region, }) {
466
474
  switch (region.kind) {
@@ -472,8 +480,7 @@ function MaterialColumn({ data, region, }) {
472
480
  sortable: false,
473
481
  } }) }));
474
482
  case "queue":
475
- return (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.QueueZone, queue: region.label }, children: _jsx(SortableRegion, { matIds: region.material.mats.map((m) => m.materialID), direction: "vertical", queueName: region.label, renderDragOverlay: (mat) => (_jsx(DragOverlayInProcMaterial, { mat: mat, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, fsize: mat.action.type === api.ActionType.Loading &&
476
- mat.action.loadOntoPalletNum === data.pallet?.palletNum
483
+ return (_jsx(MoveMaterialArrowNode, { kind: { type: MoveMaterialNodeKindType.QueueZone, queue: region.label }, children: _jsx(SortableRegion, { matIds: region.material.mats.map((m) => m.materialID), direction: "vertical", queueName: region.label, renderDragOverlay: (mat) => (_jsx(DragOverlayInProcMaterial, { mat: mat, displayActionForSinglePallet: data.pallet ? data.pallet.palletNum : 0, displayActionForSingleBasket: data.activeBasket?.basketId, fsize: isLoadingToDisplayedTarget(mat, data.pallet, data.activeBasket)
477
484
  ? data.fsize
478
485
  : undefined })), children: _jsx(MaterialRegion, { data: data, mat: {
479
486
  label: region.label,
@@ -692,11 +699,19 @@ export function LoadStation(props) {
692
699
  const baskets = LazySeq.of(data.baskets)
693
700
  .filter(([b]) => b !== data.activeBasket?.basketId)
694
701
  .sortBy(([b]) => b)
695
- .map(([b, mats]) => ({
696
- basketId: b,
697
- label: `${basketName} ${b}`,
698
- material: mats,
699
- }))
702
+ .map(([b, mats]) => {
703
+ const basket = currentSt.baskets?.[b];
704
+ return {
705
+ basketId: b,
706
+ label: `${basketName} ${b}`,
707
+ material: mats,
708
+ empty: mats.mats.length === 0 &&
709
+ mats.hiddenCnt === 0 &&
710
+ (basket?.slotCount ?? 0) > 0 &&
711
+ basket?.emptySlots?.length === basket?.slotCount &&
712
+ (basket?.unknownSlots?.length ?? 0) === 0,
713
+ };
714
+ })
700
715
  .toRArray();
701
716
  if (baskets.length > 0) {
702
717
  matCols.push({
@@ -8,17 +8,20 @@ export declare class PartIdenticon extends PureComponent<{
8
8
  render(): import("react").JSX.Element;
9
9
  }
10
10
  export type MatCardFontSize = "normal" | "large" | "x-large";
11
- export declare function MaterialAction({ mat, displayActionForSinglePallet, fsize, }: {
11
+ export declare function MaterialAction({ mat, displayActionForSinglePallet, displayActionForSingleBasket, fsize, }: {
12
12
  mat: Readonly<api.IInProcessMaterial>;
13
13
  displayActionForSinglePallet?: number;
14
+ displayActionForSingleBasket?: number;
14
15
  fsize?: MatCardFontSize;
15
16
  }): ReactNode | null;
16
17
  export declare function WorkorderFromBarcode(): import("react").JSX.Element | null;
17
18
  export interface MaterialSummaryProps {
18
19
  readonly mat: Readonly<MaterialSummaryAndCompletedData>;
20
+ readonly materialCount?: number;
19
21
  readonly inProcMat?: Readonly<api.IInProcessMaterial>;
20
22
  readonly fsize?: MatCardFontSize;
21
23
  readonly displayActionForSinglePallet?: number;
24
+ readonly displayActionForSingleBasket?: number;
22
25
  readonly focusInspectionType?: string | null;
23
26
  readonly hideWarningIcon?: boolean;
24
27
  readonly displayJob?: boolean;
@@ -30,8 +33,10 @@ export interface MaterialSummaryProps {
30
33
  export declare const MatSummary: ComponentType<MaterialSummaryProps>;
31
34
  export type InProcMaterialProps = {
32
35
  readonly mat: Readonly<api.IInProcessMaterial>;
36
+ readonly materialCount?: number;
33
37
  readonly fsize?: MatCardFontSize;
34
38
  readonly displayActionForSinglePallet?: number;
39
+ readonly displayActionForSingleBasket?: number;
35
40
  readonly displayJob?: boolean;
36
41
  readonly hideAvatar?: boolean;
37
42
  readonly hideEmptySerial?: boolean;
@@ -169,7 +169,7 @@ const MatCardDetail = styled("div", { shouldForwardProp: (prop) => prop !== "fsi
169
169
  };
170
170
  }
171
171
  });
172
- export function MaterialAction({ mat, displayActionForSinglePallet, fsize, }) {
172
+ export function MaterialAction({ mat, displayActionForSinglePallet, displayActionForSingleBasket, fsize, }) {
173
173
  const curSt = useAtomValue(currentStatus);
174
174
  const fmsInfo = useAtomValue(fmsInformation);
175
175
  const basketName = basketDisplayName(fmsInfo.basketName);
@@ -236,8 +236,18 @@ export function MaterialAction({ mat, displayActionForSinglePallet, fsize, }) {
236
236
  }
237
237
  }
238
238
  case api.ActionType.LoadingToBasket:
239
+ // The load station displays a single basket, so its slot alone identifies the destination.
240
+ if (displayActionForSingleBasket !== undefined &&
241
+ displayActionForSingleBasket === mat.action.loadToBasketId &&
242
+ mat.action.loadToBasketSlot !== undefined) {
243
+ return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load into slot ", basketSlotLabel(mat.action.loadToBasketSlot), mat.action.processAfterLoad !== undefined
244
+ ? ` for process ${mat.action.processAfterLoad}`
245
+ : ""] }));
246
+ }
239
247
  return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Load into ", basketName, " ", mat.action.loadToBasketId ?? "", mat.action.loadToBasketSlot !== undefined
240
248
  ? ` slot ${basketSlotLabel(mat.action.loadToBasketSlot)}`
249
+ : "", mat.action.processAfterLoad !== undefined
250
+ ? ` for process ${mat.action.processAfterLoad}`
241
251
  : ""] }));
242
252
  case api.ActionType.UnloadToInProcess:
243
253
  case api.ActionType.UnloadToCompletedMaterial:
@@ -251,7 +261,7 @@ export function MaterialAction({ mat, displayActionForSinglePallet, fsize, }) {
251
261
  }
252
262
  else if (mat.action.type === api.ActionType.UnloadToCompletedMaterial &&
253
263
  mat.location.type === api.LocType.InBasket) {
254
- return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload from ", basketName, " ", mat.location.basketId, " to completed material"] }));
264
+ return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload completed from ", basketName, " ", mat.location.basketId] }));
255
265
  }
256
266
  else if (mat.location.type === api.LocType.InBasket) {
257
267
  return (_jsxs(MatCardDetail, { fsize: fsize, children: ["Unload from ", basketName, " ", mat.location.basketId] }));
@@ -340,7 +350,7 @@ export function WorkorderFromBarcode() {
340
350
  const comments = currentSt.workorders?.find((w) => w.workorderId === workorderId)?.comments ?? [];
341
351
  return (_jsxs("div", { style: { marginTop: "1em", marginLeft: "1em" }, children: [_jsxs("p", { children: ["Workorder: ", workorderId] }), _jsx("ul", { children: comments.map((c, idx) => (_jsx("li", { children: c.comment }, idx))) })] }));
342
352
  }
343
- const MatCard = function MatCard({ mat, inProcMat, fsize, focusInspectionType, isDragOverlay, isActiveDrag, shake, dragRootProps, showDragHandle, setDragHandleRef, dragHandleProps, displayJob, hideEmptySerial, showRawMaterial, showJobComment, displayActionForSinglePallet, hideAvatar, hideWarningIcon, ref, }) {
353
+ const MatCard = function MatCard({ mat, materialCount = 1, inProcMat, fsize, focusInspectionType, isDragOverlay, isActiveDrag, shake, dragRootProps, showDragHandle, setDragHandleRef, dragHandleProps, displayJob, hideEmptySerial, showRawMaterial, showJobComment, displayActionForSinglePallet, displayActionForSingleBasket, hideAvatar, hideWarningIcon, ref, }) {
344
354
  const setMatToShow = useSetAtom(matDetails.materialDialogOpen);
345
355
  const completed = mat.completedInspections || {};
346
356
  let completedMsg;
@@ -354,6 +364,7 @@ const MatCard = function MatCard({ mat, inProcMat, fsize, focusInspectionType, i
354
364
  completedMsg = (_jsxs(MatCardDetail, { fsize: fsize, children: [_jsxs("span", { children: [mat.closeout_failed ? "Failed " : "", "Closed Out "] }), _jsx(TimeAgo, { date: mat.closeout_completed })] }));
355
365
  }
356
366
  return (_jsxs(Paper, { ref: ref, elevation: 4, sx: {
367
+ position: "relative",
357
368
  display: "flex",
358
369
  minWidth: "10em",
359
370
  padding: "8px",
@@ -363,7 +374,7 @@ const MatCard = function MatCard({ mat, inProcMat, fsize, focusInspectionType, i
363
374
  "&:hover": {
364
375
  animationPlayState: "paused",
365
376
  },
366
- }, onAnimationIteration: shakeAnimationIteration, ...dragRootProps, children: [showDragHandle ? (_jsx("div", { ref: setDragHandleRef, role: "button", tabIndex: 0, style: {
377
+ }, onAnimationIteration: shakeAnimationIteration, ...dragRootProps, children: [materialCount > 1 && (_jsx(Badge, { badgeContent: materialCount, color: "secondary", sx: { position: "absolute", top: 0, right: 0, zIndex: 1 } })), showDragHandle ? (_jsx("div", { ref: setDragHandleRef, role: "button", tabIndex: 0, style: {
367
378
  display: "flex",
368
379
  flexDirection: "column",
369
380
  justifyContent: "center",
@@ -387,7 +398,7 @@ const MatCard = function MatCard({ mat, inProcMat, fsize, focusInspectionType, i
387
398
  mat.workorderId === mat.serial ? undefined : (_jsxs(MatCardDetail, { fsize: fsize, children: ["Workorder: ", mat.workorderId] })), mat.jobUnique !== undefined &&
388
399
  showRawMaterial &&
389
400
  inProcMat &&
390
- inProcMat.process === 0 ? (_jsx(JobRawMaterial, { fsize: fsize, mat: inProcMat })) : undefined, showJobComment && mat.jobUnique && mat.jobUnique !== "" ? (_jsx(RebookingNoteElipsis, { fsize: fsize, uniq: mat.jobUnique })) : undefined, inProcMat ? (_jsx(MaterialAction, { mat: inProcMat, displayActionForSinglePallet: displayActionForSinglePallet, fsize: fsize })) : undefined, inProcMat?.problem ? (_jsx(MatCardDetail, { fsize: fsize, children: _jsxs(Typography, { variant: "body2", color: "error", sx: { fontWeight: "bold" }, children: ["\u26A0 ", inProcMat.problem] }) })) : undefined, completedMsg] }), _jsxs(Box, { sx: {
401
+ inProcMat.process === 0 ? (_jsx(JobRawMaterial, { fsize: fsize, mat: inProcMat })) : undefined, showJobComment && mat.jobUnique && mat.jobUnique !== "" ? (_jsx(RebookingNoteElipsis, { fsize: fsize, uniq: mat.jobUnique })) : undefined, inProcMat ? (_jsx(MaterialAction, { mat: inProcMat, displayActionForSinglePallet: displayActionForSinglePallet, displayActionForSingleBasket: displayActionForSingleBasket, fsize: fsize })) : undefined, inProcMat?.problem ? (_jsx(MatCardDetail, { fsize: fsize, children: _jsxs(Typography, { variant: "body2", color: "error", sx: { fontWeight: "bold" }, children: ["\u26A0 ", inProcMat.problem] }) })) : undefined, completedMsg] }), _jsxs(Box, { sx: {
391
402
  marginLeft: "4px",
392
403
  display: "flex",
393
404
  flexDirection: "column",
@@ -399,7 +410,7 @@ const MatCard = function MatCard({ mat, inProcMat, fsize, focusInspectionType, i
399
410
  };
400
411
  export const MatSummary = memo(MatCard);
401
412
  export const InProcMaterial = memo(function InProcMaterial(props) {
402
- return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, fsize: props.fsize, hideAvatar: props.hideAvatar, displayJob: props.displayJob, showDragHandle: props.showHandle, hideEmptySerial: props.hideEmptySerial, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment, shake: props.shake }));
413
+ return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, fsize: props.fsize, hideAvatar: props.hideAvatar, displayJob: props.displayJob, showDragHandle: props.showHandle, hideEmptySerial: props.hideEmptySerial, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment, shake: props.shake }));
403
414
  });
404
415
  export const SortableInProcMaterial = memo(function SortableInProcMaterial(props) {
405
416
  const canDrag = canReorderQueuedMaterial(props.mat) || canAddOrMoveMaterialToQueue(props.mat);
@@ -423,10 +434,10 @@ export const SortableInProcMaterial = memo(function SortableInProcMaterial(props
423
434
  : undefined,
424
435
  transition: active !== null ? transition : undefined,
425
436
  };
426
- return (_jsx(MatCard, { ref: setNodeRef, dragRootProps: { style }, showDragHandle: canDrag, dragHandleProps: handleProps, setDragHandleRef: setActivatorNodeRef, isActiveDrag: isDragging, mat: inproc_mat_to_summary(props.mat), inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, hideAvatar: props.hideAvatar, displayJob: props.displayJob, hideEmptySerial: props.hideEmptySerial, fsize: props.fsize, shake: active ? undefined : props.shake, showRawMaterial: props.showRawMaterial }));
437
+ return (_jsx(MatCard, { ref: setNodeRef, dragRootProps: { style }, showDragHandle: canDrag, dragHandleProps: handleProps, setDragHandleRef: setActivatorNodeRef, isActiveDrag: isDragging, mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, hideAvatar: props.hideAvatar, displayJob: props.displayJob, hideEmptySerial: props.hideEmptySerial, fsize: props.fsize, shake: active ? undefined : props.shake, showRawMaterial: props.showRawMaterial, showJobComment: props.showJobComment }));
427
438
  });
428
439
  export function DragOverlayInProcMaterial(props) {
429
- return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, showDragHandle: true, hideAvatar: props.hideAvatar, displayJob: props.displayJob, fsize: props.fsize, hideEmptySerial: props.hideEmptySerial, isDragOverlay: true }));
440
+ return (_jsx(MatCard, { mat: inproc_mat_to_summary(props.mat), materialCount: props.materialCount, inProcMat: props.mat, displayActionForSinglePallet: props.displayActionForSinglePallet, displayActionForSingleBasket: props.displayActionForSingleBasket, showDragHandle: true, hideAvatar: props.hideAvatar, displayJob: props.displayJob, fsize: props.fsize, hideEmptySerial: props.hideEmptySerial, isDragOverlay: true }));
430
441
  }
431
442
  export const MultiMaterial = memo(function MultiMaterial(props) {
432
443
  return (_jsx(Paper, { elevation: 4, sx: { display: "flex", minWidth: "10em", padding: "8px", margin: "8px" }, children: _jsx(Badge, { badgeContent: props.material.length < 2 ? 0 : props.material.length, color: "secondary", children: _jsx(ButtonBase, { focusRipple: true, onClick: () => props.onOpen(), children: _jsxs(Box, { sx: {
@@ -46,6 +46,15 @@ function elementToRect(e) {
46
46
  };
47
47
  }
48
48
  function arrowToPath(arr) {
49
+ if (arr.type === "loop") {
50
+ // almost a full circle, from the lower left over the top to the lower right, so the arrow
51
+ // head points back at the start
52
+ const point = (degrees) => {
53
+ const radians = (degrees * Math.PI) / 180;
54
+ return `${arr.centerX + arr.radius * Math.cos(radians)} ${arr.centerY + arr.radius * Math.sin(radians)}`;
55
+ };
56
+ return `M ${point(120)} A ${arr.radius} ${arr.radius} 0 1 1 ${point(60)}`;
57
+ }
49
58
  // mid point of line
50
59
  const mpx = (arr.fromX + arr.toX) / 2;
51
60
  const mpy = (arr.fromY + arr.toY) / 2;