diff --git a/geonode_mapstore_client/client/js/components/Autocomplete/Autocomplete.jsx b/geonode_mapstore_client/client/js/components/Autocomplete/Autocomplete.jsx
index 671f718605..8e6d8debcd 100644
--- a/geonode_mapstore_client/client/js/components/Autocomplete/Autocomplete.jsx
+++ b/geonode_mapstore_client/client/js/components/Autocomplete/Autocomplete.jsx
@@ -29,6 +29,7 @@ const Autocomplete = ({
title,
value,
valueKey = "value",
+ showLabel = true,
...props
}) => {
const getValue = () => {
@@ -46,10 +47,10 @@ const Autocomplete = ({
return (
-
+ {showLabel &&
{helpTitleIcon && !isEmpty(description) && }
-
+
}
({
type: SET_METADATA,
@@ -66,3 +67,8 @@ export const setMetadataResource = (resource) => ({
type: SET_METADATA_RESOURCE,
resource
});
+
+export const setExtraErrors = (extraErrors) => ({
+ type: SET_METADATA_EXTRA_ERRORS,
+ extraErrors
+});
diff --git a/geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_fields/SchemaField.jsx b/geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_fields/SchemaField.jsx
index 215ccde87f..25b3fc9dd2 100644
--- a/geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_fields/SchemaField.jsx
+++ b/geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_fields/SchemaField.jsx
@@ -27,11 +27,11 @@ const SchemaField = (props) => {
formData,
idSchema,
name,
- hideError,
errorSchema,
uiSchema
} = props;
- const autocomplete = uiSchema?.['ui:options']?.['geonode-ui:autocomplete'];
+ const uiOptions = uiSchema?.['ui:options'];
+ const autocomplete = uiOptions?.['geonode-ui:autocomplete'];
const isSchemaItemString = schema?.items?.type === 'string';
const isSchemaItemObject = schema?.items?.type === 'object';
const isMultiSelect = schema?.type === 'array' && (isSchemaItemString ||
@@ -40,6 +40,17 @@ const SchemaField = (props) => {
const isSingleSelect = schema?.type === 'object' && !isEmpty(schema?.properties);
if (autocomplete && (isMultiSelect || isSingleSelect)) {
+ const {
+ classNames,
+ style,
+ description,
+ disabled,
+ help: helpText,
+ hideError,
+ label,
+ placeholder: autoCompletePlaceholder,
+ title
+ } = uiOptions;
const errors = (!hideError ? castArray(errorSchema) : [])
.reduce((acc, errorEntry) => {
if (errorEntry?.__errors) {
@@ -61,11 +72,11 @@ const SchemaField = (props) => {
const resultsKey = autocompleteOptions?.resultsKey || 'results';
const valueKey = autocompleteOptions?.valueKey || 'id';
const labelKey = autocompleteOptions?.labelKey || 'label';
- const placeholder = autocompleteOptions?.placeholder ?? '...';
const creatable = !!autocompleteOptions?.creatable;
+ const placeholder = autoCompletePlaceholder ?? '...';
let autoCompleteProps = {
- className: "gn-metadata-autocomplete",
+ className: `gn-metadata-autocomplete${classNames ? ' ' + classNames : ''}`,
clearable: !isMultiSelect,
creatable,
id: idSchema.$id,
@@ -73,11 +84,14 @@ const SchemaField = (props) => {
multi: isMultiSelect,
name,
placeholder,
- title: schema.title,
+ showLabel: label ?? true,
+ title: title ?? schema.title,
value: formData,
valueKey,
helpTitleIcon: true,
- description: schema.description,
+ description: helpText ?? description ?? schema.description, // Help text is preferred over description and displayed as a tooltip
+ disabled,
+ style,
onChange: (selected) => {
let _selected = selected?.result ?? null;
if (isMultiSelect) {
diff --git a/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataEditor.jsx b/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataEditor.jsx
index 3d013f3098..d7344f7a5f 100644
--- a/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataEditor.jsx
+++ b/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataEditor.jsx
@@ -22,6 +22,7 @@ function MetadataEditor({
pk,
loading,
error,
+ extraErrors,
metadata,
schema,
uiSchema,
@@ -97,6 +98,7 @@ function MetadataEditor({
validator={validator}
templates={templates}
fields={fields}
+ extraErrors={extraErrors}
experimental_defaultFormStateBehavior={{
arrayMinItems: {
populate: 'never',
diff --git a/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataUpdateButton.jsx b/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataUpdateButton.jsx
index 8ab40979a3..1b7bfad1f3 100644
--- a/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataUpdateButton.jsx
+++ b/geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataUpdateButton.jsx
@@ -7,6 +7,7 @@
*/
import React from 'react';
+import get from 'lodash/get';
import { updateMetadata } from '@js/api/geonode/v2/metadata';
import Message from '@mapstore/framework/components/I18N/Message';
import Button from '@js/components/Button';
@@ -20,15 +21,17 @@ function MetadataUpdateButton({
updating,
setUpdating,
setUpdateError,
- setInitialMetadata
+ setInitialMetadata,
+ setExtraErrors
}) {
function handleUpdate() {
setUpdating(true);
setUpdateError(false);
updateMetadata(pk, metadata)
- .then(() => {
+ .then((res) => {
setInitialMetadata(metadata);
+ setExtraErrors(get(res, 'data.extraErrors', {}));
})
.catch(() => {
setUpdateError(true);
diff --git a/geonode_mapstore_client/client/js/plugins/MetadataEditor/index.js b/geonode_mapstore_client/client/js/plugins/MetadataEditor/index.js
index 5fcf391c36..4acdcfb85b 100644
--- a/geonode_mapstore_client/client/js/plugins/MetadataEditor/index.js
+++ b/geonode_mapstore_client/client/js/plugins/MetadataEditor/index.js
@@ -21,7 +21,8 @@ import {
setMetadataError,
setMetadataUpdating,
setMetadataUpdateError,
- setMetadataResource
+ setMetadataResource,
+ setExtraErrors
} from './actions/metadata';
import { parseDevHostname } from '@js/utils/APIUtils';
@@ -35,6 +36,7 @@ const connectMetadata = connect(
createSelector([
state => state?.metadata?.loading,
state => state?.metadata?.error,
+ state => state?.metadata?.extraErrors,
state => state?.metadata?.metadata,
state => state?.metadata?.initialMetadata,
state => state?.metadata?.schema,
@@ -42,9 +44,10 @@ const connectMetadata = connect(
state => state?.metadata?.updating,
state => state?.metadata?.updateError,
state => state?.metadata?.resource
- ], (loading, error, metadata, initialMetadata, schema, uiSchema, updating, updateError, resource) => ({
+ ], (loading, error, extraErrors, metadata, initialMetadata, schema, uiSchema, updating, updateError, resource) => ({
loading,
error,
+ extraErrors,
metadata,
schema,
uiSchema,
@@ -62,7 +65,8 @@ const connectMetadata = connect(
setInitialMetadata,
setUpdateError: setMetadataUpdateError,
setUpdating: setMetadataUpdating,
- setResource: setMetadataResource
+ setResource: setMetadataResource,
+ setExtraErrors
}
);
diff --git a/geonode_mapstore_client/client/js/plugins/MetadataEditor/reducers/metadata.js b/geonode_mapstore_client/client/js/plugins/MetadataEditor/reducers/metadata.js
index 068c6da1a0..0201fe1596 100644
--- a/geonode_mapstore_client/client/js/plugins/MetadataEditor/reducers/metadata.js
+++ b/geonode_mapstore_client/client/js/plugins/MetadataEditor/reducers/metadata.js
@@ -16,7 +16,8 @@ import {
SET_METADATA_UPDATING,
SET_METADATA_UPDATE_ERROR,
SET_METADATA_PREVIEW,
- SET_METADATA_RESOURCE
+ SET_METADATA_RESOURCE,
+ SET_METADATA_EXTRA_ERRORS
} from '../actions/metadata';
function metadata(state = {}, action) {
@@ -81,6 +82,12 @@ function metadata(state = {}, action) {
resource: action.resource
};
}
+ case SET_METADATA_EXTRA_ERRORS: {
+ return {
+ ...state,
+ extraErrors: action.extraErrors
+ };
+ }
default:
return state;
}