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 38

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

// List of all the undo operations
console.log(kiss.undoRedo.undo.log)

// Undo the last operation, add it to the redo log
kiss.undoRedo.undo() 

console.log(kiss.undoRedo.undo.log) // List of all the undo operations
console.log(kiss.undoRedo.redo.log) // List of all the redo operations

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 103

# 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 120

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 62

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 149

# static undoOperation()

Undo an operation

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

Members

Methods