Skip to content

Commit

Permalink
fix name field beeing undefined if emtpy, rename field name to author
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaspiterek committed Feb 2, 2024
1 parent 6e70caa commit 35ee667
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 60 deletions.
10 changes: 5 additions & 5 deletions locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ msgstr ""
msgid "Additional information"
msgstr "Zusatzinformationen"

#: components/schema
# defaultMessage: Author
msgid "Author"
msgstr "Autor"

#: components/schema
# defaultMessage: Cite
msgid "Cite"
Expand All @@ -31,11 +36,6 @@ msgstr "Bild"
msgid "Language"
msgstr "Sprache"

#: components/schema
# defaultMessage: Name
msgid "Name"
msgstr "Name"

#: components/schema
# defaultMessage: Quote
msgid "Quote"
Expand Down
10 changes: 5 additions & 5 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ msgstr ""
msgid "Additional information"
msgstr ""

#: components/schema
# defaultMessage: Author
msgid "Author"
msgstr ""

#: components/schema
# defaultMessage: Cite
msgid "Cite"
Expand All @@ -31,11 +36,6 @@ msgstr ""
msgid "Language"
msgstr ""

#: components/schema
# defaultMessage: Name
msgid "Name"
msgstr ""

#: components/schema
# defaultMessage: Quote
msgid "Quote"
Expand Down
12 changes: 6 additions & 6 deletions locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2024-01-30T09:51:05.697Z\n"
"POT-Creation-Date: 2024-02-02T08:52:19.982Z\n"
"Last-Translator: Plone i18n <[email protected]>\n"
"Language-Team: Plone i18n <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand All @@ -18,6 +18,11 @@ msgstr ""
msgid "Additional information"
msgstr ""

#: components/schema
# defaultMessage: Author
msgid "Author"
msgstr ""

#: components/schema
# defaultMessage: Cite
msgid "Cite"
Expand All @@ -33,11 +38,6 @@ msgstr ""
msgid "Language"
msgstr ""

#: components/schema
# defaultMessage: Name
msgid "Name"
msgstr ""

#: components/schema
# defaultMessage: Quote
msgid "Quote"
Expand Down
22 changes: 12 additions & 10 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import config from '@plone/volto/registry';
import { flattenToAppURL } from '@plone/volto/helpers';
import cx from 'classnames';
import { DetachedTextBlockEditor } from '@plone/volto-slate/blocks/Text/DetachedTextBlockEditor';
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
import React from "react";
import config from "@plone/volto/registry";
import { flattenToAppURL } from "@plone/volto/helpers";
import cx from "classnames";
import { DetachedTextBlockEditor } from "@plone/volto-slate/blocks/Text/DetachedTextBlockEditor";
import { TextBlockView } from "@plone/volto-slate/blocks/Text";

const View = (props) => {
const { data, isEditMode } = props;
Expand All @@ -13,7 +13,7 @@ const View = (props) => {
slateSettings: {
...config.settings.slate,
toolbarButtons: config.settings.slate.toolbarButtons.filter(
(index) => index - config.settings.slate.toolbarButtons,
(index) => index - config.settings.slate.toolbarButtons
),
},
};
Expand All @@ -25,7 +25,7 @@ const View = (props) => {
data.image?.[0] && (
<div className="image-wrapper">
<img
src={`${flattenToAppURL(data.image?.[0]?.['@id'])}/${
src={`${flattenToAppURL(data.image?.[0]?.["@id"])}/${
data.image?.[0]?.image_scales?.image[0]?.scales?.preview
?.download
}}`}
Expand All @@ -37,15 +37,17 @@ const View = (props) => {
)}
<blockquote
cite={data.cite}
className={cx(data.language, isEditMode && 'edit')}
className={cx(data.language, isEditMode && "edit")}
>
{!isEditMode ? (
<TextBlockView {...props} />
) : (
<DetachedTextBlockEditor {...customSlateSettings} />
)}
<footer>
{`${data.name}, `}
{data.author && data.additional_information
? data.author + ", "
: data.author}
{data.additional_information && data.cite ? (
<cite>{data.additional_information}</cite>
) : (
Expand Down
68 changes: 34 additions & 34 deletions src/components/schema.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import config from '@plone/volto/registry';
import { defineMessages } from 'react-intl';
import config from "@plone/volto/registry";
import { defineMessages } from "react-intl";

const messages = defineMessages({
quote: {
id: 'Quote',
defaultMessage: 'Quote',
id: "Quote",
defaultMessage: "Quote",
},
language: {
id: 'Language',
defaultMessage: 'Language',
id: "Language",
defaultMessage: "Language",
},
image: {
id: 'Image',
defaultMessage: 'Image',
id: "Image",
defaultMessage: "Image",
},
name: {
id: 'Name',
defaultMessage: 'Name',
author: {
id: "Author",
defaultMessage: "Author",
},
additional_information: {
id: 'Additional information',
defaultMessage: 'Additional information',
id: "Additional information",
defaultMessage: "Additional information",
},
cite: {
id: 'Cite',
defaultMessage: 'Cite',
id: "Cite",
defaultMessage: "Cite",
},
description: {
id: 'This field expects an URL as input (optional). If an URL is provided the additional information will have a relation to this URL, this is due to accessibility norms.',
id: "This field expects an URL as input (optional). If an URL is provided the additional information will have a relation to this URL, this is due to accessibility norms.",
defaultMessage:
'This field expects an URL as input (optional). If an URL is provided the additional information will have a relation to this URL, this is due to accessibility norms.',
"This field expects an URL as input (optional). If an URL is provided the additional information will have a relation to this URL, this is due to accessibility norms.",
},
});

Expand All @@ -38,14 +38,14 @@ export const QuoteBlockSchema = ({ intl }) => {
const allowed_languages =
config.blocks?.blocksConfig?.quote?.allowed_languages;
const DEFAULT_LANGUAGES = [
['EN', 'EN'],
['DE', 'DE'],
["EN", "EN"],
["DE", "DE"],
];

const filterDefaultLanguages = () => {
if (allowed_languages) {
return DEFAULT_LANGUAGES.filter((item) =>
allowed_languages.includes(item[0]),
allowed_languages.includes(item[0])
);
} else {
return DEFAULT_LANGUAGES;
Expand All @@ -54,19 +54,19 @@ export const QuoteBlockSchema = ({ intl }) => {

return {
title: intl.formatMessage(messages.quote),
block: 'quote',
block: "quote",
fieldsets: [
{
id: 'default',
title: 'Default',
id: "default",
title: "Default",
fields: config?.blocks?.blocksConfig?.quote?.showImageField
? ['language', 'image']
: ['language'],
? ["language", "image"]
: ["language"],
},
{
id: 'person',
title: 'Person',
fields: ['name', 'additional_information', 'cite'],
id: "person",
title: "Person",
fields: ["author", "additional_information", "cite"],
},
],
properties: {
Expand All @@ -78,20 +78,20 @@ export const QuoteBlockSchema = ({ intl }) => {
},
image: {
title: intl.formatMessage(messages.image),
widget: 'object_browser',
mode: 'image',
widget: "object_browser",
mode: "image",
allowExternals: true,
selectedItemAttrs: ['image_field', 'image_scales'],
selectedItemAttrs: ["image_field", "image_scales"],
},
name: {
title: intl.formatMessage(messages.name),
author: {
title: intl.formatMessage(messages.author),
},
additional_information: {
title: intl.formatMessage(messages.additional_information),
},
cite: {
title: intl.formatMessage(messages.cite),
widget: 'url',
widget: "url",
description: intl.formatMessage(messages.description),
},
},
Expand Down

0 comments on commit 35ee667

Please sign in to comment.