Skip to content

Commit

Permalink
[#4031] Update frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Apr 3, 2024
1 parent d48a379 commit e7957f5
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const ObjectsApiOptionsFormFields = ({index, name, schema, formData, onChange})
draft.version = realVersion;
if (realVersion === 2) {
draft.variablesMapping = [];
draft.geometryVariableKey = '';
} else {
delete draft.variablesMapping;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {FormattedMessage} from 'react-intl';
*
* @typedef {{
* variablesMapping: {variableKey: string, targetPath: string[]}[],
* geometryVariableKey: string,
* }} ObjectsAPIV2Options
*
* @param {Object} p
Expand All @@ -15,18 +14,6 @@ import {FormattedMessage} from 'react-intl';
* @returns {JSX.Element} - The summary, represented as the parts of the target path separated by '>'
*/
const ObjectsApiSummaryHandler = ({variable, backendOptions}) => {
const geometryVariableKey = backendOptions.geometryVariableKey;

if (geometryVariableKey === variable.key) {
return (
<FormattedMessage
description="'Mapped to geometry' registration summary message"
defaultMessage="Mapped to the {geometryPath} attribute"
values={{geometryPath: <code>record.geometry</code>}}
/>
);
}

const variableMapping = backendOptions.variablesMapping.find(
mapping => mapping.variableKey === variable.key
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {asJsonSchema} from './utils';
* objecttype: string;
* objecttypeVersion: number;
* variablesMapping: {variableKey: string, targetPath: string[]}[];
* geometryVariableKey: string;
* }} ObjectsAPIRegistrationBackendOptions
*
* @param {Object} p
Expand All @@ -39,13 +38,10 @@ const ObjectsApiVariableConfigurationEditor = ({variable}) => {
const {values: backendOptions, getFieldProps, setFieldValue} = useFormikContext();

/** @type {ObjectsAPIRegistrationBackendOptions} */
const {objecttype, objecttypeVersion, geometryVariableKey, variablesMapping, version} =
backendOptions;
const {objecttype, objecttypeVersion, variablesMapping, version} = backendOptions;

if (version !== 2) throw new Error('Not supported, must be config version 2.');

const isGeometry = geometryVariableKey === variable.key;

// get the index of our variable in the mapping, if it exists
let index = variablesMapping.findIndex(
mappedVariable => mappedVariable.variableKey === variable.key
Expand Down Expand Up @@ -115,33 +111,6 @@ const ObjectsApiVariableConfigurationEditor = ({variable}) => {
/>
</Field>
</FormRow>
<FormRow>
<Field
label={
<FormattedMessage
defaultMessage="Map to geometry field"
description="'Map to geometry field' checkbox label"
/>
}
helpText={
<FormattedMessage
description="'Map to geometry field' checkbox help text"
defaultMessage="Whether to map this variable to the {geometryPath} attribute"
values={{geometryPath: <code>record.geometry</code>}}
/>
}
name="geometryVariableKey"
disabled={!!mappedVariable.targetPath}
>
<Checkbox
checked={isGeometry}
onChange={event => {
const newValue = event.target.checked ? variable.key : undefined;
setFieldValue('geometryVariableKey', newValue);
}}
/>
</Field>
</FormRow>
<FormRow>
<Field
name={`${namePrefix}.targetPath`}
Expand All @@ -151,14 +120,12 @@ const ObjectsApiVariableConfigurationEditor = ({variable}) => {
description="'JSON Schema target' label"
/>
}
disabled={isGeometry}
>
<TargetPathSelect
name={`${namePrefix}.targetPath`}
index={index}
choices={choices}
mappedVariable={mappedVariable}
disabled={isGeometry}
/>
</Field>
</FormRow>
Expand Down

0 comments on commit e7957f5

Please sign in to comment.