@@ -557,6 +557,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
557
557
element . closest ( ".svc-question__drag-area" ) && ! element . closest ( ".svc-question__top-actions" ) ||
558
558
element . closest ( ".sd-element__header" ) && ! element . closest ( ".svc-string-editor" ) ;
559
559
}
560
+
560
561
protected updateQuestionTypeOrSubtypeListModel ( listModel : ListModel , subtypeOnly : boolean ) {
561
562
const availableItems = this . getConvertToTypes ( ) ;
562
563
const defaultJsons = this . buildDefaultJsonMap ( availableItems ) ;
@@ -565,25 +566,32 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
565
566
let selectedAction : IAction ;
566
567
let selectedSubaction : IAction = undefined ;
567
568
let selectedSubactions = undefined ;
569
+
570
+ const toolboxItemToAction = ( item , needSeparator = false ) => {
571
+ return this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
572
+ } ;
573
+
568
574
availableItems . forEach ( ( item : QuestionToolboxItem ) => {
569
575
const needSeparator = lastItem && item . category != lastItem . category ;
570
- const action = this . creator . createIActionBarItemByClass ( item , needSeparator , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
576
+ const action = toolboxItemToAction ( item , needSeparator ) ;
571
577
if ( this . toolboxItemIsCorresponded ( item , ! ! selectedAction ) ) {
572
578
selectedAction = action ;
573
- selectedSubactions = item . items ;
579
+ if ( item . items ) {
580
+ selectedSubactions = item . items . map ( subitem => toolboxItemToAction ( subitem ) ) ;
581
+ }
574
582
}
575
583
if ( item . items ?. length > 0 && this . creator . toolbox . showSubitems ) {
576
584
const subactions = [ ] ;
577
585
let selectedSubactionLocal : IAction = undefined ;
578
586
let allChildsAreCompatibleToParent = false ;
579
587
item . items . forEach ( subitem => {
580
- const subaction = this . creator . createIActionBarItemByClass ( subitem , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
588
+ const subaction = toolboxItemToAction ( subitem , ) ;
581
589
if ( this . toolboxItemIsCorresponded ( subitem , ! ! selectedAction ) ) selectedSubactionLocal = subitem ;
582
590
if ( this . jsonsAreCompatible ( item . json , subitem . json ) ) allChildsAreCompatibleToParent = true ;
583
591
subactions . push ( subaction ) ;
584
592
} ) ;
585
593
if ( ! allChildsAreCompatibleToParent && subactions . length > 0 ) {
586
- const defaultSubaction = this . creator . createIActionBarItemByClass ( item , false , ( questionType , json ) => { this . convertQuestion ( questionType , json , defaultJsons ) ; } ) ;
594
+ const defaultSubaction = toolboxItemToAction ( item ) ;
587
595
defaultSubaction . id = action . id + "-default" ;
588
596
defaultSubaction . iconName = undefined ;
589
597
defaultSubaction . markerIconName = undefined ;
@@ -626,12 +634,12 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
626
634
cssClasses : listComponentCss ,
627
635
} ) ;
628
636
this . updateQuestionTypeOrSubtypeListModel ( listModel , true ) ;
629
- if ( listModel . actions . length == 0 ) return null ;
630
-
637
+ const propName = QuestionToolbox . getSubTypePropertyName ( this . surveyElement . getType ( ) ) ;
638
+ if ( ! listModel . selectedItem && ! propName ) return null ;
631
639
const actionData : IAction = {
632
640
id : "convertInputType" ,
633
641
visibleIndex : 1 ,
634
- title : listModel . selectedItem ?. title || "SUBTYPE" ,
642
+ title : listModel . selectedItem ?. title || editorLocalization . getPropertyValueInEditor ( propName , this . surveyElement . getPropertyValue ( propName ) ) || "SUBTYPE" ,
635
643
disableShrink : true ,
636
644
iconName : "icon-chevron_16x16"
637
645
} ;
@@ -642,14 +650,13 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
642
650
this . updateQuestionTypeOrSubtypeListModel ( listModel , true ) ;
643
651
}
644
652
} ) ;
645
-
646
653
this . surveyElement . registerFunctionOnPropertiesValueChanged (
647
- [ "inputType" , "rateType" ] ,
648
- ( ) => {
654
+ [ propName ] ,
655
+ ( newValue ) => {
649
656
const popup = newAction . popupModel ;
650
657
const list = popup . contentComponentData . model ;
651
658
this . updateQuestionTypeOrSubtypeListModel ( list , true ) ;
652
- newAction . title = list . selectedItem . title ;
659
+ newAction . title = list . selectedItem ? .title || editorLocalization . getPropertyValueInEditor ( propName , newValue ) || "SUBTYPE" ;
653
660
} ,
654
661
"inputTypeAdorner"
655
662
) ;
0 commit comments