Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-2515 Add required properties for creating new objects #2516

Merged
merged 1 commit into from
Aug 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface DateTimeFieldProps {
minValue?: string;
maxValue?: string;
disabled?: boolean;
required?: boolean;
}

/**
Expand All @@ -31,7 +32,8 @@ interface DateTimeFieldProps {
export const LogHeaderDateTimeField = (
props: DateTimeFieldProps
): React.ReactElement => {
const { disabled, value, label, updateObject, minValue, maxValue } = props;
const { disabled, required, value, label, updateObject, minValue, maxValue } =
props;
const {
operationState: { timeZone }
} = useOperationState();
Expand All @@ -46,6 +48,7 @@ export const LogHeaderDateTimeField = (
}, []);

const validate = (current: string) => {
if (required && !current) return false;
return (
((!minValue || current >= minValue) &&
(!maxValue || current <= maxValue)) ||
Expand All @@ -55,6 +58,7 @@ export const LogHeaderDateTimeField = (

const getHelperText = () => {
if (!validate(value)) {
if (required && !value) return "This field is required";
if (!initiallyEmpty && (value == null || value === "")) {
return "This field cannot be deleted.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const getBhaRunProperties = (
property: "tubular",
propertyType: PropertyType.RefNameString,
validator: validRefNameString,
helperText: getRefNameStringHelperText("tubular")
helperText: getRefNameStringHelperText("tubular"),
required: true
},
{
property: "dTimStart",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export const getFormationMarkerProperties = (
property: "mdTopSample",
propertyType: PropertyType.Measure,
validator: validMeasure,
helperText: getMeasureHelperText("mdTopSample")
helperText: getMeasureHelperText("mdTopSample"),
required: true
},
{
property: "tvdTopSample",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
import { PropertiesModalMode, validText } from "components/Modals/ModalParts";
import {
PropertiesModalMode,
validOption,
validText
} from "components/Modals/ModalParts";
import { getCommonObjectOnWellboreProperties } from "components/Modals/PropertiesModal/Properties/CommonObjectOnWellboreProperties";
import { PropertiesModalProperty } from "components/Modals/PropertiesModal/propertiesModalProperty";
import { PropertyType } from "components/Modals/PropertiesModal/PropertyTypes";
import { getMaxLengthHelperText } from "components/Modals/PropertiesModal/ValidationHelpers";
import {
getMaxLengthHelperText,
getOptionHelperText
} from "components/Modals/PropertiesModal/ValidationHelpers";
import MaxLength from "models/maxLength";
import MessageObject from "models/messageObject";
import { messageTypes } from "models/messageTypes";

export const getMessageProperties = (
mode: PropertiesModalMode
): PropertiesModalProperty<MessageObject>[] => [
...getCommonObjectOnWellboreProperties(mode),
{
property: "dTim",
propertyType: PropertyType.DateTime,
required: true,
disabled: mode !== PropertiesModalMode.New
},
{
property: "typeMessage",
propertyType: PropertyType.Options,
validator: (value: string) => validOption(value, messageTypes),
helperText: getOptionHelperText("typeMessage"),
options: messageTypes,
required: true,
disabled: mode !== PropertiesModalMode.New
},
{
property: "messageText",
propertyType: PropertyType.String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ export const getRiskProperties = (
propertyType: PropertyType.Options,
validator: (value: string) => validOption(value, riskType),
helperText: getOptionHelperText("type"),
options: riskType
options: riskType,
required: true
},
{
property: "category",
propertyType: PropertyType.Options,
validator: (value: string) => validOption(value, riskCategory),
helperText: getOptionHelperText("category"),
options: riskCategory
options: riskCategory,
required: true
},
{
property: "subCategory",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const getWbGeometryProperties = (
{
property: "dTimReport",
propertyType: PropertyType.DateTime,
disabled: true
required: true,
disabled: mode !== PropertiesModalMode.New
},
{
property: "commonData.sourceName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export const getFluidsReportProperties = (
...getCommonObjectOnWellboreProperties(mode),
{
property: "dTim",
propertyType: PropertyType.DateTime
propertyType: PropertyType.DateTime,
required: true
},
{
property: "md",
propertyType: PropertyType.Measure,
validator: validMeasure,
helperText: getMeasureHelperText("md")
helperText: getMeasureHelperText("md"),
required: true
},
{
property: "tvd",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export const PropertiesRenderer = <T,>({
}
label={prop.property}
disabled={prop.disabled}
required={prop.required}
updateObject={(dateTime: string) => {
onChangeProperty(prop.property, prop.propertyType, dateTime);
}}
Expand Down
7 changes: 7 additions & 0 deletions Src/WitsmlExplorer.Frontend/models/messageTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const messageTypes = [
"alarm",
"event",
"informational",
"warning",
"unknown"
];