Skip to content

Commit

Permalink
fix : Content: No Fields Have Been Added Screen appears for Content I…
Browse files Browse the repository at this point in the history
…tems that have fields (#2519)

* Showing only "No fields have been added" for those without fields yet

* Updating the ItemCreate to pass newlyfields and adjusting the withloader so once the withloader done , the fields are already rendered

* remove redundancy of fields
  • Loading branch information
glespinosa authored Mar 14, 2024
1 parent 5af3cda commit 4c1b35d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/apps/content-editor/src/app/components/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { ThemeProvider } from "@mui/material";
import { theme } from "@zesty-io/material";
import { Breadcrumbs } from "shell/components/global-tabs/components/Breadcrumbs";
import { Field } from "./Field";
import { useGetContentModelFieldsQuery } from "../../../../../../shell/services/instance";
import { FieldError } from "./FieldError";

import styles from "./Editor.less";
import { cloneDeep } from "lodash";
import { useGetContentModelFieldsQuery } from "../../../../../../shell/services/instance";

export const MaxLengths = {
text: 150,
Expand Down Expand Up @@ -207,6 +207,7 @@ export default memo(function Editor({
{saveClicked && hasErrors && (
<FieldError errors={fieldErrors} fields={activeFields} />
)}

{activeFields.length ? (
activeFields.map((field) => {
return (
Expand Down
13 changes: 12 additions & 1 deletion src/apps/content-editor/src/app/views/ItemCreate/ItemCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { AppState } from "../../../../../../shell/store/types";
import {
useCreateItemPublishingMutation,
useGetContentItemQuery,
useGetContentModelFieldsQuery,
} from "../../../../../../shell/services/instance";
import { ScheduleFlyout } from "../ItemEdit/components/Header/ItemVersioning/ScheduleFlyout";
import { Error } from "../../components/Editor/Field/FieldShell";
Expand Down Expand Up @@ -85,6 +86,11 @@ export const ItemCreate = () => {
skip: !newItemZUID,
});

const {
isSuccess: isSuccessNewModelFields,
isFetching: isFetchingNewModelFields,
} = useGetContentModelFieldsQuery(modelZUID);

// on mount and update modelZUID, load item fields
useEffect(() => {
loadItemFields(modelZUID);
Expand Down Expand Up @@ -268,7 +274,12 @@ export const ItemCreate = () => {
}

return (
<WithLoader condition={!loading && item} message="Creating New Item">
<WithLoader
condition={
!loading && item && isSuccessNewModelFields && !isFetchingNewModelFields
}
message="Creating New Item"
>
<Box component="section">
<Header
onSave={save}
Expand Down

0 comments on commit 4c1b35d

Please sign in to comment.