Add routing for adding attributes to created compo, not working when creating a sub one on the fly

This commit is contained in:
soupette 2019-11-29 16:04:42 +01:00
parent 13bb647da8
commit cc88f62a29
2 changed files with 12 additions and 2 deletions

View File

@ -8,6 +8,7 @@ const ComponentInfos = ({ uid }) => {
// We might want to change to initialData...
// @Aurelsicoko
const { modifiedData } = useDataManager();
console.log({ modifiedData });
const currentComponent = get(modifiedData, ['components', uid], {});
const currentComponentCategory = get(currentComponent, 'category', '');
const currentComponentFriendlyName = get(
@ -15,6 +16,7 @@ const ComponentInfos = ({ uid }) => {
['schema', 'name'],
''
);
console.log({ uid, currentComponentFriendlyName });
return (
<ComponentInfosWrapper>

View File

@ -398,6 +398,7 @@ const FormModal = () => {
// Add/edit a field
} else if (isCreatingAttribute && !isCreatingComponentFromAView) {
console.log('not creat compo');
// Normal fields like boolean relations or dynamic zone
if (!isComponentAttribute) {
addAttribute(
@ -408,7 +409,6 @@ const FormModal = () => {
initialData
);
const isDynamicZoneAttribute = state.attributeType === 'dynamiczone';
console.log('oooo');
// Adding a component to a dynamiczone is not the same logic as creating a simple field
// so the search is different
// TODO make sure it works for edit
@ -530,7 +530,13 @@ const FormModal = () => {
// TODO temporary
dispatch({ type: 'RESET_PROPS' });
push({ search: '' });
// Open modal attribute for adding attr to component
// The we inverse the headerDisplayName because it becomes the last one displayed
const searchToOpenModalAttributeToAddAttributesToAComponent = `modalType=chooseAttribute&forTarget=components&targetUid=${componentUid}&headerDisplayName=${componentToCreate.name}&headerDisplayCategory=${state.headerDisplayName}`;
push({
search: searchToOpenModalAttributeToAddAttributesToAComponent,
});
return;
}
// The modal is addComponentToDynamicZone
@ -625,6 +631,8 @@ const FormModal = () => {
nestedComponents
);
console.log({ state });
// Styles
const modalBodyStyle = isPickingAttribute
? { paddingTop: '0.5rem', paddingBottom: '3rem' }