diff --git a/.changeset/tricky-deers-argue.md b/.changeset/tricky-deers-argue.md
new file mode 100644
index 000000000..993bbc864
--- /dev/null
+++ b/.changeset/tricky-deers-argue.md
@@ -0,0 +1,7 @@
+---
+"@equinor/mad-dfw": minor
+---
+
+WorkOrderCell adjusted. Renamed prop `workOrder` to `workOrderId`. Added new prop, `workOrderType`,
+this relates to the workOrderId. Removed the `symbolDirection` and `overwriteLabel` props. The
+symbol direction is now column by default.
diff --git a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx
index de19443ba..dcd082a69 100644
--- a/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx
+++ b/apps/chronicles/screens/dfw/dfwcomponents/WorkOrderCellScreen.tsx
@@ -24,7 +24,8 @@ export const WorkOrderCellScreen = () => {
{
isProductionCritical
startJobButton={{
visible: true,
+ loading: true,
onPress: () => console.log("Start"),
}}
readyForOperationButton={{
@@ -60,7 +62,8 @@ export const WorkOrderCellScreen = () => {
{
onPress: () => console.log("Complete"),
}}
showSymbols
- symbolDirection="row"
/>
@@ -94,7 +96,8 @@ export const WorkOrderCellScreen = () => {
{
);
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx
index f8c6fb36e..b6a0456fc 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/PropertyList.tsx
@@ -1,12 +1,11 @@
+import { Color } from "@equinor/mad-components";
import React from "react";
import { PropertyRow } from "../PropertyRow";
import { WorkOrder } from "./types";
-import moment from "moment";
-import { Color, useToken } from "@equinor/mad-components";
+import { formatDate } from "./utils";
-const defaultWorkOrderLabelMap: Record = {
+const workOrderLabelMap: Record = {
title: "Title",
- workOrder: "Work order",
maintenanceType: "Maintenance type",
functionalLocation: "Functional Location",
equipment: "Equipment",
@@ -18,34 +17,24 @@ const defaultWorkOrderLabelMap: Record = {
} as const;
type PropertyListProps = {
- workOrder: Partial;
+ data: Partial;
valueColor: Color;
- currentDate: Date;
- overwriteLabel?: Partial>;
};
-export const PropertyList = ({
- workOrder,
- valueColor,
- currentDate,
- overwriteLabel = {},
-}: PropertyListProps) => {
- const token = useToken();
-
- const formatDate = (dateString: string) => moment(dateString).format("DD.MM.YYYY");
-
- const requiredEnd = workOrder.requiredEnd ? new Date(workOrder.requiredEnd) : null;
+export const PropertyList = ({ data, valueColor }: PropertyListProps) => {
+ const currentDate = new Date();
+ const requiredEnd = data.requiredEnd ? new Date(data.requiredEnd) : null;
const combinedDates =
- workOrder.basicStartDate && workOrder.basicFinishDate
- ? `${formatDate(workOrder.basicStartDate)} - ${formatDate(workOrder.basicFinishDate)}`
+ data.basicStartDate && data.basicFinishDate
+ ? `${formatDate(data.basicStartDate)} - ${formatDate(data.basicFinishDate)}`
: null;
- const getLabel = (key: keyof WorkOrder) => {
+ const getLabel = (key: string) => {
if (key === "basicStartDate" && combinedDates) {
return "Basic start / finish";
}
- return overwriteLabel?.[key] ?? defaultWorkOrderLabelMap[key];
+ return workOrderLabelMap[key];
};
const getDisplayValue = (key: keyof WorkOrder, value: string | undefined) => {
@@ -60,11 +49,10 @@ export const PropertyList = ({
return (
<>
- {Object.entries(workOrder).map(([key, value], index) => {
+ {Object.entries(data).map(([key, value], index) => {
const typedKey = key as keyof WorkOrder;
if (combinedDates && typedKey === "basicFinishDate") return null;
-
if (value || (typedKey === "basicStartDate" && combinedDates)) {
const label = getLabel(typedKey);
const displayValue = getDisplayValue(typedKey, value);
@@ -75,13 +63,14 @@ export const PropertyList = ({
: valueColor;
return (
-
+ label && (
+
+ )
);
}
return null;
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
index 6007fa406..ab868010c 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCell.tsx
@@ -2,14 +2,14 @@ import {
Button,
Cell,
EDSStyleSheet,
- Label,
Typography,
useBreakpoint,
useStyles,
+ useToken,
} from "@equinor/mad-components";
-import moment from "moment";
import React, { useMemo } from "react";
import { View } from "react-native";
+import { PropertyRow } from "../PropertyRow";
import { PropertyList } from "./PropertyList";
import { StatusIcon } from "./StatusIcon";
import { WorkOrderCellProps } from "./types";
@@ -17,13 +17,13 @@ import { getStatusIconsAndLabels } from "./utils";
export const WorkOrderCell = ({
title,
+ workOrderId,
+ workOrderType,
maintenanceType,
- showSymbols,
- symbolDirection = "column",
+ showSymbols = true,
valueColor = "textTertiary",
isHseCritical,
isProductionCritical,
- overwriteLabel,
style,
startJobButton,
readyForOperationButton,
@@ -31,11 +31,14 @@ export const WorkOrderCell = ({
...rest
}: WorkOrderCellProps) => {
const breakpoint = useBreakpoint();
- const styles = useStyles(themeStyles, { symbolDirection });
+ const token = useToken();
+ const styles = useStyles(themeStyles);
const anyButtonVisible =
startJobButton?.visible ?? readyForOperationButton?.visible ?? tecoButton?.visible;
- const currentDate = moment();
+
+ const currentDate = useMemo(() => new Date(), []);
+
const iconsAndLabels = useMemo(
() =>
getStatusIconsAndLabels(
@@ -50,23 +53,28 @@ export const WorkOrderCell = ({
return (
-
+
{title}
- {showSymbols && (
-
+ {showSymbols && iconsAndLabels.length > 0 && (
+
{iconsAndLabels.map((item, index) => (
))}
)}
- {maintenanceType && }
-
+
+
+ {maintenanceType}
+
+
+
+
{anyButtonVisible && (
({
- iconContainer: {
- flexDirection: "row",
- alignItems: "center",
- gap: theme.spacing.cell.content.titleDescriptionGap,
- marginBottom: theme.spacing.cell.group.titleBottomPadding,
- },
- actionContainer: {
- gap: theme.spacing.spacer.small,
- marginTop: theme.spacing.container.paddingVertical,
- flexDirection: "row",
- justifyContent: "center",
- },
- title: {
- marginBottom: theme.spacing.container.paddingVertical,
- },
- label: {
- marginBottom: theme.spacing.cell.group.titleBottomPadding,
- },
- iconListContainer: {
- flexWrap: "wrap",
- flexDirection: symbolDirection,
- paddingBottom: theme.spacing.cell.group.titleBottomPadding,
- gap:
- symbolDirection === "row"
- ? theme.spacing.spacer.small
- : theme.spacing.cell.content.titleDescriptionGap,
- },
- }),
-);
+const themeStyles = EDSStyleSheet.create(theme => ({
+ actionContainer: {
+ gap: theme.spacing.spacer.small,
+ marginTop: theme.spacing.container.paddingVertical,
+ flexDirection: "row",
+ justifyContent: "center",
+ },
+ dataContainer: {
+ gap: theme.spacing.cell.group.titleBottomPadding,
+ },
+ iconListContainer: {
+ paddingVertical: theme.spacing.container.paddingVertical,
+ gap: theme.spacing.cell.content.titleDescriptionGap,
+ },
+}));
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCellNavigation.tsx b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCellNavigation.tsx
index 08b1ff948..f0d50c3a4 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCellNavigation.tsx
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/WorkOrderCellNavigation.tsx
@@ -1,7 +1,7 @@
-import { Cell, EDSStyleSheet, Icon, Label, Typography, useStyles } from "@equinor/mad-components";
-import moment from "moment";
+import { Cell, EDSStyleSheet, Icon, Typography, useStyles } from "@equinor/mad-components";
import React, { useMemo } from "react";
import { View } from "react-native";
+import { PropertyRow } from "../PropertyRow";
import { PropertyList } from "./PropertyList";
import { StatusIcon } from "./StatusIcon";
import { WorkOrderCellProps } from "./types";
@@ -13,19 +13,20 @@ type WorkOrderCellNavigationProps = WorkOrderCellProps & {
export const WorkOrderCellNavigation = ({
title,
+ workOrderId,
+ workOrderType,
maintenanceType,
valueColor = "textTertiary",
isHseCritical,
isProductionCritical,
showSymbols = true,
- overwriteLabel,
onPress,
style,
...rest
}: WorkOrderCellNavigationProps) => {
const styles = useStyles(themeStyles);
- const currentDate = moment();
+ const currentDate = useMemo(() => new Date(), []);
const iconsAndLabels = useMemo(
() =>
getStatusIconsAndLabels(
@@ -45,13 +46,13 @@ export const WorkOrderCellNavigation = ({
{title}
- {maintenanceType && }
-
+
+
+ {maintenanceType}
+
+
+
+
{showSymbols && (
@@ -79,8 +80,8 @@ const themeStyles = EDSStyleSheet.create(theme => ({
title: {
marginBottom: theme.spacing.container.paddingVertical,
},
- label: {
- marginBottom: theme.spacing.cell.group.titleBottomPadding,
+ dataContainer: {
+ gap: theme.spacing.cell.group.titleBottomPadding,
},
iconListContainer: {
position: "absolute",
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/index.ts b/packages/dfw/src/dfwcomponents/WorkOrderCell/index.ts
index 24e801730..3eb811723 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/index.ts
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/index.ts
@@ -1,6 +1,6 @@
import { WorkOrderCell as _WorkOrderCell } from "./WorkOrderCell";
import { WorkOrderCellNavigation } from "./WorkOrderCellNavigation";
-import { WorkOrder, WorkOrderCellProps, StatusConfig } from "./types";
+import { WorkOrder, WorkOrderType, WorkOrderCellProps, StatusConfig } from "./types";
type WorkOrderCellFamily = typeof _WorkOrderCell & {
Navigation: typeof WorkOrderCellNavigation;
@@ -10,4 +10,4 @@ const WorkOrderCell = _WorkOrderCell as WorkOrderCellFamily;
WorkOrderCell.Navigation = WorkOrderCellNavigation;
export { WorkOrderCell };
-export type { WorkOrder, WorkOrderCellProps, StatusConfig };
+export type { WorkOrder, WorkOrderType, WorkOrderCellProps, StatusConfig };
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/types.ts b/packages/dfw/src/dfwcomponents/WorkOrderCell/types.ts
index 3b9e8f855..979da112d 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/types.ts
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/types.ts
@@ -1,9 +1,21 @@
import { Color, IconName } from "@equinor/mad-components";
import { ViewProps } from "react-native";
+export type WorkOrderType =
+ | "PM01"
+ | "PM02"
+ | "PM03"
+ | "PM04"
+ | "PM05"
+ | "PM06"
+ | "PM10"
+ | "PM15"
+ | "PM20";
+
export type WorkOrder = {
+ workOrderId: string;
+ workOrderType: WorkOrderType;
title: string;
- workOrder: string;
maintenanceType?: string;
equipment?: string;
activeStatus?: string;
@@ -22,8 +34,9 @@ type ButtonOptions = {
};
export type WorkOrderCellProps = {
+ workOrderId: string;
+ workOrderType: WorkOrderType;
showSymbols?: boolean;
- symbolDirection?: "column" | "row";
valueColor?: Color;
isHseCritical?: boolean;
isProductionCritical?: boolean;
diff --git a/packages/dfw/src/dfwcomponents/WorkOrderCell/utils.ts b/packages/dfw/src/dfwcomponents/WorkOrderCell/utils.ts
index a9bf0ba97..a883207d2 100644
--- a/packages/dfw/src/dfwcomponents/WorkOrderCell/utils.ts
+++ b/packages/dfw/src/dfwcomponents/WorkOrderCell/utils.ts
@@ -1,15 +1,7 @@
-import moment from "moment";
import { StatusConfig } from "./types";
export const getStatusIconConfig = (status: string): StatusConfig | undefined => {
switch (status) {
- case "RDEX":
- return {
- icon: "circle-outline",
- label: "Ready for execution",
- textColor: "textTertiary",
- iconColor: "textPrimary",
- };
case "STRT":
return {
icon: "circle-half-full",
@@ -31,11 +23,11 @@ export const getStatusIconConfig = (status: string): StatusConfig | undefined =>
export const getStatusIconsAndLabels = (
activeStatusIds: string | undefined,
requiredEndDate: string | null,
- currentDate: moment.Moment,
+ currentDate: Date,
hseCritical?: boolean,
productionCritical?: boolean,
): StatusConfig[] => {
- const requiredEnd = requiredEndDate ? moment(requiredEndDate) : null;
+ const requiredEnd = requiredEndDate ? new Date(requiredEndDate) : null;
const activeStatuses = activeStatusIds?.split(" ");
const iconsAndLabels: StatusConfig[] = [];
@@ -67,6 +59,15 @@ export const getStatusIconsAndLabels = (
});
}
+ if (!activeStatuses?.includes("STRT")) {
+ iconsAndLabels.push({
+ icon: "circle-outline",
+ label: "Not started",
+ textColor: "textTertiary",
+ iconColor: "textPrimary",
+ });
+ }
+
activeStatuses?.forEach(status => {
const statusConfig = getStatusIconConfig(status);
if (statusConfig) {
@@ -76,3 +77,9 @@ export const getStatusIconsAndLabels = (
return iconsAndLabels;
};
+
+export const formatDate = (dateString: string): string => {
+ const date = new Date(dateString);
+ // DD.MM.YYYY
+ return date.toLocaleDateString("en-GB").replace(/\//g, ".");
+};
|