Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/dry-points-brake.md
Original file line number Diff line number Diff line change
@@ -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.
57 changes: 32 additions & 25 deletions apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,30 @@ export const WorkOrderCellScreen = () => {
<Spacer />
<WorkOrderCell
title="Work Order Cell"
workOrderId="25282760"
workOrder="25282760"
maintenanceType="Surface monitoring"
functionalLocation="TAG-123456"
equipmentId="EQUIP-123456"
activeStatusIds="STRT"
equipment="EQUIP-123456"
activeStatus="STRT"
basicStartDate="2023-04-07"
basicFinishDate="2023-09-12"
requiredEnd="2024-04-23"
workCenterId="POMISP"
workCenter="POMISP"
isHseCritical
isProductionCritical
showActions={{
startButton: true,
completeButton: true,
tecoButton: true,
startJobButton={{
visible: true,
onPress: () => 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
/>
<Spacer />
Expand All @@ -55,25 +60,27 @@ export const WorkOrderCellScreen = () => {
<Spacer />
<WorkOrderCell
title="Work Order Cell"
workOrderId="25282760"
workOrder="25282760"
maintenanceType="Surface monitoring"
functionalLocation="TAG-123456"
equipmentId="EQUIP-123456"
activeStatusIds="STRT"
equipment="EQUIP-123456"
activeStatus="STRT"
basicFinishDate="2023-04-07"
requiredEnd="2024-04-23"
workCenterId="POMISP"
workCenter="POMISP"
isHseCritical
isProductionCritical
overwriteLabel={{
functionalLocation: "Adjusted label",
}}
showActions={{
startButton: true,
completeButton: true,
startJobButton={{
visible: true,
onPress: () => console.log("Start"),
}}
readyForOperationButton={{
visible: true,
onPress: () => console.log("Complete"),
}}
onCompleteButtonPress={() => console.log("Complete")}
onStartButtonPress={() => console.log("Start")}
showSymbols
symbolDirection="row"
/>
Expand All @@ -87,15 +94,15 @@ export const WorkOrderCellScreen = () => {
<Spacer />
<WorkOrderCell.Navigation
title="Work Order Cell"
workOrderId="25282760"
workOrder="25282760"
maintenanceType="Surface monitoring"
functionalLocation="TAG-123456"
equipmentId="EQUIP-123456"
activeStatusIds="STRT"
equipment="EQUIP-123456"
activeStatus="STRT"
basicFinishDate="2023-04-07"
basicStartDate="2023-02-07"
requiredEnd="2024-04-23"
workCenterId="POMISP"
workCenter="POMISP"
isHseCritical
isProductionCritical
onPress={() => console.log("Pressed")}
Expand All @@ -110,7 +117,7 @@ export const WorkOrderCellScreen = () => {
<Spacer />
<WorkOrderCell
title="Basic Work Order Cell"
workOrderId="25282760"
workOrder="25282760"
maintenanceType="Surface monitoring"
functionalLocation="TAG-123456"
valueColor="danger"
Expand Down
8 changes: 4 additions & 4 deletions packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { Color, useToken } from "@equinor/mad-components";

const defaultWorkOrderLabelMap: Record<keyof WorkOrder, string> = {
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 = {
Expand Down
62 changes: 36 additions & 26 deletions packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 (
Expand All @@ -62,29 +67,35 @@ export const WorkOrderCell = ({
valueColor={valueColor}
currentDate={currentDate.toDate()}
/>
{showActions && (
<View style={styles.actionContainer}>
{showActions.startButton && (
{anyButtonVisible && (
<View
style={[
styles.actionContainer,
breakpoint === "xs" && { flexDirection: "column" },
]}
>
{startJobButton?.visible && (
<Button
title="Start job"
variant="outlined"
disabled={isStartDisabled}
onPress={onStartButtonPress}
disabled={startJobButton.disabled}
onPress={startJobButton.onPress}
/>
)}
{showActions.completeButton && (
{readyForOperationButton?.visible && (
<Button
title="Ready for operation"
variant="outlined"
disabled={isCompleteDisabled}
onPress={onCompleteButtonPress}
disabled={readyForOperationButton.disabled}
onPress={readyForOperationButton?.onPress}
/>
)}
{showActions.tecoButton && (
{tecoButton?.visible && (
<Button
title="Technical complete"
variant="outlined"
onPress={onTecoButtonPress}
disabled={tecoButton.disabled}
onPress={tecoButton.onPress}
/>
)}
</View>
Expand All @@ -98,13 +109,12 @@ const themeStyles = EDSStyleSheet.create(
iconContainer: {
flexDirection: "row",
alignItems: "center",

gap: theme.spacing.cell.content.titleDescriptionGap,
marginBottom: theme.spacing.cell.group.titleBottomPadding,
},
actionContainer: {
gap: theme.spacing.container.paddingVertical,
marginTop: theme.spacing.spacer.medium,
gap: theme.spacing.spacer.small,
marginTop: theme.spacing.container.paddingVertical,
flexDirection: "row",
justifyContent: "center",
},
Expand All @@ -120,7 +130,7 @@ const themeStyles = EDSStyleSheet.create(
paddingBottom: theme.spacing.cell.group.titleBottomPadding,
gap:
symbolDirection === "row"
? theme.spacing.spacer.medium
? theme.spacing.spacer.small
: theme.spacing.cell.content.titleDescriptionGap,
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export const WorkOrderCellNavigation = ({
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 (
Expand Down
23 changes: 11 additions & 12 deletions packages/dfw/src/dfwcomponents/WorkOrderCell/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import { ViewProps } from "react-native";

export type WorkOrder = {
title: string;
workOrderId: string;
workOrder: string;
maintenanceType?: string;
equipmentId?: string;
activeStatusIds?: string;
equipment?: string;
activeStatus?: string;
basicStartDate?: string;
basicFinishDate?: string;
requiredEnd?: string;
workCenterId?: string;
workCenter?: string;
functionalLocation?: string;
};

export type WorkOrderCellActions = {
startButton?: boolean;
completeButton?: boolean;
tecoButton?: boolean;
type ButtonOptions = {
disabled?: boolean;
visible: boolean;
onPress: () => void;
};

export type WorkOrderCellProps = {
Expand All @@ -28,10 +28,9 @@ export type WorkOrderCellProps = {
isProductionCritical?: boolean;
style?: ViewProps["style"];
overwriteLabel?: Partial<Record<keyof WorkOrder, string>>;
showActions?: WorkOrderCellActions;
onStartButtonPress?: () => void;
onCompleteButtonPress?: () => void;
onTecoButtonPress?: () => void;
startJobButton?: ButtonOptions;
readyForOperationButton?: ButtonOptions;
tecoButton?: ButtonOptions;
} & WorkOrder;

export type StatusConfig = {
Expand Down
Loading