From e4d0be2af3de78bccde86c1f9a7e6bea0da59988 Mon Sep 17 00:00:00 2001 From: Archidoit <75783086+Archidoit@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:34:42 +0200 Subject: [PATCH] [frontend] enable latitude and longitude removing from UI (#8440) --- .../AdministrativeAreaEditionOverview.tsx | 10 ++++++---- .../locations/cities/CityEditionOverview.tsx | 10 ++++++---- .../locations/positions/PositionEditionOverview.jsx | 12 +++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/opencti-platform/opencti-front/src/private/components/locations/administrative_areas/AdministrativeAreaEditionOverview.tsx b/opencti-platform/opencti-front/src/private/components/locations/administrative_areas/AdministrativeAreaEditionOverview.tsx index 897eea330822..ae293141fc10 100644 --- a/opencti-platform/opencti-front/src/private/components/locations/administrative_areas/AdministrativeAreaEditionOverview.tsx +++ b/opencti-platform/opencti-front/src/private/components/locations/administrative_areas/AdministrativeAreaEditionOverview.tsx @@ -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') { @@ -212,7 +212,7 @@ AdministrativeAreaEditionOverviewProps editor.fieldPatch({ variables: { id: administrativeArea.id, - input: [{ key: name, value: [finalValue ?? ''] }], + input: [{ key: name, value: [finalValue ?? null] }], }, }); }) @@ -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={ } @@ -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={ } diff --git a/opencti-platform/opencti-front/src/private/components/locations/cities/CityEditionOverview.tsx b/opencti-platform/opencti-front/src/private/components/locations/cities/CityEditionOverview.tsx index ed2b6d97dc26..a8de69230a0f 100644 --- a/opencti-platform/opencti-front/src/private/components/locations/cities/CityEditionOverview.tsx +++ b/opencti-platform/opencti-front/src/private/components/locations/cities/CityEditionOverview.tsx @@ -187,7 +187,7 @@ const CityEditionOverview: FunctionComponent = ({ }, }); }; - 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') { @@ -199,7 +199,7 @@ const CityEditionOverview: FunctionComponent = ({ editor.fieldPatch({ variables: { id: city.id, - input: [{ key: name, value: [finalValue ?? ''] }], + input: [{ key: name, value: [finalValue ?? null] }], }, }); }) @@ -273,10 +273,11 @@ const CityEditionOverview: FunctionComponent = ({ 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={ } @@ -286,10 +287,11 @@ const CityEditionOverview: FunctionComponent = ({ 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={ } diff --git a/opencti-platform/opencti-front/src/private/components/locations/positions/PositionEditionOverview.jsx b/opencti-platform/opencti-front/src/private/components/locations/positions/PositionEditionOverview.jsx index f54765eb9d9a..87e42234370e 100644 --- a/opencti-platform/opencti-front/src/private/components/locations/positions/PositionEditionOverview.jsx +++ b/opencti-platform/opencti-front/src/private/components/locations/positions/PositionEditionOverview.jsx @@ -153,10 +153,10 @@ const PositionEditionOverviewComponent = (props) => { editor.fieldPatch({ variables: { id: position.id, - input: { + input: [{ key: name, - value: finalValue ?? '', - }, + value: finalValue ?? [null], + }], }, }); }) @@ -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={ } @@ -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={ }