import { Action , Item , ItemId , State , AppHistory } from '../interfaces' ; export default class DeleteVertexAction extends Action { prevItem : Item ; constructor ( readonly vertexIndex ) { super ( ) ; } prepare ( h ) { this . prevItem = h . state . items . get ( h . state . selIdSet . first ( ) as number ) ; return h ; } next ( state ) { return state . update ( 'items' , items => items . update ( state . selIdSet . first ( ) as number , item => ( item . supportEditVertex ( ) ? item . deleteVertex ( this . vertexIndex ) : item ) ) ) ; } prev ( state ) { return state . update ( 'items' , items => items . set ( this . prevItem . id , this . prevItem ) ) ; } getMessage ( ) { return `Delete vertex. item-id=${ this . prevItem . id }, vertex-index=${ this . vertexIndex }` ; } }