[IMP] website: move custom scripts in the assets; fix website_sale_option to display modal in grid view
This commit is contained in:
parent
95c7cf8a68
commit
77a07670cf
|
@ -452,7 +452,6 @@
|
|||
openerp.jsonRpc('/website/customize_template_get', 'call', { 'xml_id': view_name }).then(
|
||||
function(result) {
|
||||
_.each(result, function (item) {
|
||||
if (item.xml_id === "website.debugger" && !window.location.search.match(/[&?]debug(&|$)/)) return;
|
||||
if (item.header) {
|
||||
menu.append('<li class="dropdown-header">' + item.name + '</li>');
|
||||
} else {
|
||||
|
|
|
@ -251,12 +251,6 @@
|
|||
<script type="text/javascript" src="/website/static/src/js/jQuery.transfo.js"></script>
|
||||
</template>
|
||||
|
||||
<template id="debugger" inherit_id="website.layout" optional="disabled" name="Debugger & Tests">
|
||||
<xpath expr='//t[@name="layout_head"]' position="after">
|
||||
<t t-set="debugger_hook" t-value="1" />
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="login_layout" inherit_id="web.login_layout" name="Website Login Layout">
|
||||
<xpath expr="t" position="replace">
|
||||
<t t-call="website.layout">
|
||||
|
|
|
@ -4,7 +4,6 @@ import openerp.tests
|
|||
|
||||
inject = [
|
||||
("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
|
||||
("openerp.Tour.ShopTest", os.path.join(os.path.dirname(__file__), "../static/src/js/website.tour.event_sale.js")),
|
||||
]
|
||||
|
||||
@openerp.tests.common.at_install(False)
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="debugger" inherit_id="website.debugger" name="Event Debugger">
|
||||
<xpath expr='//t[@t-set="debugger_hook"]' position="after">
|
||||
<script type="text/javascript" src="/website_event_sale/static/src/js/website.tour.event_sale.js"></script>
|
||||
</xpath>
|
||||
<template id="assets_editor" inherit_id="website.assets_frontend" name="Event Sale">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_event_sale/static/src/js/website.tour.event_sale.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
<template id="index" inherit_id="website_event.index" name="Event's Ticket">
|
||||
<xpath expr="//li[@t-foreach='event_ids']/div/h4" position="before">
|
||||
<t t-if="event.state in ['draft', 'confirm'] and event.event_ticket_ids">
|
||||
|
|
|
@ -280,7 +280,7 @@ class website_sale(http.Controller):
|
|||
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True)
|
||||
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
|
||||
cr, uid, context = request.cr, request.uid, request.context
|
||||
request.website.sale_get_order(force_create=1)._cart_update(product_id=int(product_id), add_qty=add_qty, set_qty=set_qty)
|
||||
request.website.sale_get_order(force_create=1)._cart_update(product_id=int(product_id), add_qty=float(add_qty), set_qty=float(set_qty))
|
||||
return request.redirect("/shop/cart")
|
||||
|
||||
@http.route(['/shop/cart/update_json'], type='json', auth="public", methods=['POST'], website=True)
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
$(document).ready(function () {
|
||||
var $shippingDifferent = $(".oe_website_sale input[name='shipping_different']");
|
||||
$('.oe_website_sale').each(function () {
|
||||
var oe_website_sale = this;
|
||||
|
||||
var $shippingDifferent = $("input[name='shipping_different']", oe_website_sale);
|
||||
if ($shippingDifferent.is(':checked')) {
|
||||
$(".oe_website_sale .js_shipping").show();
|
||||
$(".js_shipping", oe_website_sale).show();
|
||||
}
|
||||
$shippingDifferent.change(function () {
|
||||
$(".oe_website_sale .js_shipping").toggle();
|
||||
$(".js_shipping", oe_website_sale).toggle();
|
||||
});
|
||||
|
||||
// change for css
|
||||
$(document).on('mouseup touchend', '.js_publish', function (ev) {
|
||||
$(oe_website_sale).on('mouseup touchend', '.js_publish', function (ev) {
|
||||
$(ev.currentTarget).parents(".thumbnail").toggleClass("disabled");
|
||||
});
|
||||
|
||||
$(".oe_website_sale .oe_cart input.js_quantity").change(function () {
|
||||
$(oe_website_sale).on("change", ".oe_cart input.js_quantity", function () {
|
||||
var $input = $(this);
|
||||
var value = parseInt($input.val(), 10);
|
||||
var line_id = parseInt($input.data('line-id'),10);
|
||||
|
@ -26,11 +29,6 @@ $(document).ready(function () {
|
|||
location.reload();
|
||||
return;
|
||||
}
|
||||
if (data.option_ids.length) {
|
||||
_.each(data.option_ids, function (line_id) {
|
||||
$(".js_quantity[data-line-id="+line_id+"]").text(data.quantity);
|
||||
});
|
||||
}
|
||||
var $q = $(".my_cart_quantity");
|
||||
$q.parent().parent().removeClass("hidden", !data.quantity);
|
||||
$q.html(data.cart_quantity).hide().fadeIn(600);
|
||||
|
@ -42,7 +40,7 @@ $(document).ready(function () {
|
|||
});
|
||||
|
||||
// hack to add and rome from cart with json
|
||||
$('.oe_website_sale').on('click', 'a.js_add_cart_json', function (ev) {
|
||||
$(oe_website_sale).on('click', 'a.js_add_cart_json', function (ev) {
|
||||
ev.preventDefault();
|
||||
var $link = $(ev.currentTarget);
|
||||
var $input = $link.parent().parent().find("input");
|
||||
|
@ -55,15 +53,15 @@ $(document).ready(function () {
|
|||
return false;
|
||||
});
|
||||
|
||||
$('.a-submit').on('click', function () {
|
||||
$('.a-submit', oe_website_sale).off('click').on('click', function () {
|
||||
$(this).closest('form').submit();
|
||||
});
|
||||
$('form.js_attributes input, form.js_attributes select').on('change', function () {
|
||||
$('.form.js_attributes input, form.js_attributes select', oe_website_sale).on('change', function () {
|
||||
$(this).closest("form").submit();
|
||||
});
|
||||
|
||||
// change price when they are variants
|
||||
$('form.js_add_cart_json label').on('mouseup touchend', function (ev) {
|
||||
$('form.js_add_cart_json label', oe_website_sale).on('mouseup touchend', function (ev) {
|
||||
var $label = $(this);
|
||||
var $price = $label.parents("form:first").find(".oe_price .oe_currency_value");
|
||||
if (!$price.data("price")) {
|
||||
|
@ -74,7 +72,7 @@ $(document).ready(function () {
|
|||
$price.html(value + (dec < 0.01 ? ".00" : (dec < 1 ? "0" : "") ));
|
||||
});
|
||||
// hightlight selected color
|
||||
$('.css_attribute_color input').on('change', function (ev) {
|
||||
$('.css_attribute_color input', oe_website_sale).on('change', function (ev) {
|
||||
$('.css_attribute_color').removeClass("active");
|
||||
$('.css_attribute_color:has(input:checked)').addClass("active");
|
||||
});
|
||||
|
@ -85,7 +83,7 @@ $(document).ready(function () {
|
|||
return price + (dec ? '' : '.0') + (dec%10 ? '' : '0');
|
||||
}
|
||||
|
||||
$('.oe_website_sale').on('change', 'input.js_variant_change, select.js_variant_change', function (ev) {
|
||||
$(oe_website_sale).on('change', 'input.js_variant_change, select.js_variant_change', function (ev) {
|
||||
var $ul = $(this).parents('ul.js_add_cart_variants:first');
|
||||
var $parent = $ul.closest('.js_product');
|
||||
var $product_id = $parent.find('input.product_id').first();
|
||||
|
@ -138,21 +136,21 @@ $(document).ready(function () {
|
|||
$parent.find(".js_check_product").attr("disabled", "disabled");
|
||||
}
|
||||
});
|
||||
$('ul.js_add_cart_variants').each(function () {
|
||||
$('ul.js_add_cart_variants', oe_website_sale).each(function () {
|
||||
$('input.js_variant_change, select.js_variant_change', this).first().trigger('change');
|
||||
});
|
||||
|
||||
$(".oe_website_sale").on('change', "select[name='country_id']", function () {
|
||||
$(oe_website_sale).on('change', "select[name='country_id']", function () {
|
||||
var $select = $("select[name='state_id']");
|
||||
$select.find("option:not(:first)").hide();
|
||||
var nb = $select.find("option[data-country_id="+($(this).val() || 0)+"]").show().size();
|
||||
$select.parent().toggle(nb>1);
|
||||
}).change();
|
||||
$(".oe_website_sale").on('change', "select[name='shipping_country_id']", function () {
|
||||
$(oe_website_sale).on('change', "select[name='shipping_country_id']", function () {
|
||||
var $select = $("select[name='shipping_state_id']");
|
||||
$select.find("option:not(:first)").hide();
|
||||
var nb = $select.find("option[data-country_id="+($(this).val() || 0)+"]").show().size();
|
||||
$select.parent().toggle(nb>1);
|
||||
}).change();
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,6 @@ import openerp.tests
|
|||
|
||||
inject = [
|
||||
("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
|
||||
("openerp.Tour.ShopTest", os.path.join(os.path.dirname(__file__), "../static/src/js/website.tour.sale.js")),
|
||||
]
|
||||
|
||||
@openerp.tests.common.at_install(False)
|
||||
|
|
|
@ -4,12 +4,6 @@
|
|||
|
||||
<!-- Layout and common templates -->
|
||||
|
||||
<template id="debugger" inherit_id="website.debugger" name="Event Debugger">
|
||||
<xpath expr='//t[@t-set="debugger_hook"]' position="after">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website.tour.sale.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="assets_editor" inherit_id="website.assets_editor" name="Shop Editor" groups="base.group_sale_manager">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.editor.js"></script>
|
||||
|
@ -17,6 +11,17 @@
|
|||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="assets_editor" inherit_id="website.assets_frontend" name="Shop">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website.tour.sale.js"></script>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_mail.css'/>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_payment.js"></script>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_validate.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="header" inherit_id="website.layout" name="Header Shop My Cart Link">
|
||||
<xpath expr="//header//ul[@id='top_menu']/li" position="before">
|
||||
<t t-set="website_sale_order" t-value="website.sale_get_order()"/>
|
||||
|
@ -60,6 +65,7 @@
|
|||
<!-- Product item used by /shop and /shop/cart -->
|
||||
|
||||
<template id="products_item" name="Product item">
|
||||
<form action="/shop/cart/update" method="post" style="display: inline-block;">
|
||||
<div itemscope="itemscope" itemtype="http://schema.org/Product">
|
||||
<div class="ribbon-wrapper">
|
||||
<div class="ribbon btn btn-danger">Sale</div>
|
||||
|
@ -91,6 +97,7 @@
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<template id="products_description" inherit_id="website_sale.products_item" optional="disabled" name="Product Description">
|
||||
|
@ -103,10 +110,8 @@
|
|||
|
||||
<template id="products_add_to_cart" inherit_id="website_sale.products_item" optional="disabled" name="Add to Cart">
|
||||
<xpath expr="//div[@class='product_price']" position="inside">
|
||||
<form action="/shop/cart/update" method="post" style="display: inline-block;">
|
||||
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
|
||||
<a class="btn btn-default btn-xs fa fa-shopping-cart a-submit"/>
|
||||
</form>
|
||||
<input name="product_id" t-att-value="product.product_variant_ids[0].id" type="hidden"/>
|
||||
<a class="btn btn-default btn-xs fa fa-shopping-cart a-submit"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
@ -114,15 +119,13 @@
|
|||
|
||||
<template id="products" name="Products">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<!--t t-set="head">
|
||||
<t t-call="web.jqueryui_conflict">
|
||||
<script type="text/javascript" src="/web/static/lib/jquery.ui/js/jquery-ui-1.9.1.custom.js"></script>
|
||||
</t>
|
||||
<link rel='stylesheet' href="/web/static/lib/jquery.ui/css/smoothness/jquery-ui-1.9.1.custom.css"/>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
</t-->
|
||||
<t t-set="additional_title">Shop</t>
|
||||
<div id="wrap" class="js_sale">
|
||||
<div class="oe_structure"/>
|
||||
|
@ -340,11 +343,6 @@
|
|||
|
||||
<template id="product" name="Product">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_mail.css'/>
|
||||
</t>
|
||||
<t t-set="additional_title" t-value="product.name"/>
|
||||
<div itemscope="itemscope" itemtype="http://schema.org/Product" id="wrap" class="js_sale">
|
||||
|
||||
|
@ -650,11 +648,6 @@
|
|||
|
||||
<template id="cart" name="Shopping Cart">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
<div id="wrap">
|
||||
<div class="container oe_website_sale">
|
||||
|
||||
|
@ -842,11 +835,6 @@
|
|||
|
||||
<template id="checkout">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
<t t-set="additional_title">Shop - Checkout</t>
|
||||
<div id="wrap">
|
||||
<div class="container oe_website_sale">
|
||||
|
@ -1009,12 +997,6 @@
|
|||
|
||||
<template id="payment">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_payment.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
<t t-set="additional_title">Shop - Select Payment Mode</t>
|
||||
<div id="wrap">
|
||||
<div class="container oe_website_sale">
|
||||
|
@ -1133,11 +1115,6 @@
|
|||
|
||||
<template id="confirmation">
|
||||
<t t-call="website.layout">
|
||||
<t t-set="head">
|
||||
<link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
|
||||
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_validate.js"></script>
|
||||
<t t-raw="head or ''"/>
|
||||
</t>
|
||||
<t t-set="additional_title">Shop - Confirmed</t>
|
||||
<div id="wrap">
|
||||
<div class="container oe_website_sale">
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
$(document).ready(function () {
|
||||
|
||||
$('#add_to_cart')
|
||||
$('.oe_website_sale #add_to_cart, .oe_website_sale #products_grid .a-submit')
|
||||
.off('click')
|
||||
.removeClass('a-submit')
|
||||
.click(function (event) {
|
||||
var $form = $(this).closest('form');
|
||||
var quantity = parseFloat($form.find('input[name="add_qty"]').val());
|
||||
var quantity = parseFloat($form.find('input[name="add_qty"]').val() || 1);
|
||||
event.preventDefault();
|
||||
openerp.jsonRpc("/shop/modal", 'call', {
|
||||
'product_id': parseInt($('input.product_id[name="product_id"]').val(),10),
|
||||
'product_id': parseInt($form.find('input[name="product_id"]').val(),10),
|
||||
kwargs: {
|
||||
context: openerp.website.get_context()
|
||||
},
|
||||
|
@ -27,7 +26,7 @@ $(document).ready(function () {
|
|||
url: '/shop/cart/update_option',
|
||||
success: function (quantity) {
|
||||
if (!$a.hasClass('js_goto_shop')) {
|
||||
window.location.href = "../cart";
|
||||
window.location.href = window.location.href.replace(/shop([\/?].*)?$/, "shop/cart");
|
||||
}
|
||||
var $q = $(".my_cart_quantity");
|
||||
$q.parent().parent().removeClass("hidden", !quantity);
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
openerp.Tour.tours.shop_buy_product.steps.splice(3, 0, {
|
||||
title: "click in modal on 'Proceed to checkout' button",
|
||||
element: '.modal a:contains("Proceed to checkout")',
|
||||
});
|
||||
var steps = openerp.Tour.tours.shop_buy_product.steps;
|
||||
for (var k=0; k<steps.length; k++) {
|
||||
if (steps[k].title === "click on add to cart") {
|
||||
steps.splice(k+1, 0, {
|
||||
title: "click in modal on 'Proceed to checkout' button",
|
||||
element: '.modal a:contains("Proceed to checkout")',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
openerp.Tour.register({
|
||||
id: 'shop_customize',
|
||||
|
|
|
@ -4,7 +4,6 @@ import openerp.tests
|
|||
|
||||
inject = [
|
||||
("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
|
||||
("openerp.Tour.ShopTest", os.path.join(os.path.dirname(__file__), "../static/src/js/website.tour.sale.js")),
|
||||
]
|
||||
|
||||
@openerp.tests.common.at_install(False)
|
||||
|
|
|
@ -2,14 +2,9 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<template id="debugger" inherit_id="website.debugger" name="Event Debugger">
|
||||
<xpath expr='//t[@t-set="debugger_hook"]' position="after">
|
||||
<script type="text/javascript" src="/website_sale_options/static/src/js/website_sale.test.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="product_options_script" inherit_id="website_sale.product" name="Script for Options">
|
||||
<xpath expr="//t[@t-set='head']" position="inside">
|
||||
<template id="assets_editor" inherit_id="website.assets_frontend" name="Shop Product Options">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_sale_options/static/src/js/website_sale.test.js"></script>
|
||||
<script type="text/javascript" src="/website_sale_options/static/src/js/website_sale.js"></script>
|
||||
<link rel='stylesheet' href='/website_sale_options/static/src/css/website_sale.css'/>
|
||||
</xpath>
|
||||
|
|
Loading…
Reference in New Issue