Skip to content

Commit dec2389

Browse files
bso-odoodetrouxdev
authored andcommitted
[REF] website: convert s_website_controller_page_listing to Owl
task-3850413
1 parent b0a048a commit dec2389

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

addons/website/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
'views/snippets/s_dynamic_snippet.xml',
9696
'views/snippets/s_dynamic_snippet_carousel.xml',
9797
'views/snippets/s_embed_code.xml',
98-
'views/snippets/s_website_controller_page_listing_layout.xml',
9998
'views/snippets/s_website_form.xml',
10099
'views/snippets/s_searchbar.xml',
101100
'views/snippets/s_button.xml',
@@ -285,6 +284,7 @@
285284
'website/static/src/snippets/s_dynamic_snippet_carousel/options.js',
286285
'website/static/src/snippets/s_dynamic_snippet_carousel/options.xml',
287286
'website/static/src/snippets/s_website_controller_page_listing_layout/options.js',
287+
'website/static/src/snippets/s_website_controller_page_listing_layout/options.xml',
288288
'website/static/src/snippets/s_website_form/options.js',
289289
'website/static/src/js/form_editor_registry.js',
290290
'website/static/src/js/send_mail_form.js',

addons/website/static/src/snippets/s_website_controller_page_listing_layout/options.js

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
/** @odoo-module **/
22

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";
47
import { rpc } from "@web/core/network/rpc";
8+
import {
9+
registerWebsiteOption,
10+
} from "@website/js/editor/snippets.registry";
511

612
const mainObjectRe = /website\.controller\.page\(((\d+,?)*)\)/;
713

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;
1219
this.resModel = "website.controller.page";
13-
},
20+
}
1421

1522
/**
1623
* @override
1724
*/
1825
async willStart() {
19-
const _super = this._super.bind(this);
2026
const mainObjectRepr = this.$target[0].ownerDocument.documentElement.getAttribute("data-main-object");
2127
const match = mainObjectRe.exec(mainObjectRepr);
2228
if (match && match[1]) {
@@ -31,8 +37,8 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
3137

3238
const results = await this.orm.read(this.resModel, this.resIds, ["default_layout"]);
3339
this.layout = results[0]["default_layout"];
34-
return _super(...arguments);
35-
},
40+
return super.willStart(...arguments);
41+
}
3642

3743
//--------------------------------------------------------------------------
3844
// Options
@@ -48,7 +54,7 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
4854
this.orm.write(this.resModel, this.resIds, { default_layout: widgetValue }),
4955
rpc("/website/save_session_layout_mode", params),
5056
]);
51-
},
57+
}
5258

5359
//--------------------------------------------------------------------------
5460
// Private
@@ -68,5 +74,17 @@ options.registry.WebsiteControllerPageListingLayout = options.Class.extend({
6874
}
6975
}
7076
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+
},
7290
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<templates id="template" xml:space="preserve">
3+
4+
<t t-name="website.s_website_controller_page_listing_layout_option">
5+
<!-- All records page -->
6+
<WeRow title.translate="Default Layout">
7+
<WeSelect name="'default_listing_layout'" noPreview="'true'" reload="'/'">
8+
<WeButton setLayout="'grid'" name="'grid_view_opt'">Grid</WeButton>
9+
<WeButton setLayout="'list'" name="'list_view_opt'">List</WeButton>
10+
</WeSelect>
11+
</WeRow>
12+
</t>
13+
14+
</templates>

addons/website/views/snippets/s_website_controller_page_listing_layout.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)