add remove row action && table types

This commit is contained in:
Chika 2020-09-15 19:23:32 +03:00
parent 51b54abd2b
commit 2d0e254f0e
3 changed files with 20 additions and 8 deletions

View File

@ -50,13 +50,16 @@ const CalculationStore: ICalculationStore = observable(
tableName: string,
rowIndex: number,
propName: string,
value: any
value: any,
) {
this.tables[tableName].values[rowIndex][propName] = value;
},
deleteTableRow(tableName: string, rowIndex: number) {
this.tables[tableName].values.splice(rowIndex, 1);
},
},
computedEffects
)
computedEffects,
),
);
autorunEffects.map(autorunEffect =>

View File

@ -26,4 +26,5 @@ export interface ICalculationStore {
propName: string,
value: any
) => void;
deleteTableRow: (tableName: string, rowIndex: number) => void;
}

View File

@ -1,8 +1,16 @@
import { Status } from './statuses';
export type TableNames = 'fruitTable';
export type TableValuesNames = 'fruit' | 'number';
export type TTableValues<T> = {
[propName in TableValuesNames]?: T;
};
export type IStoreTable = {
[tableName: string]: {
values: Array<any>;
options?: Array<any>;
status?: Array<any>;
filter?: Array<any>;
[tableName in TableNames]: {
values: TTableValues<any>[];
options?: TTableValues<any>[];
status?: TTableValues<Status>[];
filter?: TTableValues<any>[];
};
};