[IMP] website, website_event: add edit event menu dropdown
This commit adds a new menu item in the "Site" menu section. This "Edit Event Menu" item is only shown when a [data-content_menu_id] element is displayed within the iframe (such data attribute is added on the event menus). The contentMenuId is taken from the currentWebsite.metadata to keep data taken from the iframe's document centralized in the service. The spec is different from the previous implementation, that was prompting a dialog to select the menu to edit, before prompting the dialog to edit the menu. Here we have two different dropwdown items. See merge commit for more information. task-2687506
This commit is contained in:
@@ -93,6 +93,7 @@ export const websiteService = {
|
||||
currentMetadata = {};
|
||||
} else {
|
||||
const { mainObject, seoObject, isPublished, canPublish, editableInBackend, translatable, viewXmlid } = document.documentElement.dataset;
|
||||
const contentMenuEl = document.querySelector('[data-content_menu_id]');
|
||||
currentMetadata = {
|
||||
path: document.location.href,
|
||||
mainObject: unslugHtmlDataObject(mainObject),
|
||||
@@ -102,6 +103,7 @@ export const websiteService = {
|
||||
editableInBackend: editableInBackend === 'True',
|
||||
title: document.title,
|
||||
translatable: !!translatable,
|
||||
contentMenuId: contentMenuEl && contentMenuEl.dataset.content_menu_id,
|
||||
// TODO: Find a better way to figure out if
|
||||
// a page is editable or not. For now, we use
|
||||
// the editable selector because it's the common
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
],
|
||||
'website.assets_editor': [
|
||||
'website_event/static/src/js/systray_items/*.js',
|
||||
'website_event/static/src/js/components/navbar/navbar.js',
|
||||
],
|
||||
},
|
||||
'license': 'LGPL-3',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { patch } from 'web.utils';
|
||||
import { NavBar } from '@web/webclient/navbar/navbar';
|
||||
import { EditMenuDialog } from '@website/components/dialog/edit_menu';
|
||||
|
||||
const { onWillStart } = owl;
|
||||
|
||||
patch(NavBar.prototype, 'website_events_navbar', {
|
||||
setup() {
|
||||
this._super();
|
||||
|
||||
onWillStart(() => {
|
||||
this.websiteEditingMenus['website_event.menu_edit_menu'] = {
|
||||
Component: EditMenuDialog,
|
||||
isDisplayed: () => this.websiteService.currentWebsite && this.websiteService.currentWebsite.metadata.contentMenuId,
|
||||
getProps: () => ({
|
||||
rootID: parseInt(this.websiteService.currentWebsite.metadata.contentMenuId, 10),
|
||||
}),
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -8,4 +8,10 @@
|
||||
groups="base.group_no_one"
|
||||
sequence="99"/>
|
||||
|
||||
<menuitem id="menu_edit_menu"
|
||||
name="Edit Event Menu "
|
||||
sequence="35"
|
||||
parent="website.menu_site"
|
||||
action="website.website_preview"/>
|
||||
|
||||
</data></odoo>
|
||||
|
||||
Reference in New Issue
Block a user