zpt
Version:
Zenon Page Templates - JS (ZPT-JS)
39 lines (26 loc) • 1.09 kB
JavaScript
/*
Class ArrayUpdate
*/
import { AbstractArrayAction } from './abstractArrayAction.js';
export const ArrayUpdate = function( object, dictionary ) {
AbstractArrayAction.call( this, object, dictionary );
this.newElement = object.newElement;
};
ArrayUpdate.prototype = Object.create( AbstractArrayAction.prototype );
ArrayUpdate.prototype.updateDictionary = function( dictionary ){
this.indexToUse = this.getIndexToUse( dictionary );
var arrayValue = this.getValue( dictionary );
arrayValue[ this.indexToUse ] = this.newElement;
};
ArrayUpdate.prototype.updateHTML = function( indexItem, parserUpdater, actionInstance ){
// Must get the nodeToUpdate
var nodeToUpdate = this.resolveChildNode( indexItem, parserUpdater );
if ( ! nodeToUpdate ){
throw 'No node found to be updated at this index: ' + this.indexToUse;
}
// Update the selected node
parserUpdater.updateNode( nodeToUpdate, true );
// Run animation
parserUpdater.runAnimation( actionInstance, nodeToUpdate );
return true;
};