Skip to content

Commit

Permalink
fix(app-aco): add support for titleFieldId defined in the content m…
Browse files Browse the repository at this point in the history
…odel (#3554)
  • Loading branch information
leopuleo committed Oct 3, 2023
1 parent 770a185 commit 115653b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/app-aco/src/contexts/acoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const getCurrentRecordList = <T = GenericSearchData,>(
export interface AcoListProviderProps {
children: React.ReactNode;
own?: boolean;
titleFieldId: string | null;
}

export const AcoListProvider: React.VFC<AcoListProviderProps> = ({ children, ...props }) => {
Expand Down Expand Up @@ -208,7 +209,10 @@ export const AcoListProvider: React.VFC<AcoListProviderProps> = ({ children, ...
*/
useEffect(() => {
setFolders(prev => {
return sortTableItems(prev, state.listSort);
const titleField = props?.titleFieldId || "id";
return sortTableItems(prev, state.listSort, {
[titleField]: "title"
});
});
}, [state.listSort]);

Expand Down
2 changes: 1 addition & 1 deletion packages/app-aco/src/contexts/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export const AcoAppProvider: React.VFC<AcoAppProviderProps> = ({
createListLink={createNavigateFolderListLink}
createStorageKey={createNavigateFolderStorageKey}
>
<AcoListProvider own={own}>
<AcoListProvider own={own} titleFieldId={model.titleFieldId}>
<DialogsContextProvider>{children}</DialogsContextProvider>
</AcoListProvider>
</NavigateFolderWithRouterProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export const Table = forwardRef<HTMLDivElement, Props>((props, ref) => {
);

const columns: Columns<Entry> = useMemo(() => {
const titleColumnId = model.titleFieldId || "id";

return {
title: {
[titleColumnId]: {
header: "Name",
className: "cms-aco-list-title",
cell: (record: Entry) => {
Expand Down

0 comments on commit 115653b

Please sign in to comment.