import * as Survey from "survey-knockout" ; import { SurveyNestedPropertyEditor } from "./propertyNestedPropertyEditor" ; import { SurveyPropertyEditorBase } from "./propertyEditorBase" ; import { SurveyPropertyEditorFactory } from "./propertyEditorFactory" ; import { SurveyHelper } from "../surveyHelper" ; export class SurveyPropertyCalculatedValueEditor extends SurveyNestedPropertyEditor { public static ValueBaseName = "var" ; constructor ( property ) { super ( property ) ; } public get editorType ( ) : string { return "calculated-values" ; } public get editorTypeTemplate ( ) : string { return "nested-items" ; } protected getEditorName ( ) { if ( ! this . koEditItem ( ) ) return "" ; return this . koEditItem ( ) . name ; } protected createNewItem ( ) { return new Survey . CalculatedValue ( this . getNewName ( ) ) ; } protected getColumnsProperties ( ) { var names = this . getPropertiesNames ( "calculatedvalue@items" , [ ] ) ; return this . getPropertiesByNames ( "calculatedvalue" , names ) ; } private getNewName ( ) { var objs = [ ] ; var items = this . originalValue ; for ( var i = 0 ; i < items . length ; i ++ ) { var item = items [ i ] ; if ( ! ! item ) { objs . push ( { name : item . name } ) ; } } return SurveyHelper . getNewName ( objs , SurveyPropertyCalculatedValueEditor . ValueBaseName ) ; } } SurveyPropertyEditorFactory . registerEditor ( "calculatedvalues" , function ( property ) : SurveyPropertyEditorBase { return new SurveyPropertyCalculatedValueEditor ( property ) ; } ) ;