8000 fix logo adding/removing option · odoo-dev/odoo@db7bf6a · GitHub
[go: up one dir, main page]

Skip to content

Commit db7bf6a

Browse files
author
Serhii Rubanskyi - seru
committed
fix logo adding/removing option
We need a different action for the logo because it can have two views: image and a text one, so we can't just pass the two views to websiteConfig because it will try to disable (or enable) both of them which ends up in error
1 parent 4443c63 commit db7bf6a

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

addons/html_builder/static/src/website_builder/plugins/customize_website_plugin.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,49 @@ export class CustomizeWebsitePlugin extends Plugin {
319319
apply: async (action) => this.toggleConfig(action, true),
320320
clean: (action) => this.toggleConfig(action, false),
321321
},
322+
logoConfig: {
323+
reload: {},
324+
prepare: async ({ actionParam }) => this.loadConfigKey(actionParam),
325+
getPriority: ({ params }) => {
326+
const records = [...(params.views || []), ...(params.assets || [])];
327+
return records.length;
328+
},
329+
isApplied: ({ params }) => {
330+
const records = params.views || [];
331+
const configKeysIsApplied = records.some((v) => this.getConfigKey(v));
332+
return configKeysIsApplied;
333+
},
334+
apply: async ({ params }) => {
335+
// as we have hidden the logo we enable the first one
336+
// from views which can later be changed in the logo option
337+
const recordToEnable = params.views[0];
338+
if (recordToEnable) {
339+
const isViewData = true;
340+
const shouldReset = !!params.resetViewArch;
341+
return this.customizeThemeData(
342+
isViewData,
343+
shouldReset,
344+
new Set([recordToEnable]),
345+
new Set()
346+
);
347+
}
348+
},
349+
clean: async ({ params }) => {
350+
const records = params.views;
351+
for (const record of records) {
352+
if (this.getConfigKey(record)) {
353+
const isViewData = true;
354+
const shouldReset = !!params.resetViewArch;
355+
return this.customizeThemeData(
356+
isViewData,
357+
shouldReset,
358+
new Set(),
359+
new Set([record])
360+
);
361+
}
362+
}
363+
},
364+
},
322365
selectTemplate: {
323366
prepare: async ({ actionParam }) => {
324367
await this.loadTemplateKey(actionParam.view);

addons/html_builder/static/src/website_builder/plugins/options/header_option.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@
383383
<BuilderButton
384384
title.translate="Show/hide logo"
385385
className="'flex-grow-1'"
386+
action="'logoConfig'"
386387
actionParam="{
387-
views: ['website.option_header_brand_name', 'website.option_header_brand_logo'],
388+
views: ['website.option_header_brand_logo', 'website.option_header_brand_name'],
388389
resetViewArch: true,
389390
}"
390391
>

0 commit comments

Comments
 (0)
0