-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] website_sale_product_assortment: Migration to 18.0
- Loading branch information
1 parent
5f30180
commit 2621dfe
Showing
9 changed files
with
114 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
website_sale_product_assortment/static/src/js/assortment_list_preview.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import core from "web.core"; | ||
|
||
var WebsiteSaleProductAssortment = { | ||
selector: "#products_grid", | ||
|
||
start: function () { | ||
return $.when.apply($, [ | ||
this._super.apply(this, arguments), | ||
this.render_assortments(), | ||
]); | ||
}, | ||
render_assortments: function () { | ||
const $products = $(".o_wsale_product_grid_wrapper"); | ||
const product_dic = {}; | ||
$products.each(function () { | ||
product_dic[this.querySelector("a img").src.split("/")[6]] = this; | ||
}); | ||
const product_ids = Object.keys(product_dic).map(Number); | ||
return this._rpc({ | ||
route: "/sale/get_info_assortment_preview", | ||
params: {product_template_ids: product_ids}, | ||
}).then((product_values) => { | ||
for (const product of product_values) { | ||
this.render_product_assortment(product_dic[product.id], product); | ||
} | ||
}); | ||
}, | ||
render_product_assortment: function (product_info, product) { | ||
$(product_info) | ||
.find(".product_price") | ||
.append( | ||
$( | ||
core.qweb.render( | ||
"website_sale_product_assortment.product_availability", | ||
{ | ||
message_unavailable: product.message_unavailable, | ||
product_template_id: product.id, | ||
} | ||
) | ||
).get(0) | ||
); | ||
|
||
$(product_info).find(".fa-shopping-cart").parent().addClass("disabled"); | ||
}, | ||
}; | ||
|
||
export default WebsiteSaleProductAssortment; |
50 changes: 0 additions & 50 deletions
50
website_sale_product_assortment/static/src/js/assortment_list_preview.js
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
website_sale_product_assortment/static/src/js/variant_mixin.esm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2021 Tecnativa - Carlos Roca | ||
// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
import {QWeb} from "web.core"; | ||
import VariantMixin from "@website_sale/js/sale_variant_mixin"; | ||
|
||
VariantMixin._onChangeCombinationAssortment = function (ev, $parent, combination) { | ||
let product_id = 0; | ||
if ($parent.find("input.product_id:checked").length) { | ||
product_id = $parent.find("input.product_id:checked").val(); | ||
} else { | ||
product_id = $parent.find(".product_id").val(); | ||
} | ||
const isMainProduct = | ||
combination.product_id && | ||
($parent.is(".js_main_product") || $parent.is(".main_product")) && | ||
combination.product_id === parseInt(product_id); | ||
if (!this.isWebsite || !isMainProduct) { | ||
return; | ||
} | ||
$(".oe_website_sale") | ||
.find("#message_unavailable_" + combination.product_template_id) | ||
.remove(); | ||
$("#product_full_assortment_description").remove(); | ||
if (!combination.product_avoid_purchase) { | ||
return; | ||
} | ||
$parent.find("#add_to_cart").addClass("disabled"); | ||
$parent.find("#buy_now").addClass("disabled"); | ||
$(".oe_website_sale") | ||
.find("#product_option_block") | ||
.prepend( | ||
QWeb.render( | ||
"website_sale_product_assortment.product_availability", | ||
combination | ||
) | ||
); | ||
if (combination.assortment_information) { | ||
$("#product_detail").after( | ||
"<div id='product_full_assortment_description'>" + | ||
combination.assortment_information + | ||
"</div>" | ||
); | ||
} | ||
}; | ||
|
||
VariantMixin._onChangeCombination = function (ev, $parent, combination) { | ||
this._super.apply(this, arguments); | ||
this._onChangeCombinationAssortment(ev, $parent, combination); | ||
}; | ||
|
||
export default VariantMixin; |
65 changes: 0 additions & 65 deletions
65
website_sale_product_assortment/static/src/js/variant_mixin.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters