1
1
/** @odoo -module **/
2
2
3
- import options from "@web_editor/js/editor/snippets.options.legacy" ;
3
+ import { _t } from "@web/core/l10n/translation" ;
4
+ import {
5
+ SnippetOption ,
6
+ } from "@web_editor/js/editor/snippets.options" ;
4
7
import { rpc } from "@web/core/network/rpc" ;
8
+ import {
9
+ registerWebsiteOption ,
10
+ } from "@website/js/editor/snippets.registry" ;
5
11
6
12
const mainObjectRe = / w e b s i t e \. c o n t r o l l e r \. p a g e \( ( ( \d + , ? ) * ) \) / ;
7
13
8
- options . registry . WebsiteControllerPageListingLayout = options . Class . extend ( {
9
- init ( ) {
10
- this . _super ( ...arguments ) ;
11
- this . orm = this . bindService ( "orm" ) ;
14
+ export class WebsiteControllerPageListingLayoutOption extends SnippetOption {
15
+
16
+ constructor ( ) {
17
+ super ( ...arguments ) ;
18
+ this . orm = this . env . services . orm ;
12
19
this . resModel = "website.controller.page" ;
13
- } ,
20
+ }
14
21
15
22
/**
16
23
* @override
17
24
*/
18
25
async willStart ( ) {
19
- const _super = this . _super . bind ( this ) ;
20
26
const mainObjectRepr = this . $target [ 0 ] . ownerDocument . documentElement . getAttribute ( "data-main-object" ) ;
21
27
const match = mainObjectRe . exec ( mainObjectRepr ) ;
22
28
if ( match && match [ 1 ] ) {
@@ -31,8 +37,8 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
31
37
32
38
const results = await this . orm . read ( this . resModel , this . resIds , [ "default_layout" ] ) ;
33
39
this . layout = results [ 0 ] [ "default_layout" ] ;
34
- return _super ( ...arguments ) ;
35
- } ,
40
+ return super . willStart ( ...arguments ) ;
41
+ }
36
42
37
43
//--------------------------------------------------------------------------
38
44
// Options
@@ -48,7 +54,7 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
48
54
this . orm . write ( this . resModel , this . resIds , { default_layout : widgetValue } ) ,
49
55
rpc ( "/website/save_session_layout_mode" , params ) ,
50
56
] ) ;
51
- } ,
57
+ }
52
58
53
59
//--------------------------------------------------------------------------
54
60
// Private
@@ -68,5 +74,17 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
68
74
}
69
75
}
70
76
return this . _super ( ...arguments ) ;
71
- } ,
77
+ }
78
+ }
79
+
80
+ registerWebsiteOption ( "WebsiteControllerPageListingLayout" , {
81
+ Class : WebsiteControllerPageListingLayoutOption ,
82
+ template : "website.s_website_controller_page_listing_layout_option" ,
83
+ selector : ".listing_layout_switcher" ,
84
+ noCheck : true ,
85
+ data : {
86
+ string : _t ( "Layout" ) ,
87
+ pageOptions :true ,
88
+ groups : [ "website.group_website_designer" ]
89
+ } ,
72
90
} ) ;
0 commit comments