From 1ec2cb93315f556cb553e338a6cecf67fc880b6c Mon Sep 17 00:00:00 2001 From: ddm Date: Tue, 19 Nov 2013 13:23:19 +0100 Subject: [PATCH] [IMP] Shop tutorial continued bzr revid: ddm@openerp.com-20131119122319-45fu90nooiwb7so7 --- .../static/src/js/website.tour.banner.js | 13 +---- .../static/src/js/website.tour.install-app.js | 2 +- addons/website/static/src/js/website.tour.js | 15 ++++-- .../static/src/js/website.tour.menu-editor.js | 2 +- .../static/src/js/website.tour.shop.js | 53 ++++++++++++++++--- .../static/src/xml/website_sale.xml | 2 +- 6 files changed, 61 insertions(+), 26 deletions(-) diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js index 0b47700169e..f192c1f9280 100644 --- a/addons/website/static/src/js/website.tour.banner.js +++ b/addons/website/static/src/js/website.tour.banner.js @@ -6,9 +6,9 @@ var render = website.tour.render; website.EditorBannerTour = website.EditorTour.extend({ - id: 'add_banner_tour', + id: 'banner-tutorial', name: "Insert a banner", - urlTrigger: '?banner-tutorial=true', + startPath: '/page/website.homepage', init: function (editor) { var self = this; var $body = $(document.body); @@ -134,17 +134,8 @@ return (currentStepIndex === secondPartIndex || currentStepIndex === showTutorialsIndex) && !this.tour.ended(); }, continueTour: function () { - return this.startOfPart2(); - }, - canResume: function () { return this.startOfPart2() || this._super(); }, - redirect: function (url) { - url = url || new website.UrlParser(window.location.href); - if (url.pathname !== '/' && url.pathname !== '/page/website.homepage') { - window.location.replace('/page/website.homepage?banner-tutorial=true'); - } - }, }); website.EditorBar.include({ diff --git a/addons/website/static/src/js/website.tour.install-app.js b/addons/website/static/src/js/website.tour.install-app.js index b4be2420c35..ef920b51b3c 100644 --- a/addons/website/static/src/js/website.tour.install-app.js +++ b/addons/website/static/src/js/website.tour.install-app.js @@ -6,7 +6,7 @@ var render = website.tour.render; website.InstallAppTour = website.EditorTour.extend({ - id: 'install_app', + id: 'install-app', name: "Install a new App", init: function (editor) { var self = this; diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js index 9181029c7a2..b7cd46dff59 100644 --- a/addons/website/static/src/js/website.tour.js +++ b/addons/website/static/src/js/website.tour.js @@ -53,7 +53,7 @@ } }, canResume: function () { - return (this.currentStepIndex() === 0) && !this.tour.ended(); + return this.continueTour() || ((this.currentStepIndex() === 0) && !this.tour.ended()); }, currentStepIndex: function () { var index = this.tourStorage.getItem(this.id+'_current_step') || 0; @@ -84,10 +84,14 @@ }, continueTour: function () { // Override if necessary - return true; + return this.currentStepIndex() === 0; }, - redirect: function () { - // Override if necessary + redirect: function (url) { + url = url || new website.UrlParser(window.location.href); + if (this.startPath && url.pathname !== this.startPath) { + var newUrl = this.startPath + (url.search ? (url.search + "&") : "?") + this.id + "=true" + window.location.replace(newUrl); + } }, }); @@ -123,7 +127,8 @@ tour.start(); }); menu.append($menuItem); - if (tour.urlTrigger && (url.search.indexOf(tour.urlTrigger) === 0 || tour.continueTour())) { + var urlTrigger = tour.id + "=true"; + if (url.search.indexOf(urlTrigger) >= 0) { tour.start(); } }); diff --git a/addons/website/static/src/js/website.tour.menu-editor.js b/addons/website/static/src/js/website.tour.menu-editor.js index b82b21f4b85..f4a56713e2b 100644 --- a/addons/website/static/src/js/website.tour.menu-editor.js +++ b/addons/website/static/src/js/website.tour.menu-editor.js @@ -6,7 +6,7 @@ var render = website.tour.render; website.EditorBuilderTour = website.EditorTour.extend({ - id: 'menu_editor', + id: 'menu-editor', name: "Add a new page", init: function (editor) { var self = this; diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js index a665327c563..637c9ef5fc5 100644 --- a/addons/website_sale/static/src/js/website.tour.shop.js +++ b/addons/website_sale/static/src/js/website.tour.shop.js @@ -6,9 +6,9 @@ var render = website.tour.render; website.EditorShopTour = website.EditorTour.extend({ - id: 'shop_tour', + id: 'shop-tutorial', name: "Create a product", - urlTrigger: '?shop-tutorial=true', + startPath: '/shop', init: function (editor) { var self = this; var $body = $(document.body); @@ -30,14 +30,53 @@ content: "Click here to add a new product.", template: render('website.tour_popover'), }, + { + stepId: 'edit-entry', + element: '#create-new-product', + placement: 'left', + title: "Create a new product", + content: "Select 'New Product' to create it and manage its properties to boost your sales.", + template: render('website.tour_popover'), + onShow: function () { + editor.on('tour:menu_editor_dialog_ready', editor, function () { + self.movetoStep('add-menu-entry'); + }); + }, + }, + { + stepId: 'product-page', + orphan: true, + backdrop: true, + title: "New product created", + content: "This page contains all the information related to the new product.", + template: render('website.tour_popover', { next: "OK" }), + }, + { + stepId: 'edit-price', + element: '.product_price', + placement: 'left', + title: "Change the public price", + content: "Edit the sale price of this product by clicking on the amount. The price is the sale price used in all sale order when selling this product.", + template: render('website.tour_popover', { next: "OK" }), + }, + { + stepId: 'add-block', + element: 'button[data-action=snippet]', + placement: 'bottom', + title: "Describe the product for your audience", + content: "Insert blocks like text-image, or gallery to fully describe the product and make your visitors want to buy this product.", + template: render('website.tour_popover'), + }, ]; return this._super(); }, - redirect: function (url) { - url = url || new website.UrlParser(window.location.href); - if (url.pathname !== '/shop') { - window.location.replace('/shop?shop-tutorial=true'); - } + productPage: function () { + var currentStepIndex = this.currentStepIndex(); + var productPageIndex = this.indexOfStep('product-page'); + return (currentStepIndex === productPageIndex) && !this.tour.ended(); + }, + continueTour: function () { + return this.productPage(); }, }); diff --git a/addons/website_sale/static/src/xml/website_sale.xml b/addons/website_sale/static/src/xml/website_sale.xml index 01ac14c8f74..59bb928cfe2 100644 --- a/addons/website_sale/static/src/xml/website_sale.xml +++ b/addons/website_sale/static/src/xml/website_sale.xml @@ -1,7 +1,7 @@ -
  • New Product
  • +
  • New Product