fix: 🐛 update wysiwyg content when changing value on dynamic fields
This commit is contained in:
parent
cd6d4dbce7
commit
ab2e9e09c6
1 changed files with 8 additions and 7 deletions
|
|
@ -72,8 +72,9 @@ export default function Form({
|
|||
const enumUserRole = usePage().props.enumUserRole as LaravelEnum;
|
||||
const enumDynamicPageStatus = usePage().props.enumDynamicPageStatus as LaravelEnum;
|
||||
const pageConfigModels = usePage().props.pageConfigModels as Array<PageConfigModel>;
|
||||
const defaultConfigId = 0;
|
||||
const configOptions = [{
|
||||
'id': 0,
|
||||
'id': defaultConfigId,
|
||||
'label': {},
|
||||
'config': {},
|
||||
'policies': {
|
||||
|
|
@ -87,7 +88,7 @@ export default function Form({
|
|||
'updated_at': new Date,
|
||||
'deleted_at': new Date,
|
||||
} as PageConfigModel, ...pageConfigModels];
|
||||
configOptions[0].label[locale] = useTrans('back.config_none_selected');
|
||||
configOptions[defaultConfigId].label[locale] = useTrans('back.config_none_selected');
|
||||
const contentAssociateToModel = str(
|
||||
useTrans("back.form_associate_to", {
|
||||
params: { attribute: useTrans("validation.attributes.content") },
|
||||
|
|
@ -109,7 +110,7 @@ export default function Form({
|
|||
const { post, patch, setData, data } = useForm({
|
||||
title: model?.title ? model?.title[locale]: "",
|
||||
content: model?.content ? model?.content[locale]: "",
|
||||
config_id: model?.config_id ?? configOptions[0].id,
|
||||
config_id: model?.config_id ?? configOptions[defaultConfigId].id,
|
||||
status: model?.status ?? enumDynamicPageStatus.draft.value,
|
||||
isLocked: model?.isLocked ?? false,
|
||||
});
|
||||
|
|
@ -149,7 +150,7 @@ export default function Form({
|
|||
useEffect(() => {
|
||||
setData("title", model?.title ? model?.title[locale]: "");
|
||||
setData("content", model?.content ? model?.content[locale]: "");
|
||||
setData("config_id", model?.config_id ?? configOptions[0].id);
|
||||
setData("config_id", model?.config_id ?? configOptions[defaultConfigId].id);
|
||||
setData("status", model?.status ?? enumDynamicPageStatus.draft.value);
|
||||
setData("isLocked", model?.isLocked ?? false);
|
||||
}, [locale]);
|
||||
|
|
@ -234,7 +235,7 @@ export default function Form({
|
|||
required={false}
|
||||
setData={setData}
|
||||
/>
|
||||
{userModel.role === enumUserRole.conceptor.value && data.config_id != 0 && (
|
||||
{userModel.role === enumUserRole.conceptor.value && data.config_id != defaultConfigId && (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
|
|
@ -265,12 +266,12 @@ export default function Form({
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
{data.config_id == 0 ? (
|
||||
{data.config_id == defaultConfigId ? (
|
||||
<SimpleWysiwyg
|
||||
name="content"
|
||||
model="DynamicPage"
|
||||
label={contentAssociateToModel}
|
||||
value={String(data.content)}
|
||||
value={String(typeof data.content === "string" ? data.content : "")}
|
||||
setData={setData}
|
||||
/>
|
||||
) : (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue