import * as ko from "knockout" ; import * as Survey from "survey-knockout" ; import { SurveyPropertyEditorBase , ISurveyObjectEditorOptions } from "./propertyEditorBase" ; import { SurveyHelper } from "../surveyHelper" ; import { editorLocalization } from "../editorLocalization" ; import { SurveyNestedPropertyEditor } from "./propertyNestedPropertyEditor" ; import { SurveyPropertyEditorFactory } from "./propertyEditorFactory" ; export class SurveyPropertyTextItemsEditor extends SurveyNestedPropertyEditor { constructor ( property ) { super ( property ) ; } public get editorType ( ) : string { return "textitems" ; } public get editorTypeTemplate ( ) : string { return "nested-items" ; } protected getEditorName ( ) { if ( ! this . koEditItem ( ) ) return "" ; return this . koEditItem ( ) . text ; } protected createNewItem ( ) { return new Survey . MultipleTextItem ( this . getNewName ( ) ) ; } protected getItemClassName ( item ) { return "multipletextitem" ; } protected getColumnsProperties ( ) { var names = this . getPropertiesNames ( "multipletext@items" , [ ] ) ; return this . getPropertiesByNames ( "multipletextitem" , 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 , editorLocalization . getString ( "ed.newTextItemName" ) ) ; } } SurveyPropertyEditorFactory . registerEditor ( "textitems" , function ( property ) : SurveyPropertyEditorBase { return new SurveyPropertyTextItemsEditor ( property ) ; } ) ;