Skip to content

Commit

Permalink
Client: Fixed incorrect column name keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Donkie committed Sep 16, 2023
1 parent 3b32361 commit f722ade
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion client/src/pages/filaments/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ interface IFilamentCollapsed extends Omit<IFilament, "vendor"> {
"vendor.name": string | null;
}

function translateColumnI18nKey(columnName: string): string {
columnName = columnName.replace(".", "_");
return `filament.fields.${columnName}`;
}

const namespace = "filamentList-v2";

export const FilamentList: React.FC<IResourceComponentsProps> = () => {
Expand Down Expand Up @@ -125,7 +130,7 @@ export const FilamentList: React.FC<IResourceComponentsProps> = () => {
menu={{
items: allColumns.map((column_id) => ({
key: column_id,
label: t(`filament.fields.${column_id.replace(".", "_")}`),
label: t(translateColumnI18nKey(column_id)),
})),
selectedKeys: showColumns,
selectable: true,
Expand Down
13 changes: 10 additions & 3 deletions client/src/pages/spools/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ interface ISpoolCollapsed extends ISpool {
"filament.material"?: string;
}

function translateColumnI18nKey(columnName: string): string {
columnName = columnName.replace(".", "_");
if (columnName === "combined_name") columnName = "filament_name";
else if (columnName === "filament_material") columnName = "material";
return `spool.fields.${columnName}`;
}

const namespace = "spoolList-v2";

export const SpoolList: React.FC<IResourceComponentsProps> = () => {
Expand Down Expand Up @@ -179,9 +186,9 @@ export const SpoolList: React.FC<IResourceComponentsProps> = () => {
<Dropdown
trigger={["click"]}
menu={{
items: allColumns.map((column) => ({
key: column,
label: t(`spool.fields.${column.replace(".", "_")}`),
items: allColumns.map((column_id) => ({
key: column_id,
label: t(translateColumnI18nKey(column_id)),
})),
selectedKeys: showColumns,
selectable: true,
Expand Down

0 comments on commit f722ade

Please sign in to comment.