@@ -742,7 +742,7 @@ export class UserValue {
742
742
* Opens the widget (only meaningful for widgets that can be opened).
743
743
*/
744
744
open ( ) {
745
- this . env . userValueWidgetOpening ( ) ;
745
+ this . env . userValueWidgetOpening ( this ) ;
746
746
this . _state . opened = true ;
747
747
}
748
748
/**
@@ -10164,28 +10164,36 @@ export class MultipleItems extends SnippetOption {
10164
10164
_removeItemCallback ( $target ) { }
10165
10165
}
10166
10166
10167
- legacyRegistry . SelectTemplate = SnippetOptionWidget . extend ( {
10168
- custom_events : Object . assign ( { } , SnippetOptionWidget . prototype . custom_events , {
10169
- 'user_value_widget_opening' : '_onWidgetOpening' ,
10170
- } ) ,
10167
+ export class SelectTemplateComponent extends SnippetOptionComponent {
10168
+ setup ( ) {
10169
+ super . setup ( ) ;
10170
+ useChildSubEnv ( {
10171
+ userValueWidgetOpening : ( userValue ) => {
10172
+ this . env . userValueWidgetOpening ( userValue ) ;
10173
+ this . props . snippetOption . instance . onUserValueWidgetOpening ( userValue ) ;
10174
+ } ,
10175
+ } ) ;
10176
+ }
10177
+ }
10171
10178
10179
+ export class SelectTemplate extends SnippetOption {
10172
10180
/**
10173
- * @constructor
10181
+ * @override
10174
10182
*/
10175
- init ( ) {
10176
- this . _super ( ...arguments ) ;
10183
+ static defaultRenderingComponent = SelectTemplateComponent ;
10184
+
10185
+ constructor ( ) {
10186
+ super ( ...arguments ) ;
10177
10187
this . containerSelector = '' ;
10178
10188
this . selectTemplateWidgetName = '' ;
10179
- this . orm = this . bindService ( "orm" ) ;
10180
- } ,
10181
- /**
10182
- * @constructor
10183
- */
10184
- async start ( ) {
10189
+ this . orm = this . env . services . orm ;
10190
+ }
10191
+
10192
+ async willStart ( ) {
10193
+ await super . willStart ( ...arguments ) ;
10185
10194
this . containerEl = this . containerSelector ? this . $target . find ( this . containerSelector ) [ 0 ] : this . $target [ 0 ] ;
10186
10195
this . _templates = { } ;
10187
- return this . _super ( ...arguments ) ;
10188
- } ,
10196
+ }
10189
10197
10190
10198
//--------------------------------------------------------------------------
10191
10199
// Options
@@ -10234,7 +10242,7 @@ legacyRegistry.SelectTemplate = SnippetOptionWidget.extend({
10234
10242
// added by other options or custo).
10235
10243
this . beforePreviewNodes = null ;
10236
10244
}
10237
- } ,
10245
+ }
10238
10246
10239
10247
//--------------------------------------------------------------------------
10240
10248
// Private
@@ -10245,7 +10253,7 @@ legacyRegistry.SelectTemplate = SnippetOptionWidget.extend({
10245
10253
*
10246
10254
* @private
10247
10255
* @param {string } xmlid
10248
- * @returns {string }
10256
+ * @returns {Promise< string> }
10249
10257
*/
10250
10258
async _getTemplate ( xmlid ) {
10251
10259
if ( ! this . _templates [ xmlid ] ) {
@@ -10257,21 +10265,20 @@ legacyRegistry.SelectTemplate = SnippetOptionWidget.extend({
10257
10265
) ;
10258
10266
}
10259
10267
return this . _templates [ xmlid ] ;
10260
- } ,
10268
+ }
10261
10269
10262
10270
//--------------------------------------------------------------------------
10263
10271
// Handlers
10264
10272
//--------------------------------------------------------------------------
10265
10273
10266
10274
/**
10267
- * @private
10268
- * @param {OdooEvent } ev
10275
+ * @override
10269
10276
*/
10270
- _onWidgetOpening ( ev ) {
10271
- if ( this . _templatesLoading || ev . target . getName ( ) !== this . selectTemplateWidgetName ) {
10277
+ onUserValueWidgetOpening ( userValue ) {
10278
+ if ( this . _templatesLoading || userValue . getName ( ) !== this . selectTemplateWidgetName ) {
10272
10279
return ;
10273
10280
}
10274
- const templateParams = ev . target . getMethodsParams ( 'selectTemplate' ) ;
10281
+ const templateParams = userValue . getMethodsParams ( 'selectTemplate' ) ;
10275
10282
const proms = templateParams . possibleValues . map ( async xmlid => {
10276
10283
if ( ! xmlid ) {
10277
10284
return ;
@@ -10282,8 +10289,8 @@ legacyRegistry.SelectTemplate = SnippetOptionWidget.extend({
10282
10289
await this . _getTemplate ( xmlid ) ;
10283
10290
} ) ;
10284
10291
this . _templatesLoading = Promise . all ( proms ) ;
10285
- } ,
10286
- } ) ;
10292
+ }
10293
+ }
10287
10294
10288
10295
/*
10289
10296
* Abstract option to be extended by the Carousel and gallery options (through
0 commit comments