RootOperation
Operation that creates (or attaches) or detaches a root element.
Properties
affectedSelectable : ModelSelectablereadonlymodule:engine/model/operation/rootoperation~RootOperation#affectedSelectableA selectable that will be affected by the operation after it is executed.
The exact returned parameter differs between operation types.
baseVersion : null | numberinheritedmodule:engine/model/operation/rootoperation~RootOperation#baseVersionversionon which operation can be applied. If you try to apply operation with different base version than the document version the model-document-applyOperation-wrong-version error is thrown.module:engine/model/operation/rootoperation~RootOperation#batchBatch to which the operation is added or
nullif the operation is not added to any batch yet.Note, that a non-document operation has this property always set to
null, and is never added to any batch.elementName : stringreadonlymodule:engine/model/operation/rootoperation~RootOperation#elementNameRoot element name.
isAdd : booleanreadonlymodule:engine/model/operation/rootoperation~RootOperation#isAddSpecifies whether the operation adds (
true) or detaches the root (false).isDocumentOperation : booleanreadonlyinheritedmodule:engine/model/operation/rootoperation~RootOperation#isDocumentOperationDefines whether operation is executed on attached or detached items.
rootName : stringreadonlymodule:engine/model/operation/rootoperation~RootOperation#rootNameRoot name to create or detach.
type : 'addRoot' | 'detachRoot'readonlymodule:engine/model/operation/rootoperation~RootOperation#typeOperation type.
_document : ModelDocumentprivatereadonlymodule:engine/model/operation/rootoperation~RootOperation#_documentDocument which owns the root.
Static properties
className : stringreadonlystaticmodule:engine/model/operation/rootoperation~RootOperation.classNameName of the operation class used for serialization.
Methods
constructor( rootName, elementName, isAdd, document, baseVersion )module:engine/model/operation/rootoperation~RootOperation#constructorCreates an operation that creates or removes a root element.
Parameters
rootName : stringRoot name to create or detach.
elementName : stringRoot element name.
isAdd : booleanSpecifies whether the operation adds (
true) or detaches the root (false).document : ModelDocumentDocument which owns the root.
baseVersion : numberDocument
versionon which operation can be applied.
clone() → RootOperationmodule:engine/model/operation/rootoperation~RootOperation#cloneCreates and returns an operation that has the same parameters as this operation.
Returns
RootOperationClone of this operation.
module:engine/model/operation/rootoperation~RootOperation#getReversedCreates and returns a reverse operation. Reverse operation when executed right after the original operation will bring back tree model state to the point before the original operation execution. In other words, it reverses changes done by the original operation.
Keep in mind that tree model state may change since executing the original operation, so reverse operation will be "outdated". In that case you will need to transform it by all operations that were executed after the original operation.
Returns
RootOperationReversed operation.
toJSON() → unknownmodule:engine/model/operation/rootoperation~RootOperation#toJSONCustom toJSON method to solve child-parent circular dependencies.
Returns
unknownClone of this object with the operation property replaced with string.
_execute() → voidinternalmodule:engine/model/operation/rootoperation~RootOperation#_executeExecutes the operation - modifications described by the operation properties will be applied to the model tree.
Returns
void
_validate() → voidinternalinheritedmodule:engine/model/operation/rootoperation~RootOperation#_validateChecks whether the operation's parameters are correct and the operation can be correctly executed. Throws an error if operation is not valid.
Returns
void
Static methods
fromJSON( json, document ) → RootOperationstaticmodule:engine/model/operation/rootoperation~RootOperation.fromJSONCreates
RootOperationobject from deserialized object, i.e. from parsed JSON string.Parameters
json : anyDeserialized JSON object.
document : ModelDocumentDocument on which this operation will be applied.
Returns