Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): add item title and border at bottom of header #1269

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/src/components/molecules/Content/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type Props = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
initialFormValues: Record<string, any>;
initialMetaFormValues: Record<string, unknown>;
title: string;
item?: Item;
itemId?: string;
itemLoading: boolean;
Expand Down Expand Up @@ -113,6 +114,7 @@ const ContentDetailsMolecule: React.FC<Props> = ({
modelsMenu,
initialFormValues,
initialMetaFormValues,
title,
item,
itemId,
itemLoading,
Expand Down Expand Up @@ -194,6 +196,7 @@ const ContentDetailsMolecule: React.FC<Props> = ({
<NotFound />
) : (
<ContentForm
title={title}
item={item}
linkItemModalTitle={linkItemModalTitle}
linkItemModalTotalCount={linkItemModalTotalCount}
Expand Down
5 changes: 4 additions & 1 deletion web/src/components/molecules/Content/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { DefaultField } from "./fields/FieldComponents";
import { FIELD_TYPE_COMPONENT_MAP } from "./fields/FieldTypesMap";

type Props = {
title: string;
item?: Item;
loadingReference: boolean;
linkedItemsModalList?: FormItem[];
Expand Down Expand Up @@ -122,6 +123,7 @@ type Props = {
};

const ContentForm: React.FC<Props> = ({
title,
item,
loadingReference,
linkedItemsModalList,
Expand Down Expand Up @@ -484,7 +486,7 @@ const ContentForm: React.FC<Props> = ({
initialValues={initialFormValues}
onValuesChange={handleValuesChange}>
<PageHeader
title={model?.name}
title={title}
onBack={onBack}
extra={
<>
Expand Down Expand Up @@ -724,6 +726,7 @@ const FormItemsWrapper = styled.div`
max-height: calc(100% - 72px);
overflow-y: auto;
padding: 36px;
border-top: 1px solid #00000008;
`;

const SideBarWrapper = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ export default () => {
[checkIfItemIsReferenced],
);

const title = useMemo(() => {
let result = currentModel?.name ?? "";
if (currentItem) {
const titleField = currentModel?.schema.fields.find(field => field.isTitle);
const titleValue = titleField && initialFormValues[titleField.id];
result += `/ ${titleValue || currentItem.id}`;
}
return result;
}, [currentItem, currentModel?.name, currentModel?.schema.fields, initialFormValues]);

return {
loadingReference,
linkedItemsModalList,
Expand All @@ -585,6 +595,7 @@ export default () => {
itemLoading,
requestCreationLoading,
currentModel,
title,
currentItem,
initialFormValues,
initialMetaFormValues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ContentDetails: React.FC = () => {
itemId,
itemLoading,
currentModel,
title,
currentItem,
initialFormValues,
initialMetaFormValues,
Expand Down Expand Up @@ -125,6 +126,7 @@ const ContentDetails: React.FC = () => {
/>
) : undefined
}
title={title}
item={currentItem}
itemId={itemId}
itemLoading={itemLoading}
Expand Down
Loading