mirror of
https://github.com/hexastack/hexabot
synced 2025-01-22 10:35:37 +00:00
fix: resolve block list edit form missing default values
This commit is contained in:
parent
24f0a6d85a
commit
377ef714bc
@ -181,17 +181,19 @@ const ListMessageForm = () => {
|
|||||||
}}
|
}}
|
||||||
defaultValue={content?.fields?.title}
|
defaultValue={content?.fields?.title}
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const { onChange, ...rest } = field;
|
const { onChange, value, ...rest } = field;
|
||||||
|
const options = (contentType?.fields || []).filter(
|
||||||
|
({ type }) => ContentFieldType.TEXT === type,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoCompleteSelect<ContentField, "label", false>
|
<AutoCompleteSelect<ContentField, "label", false>
|
||||||
options={(contentType?.fields || []).filter(
|
options={options}
|
||||||
({ type }) => ContentFieldType.TEXT === type,
|
|
||||||
)}
|
|
||||||
idKey="name"
|
idKey="name"
|
||||||
labelKey="label"
|
labelKey="label"
|
||||||
label={t("label.title")}
|
label={t("label.title")}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
|
{...(options.length && { value })}
|
||||||
{...rest}
|
{...rest}
|
||||||
onChange={(_e, selected) => onChange(selected?.name)}
|
onChange={(_e, selected) => onChange(selected?.name)}
|
||||||
error={!!errors?.options?.["content"]?.fields?.title}
|
error={!!errors?.options?.["content"]?.fields?.title}
|
||||||
@ -209,20 +211,22 @@ const ListMessageForm = () => {
|
|||||||
control={control}
|
control={control}
|
||||||
defaultValue={content?.fields?.subtitle}
|
defaultValue={content?.fields?.subtitle}
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const { onChange, ...rest } = field;
|
const { onChange, value, ...rest } = field;
|
||||||
|
const options = (contentType?.fields || []).filter(
|
||||||
return (
|
|
||||||
<AutoCompleteSelect<ContentField, "label", false>
|
|
||||||
options={(contentType?.fields || []).filter(
|
|
||||||
({ type }) =>
|
({ type }) =>
|
||||||
ContentFieldType.TEXT === type ||
|
ContentFieldType.TEXT === type ||
|
||||||
ContentFieldType.TEXTAREA === type,
|
ContentFieldType.TEXTAREA === type,
|
||||||
)}
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AutoCompleteSelect<ContentField, "label", false>
|
||||||
|
options={options}
|
||||||
idKey="name"
|
idKey="name"
|
||||||
labelKey="label"
|
labelKey="label"
|
||||||
label={t("label.subtitle")}
|
label={t("label.subtitle")}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onChange={(_e, selected) => onChange(selected?.name)}
|
onChange={(_e, selected) => onChange(selected?.name)}
|
||||||
|
{...(options.length && { value })}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -235,18 +239,20 @@ const ListMessageForm = () => {
|
|||||||
control={control}
|
control={control}
|
||||||
defaultValue={content?.fields?.image_url}
|
defaultValue={content?.fields?.image_url}
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const { onChange, ...rest } = field;
|
const { onChange, value, ...rest } = field;
|
||||||
|
const options = (contentType?.fields || []).filter(({ type }) =>
|
||||||
|
[ContentFieldType.FILE].includes(type),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoCompleteSelect<ContentField, "label", false>
|
<AutoCompleteSelect<ContentField, "label", false>
|
||||||
options={(contentType?.fields || []).filter(({ type }) =>
|
options={options}
|
||||||
[ContentFieldType.FILE].includes(type),
|
|
||||||
)}
|
|
||||||
idKey="name"
|
idKey="name"
|
||||||
labelKey="label"
|
labelKey="label"
|
||||||
label={t("label.image_url")}
|
label={t("label.image_url")}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onChange={(_e, selected) => onChange(selected?.name)}
|
onChange={(_e, selected) => onChange(selected?.name)}
|
||||||
|
{...(options.length && { value })}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@ -259,18 +265,20 @@ const ListMessageForm = () => {
|
|||||||
control={control}
|
control={control}
|
||||||
defaultValue={content?.fields?.url}
|
defaultValue={content?.fields?.url}
|
||||||
render={({ field }) => {
|
render={({ field }) => {
|
||||||
const { onChange, ...rest } = field;
|
const { onChange, value, ...rest } = field;
|
||||||
|
const options = (contentType?.fields || []).filter(({ type }) =>
|
||||||
|
[ContentFieldType.URL].includes(type),
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutoCompleteSelect<ContentField, "label", false>
|
<AutoCompleteSelect<ContentField, "label", false>
|
||||||
options={(contentType?.fields || []).filter(({ type }) =>
|
options={options}
|
||||||
[ContentFieldType.URL].includes(type),
|
|
||||||
)}
|
|
||||||
idKey="name"
|
idKey="name"
|
||||||
labelKey="label"
|
labelKey="label"
|
||||||
label={t("label.url")}
|
label={t("label.url")}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
onChange={(_e, selected) => onChange(selected?.name)}
|
onChange={(_e, selected) => onChange(selected?.name)}
|
||||||
|
{...(options.length && { value })}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user