diff --git a/.changeset/dry-points-brake.md b/.changeset/dry-points-brake.md new file mode 100644 index 000000000..abb80bfd5 --- /dev/null +++ b/.changeset/dry-points-brake.md @@ -0,0 +1,8 @@ +--- +"@equinor/mad-dfw": minor +--- + +Adjusted props related to data display and buttons in the `WorkOrderCell` component. Removed the +`Id` part from the data props. Removed/adjusted the props: `showActions`, `onStartButtonPress`, `onReadyForOperationPress` +and `onTecoButtonPress`. New props for this: `startJobButton`, `readyForOperationButton` and `tecoButton`. These props have three options +`visible`, `disabled` and `onpress`. Removed validations for when the buttons are displayed. diff --git a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx index 7926bf70a..de19443ba 100644 --- a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx +++ b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx @@ -24,25 +24,30 @@ export const WorkOrderCellScreen = () => { console.log("Start"), + }} + readyForOperationButton={{ + visible: true, + disabled: true, + onPress: () => console.log("Complete"), + }} + tecoButton={{ + visible: true, + onPress: () => console.log("TECO"), }} - onCompleteButtonPress={() => console.log("Complete")} - onStartButtonPress={() => console.log("Start")} - onTecoButtonPress={() => console.log("TECO")} showSymbols /> @@ -55,25 +60,27 @@ export const WorkOrderCellScreen = () => { console.log("Start"), + }} + readyForOperationButton={{ + visible: true, + onPress: () => console.log("Complete"), }} - onCompleteButtonPress={() => console.log("Complete")} - onStartButtonPress={() => console.log("Start")} showSymbols symbolDirection="row" /> @@ -87,15 +94,15 @@ export const WorkOrderCellScreen = () => { console.log("Pressed")} @@ -110,7 +117,7 @@ export const WorkOrderCellScreen = () => { = { title: "Title", - workOrderId: "Work order ID", + workOrder: "Work order", maintenanceType: "Maintenance type", functionalLocation: "Functional Location", - equipmentId: "Equipment", - activeStatusIds: "Active status", + equipment: "Equipment", + activeStatus: "Active status", basicStartDate: "Basic start", basicFinishDate: "Basic finish", requiredEnd: "Required end", - workCenterId: "Work center", + workCenter: "Work center", } as const; type PropertyListProps = { diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx index 058e204c6..7ad36a4c0 100644 --- a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx +++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx @@ -1,4 +1,12 @@ -import { Button, Cell, EDSStyleSheet, Label, Typography, useStyles } from "@equinor/mad-components"; +import { + Button, + Cell, + EDSStyleSheet, + Label, + Typography, + useBreakpoint, + useStyles, +} from "@equinor/mad-components"; import moment from "moment"; import React, { useMemo } from "react"; import { View } from "react-native"; @@ -15,32 +23,29 @@ export const WorkOrderCell = ({ valueColor = "textTertiary", isHseCritical, isProductionCritical, - showActions, overwriteLabel, style, - onStartButtonPress, - onCompleteButtonPress, - onTecoButtonPress, + startJobButton, + readyForOperationButton, + tecoButton, ...rest }: WorkOrderCellProps) => { + const breakpoint = useBreakpoint(); const styles = useStyles(themeStyles, { symbolDirection }); + const anyButtonVisible = + startJobButton?.visible ?? readyForOperationButton?.visible ?? tecoButton?.visible; const currentDate = moment(); - const activeStatuses = rest.activeStatusIds?.split(" "); - const isStartDisabled = activeStatuses?.includes("STRT") ?? activeStatuses?.includes("RDOP"); - const isCompleteDisabled = - !activeStatuses?.includes("STRT") ?? activeStatuses?.includes("RDOP"); - const iconsAndLabels = useMemo( () => getStatusIconsAndLabels( - rest.activeStatusIds, + rest.activeStatus, rest.requiredEnd ?? null, currentDate, isHseCritical, isProductionCritical, ), - [rest.activeStatusIds, rest.requiredEnd, currentDate, isHseCritical, isProductionCritical], + [rest.activeStatus, rest.requiredEnd, currentDate, isHseCritical, isProductionCritical], ); return ( @@ -62,29 +67,35 @@ export const WorkOrderCell = ({ valueColor={valueColor} currentDate={currentDate.toDate()} /> - {showActions && ( - - {showActions.startButton && ( + {anyButtonVisible && ( + + {startJobButton?.visible && (