Skip to content

Commit

Permalink
[frontend] enable latitude and longitude removing from UI (#8440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit authored Sep 24, 2024
1 parent 2dd7701 commit e4d0be2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ AdministrativeAreaEditionOverviewProps
},
});
};
const handleSubmitField = (name: string, value: Option | string) => {
const handleSubmitField = (name: string, value: Option | string | null) => {
if (!enableReferences) {
let finalValue: string = value as string;
if (name === 'x_opencti_workflow_id') {
Expand All @@ -212,7 +212,7 @@ AdministrativeAreaEditionOverviewProps
editor.fieldPatch({
variables: {
id: administrativeArea.id,
input: [{ key: name, value: [finalValue ?? ''] }],
input: [{ key: name, value: [finalValue ?? null] }],
},
});
})
Expand Down Expand Up @@ -286,10 +286,11 @@ AdministrativeAreaEditionOverviewProps
variant="standard"
style={{ marginTop: 20 }}
name="latitude"
type="number"
label={t_i18n('Latitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name: string, value: string) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="latitude" />
}
Expand All @@ -299,10 +300,11 @@ AdministrativeAreaEditionOverviewProps
variant="standard"
style={{ marginTop: 20 }}
name="longitude"
type="number"
label={t_i18n('Longitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name: string, value: string) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="longitude" />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const CityEditionOverview: FunctionComponent<CityEditionOverviewProps> = ({
},
});
};
const handleSubmitField = (name: string, value: Option | string) => {
const handleSubmitField = (name: string, value: Option | string | null) => {
if (!enableReferences) {
let finalValue: string = value as string;
if (name === 'x_opencti_workflow_id') {
Expand All @@ -199,7 +199,7 @@ const CityEditionOverview: FunctionComponent<CityEditionOverviewProps> = ({
editor.fieldPatch({
variables: {
id: city.id,
input: [{ key: name, value: [finalValue ?? ''] }],
input: [{ key: name, value: [finalValue ?? null] }],
},
});
})
Expand Down Expand Up @@ -273,10 +273,11 @@ const CityEditionOverview: FunctionComponent<CityEditionOverviewProps> = ({
variant="standard"
style={{ marginTop: 20 }}
name="latitude"
type="number"
label={t_i18n('Latitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name: string, value: string) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="latitude" />
}
Expand All @@ -286,10 +287,11 @@ const CityEditionOverview: FunctionComponent<CityEditionOverviewProps> = ({
variant="standard"
style={{ marginTop: 20 }}
name="longitude"
type="number"
label={t_i18n('Longitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name: string, value: string) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="longitude" />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ const PositionEditionOverviewComponent = (props) => {
editor.fieldPatch({
variables: {
id: position.id,
input: {
input: [{
key: name,
value: finalValue ?? '',
},
value: finalValue ?? [null],
}],
},
});
})
Expand Down Expand Up @@ -238,10 +238,11 @@ const PositionEditionOverviewComponent = (props) => {
variant="standard"
style={{ marginTop: 20 }}
name="latitude"
type="number"
label={t_i18n('Latitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name, value) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="latitude" />
}
Expand All @@ -251,10 +252,11 @@ const PositionEditionOverviewComponent = (props) => {
variant="standard"
style={{ marginTop: 20 }}
name="longitude"
type="number"
label={t_i18n('Longitude')}
fullWidth={true}
onFocus={editor.changeFocus}
onSubmit={handleSubmitField}
onSubmit={(name, value) => handleSubmitField(name, (value === '' ? null : value))}
helperText={
<SubscriptionFocus context={context} fieldName="longitude" />
}
Expand Down

0 comments on commit e4d0be2

Please sign in to comment.