Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh committed Jan 21, 2025
1 parent d41e605 commit 5f66a77
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,16 @@ function deleteBlock(formData, blockId: string) {
* ```
*/
const ObjectListWidget = (props: BlocksObjectWidgetProps) => {
const { block, fieldSet, id, schema, value, onChange, schemaExtender } =
props;
const {
block,
fieldSet,
id,
schema,
value,
onChange,
schemaExtender,
error,
} = props;
const [localActiveObject, setLocalActiveObject] = useState(
props.activeObject ?? value?.blocks_layout?.items?.length - 1,
);
Expand Down Expand Up @@ -319,6 +327,7 @@ const ObjectListWidget = (props: BlocksObjectWidgetProps) => {
},
});
}}
errors={error}
/>
</Segment>
</Accordion.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,47 +57,46 @@ const messages = defineMessages({
},
});

const FooterLinksWidget = (props) => {
const { value, onChange } = props;
const intl = useIntl();

function schema(props: BlockEditProps) {
return {
title: intl.formatMessage(messages.item),
addMessage: intl.formatMessage(messages.addLink),
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['title', 'href', 'openLinkInNewTab'],
},
],
export function JSONSchemaField({ intl }) {
return {
title: intl.formatMessage(messages.item),
addMessage: intl.formatMessage(messages.addLink),
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['title', 'href', 'openLinkInNewTab'],
},
],

properties: {
title: {
title: intl.formatMessage(messages.title),
},
href: {
title: intl.formatMessage(messages.Target),
widget: 'object_browser',
mode: 'link',
selectedItemAttrs: ['Title', 'Description', '@type'],
allowExternals: true,
},
openLinkInNewTab: {
title: intl.formatMessage(messages.openLinkInNewTab),
type: 'boolean',
},
properties: {
title: {
title: intl.formatMessage(messages.title),
},
href: {
title: intl.formatMessage(messages.Target),
widget: 'object_browser',
mode: 'link',
selectedItemAttrs: ['Title', 'Description', '@type'],
allowExternals: true,
},
required: [],
};
}
openLinkInNewTab: {
title: intl.formatMessage(messages.openLinkInNewTab),
type: 'boolean',
},
},
required: ['title'],
};
}

const FooterLinksWidget = (props) => {
const { value, onChange } = props;

return (
<BlocksObjectWidget
{...props}
value={value}
schema={schema}
schema={JSONSchemaField}
onChange={onChange}
/>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/volto-light-theme/src/config/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import FooterLogosWidget from '../components/Widgets/FooterLogosWidget';
import FooterLinksWidget from '../components/Widgets/FooterLinksWidget';
import SizeWidget from '../components/Widgets/SizeWidget';
import ThemeColorPicker from '../components/Widgets/ThemeColorPicker';
import { JSONSchemaField } from '../components/Widgets/FooterLinksWidget';

declare module '@plone/types' {
export interface WidgetsConfigByWidget {
Expand All @@ -30,5 +31,12 @@ export default function install(config: ConfigType) {
config.widgets.widget.footerLinks = FooterLinksWidget;
config.widgets.widget.sizeWidget = SizeWidget;

config.registerUtility({
name: 'footer_links',
type: 'schema',
dependencies: { fieldName: 'footer_links' },
method: JSONSchemaField,
});

return config;
}

0 comments on commit 5f66a77

Please sign in to comment.