Namespace

undoRedo

kiss.undoRedo

Undo / Redo operations

This module captures the Ctrl+Z (undo) and Ctrl+Y (redo) keys then execute the corresponding callback actions.

View Source client/core/modules/undoRedo.js, line 10

Members

object

# static log

Log of all the operations

Properties:
Name Type Description
log.undo array

List of all the undo operations

log.redo array

List of all the redo operations

View Source client/core/modules/undoRedo.js, line 29

Example
kiss.undoRedo.log.undo.push({
 action: "updateField",
 createdAt: new Date(),
 modelId: "contact",
 recordId: "01927830-96f4-7167-8aad-1608c82cc415",
 fieldId: "fullname",
 oldValue: "John Doe",
 newValue: "John Doe Jr."
})

Methods

# static addOperation(operation)

Add an operation to the undo log

Parameters:
Name Type Description
operation object

Operation to add to the undo log

View Source client/core/modules/undoRedo.js, line 94

# static getOperations(order) → {Array.<object>}

Get the operations from the undo log

Parameters:
Name Type Description
order string

Order of the operations. Use "asc" (default) or "desc"

View Source client/core/modules/undoRedo.js, line 111

List of operations, in the specified order

Array.<object>

# static init(config)

Init the undo/redo module and specify the callbacks to execute when pressing Ctrl+Z or Ctrl+Y

Parameters:
Name Type Description
config object
undo function

Function to call to undo (Ctrl+Z). Can be async.

redo function

Function to call to redo (Ctrl+Y). Can be async.

View Source client/core/modules/undoRedo.js, line 53

Example
kiss.undoRedo.init({
 async undo() {
    // Undo code here
 },
 async redo() {
  // Redo code here
 }
})

kiss.undoRedo.undo() // Undo the last operation

# static redoOperation()

Redo an operation

View Source client/core/modules/undoRedo.js, line 140

# static undoOperation()

Undo an operation

View Source client/core/modules/undoRedo.js, line 122