UndoRedo

A widget encapsulating undo/redo functionality for the project of a TaskBoard.

To make use of this, the project must be configured with a State Tracking Manager.

If inserted into a TaskBoard (such as into a tbar, or bbar), the project of the that TaskBoard will be used.

If this widget is to be used "standalone" (rendered into the DOM outside of a TaskBoard), this must be configured with a reference the TaskBoard.

There are three child widgets encapsulated which may be referenced through the widgetMap:

  • undoBtn - The button which operates the undo operation
  • transactionsCombo - A combobox into which is pushed the list of transactions,
  • redoBtn - The button which operates the redo operation

The transactionsCombo may be configured away if only the buttons are required:

{
    type      : 'undoredo',
    items     : {
        transactionsCombo : null
    }
}

The example below illustrated how to embed an undoredo widget in the top toolbar of a TaskBoard:

Undo redo
//<code-header>
fiddle.title = 'Undo redo';
//</code-header>
const taskBoard = new TaskBoard({
    appendTo : targetElement,

    features : {
        columnToolbars : false
    },

    tbar : [
        { type : 'taskboardundoredo', items : { transactionsCombo : { width : '20em' } } }
    ],

    // Columns to display
    columns : [
        'todo',
        'doing',
        'done'
    ],

    // Field used to pair a task to a column
    columnField : 'status',

    // Project using inline data
    project : {
        tasks : [
            { id : 1, name : 'Task 1', status : 'doing' },
            { id : 2, name : 'Task 2', status : 'done' },
            { id : 3, name : 'Task 3', status : 'todo' },
            { id : 4, name : 'Task 4', status : 'todo' },
            { id : 5, name : 'Task 5', status : 'todo' },
            { id : 6, name : 'Task 6', status : 'doing' },
            { id : 7, name : 'Task 7', status : 'done' },
            { id : 8, name : 'Task 8', status : 'done' },
            { id : 9, name : 'Task 9', status : 'todo' },
            { id : 10, name : 'Task 10', status : 'todo' }
        ],
        // Turn on automatic undo/redo recording
        stm : {
            autoRecord : true,
            disabled   : false,

            getTransactionTitle(transaction) {
                const lastAction = transaction.queue[transaction.queue.length - 1];

                let { type, model, newData } = lastAction;

                if (lastAction.modelList && lastAction.modelList.length) {
                    model = lastAction.modelList[0];
                }

                let title = 'Transaction ' + this.position;

                if (model.isEventModel) {
                    if (type === 'UpdateAction') {
                        if (newData.status) {
                            title = `Set task ${model.name} status to ${newData.status}`;
                        }
                        else if (newData.prio) {
                            title = `Set task ${model.name} prio to ${newData.prio}`;
                        }
                        else {
                            title = `Edit task ${model.name}`;
                        }
                    }
                    else if (type === 'RemoveAction') {
                        title = `Remove task ${model.name}`;
                    }
                    else if (type === 'AddAction') {
                        title = `Add task ${model.name}`;
                    }
                }
                else if (model.isAssignmentModel) {
                    if (type === 'RemoveAction') {
                        title = `Unassigned ${model.resource.name} from ${model.event.name}`;
                    }
                    else if (type === 'UpdateAction') {
                        title = `Assigned ${model.resource.name} to ${model.event.name}`;
                    }
                }

                return title;
            }
        }
    }
});

Configs

94

Common

listenersEvents

Other

Button color for the undo and redo buttons. See color.

Configure as true to show "0" badge on the undo and redo buttons when they have no actions left to perform. By default when there are no actions, no badge is displayed.

Configure as true to show "Undo" and "Redo" as button texts. The buttons always have a tooltip as a hint to the user as to their purpose.

columnWidget
defaultFocusContainer
labelPositionContainer
renditionContainer
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

Content

defaultsContainer
itemsContainer
lazyItemsContainer
namedItemsContainer
textContentContainer

CSS

borderContainer
clsWidget
htmlClsWidget
itemClsContainer
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
hideWhenEmptyContainer
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

misc

tabBarItemsContainer

Misc

dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Record

recordContainer

Scrolling

Properties

84

Class hierarchy

isUndoRedo: Boolean= truereadonly
Identifies an object as an instance of UndoRedo class, or subclass thereof.
isUndoRedo: Boolean= truereadonlystatic
Identifies an object as an instance of UndoRedo class, or subclass thereof.
isUndoRedoBase: Boolean= truereadonlyUndoRedoBase
Identifies an object as an instance of UndoRedoBase class, or subclass thereof.
isUndoRedoBase: Boolean= truereadonlystaticUndoRedoBase
Identifies an object as an instance of UndoRedoBase class, or subclass thereof.
isContainerContainer
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isWidgetWidget

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
tooltipWidget

Other

$namestaticWidget
columnWidget
firstItemContainer
hasChangesContainer
isValidContainer
itemsContainer
labelPositionContainer
lastItemContainer
renditionContainer
rtlRTL
spanWidget
typestaticWidget
valuesContainer

Record

recordContainer

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

67

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

addContainer
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getWidgetByIdContainer
insertContainer
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
setValuesContainer
triggerEvents
unEvents
unmaskWidget

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

16
catchAllEvents
destroyEvents
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

16

Typedefs

6

CSS variables

31

Inherited