Skip to content

Commit

Permalink
feat: add title and description
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim authored and nzambello committed Jul 5, 2021
1 parent 2390c88 commit 0b7be9f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dist
.env.development.local
.env.test.local
.env.production.local
*~
5 changes: 5 additions & 0 deletions src/components/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class Edit extends SubblocksEdit {
return (
<div className="public-ui">
<Segment>
{this.props.data.title && <h2>{this.props.data.title}</h2>}
{this.props.data.description && (
<p className="description">{this.props.data.description}</p>
)}

<SubblocksWrapper node={this.node}>
{this.state.subblocks.map((subblock, subindex) => (
<Form.Field key={subindex}>
Expand Down
4 changes: 4 additions & 0 deletions src/components/FormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const FormView = ({
<div className="block form">
<div className="public-ui">
<Segment style={{ margin: '2rem 0' }} padded>
{data.title && <h2>{data.title}</h2>}
{data.description && (
<p className="description">{data.description}</p>
)}
{formState.error ? (
<Message error role="alert">
<Message.Header as="h4">
Expand Down
33 changes: 33 additions & 0 deletions src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
SelectWidget,
ArrayWidget,
FormFieldWrapper,
TextareaWidget,
} from '@plone/volto/components';

import upSVG from '@plone/volto/icons/up-key.svg';
Expand All @@ -30,6 +31,14 @@ import deleteSVG from '@plone/volto/icons/delete.svg';
import { getFormData, exportCsvFormData, clearFormData } from '../actions';

const messages = defineMessages({
title: {
id: 'title',
defaultMessage: 'Title',
},
description: {
id: 'description',
defaultMessage: 'Description',
},
default_to: {
id: 'form_to',
defaultMessage: 'Recipients',
Expand Down Expand Up @@ -193,6 +202,30 @@ const Sidebar = ({
</h2>
</header>
<Segment>
<TextWidget
id="title"
title={intl.formatMessage(messages.title)}
required={false}
value={data.title}
onChange={(name, value) => {
onChangeBlock(block, {
...data,
[name]: value,
});
}}
/>
<TextareaWidget
id="description"
title={intl.formatMessage(messages.description)}
required={false}
value={data.description}
onChange={(name, value) => {
onChangeBlock(block, {
...data,
[name]: value,
});
}}
/>
<TextWidget
id="default_to"
title={intl.formatMessage(messages.default_to)}
Expand Down

0 comments on commit 0b7be9f

Please sign in to comment.