Raw
1 import { Command } from "../../../hooks/use-command-history"
2
3 export type DataGridBulkUpdateCommandArgs = {
4 fields: string[]
5 next: any[]
6 prev: any[]
7 setter: (fields: string[], values: any[], isHistory?: boolean) => void
8 }
9
10 export class DataGridBulkUpdateCommand implements Command {
11 private _fields: string[]
12
13 private _prev: any[]
14 private _next: any[]
15
16 private _setter: (
17 fields: string[],
18 values: any[],
19 isHistory?: boolean
20 ) => void
21
22 constructor({ fields, prev, next, setter }: DataGridBulkUpdateCommandArgs) {
23 this._fields = fields
24 this._prev = prev
25 this._next = next
26 this._setter = setter
27 }
28
29 execute(redo = false): void {
30 this._setter(this._fields, this._next, redo)
31 }
32 undo(): void {
33 this._setter(this._fields, this._prev, true)
34 }
35 redo(): void {
36 this.execute(true)
37 }
38 }