[IMP] website: make homepage tour, available on homepage only
Homepage tour starts with a very generic step 'drop snippet' So, you can be in the middle of another tour and see the step of homepage tour. This doesn't fix all cases, but make conflict less frequent. E.g. go to step 4 of tour event click on save (before doing the step 5) click on edit Element is no more dirty (because save before step 5) so the step 5 not visible, Tour with higher sequence (== lower priority) become visible. (e.g.: homepage) Forward-Port of bca6cf2693d38c76b1af08398a3125bb16b59c15 closes odoo/odoo#61157 Related: odoo/design-themes#416 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
@@ -240,8 +240,13 @@
|
||||
<field name="url">/</field>
|
||||
<field name="target">self</field>
|
||||
</record>
|
||||
<record id="action_website_edit" model="ir.actions.act_url">
|
||||
<field name="name">Website Edit Mode</field>
|
||||
<field name="url">/?enable_editor=1</field>
|
||||
<field name="target">self</field>
|
||||
</record>
|
||||
<record id="base.open_menu" model="ir.actions.todo">
|
||||
<field name="action_id" ref="action_website"/>
|
||||
<field name="action_id" ref="action_website_edit"/>
|
||||
<field name="state">open</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -60,3 +60,18 @@ class ServerAction(models.Model):
|
||||
"""
|
||||
res = super(ServerAction, self)._run_action_code_multi(eval_context)
|
||||
return eval_context.get('response', res)
|
||||
|
||||
|
||||
class IrActionsTodo(models.Model):
|
||||
_name = 'ir.actions.todo'
|
||||
_inherit = 'ir.actions.todo'
|
||||
|
||||
def action_launch(self):
|
||||
res = super().action_launch() # do ensure_one()
|
||||
|
||||
if self.id == self.env.ref('website.theme_install_todo').id:
|
||||
# Pick a theme consume all ir.actions.todo by default (due to lower sequence).
|
||||
# Once done, we re-enable the main ir.act.todo: open_menu
|
||||
self.env.ref('base.open_menu').action_open()
|
||||
|
||||
return res
|
||||
|
||||
@@ -360,7 +360,11 @@ class IrModuleModule(models.Model):
|
||||
# this will install 'self' if it is not installed yet
|
||||
self._theme_upgrade_upstream()
|
||||
|
||||
return website.button_go_website(mode_edit=True)
|
||||
active_todo = self.env['ir.actions.todo'].search([('state', '=', 'open')], limit=1)
|
||||
if active_todo:
|
||||
return active_todo.action_launch()
|
||||
else:
|
||||
return website.button_go_website(mode_edit=True)
|
||||
|
||||
def button_remove_theme(self):
|
||||
"""Remove the current theme of the current website."""
|
||||
|
||||
@@ -5,6 +5,7 @@ var core = require('web.core');
|
||||
var Dialog = require('web.Dialog');
|
||||
var websiteNavbarData = require('website.navbar');
|
||||
var wUtils = require('website.utils');
|
||||
var tour = require('web_tour.tour');
|
||||
|
||||
var qweb = core.qweb;
|
||||
var _t = core._t;
|
||||
@@ -56,6 +57,15 @@ var NewContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
this.$lastLink = this.$newContentMenuChoices.find('a:last');
|
||||
|
||||
if ($.deparam.querystring()[enableFlag] !== undefined) {
|
||||
Object.keys(tour.tours).forEach(
|
||||
el => {
|
||||
let element = tour.tours[el];
|
||||
if (element.steps[0].trigger == '#new-content-menu > a'
|
||||
&& !element.steps[0].extra_trigger) {
|
||||
element.steps[0].auto = true;
|
||||
}
|
||||
}
|
||||
);
|
||||
this._showMenu();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
|
||||
@@ -3,12 +3,11 @@ odoo.define("website.tour.homepage", function (require) {
|
||||
|
||||
var core = require("web.core");
|
||||
var tour = require("web_tour.tour");
|
||||
const wTourUtils = require("website.tour_utils");
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
tour.register("homepage", {
|
||||
url: "/",
|
||||
}, [{
|
||||
wTourUtils.registerThemeHomepageTour('homepage', [{
|
||||
trigger: "a[data-action=edit]",
|
||||
content: _t("<b>Click Edit</b> to start designing your homepage."),
|
||||
extra_trigger: ".homepage",
|
||||
|
||||
@@ -4,6 +4,8 @@ odoo.define("website.tour_utils", function (require) {
|
||||
const core = require("web.core");
|
||||
const _t = core._t;
|
||||
|
||||
var tour = require("web_tour.tour");
|
||||
|
||||
/**
|
||||
|
||||
const snippets = [
|
||||
@@ -216,7 +218,28 @@ function selectSnippetColumn(snippet, index = 0, position = "bottom") {
|
||||
position: position,
|
||||
run: "click",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function prepend_trigger(steps, prepend_text='') {
|
||||
for (const step of steps) {
|
||||
if (!step.noPrepend && prepend_text) {
|
||||
step.trigger = prepend_text + step.trigger;
|
||||
}
|
||||
}
|
||||
return steps;
|
||||
}
|
||||
|
||||
function registerThemeHomepageTour(name, steps) {
|
||||
tour.register(name, {
|
||||
url: "/",
|
||||
sequence: 1010,
|
||||
saveAs: "homepage",
|
||||
}, prepend_trigger(
|
||||
steps,
|
||||
"html[data-view-xmlid='website.homepage'] "
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
addMedia,
|
||||
@@ -236,5 +259,7 @@ return {
|
||||
goToOptions,
|
||||
selectHeader,
|
||||
selectSnippetColumn,
|
||||
|
||||
registerThemeHomepageTour,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -443,6 +443,7 @@
|
||||
</record>
|
||||
|
||||
<record id="theme_install_todo" model="ir.actions.todo">
|
||||
<field name="name">Go to theme</field>
|
||||
<field name="action_id" ref="theme_install_act_url"/>
|
||||
<field name="sequence">0</field>
|
||||
</record>
|
||||
|
||||
@@ -10,8 +10,9 @@ odoo.define("website_blog.tour", function (require) {
|
||||
url: "/",
|
||||
}, [{
|
||||
trigger: '#new-content-menu > a',
|
||||
auto: true,
|
||||
content: _t("Click here to add new content on your website."),
|
||||
position: 'bottom',
|
||||
|
||||
}, {
|
||||
trigger: "a[data-action=new_blog_post]",
|
||||
content: _t("Select this menu item to create a new blog post."),
|
||||
|
||||
@@ -9,8 +9,8 @@ odoo.define("website_event.tour", function (require) {
|
||||
tour.register("event", {
|
||||
url: "/",
|
||||
}, [{
|
||||
content: _t("Click here to add new content on your website."),
|
||||
trigger: '#new-content-menu > a',
|
||||
auto: true,
|
||||
position: 'bottom',
|
||||
}, {
|
||||
trigger: "a[data-action=new_event]",
|
||||
@@ -19,7 +19,7 @@ odoo.define("website_event.tour", function (require) {
|
||||
}, {
|
||||
trigger: '.modal-dialog #editor_new_event input[type=text]',
|
||||
content: _t("Create a name for your new event and click <em>\"Continue\"</em>. e.g: Technical Training"),
|
||||
position: "right",
|
||||
position: "left",
|
||||
}, {
|
||||
trigger: '.modal-footer button.btn-primary.btn-continue',
|
||||
extra_trigger: '#editor_new_event input[type=text][value!=""]',
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
<field name="params" eval="{'menu_id': ref('base.menu_administration')}"/>
|
||||
</record>
|
||||
<record id="open_menu" model="ir.actions.todo">
|
||||
<field name="name">Open Menu</field>
|
||||
<field name="action_id" ref="action_client_base_menu"/>
|
||||
<field name="sequence">100</field>
|
||||
<field name="state">done</field>
|
||||
|
||||
Reference in New Issue
Block a user