diff --git a/packages/strapi-plugin-content-manager/admin/src/components/FieldItem/index.js b/packages/strapi-plugin-content-manager/admin/src/components/FieldItem/index.js
index 5ba11b46dc..a0b6ef05a9 100644
--- a/packages/strapi-plugin-content-manager/admin/src/components/FieldItem/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/components/FieldItem/index.js
@@ -59,7 +59,10 @@ const FieldItem = forwardRef(
) : (
{
+ e.stopPropagation();
+ onClickRemove();
+ }}
withLongerHeight={withLongerHeight}
isDragging={isOver && isSelected}
/>
diff --git a/packages/strapi-plugin-content-manager/admin/src/components/SelectWrapper/index.js b/packages/strapi-plugin-content-manager/admin/src/components/SelectWrapper/index.js
index 260d53116a..e80fe6749d 100644
--- a/packages/strapi-plugin-content-manager/admin/src/components/SelectWrapper/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/components/SelectWrapper/index.js
@@ -13,6 +13,7 @@ import SelectMany from '../SelectMany';
import { Nav, Wrapper } from './components';
function SelectWrapper({
+ description,
editable,
label,
mainField,
@@ -42,6 +43,7 @@ function SelectWrapper({
const ref = useRef();
const startRef = useRef();
startRef.current = state._start;
+ console.log({ description });
ref.current = async (signal, params = state) => {
try {
@@ -144,6 +146,9 @@ function SelectWrapper({
{isSingle && link}
+ {!isEmpty(description) && (
+ {description}
+ )}
{
addRelation({ target: { name, value } });
diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/index.js b/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/index.js
index 04cbe5e8fc..72a5f7c3ff 100644
--- a/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/index.js
@@ -2,7 +2,7 @@ import React, { memo, useEffect, useCallback, useState, useMemo } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
-import { get, isEqual, upperFirst } from 'lodash';
+import { get, isEqual, isEmpty, upperFirst } from 'lodash';
import {
BackHeader,
@@ -382,15 +382,16 @@ function SettingViewModel({
removeItem={removeRelation}
/>
)}
- {settingType === 'edit-settings' && (
-
- )}
+ {settingType === 'edit-settings' &&
+ !isEmpty(itemNameToSelect) && (
+
+ )}
diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/reducer.js b/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/reducer.js
index f406ebb20c..0f760285ba 100644
--- a/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/reducer.js
+++ b/packages/strapi-plugin-content-manager/admin/src/containers/SettingViewModel/reducer.js
@@ -59,6 +59,8 @@ const getSize = type => {
function settingViewModelReducer(state = initialState, action) {
const layoutPath = ['modifiedData', 'layouts', 'edit'];
const { dragIndex, hoverIndex, dragRowIndex, hoverRowIndex } = action;
+ const getFieldType = name =>
+ state.getIn(['modifiedData', 'schema', 'attributes', name, 'type']);
switch (action.type) {
case ADD_FIELD_TO_LIST:
@@ -66,10 +68,12 @@ function settingViewModelReducer(state = initialState, action) {
list.push(action.field)
);
case ADD_RELATION:
- return state.updateIn(
- ['modifiedData', 'layouts', 'editRelations'],
- list => list.push(action.name)
- );
+ return state
+ .updateIn(['modifiedData', 'layouts', 'editRelations'], list =>
+ list.push(action.name)
+ )
+ .update('itemNameToSelect', () => action.name)
+ .update('itemFormType', () => getFieldType(action.name));
case GET_DATA_SUCCEEDED:
return state
.update('initialData', () => fromJS(action.layout || {}))
@@ -112,6 +116,7 @@ function settingViewModelReducer(state = initialState, action) {
'type',
])
);
+
const listSize = state.getIn(layoutPath).size;
const newList = state
.getIn(layoutPath)
@@ -127,7 +132,10 @@ function settingViewModelReducer(state = initialState, action) {
});
const formattedList = formatLayout(newList.toJS());
- return state.updateIn(layoutPath, () => fromJS(formattedList));
+ return state
+ .updateIn(layoutPath, () => fromJS(formattedList))
+ .update('itemNameToSelect', () => action.name)
+ .update('itemFormType', () => getFieldType(action.name));
}
case ON_CHANGE:
@@ -164,16 +172,35 @@ function settingViewModelReducer(state = initialState, action) {
case REMOVE_FIELD: {
const row = state.getIn([...layoutPath, action.rowIndex, 'rowContent']);
let newState;
+ let fieldName;
// Delete the entire row if length is one or if lenght is equal to 2 and the second element is the hidden div used to make the dnd exp smoother
if (
row.size === 1 ||
(row.size == 2 && row.getIn([1, 'name']) === '_TEMP_')
) {
+ fieldName = state.getIn([
+ 'modifiedData',
+ 'layouts',
+ 'edit',
+ action.rowIndex,
+ 'rowContent',
+ 0,
+ 'name',
+ ]);
newState = state.updateIn(layoutPath, list =>
list.delete(action.rowIndex)
);
} else {
+ fieldName = state.getIn([
+ 'modifiedData',
+ 'layouts',
+ 'edit',
+ action.rowIndex,
+ 'rowContent',
+ action.fieldIndex,
+ name,
+ ]);
newState = state.updateIn(
[...layoutPath, action.rowIndex, 'rowContent'],
list => list.delete(action.fieldIndex)
@@ -181,6 +208,11 @@ function settingViewModelReducer(state = initialState, action) {
}
const updatedList = formatLayout(newState.getIn(layoutPath).toJS());
+ if (state.get('itemNameToSelect') === fieldName) {
+ // TODO select next item
+ return state.updateIn(layoutPath, () => fromJS(updatedList));
+ }
+
return state.updateIn(layoutPath, () => fromJS(updatedList));
}
case REMOVE_RELATION: