generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
b343119
commit d981c6b
Showing
6 changed files
with
161 additions
and
99 deletions.
There are no files selected for viewing
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,3 +1,4 @@ | ||
export GroupBlockEdit from './manage/Blocks/Group/Edit'; | ||
export GroupBlockView from './manage/Blocks/Group/View'; | ||
export GroupBlockLayout from './manage/Blocks/Group/LayoutSchema'; | ||
export GroupBlockDefaultBody from './manage/Blocks/Group/DefaultBody'; |
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,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { GroupBlockDefaultBody } from '@eeacms/volto-group-block/components'; | ||
|
||
const Body = (props) => { | ||
const { variation } = props; | ||
|
||
const BodyComponent = variation?.template || GroupBlockDefaultBody; | ||
|
||
return <BodyComponent {...props} />; | ||
}; | ||
|
||
Body.propTypes = { | ||
variation: PropTypes.objectOf(PropTypes.any).isRequired, | ||
}; | ||
|
||
export default Body; |
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,101 @@ | ||
import { Button } from 'semantic-ui-react'; | ||
import { isEmpty } from 'lodash'; | ||
import { BlocksForm, Icon, RenderBlocks } from '@plone/volto/components'; | ||
import { emptyBlocksForm } from '@plone/volto/helpers'; | ||
import EditBlockWrapper from './EditBlockWrapper'; | ||
|
||
import helpSVG from '@plone/volto/icons/help.svg'; | ||
|
||
const GroupBlockDefaultBody = (props) => { | ||
const { | ||
block, | ||
data, | ||
onChangeBlock, | ||
onChangeField, | ||
pathname, | ||
selected, | ||
selectedBlock, | ||
setSelectedBlock, | ||
manage, | ||
childBlocksForm, | ||
formDescription, | ||
isEditMode, | ||
} = props; | ||
const metadata = props.metadata || props.properties; | ||
const blockState = {}; | ||
|
||
// Get editing instructions from block settings or props | ||
let instructions = data?.instructions?.data || data?.instructions; | ||
if (!instructions || instructions === '<p><br/></p>') { | ||
instructions = formDescription; | ||
} | ||
return isEditMode ? ( | ||
<BlocksForm | ||
metadata={metadata} | ||
properties={childBlocksForm} | ||
manage={manage} | ||
selectedBlock={selected ? selectedBlock : null} | ||
allowedBlocks={data.allowedBlocks} | ||
title={data.placeholder} | ||
description={instructions} | ||
onSelectBlock={(id) => { | ||
setSelectedBlock(id); | ||
}} | ||
onChangeFormData={(newFormData) => { | ||
onChangeBlock(block, { | ||
...data, | ||
data: newFormData, | ||
}); | ||
}} | ||
onChangeField={(id, value) => { | ||
if (['blocks', 'blocks_layout'].indexOf(id) > -1) { | ||
blockState[id] = value; | ||
onChangeBlock(block, { | ||
...data, | ||
data: { | ||
...data.data, | ||
...blockState, | ||
}, | ||
}); | ||
} else { | ||
onChangeField(id, value); | ||
} | ||
}} | ||
pathname={pathname} | ||
> | ||
{({ draginfo }, editBlock, blockProps) => ( | ||
<EditBlockWrapper | ||
draginfo={draginfo} | ||
blockProps={blockProps} | ||
disabled={data.disableInnerButtons} | ||
extraControls={ | ||
<> | ||
{instructions && ( | ||
<> | ||
<Button | ||
icon | ||
basic | ||
title="Section help" | ||
onClick={() => { | ||
setSelectedBlock(); | ||
const tab = manage ? 0 : 1; | ||
props.setSidebarTab(tab); | ||
}} | ||
> | ||
<Icon name={helpSVG} className="" size="19px" /> | ||
</Button> | ||
</> | ||
)} | ||
</> | ||
} | ||
> | ||
{editBlock} | ||
</EditBlockWrapper> | ||
)} | ||
</BlocksForm> | ||
) : ( | ||
<RenderBlocks {...props} metadata={metadata} content={data?.data || {}} /> | ||
); | ||
}; | ||
|
||
export default GroupBlockDefaultBody; |
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
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
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