|
1
|
import { Command } from "../../../hooks/commands/use-command-history"; |
|
2
|
|
|
3
|
export type DataGridUpdateCommandArgs = { |
|
4
|
prev: any; |
|
5
|
next: any; |
|
6
|
setter: (value: any) => void; |
|
7
|
}; |
|
8
|
|
|
9
|
export class DataGridUpdateCommand implements Command { |
|
10
|
private _prev: any; |
|
11
|
private _next: any; |
|
12
|
|
|
13
|
private _setter: (value: any) => void; |
|
14
|
|
|
15
|
constructor({ prev, next, setter }: DataGridUpdateCommandArgs) { |
|
16
|
this._prev = prev; |
|
17
|
this._next = next; |
|
18
|
|
|
19
|
this._setter = setter; |
|
20
|
} |
|
21
|
|
|
22
|
execute(): void { |
|
23
|
this._setter(this._next); |
|
24
|
} |
|
25
|
|
|
26
|
undo(): void { |
|
27
|
this._setter(this._prev); |
|
28
|
} |
|
29
|
|
|
30
|
redo(): void { |
|
31
|
this.execute(); |
|
32
|
} |
|
33
|
} |