fix adding of language
This commit is contained in:
parent
aadc27262a
commit
4fba9cc23c
2 changed files with 24 additions and 7 deletions
|
@ -11,7 +11,7 @@ export interface GridApi {
|
|||
readonly selection: Accessor<SelectionItem<number, Entry>[]>;
|
||||
remove(indices: number[]): void;
|
||||
addKey(key: string): void;
|
||||
addLocale(locale: string): void;
|
||||
// addLocale(locale: string): void;
|
||||
};
|
||||
|
||||
const groupBy = (rows: DataSetRowNode<number, Entry>[]) => {
|
||||
|
@ -49,6 +49,15 @@ export function Grid(props: { class?: string, rows: Entry[], locales: string[],
|
|||
|
||||
const [api, setApi] = createSignal<GridCompApi<Entry>>();
|
||||
|
||||
createEffect(() => {
|
||||
const r = rows();
|
||||
const l = locales();
|
||||
|
||||
r.mutateEach(({ key, ...rest }) => {
|
||||
return ({ key, ...Object.fromEntries(l.map(locale => [locale, rest[locale] ?? ''])) });
|
||||
});
|
||||
});
|
||||
|
||||
createEffect(() => {
|
||||
const r = rows();
|
||||
|
||||
|
@ -59,9 +68,6 @@ export function Grid(props: { class?: string, rows: Entry[], locales: string[],
|
|||
addKey(key) {
|
||||
r.insert({ key, ...Object.fromEntries(locales().map(l => [l, ''])) });
|
||||
},
|
||||
addLocale(locale) {
|
||||
r.mutateEach(entry => ({ ...entry, [locale]: '' }));
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue