mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-29 09:31:01 +00:00
Merge branch 'WorkflowChange' of https://github.com/Tria-plc/emaui into estif-branch-1
This commit is contained in:
@@ -140,7 +140,10 @@ export function LocationForm({
|
||||
placeholder={t('location.selectType')}
|
||||
data={allAtLevel.map((lt) => ({
|
||||
value: lt.id,
|
||||
label: lt.names[locale],
|
||||
// Not every locale is filled in on every row, and an option
|
||||
// with no label is unpickable — fall back to English, then the
|
||||
// code, which always exists.
|
||||
label: lt.names[locale] || lt.names.en || lt.code,
|
||||
}))}
|
||||
{...form.getInputProps('locationTypeId')}
|
||||
size="sm"
|
||||
|
||||
@@ -178,7 +178,7 @@ export function LocationTree({
|
||||
if (!search) return tree;
|
||||
|
||||
const matches = (loc: Location): boolean => {
|
||||
const nameMatch = loc.names.en
|
||||
const nameMatch = (loc.names.en ?? '')
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase());
|
||||
const childMatch =
|
||||
|
||||
@@ -26,7 +26,10 @@ export function locationTypeColumns(
|
||||
},
|
||||
{
|
||||
header: t('location.name'),
|
||||
cell: ({ row }) => row.original.names[locale],
|
||||
// Falls back like the type Select: a row missing this locale shows its
|
||||
// English name, then its code, rather than an empty cell.
|
||||
cell: ({ row }) =>
|
||||
row.original.names[locale] || row.original.names.en || row.original.code,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
useDeleteLocationTypeMutation,
|
||||
} from '../../api/location-api';
|
||||
import { AdvancedTable, notify, useErrorHandler, useServerTable } from '@ema-platform/ui';
|
||||
import type { LocationType } from '../../types/location';
|
||||
import { locationTypeColumns } from './columns';
|
||||
import { locationTypeColumnActions } from './actions';
|
||||
|
||||
@@ -68,12 +69,14 @@ export function LocationTypeModal({ opened, onClose }: { opened: boolean; onClos
|
||||
setShowForm(false);
|
||||
};
|
||||
|
||||
const handleEdit = (type: { id: string; code: string; names: { en: string; am: string }; level: number }) => {
|
||||
const handleEdit = (type: LocationType) => {
|
||||
setEditingId(type.id);
|
||||
form.setValues({
|
||||
code: type.code,
|
||||
namesEn: type.names.en,
|
||||
namesAm: type.names.am,
|
||||
// The form's inputs are controlled strings; a locale the row never had
|
||||
// must edit as empty rather than reading back "undefined".
|
||||
namesEn: type.names.en ?? '',
|
||||
namesAm: type.names.am ?? '',
|
||||
level: type.level,
|
||||
});
|
||||
setShowForm(true);
|
||||
|
||||
Reference in New Issue
Block a user