From f984350aae15d0cbcf0d2702465ea9584b5a9cd9 Mon Sep 17 00:00:00 2001 From: Jonas-Omdal Date: Tue, 10 Sep 2024 13:49:52 +0200 Subject: [PATCH 1/6] fix(workordercell): fix deviations --- .changeset/dry-points-brake.md | 8 +++ .../dfw/dfwcomponents/WorkOrderCellScreen.tsx | 54 +++++++++++-------- .../WorkOrderCell/PropertyList.tsx | 8 +-- .../WorkOrderCell/WorkOrderCell.tsx | 52 ++++++++++-------- .../WorkOrderCell/WorkOrderCellNavigation.tsx | 4 +- .../src/dfwcomponents/WorkOrderCell/types.ts | 27 ++++++---- 6 files changed, 95 insertions(+), 58 deletions(-) create mode 100644 .changeset/dry-points-brake.md diff --git a/.changeset/dry-points-brake.md b/.changeset/dry-points-brake.md new file mode 100644 index 000000000..9da6557a4 --- /dev/null +++ b/.changeset/dry-points-brake.md @@ -0,0 +1,8 @@ +--- +"@equinor/mad-dfw": minor +--- + +Adjusted props related to the data display and buttons in the `WorkOrderCell` component. Removed the +`Id` part from the data props. Renamed `completeButton` to `ReadyForOperationButton`. Renamed +`onCompleteButtonPress` to `onReadyForOperationPress`. Renamed `showActions`to`actions`. The actions +have two new props `visible`and`disabled`. 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..d8c23d318 100644 --- a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx +++ b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx @@ -24,23 +24,29 @@ export const WorkOrderCellScreen = () => { console.log("Complete")} + onReadyForOperationPress={() => console.log("Complete")} onStartButtonPress={() => console.log("Start")} onTecoButtonPress={() => console.log("TECO")} showSymbols @@ -55,24 +61,28 @@ export const WorkOrderCellScreen = () => { console.log("Complete")} + onReadyForOperationPress={() => console.log("Complete")} onStartButtonPress={() => console.log("Start")} showSymbols symbolDirection="row" @@ -87,15 +97,15 @@ export const WorkOrderCellScreen = () => { console.log("Pressed")} @@ -110,7 +120,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..ff1f52e1c 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, + actions, overwriteLabel, style, onStartButtonPress, - onCompleteButtonPress, + onReadyForOperationPress, onTecoButtonPress, ...rest }: WorkOrderCellProps) => { + const breakpoint = useBreakpoint(); const styles = useStyles(themeStyles, { symbolDirection }); 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,28 +67,34 @@ export const WorkOrderCell = ({ valueColor={valueColor} currentDate={currentDate.toDate()} /> - {showActions && ( - - {showActions.startButton && ( + {actions && ( + + {actions.startButton?.visible && (