From f61e65539eadd44be7894395d0b50cc97a73d0f9 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 10 Sep 2013 14:26:46 +0200 Subject: [PATCH] [IMP] website: auto open editor when create new product (use ?unable_editor in url) bzr revid: chm@openerp.com-20130910122646-ug8dn61rqgbm3eq3 --- addons/website/static/src/css/website.css | 5 ++--- addons/website/static/src/css/website.sass | 4 ++-- addons/website/static/src/js/website.editor.js | 10 +++++++--- addons/website_sale/controllers/main.py | 9 +++++---- addons/website_sale/views/website_sale.xml | 16 +++------------- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index 3c8aee57ef2..77db53b45e9 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -193,6 +193,8 @@ a[data-publish][data-publish='on']:hover .css_published { [data-publish]:not(a) { position: relative; overflow: visible; + /*&:hover > [data-publish] */ + /* display: block */ } [data-publish]:not(a) > [data-publish] { position: absolute; @@ -200,6 +202,3 @@ a[data-publish][data-publish='on']:hover .css_published { top: -10px; display: none; } -[data-publish]:not(a):hover > [data-publish] { - display: block; -} diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index b5468a4b0e8..9992a8586ef 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -156,5 +156,5 @@ a[data-publish] right: -6px top: -10px display: none - &:hover > [data-publish] - display: block \ No newline at end of file + /*&:hover > [data-publish]*/ + /* display: block*/ \ No newline at end of file diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js index 8056998eef9..dff61f1dd4a 100644 --- a/addons/website/static/src/js/website.editor.js +++ b/addons/website/static/src/js/website.editor.js @@ -118,7 +118,11 @@ var editor = new website.EditorBar(); var $body = $(document.body); - editor.prependTo($body); + editor.prependTo($body).then(function () { + if (location.search.indexOf("unable_editor") >= 0) { + editor.edit(); + } + }); $body.css('padding-top', '50px'); // Not working properly: editor.$el.outerHeight()); }; /* ----- TOP EDITOR BAR FOR ADMIN ---- */ @@ -240,7 +244,7 @@ defs.push(def); }); return $.when.apply(null, defs).then(function () { - window.location.reload(); + window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/, ''); }); }, saveElement: function ($el) { @@ -263,7 +267,7 @@ }); }, cancel: function () { - window.location.reload(); + window.location.href = window.location.href.replace(/unable_editor(=[^&]*)?/, ''); }, }); diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index e50bdb71707..d36f822d273 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -122,10 +122,11 @@ class Ecommerce(http.Controller): } return request.webcontext.render("website_sale.product", values) - @website.route(['/shop/add_product/'], type='http', auth="public") - def add_product(self, **post): - product_id = request.registry.get('product.product').create(request.cr, request.uid, {'name': 'New Product'}, request.context) - return werkzeug.utils.redirect("/shop/product/%s/" % product_id) + @website.route(['/shop/add_product/', '/shop/category//add_product/'], type='http', auth="public") + def add_product(self, cat_id=0, **post): + product_id = request.registry.get('product.product').create(request.cr, request.uid, + {'name': 'New Product', 'public_categ_id': cat_id}, request.context) + return werkzeug.utils.redirect("/shop/product/%s/?unable_editor=1" % product_id) @website.route(['/shop/change_category//'], type='http', auth="public") def edit_product(self, product_id=0, **post): diff --git a/addons/website_sale/views/website_sale.xml b/addons/website_sale/views/website_sale.xml index 2d3ed3f20dc..7633109a3a4 100644 --- a/addons/website_sale/views/website_sale.xml +++ b/addons/website_sale/views/website_sale.xml @@ -73,7 +73,6 @@ Shop - Categories
- Create New Product
@@ -121,6 +120,8 @@ Product + Create New Product +
pull-left @@ -182,18 +183,7 @@ -
-

Category
Select the public category

- -

Short Description for Quotations
Displayed in your shop categories and for quotations

-
Enter a short description for this product
-
-
Enter a short Website description for this product
+
Replace this text with your Website product description
€