@@ -8,7 +8,7 @@ import Configuration, { bindOptionWatchers, setEmitOptionChangedFunc } from "./c
88import { getConfig , getInnerChanges , IConfigurable , initOptionChangedFunc } from "./configuration-component" ;
99import { DX_REMOVE_EVENT } from "./constants" ;
1010import { IExtension , IExtensionComponentNode } from "./extension-component" ;
11- import { camelize , forEachChildNode , toComparable } from "./helpers" ;
11+ import { camelize , forEachChildNode , getOptionValue , toComparable } from "./helpers" ;
1212import {
1313 IEventBusHolder
1414} from "./templates-discovering" ;
@@ -23,6 +23,7 @@ interface IWidgetComponent extends IConfigurable {
2323
2424interface IBaseComponent extends IVue , IWidgetComponent , IEventBusHolder {
2525 $_isExtension : boolean ;
26+ $_applyConfigurationChanges : ( ) => void ;
2627 $_createWidget : ( element : any ) => void ;
2728 $_getIntegrationOptions : ( ) => void ;
2829 $_getExtraIntegrationOptions : ( ) => void ;
@@ -95,31 +96,8 @@ const BaseComponent: VueConstructor<IBaseComponent> = Vue.extend({
9596 }
9697 ( this as IBaseComponent ) . $_pendingOptions = { } ;
9798
98- if ( this . $_config . componentsCountChanged ) {
99- const options = this . $_config . getNestedOptionValues ( ) ;
100- const prevOptions = this . $_config . prevNestedOptions ;
101- const optionsList = Object . keys ( options ) ;
102- const prevOptionsList = Object . keys ( prevOptions ) ;
103- if ( optionsList . length < prevOptionsList . length ) {
104- prevOptionsList . forEach ( ( prevName ) => {
105- const hasOption = optionsList . some ( ( name ) => {
106- return prevName === name ;
107- } ) ;
108-
109- if ( ! hasOption ) {
110- this . $_instance . resetOption ( prevName ) ;
111- }
112- } ) ;
113- }
114-
115- for ( const name in options ) {
116- if ( options . hasOwnProperty ( name ) ) {
117- this . $_instance . option ( name , options [ name ] ) ;
118- }
119- }
99+ this . $_applyConfigurationChanges ( ) ;
120100
121- this . $_config . componentsCountChanged = false ;
122- }
123101 this . $_instance . endUpdate ( ) ;
124102 this . eventBus . $emit ( "updated" ) ;
125103 } ,
@@ -145,6 +123,19 @@ const BaseComponent: VueConstructor<IBaseComponent> = Vue.extend({
145123 } ,
146124
147125 methods : {
126+ $_applyConfigurationChanges ( ) : void {
127+ this . $_config . componentsCountChanged . forEach ( ( { optionPath, isCollection, removed } ) => {
128+ const options = this . $_config . getNestedOptionValues ( ) ;
129+
130+ if ( ! isCollection && removed ) {
131+ this . $_instance . resetOption ( optionPath ) ;
132+ } else {
133+ this . $_instance . option ( optionPath , getOptionValue ( options , optionPath ) ) ;
134+ }
135+ } ) ;
136+
137+ this . $_config . cleanComponentsCountChanged ( ) ;
138+ } ,
148139 $_createWidget ( element : any ) : void {
149140 const thisComponent = this as IBaseComponent ;
150141
0 commit comments