first attempt with deleting rows. deep diff algorithm needs more time in the cooker
This commit is contained in:
parent
041de66c64
commit
6d1e011621
2 changed files with 33 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
import { Accessor, Component, createContext, createEffect, createMemo, createRenderEffect, createSignal, createUniqueId, For, onMount, ParentComponent, Show, useContext } from "solid-js";
|
||||
import { createStore, unwrap } from "solid-js/store";
|
||||
import { createStore, produce, unwrap } from "solid-js/store";
|
||||
import { SelectionProvider, useSelection, selectable } from "../selectable";
|
||||
import { debounce, deepCopy, deepDiff, Mutation } from "~/utilities";
|
||||
import css from './grid.module.css';
|
||||
|
@ -17,6 +17,7 @@ export interface GridContextType {
|
|||
readonly mutations: Accessor<Mutation[]>;
|
||||
readonly selection: Accessor<SelectionItem[]>;
|
||||
mutate(prop: string, lang: string, value: string): void;
|
||||
remove(props: string[]): void;
|
||||
}
|
||||
|
||||
export interface GridApi {
|
||||
|
@ -25,6 +26,7 @@ export interface GridApi {
|
|||
readonly mutations: Accessor<Mutation[]>;
|
||||
selectAll(): void;
|
||||
clear(): void;
|
||||
remove(keys: string[]): void;
|
||||
}
|
||||
|
||||
const GridContext = createContext<GridContextType>();
|
||||
|
@ -60,6 +62,20 @@ const GridProvider: ParentComponent<{ rows: Rows }> = (props) => {
|
|||
mutate(prop: string, lang: string, value: string) {
|
||||
setState('rows', prop, lang, value);
|
||||
},
|
||||
|
||||
remove(props: string[]) {
|
||||
console.log(props);
|
||||
|
||||
|
||||
setState('rows', produce(rows => {
|
||||
for (const prop of props) {
|
||||
delete rows[prop];
|
||||
}
|
||||
|
||||
return rows;
|
||||
}));
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
return <GridContext.Provider value={ctx}>
|
||||
|
@ -124,6 +140,9 @@ const Api: Component<{ api: undefined | ((api: GridApi) => any) }> = (props) =>
|
|||
clear() {
|
||||
selectionContext.clear();
|
||||
},
|
||||
remove(props: string[]) {
|
||||
gridContext.remove(props);
|
||||
},
|
||||
};
|
||||
|
||||
createEffect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue