* feat(dashboard): Add UI for bulk editing inventory stock (#10556) * progress * cleanup types * add changeset * fix 0 values * format schema * add delete event and allow copy/pasting enabled for some fields * add response types * add tests * work on fixing setValue behaviour * cleanup toggle logic * add loading state * format schema * add support for bidirectional actions in DataGrid and update Checkbox and RadioGroup * update lock * lint * fix 404 * address feedback * update cursor on bidirectional select
39 lines
847 B
TypeScript
39 lines
847 B
TypeScript
import { Command } from "../../../hooks/use-command-history"
|
|
|
|
export type DataGridBulkUpdateCommandArgs = {
|
|
fields: string[]
|
|
next: any[]
|
|
prev: any[]
|
|
setter: (fields: string[], values: any[], isHistory?: boolean) => void
|
|
}
|
|
|
|
export class DataGridBulkUpdateCommand implements Command {
|
|
private _fields: string[]
|
|
|
|
private _prev: any[]
|
|
private _next: any[]
|
|
|
|
private _setter: (
|
|
fields: string[],
|
|
values: any[],
|
|
isHistory?: boolean
|
|
) => void
|
|
|
|
constructor({ fields, prev, next, setter }: DataGridBulkUpdateCommandArgs) {
|
|
this._fields = fields
|
|
this._prev = prev
|
|
this._next = next
|
|
this._setter = setter
|
|
}
|
|
|
|
execute(redo = false): void {
|
|
this._setter(this._fields, this._next, redo)
|
|
}
|
|
undo(): void {
|
|
this._setter(this._fields, this._prev, true)
|
|
}
|
|
redo(): void {
|
|
this.execute(true)
|
|
}
|
|
}
|