diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 6239f0f9f4e..9268a74c14e 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -223,7 +223,7 @@ class Website(Home): } return request.render('website.website_info', values) - @http.route(['/website/configurator/'], type='http', auth="user", website=True) + @http.route(['/website/configurator', '/website/configurator/'], type='http', auth="user", website=True, multilang=False) def website_configurator(self, step=1, **kwargs): if not request.env.user.has_group('website.group_website_designer'): raise werkzeug.exceptions.NotFound() diff --git a/addons/website/models/website.py b/addons/website/models/website.py index 7eb43cf6dd3..7964e8fa8ec 100644 --- a/addons/website/models/website.py +++ b/addons/website/models/website.py @@ -272,15 +272,14 @@ class Website(models.Model): return r @api.model - def configurator_recommended_themes(self, industry_name, palette): + def configurator_recommended_themes(self, industry_id, palette): domain = [('name', '=like', 'theme%'), ('name', 'not in', ['theme_default', 'theme_common'])] client_themes = request.env['ir.module.module'].search(domain).mapped('name') params = { - 'industry_name': industry_name, 'palette': palette, 'client_themes': client_themes, } - return self._website_api_rpc('/api/website/1/configurator/recommended_themes', params) + return self._website_api_rpc('/api/website/1/configurator/recommended_themes/%s' % industry_id, params) @api.model def configurator_skip(self): @@ -362,12 +361,13 @@ class Website(models.Model): pages_views = set_features(kwargs.get('selected_features')) # Load suggestion from iap for selected pages + requested_pages = list(pages_views.keys()) + requested_pages.append('homepage') params = { 'theme': kwargs.get('theme_name'), - 'industry': kwargs.get('industry'), - 'pages': list(pages_views.keys()), + 'pages': requested_pages, } - custom_resources = self._website_api_rpc('/api/website/1/configurator/custom_resources', params) + custom_resources = self._website_api_rpc('/api/website/1/configurator/custom_resources/%s' % kwargs.get('industry_id'), params) # Update pages pages = custom_resources.get('pages', {}) diff --git a/addons/website/static/src/components/configurator/configurator.js b/addons/website/static/src/components/configurator/configurator.js index c59fdf588f7..0749dffa81b 100644 --- a/addons/website/static/src/components/configurator/configurator.js +++ b/addons/website/static/src/components/configurator/configurator.js @@ -84,7 +84,7 @@ class DescriptionScreen extends Component { super(...arguments); this.industrySelection = useRef('industrySelection'); this.state = useStore((state) => state); - this.labelToName = {}; + this.labelToId = {}; this.getters = useGetters(); this.dispatch = useDispatch(); } @@ -111,7 +111,7 @@ class DescriptionScreen extends Component { return val.label.startsWith(lcTerm); }); let results = matches.slice(0, limit); - this.labelToName = {}; + this.labelToId = {}; let labels = results.map((val) => val.label); if (labels.length < limit) { let relaxedMatches = this.state.industries.filter((val) => { @@ -122,20 +122,20 @@ class DescriptionScreen extends Component { labels = results.map((val) => val.label); } results.forEach((r) => { - this.labelToName[r.label] = r.name; + this.labelToId[r.label] = r.id; }); response(labels); } selectIndustry(_, ui) { - this.dispatch('selectIndustry', this.labelToName[ui.item.label]); + this.dispatch('selectIndustry', this.labelToId[ui.item.label]); this.checkDescriptionCompletion(); } blurIndustrySelection(ev) { - const name = this.labelToName[ev.target.outerText]; - this.dispatch('selectIndustry', name); - if (name === undefined) { + const id = this.labelToId[ev.target.outerText]; + this.dispatch('selectIndustry', id); + if (id === undefined) { this.industrySelection.el.textContent = ''; } else { this.checkDescriptionCompletion(); @@ -143,7 +143,7 @@ class DescriptionScreen extends Component { } inputIndustrySelection(ev) { - this.dispatch('selectIndustry', this.labelToName[ev.target.outerText]); + this.dispatch('selectIndustry', this.labelToId[ev.target.outerText]); } selectWebsiteType(ev) { @@ -233,13 +233,13 @@ class FeaturesSelectionScreen extends Component { } async buildWebsite() { - const industryName = this.state.selectedIndustry; - if (!industryName) { + const industryId = this.state.selectedIndustry; + if (!industryId) { this.env.router.navigate({to: 'CONFIGURATOR_DESCRIPTION_SCREEN'}); return; } const params = { - industry_name: industryName, + industry_id: industryId, palette: this.state.selectedPalette }; const themes = await rpc.query({ @@ -295,12 +295,11 @@ Object.assign(App, { //--------------------------------------------------------- const ROUTES = [ - {name: 'CONFIGURATOR_WELCOME_SCREEN', path: '/website/configurator/1', component: WelcomeScreen}, + {name: 'CONFIGURATOR_WELCOME_SCREEN', path: '/website/configurator', component: WelcomeScreen}, {name: 'CONFIGURATOR_DESCRIPTION_SCREEN', path: '/website/configurator/2', component: DescriptionScreen}, {name: 'CONFIGURATOR_PALETTE_SELECTION_SCREEN', path: '/website/configurator/3', component: PaletteSelectionScreen}, {name: 'CONFIGURATOR_FEATURES_SELECTION_SCREEN', path: '/website/configurator/4', component: FeaturesSelectionScreen}, {name: 'CONFIGURATOR_THEME_SELECTION_SCREEN', path: '/website/configurator/5', component: ThemeSelectionScreen}, - {name: 'CONFIGURATOR_WELCOME_SCREEN_LANG', path: '/{{lang}}/website/configurator/1', component: WelcomeScreen}, ]; //--------------------------------------------------------- @@ -347,8 +346,8 @@ const actions = { selectWebsitePurpose({state}, id) { state.selectedPurpose = id; }, - selectIndustry({state}, name) { - state.selectedIndustry = name; + selectIndustry({state}, id) { + state.selectedIndustry = id; }, changeLogo({state}, data) { state.logo = data; @@ -471,7 +470,7 @@ async function applyConfigurator(self, themeName) { const data = { selected_features: selectedFeatures, logo: self.state.logo, - industry: self.state.selectedIndustry, + industry_id: self.state.selectedIndustry, selected_palette: self.state.selectedPalette.id, theme_name: themeName, }; diff --git a/addons/website/views/website_views.xml b/addons/website/views/website_views.xml index 93aa1f48f71..2a2e22a8986 100644 --- a/addons/website/views/website_views.xml +++ b/addons/website/views/website_views.xml @@ -549,7 +549,7 @@ Website Configurator - /website/configurator/1 + /website/configurator self