Fix ModalHeader title

This commit is contained in:
soupette 2019-11-20 09:52:54 +01:00 committed by Alexandre Bodin
parent 4c840e07ff
commit cd6c2c5c36
3 changed files with 24 additions and 4 deletions

View File

@ -105,6 +105,7 @@ const DataManagerProvider = ({ children }) => {
contentTypes,
createSchema,
initialData,
isInContentTypeView,
modifiedData,
setModifiedData,
}}

View File

@ -244,7 +244,8 @@ const FormModal = () => {
>
<HeaderModal>
<ModalHeader
name={state.forTarget || name}
// name={state.forTarget || name}
name={name}
headerId={headerId}
iconType={iconType || 'contentType'}
/>
@ -296,7 +297,7 @@ const FormModal = () => {
<hr
style={{
width: 'calc(100% - 30px)',
marginBottom: 7,
marginBottom: 25,
}}
/>
)}

View File

@ -1,5 +1,5 @@
import React, { useEffect, useRef } from 'react';
import { useLocation } from 'react-router-dom';
import { useHistory, useLocation } from 'react-router-dom';
import { get } from 'lodash';
import { ViewContainer } from 'strapi-helper-plugin';
import useDataManager from '../../hooks/useDataManager';
@ -7,7 +7,13 @@ import LeftMenu from '../LeftMenu';
const ListPage = () => {
const { pathname } = useLocation();
const { modifiedData, setModifiedData } = useDataManager();
const {
initialData,
modifiedData,
isInContentTypeView,
setModifiedData,
} = useDataManager();
const { push } = useHistory();
const setModifiedDataRef = useRef();
setModifiedDataRef.current = setModifiedData;
@ -16,13 +22,25 @@ const ListPage = () => {
}, [pathname]);
const attributes = get(modifiedData, ['schema', 'attributes'], {});
const handleClick = () => {
const currentDataName = get(initialData, ['schema', 'name'], '');
const forTarget = isInContentTypeView ? 'contentType' : 'component';
const search = `modalType=chooseAttribute&forTarget=${forTarget}&targetr=${currentDataName}`;
push({ search });
};
console.log({ allSchema: modifiedData });
return (
<ViewContainer>
<div className="container-fluid">
<div className="row">
<LeftMenu />
<div className="col-md-9">
<button type="button" onClick={handleClick}>
Add field
</button>
<ul>
{Object.keys(attributes).map(attr => (
<li key={attr}>{attr}</li>