-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ed9166
commit 555215f
Showing
6 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
frontend/packages/volto-portal-governo/src/components/Blocks/GestorBlock/Data.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { BlockDataForm } from '@plone/volto/components'; | ||
import { gestorSchema } from './schema'; | ||
import { useIntl } from 'react-intl'; | ||
const GestorBlockData = (props) => { | ||
const { data, block, onChangeBlock, blocksConfig, navRoot, contentType } = | ||
props; | ||
const intl = useIntl(); | ||
const schema = gestorSchema({ ...props, intl }); | ||
const onChangeField = (id, value) => { | ||
onChangeBlock(block, { | ||
...data, | ||
[id]: value, | ||
}); | ||
}; | ||
return ( | ||
<BlockDataForm | ||
schema={schema} | ||
title={schema.title} | ||
onChangeField={onChangeField} | ||
onChangeBlock={onChangeBlock} | ||
formData={data} | ||
block={block} | ||
blocksConfig={blocksConfig} | ||
navRoot={navRoot} | ||
contentType={contentType} | ||
/> | ||
); | ||
}; | ||
export default GestorBlockData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
frontend/packages/volto-portal-governo/src/components/Blocks/GestorBlock/Edit.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,24 @@ | ||
import React from 'react'; | ||
import View from './View'; | ||
import { withBlockExtensions } from '@plone/volto/helpers'; | ||
import { SidebarPortal } from '@plone/volto/components'; | ||
|
||
import GestorBlockData from './Data'; | ||
import GestorBlockView from './View'; | ||
|
||
const Edit = (props) => { | ||
return <View {...props} />; | ||
const { data, onChangeBlock, block, selected } = props; | ||
return ( | ||
<> | ||
<GestorBlockView {...props} isEditMode /> | ||
<SidebarPortal selected={selected}> | ||
<GestorBlockData | ||
data={data} | ||
block={block} | ||
onChangeBlock={onChangeBlock} | ||
/> | ||
</SidebarPortal> | ||
</> | ||
); | ||
}; | ||
|
||
export default Edit; |
11 changes: 9 additions & 2 deletions
11
frontend/packages/volto-portal-governo/src/components/Blocks/GestorBlock/View.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import React from 'react'; | ||
import { Container } from '@plone/components'; | ||
import GestorView from './DefaultView'; | ||
|
||
const View = (props) => { | ||
const { properties } = props; | ||
const { data, isEditMode, properties } = props; | ||
const gestor = properties.gestor; | ||
return <GestorView content={gestor} />; | ||
return gestor ? ( | ||
<GestorView content={gestor} data={data} /> | ||
) : ( | ||
<Container narrow className={'block gestor empty'}> | ||
{isEditMode && <span>Por favor selecione um gestor.</span>} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default View; |
19 changes: 19 additions & 0 deletions
19
frontend/packages/volto-portal-governo/src/components/Blocks/GestorBlock/schema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const gestorSchema = (props) => { | ||
return { | ||
title: 'Bloco do Gestor', | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Default', | ||
fields: ['headline'], | ||
}, | ||
], | ||
properties: { | ||
headline: { | ||
title: 'Chamada do bloco', | ||
default: 'Secretário', | ||
}, | ||
}, | ||
required: ['headline'], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters