Commit f90344cb authored by PDuarte's avatar PDuarte

asset textual UI ok

parent 98f489d0
...@@ -90,19 +90,12 @@ const handleError = (text) => { ...@@ -90,19 +90,12 @@ const handleError = (text) => {
} }
}, },
handleAddBlock = () => { handleTextualChange = value => {
if (!dataElement) return const newData = {
...dataElement,
const newData = dataElement textual: value
newData.menu_page_layouts.push({ }
id: '<generated>', setElementData(newData)
layout_id: null,
order: 1,
page_id: dataElement.id
})
setElementData(newData)
setActiveTab(newData.menu_page_layouts.length - 1)
console.log(newData)
} }
...@@ -268,7 +261,10 @@ return ( ...@@ -268,7 +261,10 @@ return (
> >
<TabPane tabId={0}> <TabPane tabId={0}>
<TextualBlock dataElement={dataElement && dataElement.textual}/> <TextualBlock
dataElement={dataElement && dataElement.textual}
handleTextualChange={handleTextualChange}
/>
</TabPane> </TabPane>
</TabContent> </TabContent>
</CardBody> </CardBody>
......
...@@ -6,7 +6,12 @@ import {getProject} from '../../../settings/store/actions' ...@@ -6,7 +6,12 @@ import {getProject} from '../../../settings/store/actions'
import { Card, CardBody, Row, Col, CardHeader, CardTitle, Label, Input, FormGroup, CardText } from 'reactstrap' import { Card, CardBody, Row, Col, CardHeader, CardTitle, Label, Input, FormGroup, CardText } from 'reactstrap'
import { languages } from 'prismjs' import { languages } from 'prismjs'
const PlanLang = ({language, dataElement}) => { const PlanLang = ({language, dataElement, LangChange}) => {
const handleInputChange = (value, field) => {
dataElement[field] = value
LangChange(dataElement)
}
return <Fragment> return <Fragment>
<CardTitle tag="h5">{language.name} Textual </CardTitle> <CardTitle tag="h5">{language.name} Textual </CardTitle>
<Col md='12' sm='12'> <Col md='12' sm='12'>
...@@ -19,6 +24,7 @@ const PlanLang = ({language, dataElement}) => { ...@@ -19,6 +24,7 @@ const PlanLang = ({language, dataElement}) => {
// innerRef={register({ required: true })} // innerRef={register({ required: true })}
placeholder='title' placeholder='title'
defaultValue={dataElement && dataElement.title} defaultValue={dataElement && dataElement.title}
onChange={(e) => handleInputChange(e.target.value, 'title')}
// className={classnames({ 'is-invalid': errors['title'] })} // className={classnames({ 'is-invalid': errors['title'] })}
/> />
</FormGroup> </FormGroup>
...@@ -33,6 +39,7 @@ const PlanLang = ({language, dataElement}) => { ...@@ -33,6 +39,7 @@ const PlanLang = ({language, dataElement}) => {
// innerRef={register({ required: true })} // innerRef={register({ required: true })}
placeholder='longdescription' placeholder='longdescription'
defaultValue={dataElement && dataElement.longdescription} defaultValue={dataElement && dataElement.longdescription}
onChange={(e) => handleInputChange(e.target.value, 'longdescription')}
// className={classnames({ 'is-invalid': errors['shortdescriptions'] })} // className={classnames({ 'is-invalid': errors['shortdescriptions'] })}
/> />
</FormGroup> </FormGroup>
...@@ -47,6 +54,8 @@ const PlanLang = ({language, dataElement}) => { ...@@ -47,6 +54,8 @@ const PlanLang = ({language, dataElement}) => {
// innerRef={register({ required: true })} // innerRef={register({ required: true })}
placeholder='shortdescriptions' placeholder='shortdescriptions'
defaultValue={dataElement && dataElement.shortdescriptions} defaultValue={dataElement && dataElement.shortdescriptions}
onChange={(e) => handleInputChange(e.target.value, 'shortdescriptions')}
// className={classnames({ 'is-invalid': errors['shortdescriptions'] })} // className={classnames({ 'is-invalid': errors['shortdescriptions'] })}
/> />
</FormGroup> </FormGroup>
...@@ -54,9 +63,12 @@ const PlanLang = ({language, dataElement}) => { ...@@ -54,9 +63,12 @@ const PlanLang = ({language, dataElement}) => {
</Fragment> </Fragment>
} }
const TextualBlock = ({dataElement}) => { const TextualBlock = ({dataElement, handleTextualChange}) => {
const store = useSelector(state => state.projectsettings), const store = useSelector(state => state.projectsettings),
dispatch = useDispatch() dispatch = useDispatch(),
handleLangChange = () => {
handleTextualChange(dataElement)
}
// populate layout menus // populate layout menus
useEffect(() => { useEffect(() => {
...@@ -84,9 +96,14 @@ const TextualBlock = ({dataElement}) => { ...@@ -84,9 +96,14 @@ const TextualBlock = ({dataElement}) => {
title: '' title: ''
} }
] ]
console.log(textuals)
} }
return <PlanLang key={language.id} language={language} dataElement={textuals[0]} />
return <PlanLang
key={language.id}
language={language}
dataElement={textuals[0]}
LangChange={handleLangChange}
/>
} }
)} )}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment