From a261bd5bcd194592dbc6c7c816b55e20ebe656ce Mon Sep 17 00:00:00 2001 From: "David Monnom (moda)" Date: Fri, 29 Dec 2023 12:10:58 +0100 Subject: [PATCH] [IMP] point_of_sale: improve UX of product configurator popup - Improved the UX of the product configurator. - Display of attribute name in orderline name. Previously, the user had to click on the checkbox or radio to select the option, clicking on the label didn't work. The attribute name was not displayed in the orderline name, only the values. Now the input has been replaced by a button, making it easier to use on touch-screen devices. The attribute name is displayed in the orderline name in the format `Size: M, Fabric: Leather`. closes odoo/odoo#147744 Taskids: 3638192 & 3633555 Signed-off-by: Joseph Caburnay (jcb) --- .../product_configurator_popup.js | 12 ++- .../product_configurator_popup.xml | 102 +++++++++++++----- .../helpers/ProductConfiguratorTourMethods.js | 2 +- .../attribute_selection.js | 3 +- .../attribute_selection.xml | 2 +- 5 files changed, 89 insertions(+), 32 deletions(-) diff --git a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.js b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.js index a406ada3a33..c443060a968 100644 --- a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.js +++ b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.js @@ -38,6 +38,11 @@ export class BaseProductAttribute extends Component { extra, }; } + + getFormatPriceExtra(val) { + const sign = val < 0 ? "- " : "+ "; + return sign + this.env.utils.formatCurrency(Math.abs(val)); + } } export class RadioProductAttribute extends BaseProductAttribute { @@ -57,6 +62,10 @@ export class RadioProductAttribute extends BaseProductAttribute { } } +export class PillsProductAttribute extends BaseProductAttribute { + static template = "point_of_sale.PillsProductAttribute"; +} + export class SelectProductAttribute extends BaseProductAttribute { static template = "point_of_sale.SelectProductAttribute"; } @@ -71,7 +80,7 @@ export class MultiProductAttribute extends BaseProductAttribute { setup() { super.setup(); this.state = useState({ - attribute_value_ids: [], + attribute_value_ids: {}, custom_value: "", }); @@ -91,6 +100,7 @@ export class ProductConfiguratorPopup extends AbstractAwaitablePopup { static template = "point_of_sale.ProductConfiguratorPopup"; static components = { RadioProductAttribute, + PillsProductAttribute, SelectProductAttribute, ColorProductAttribute, MultiProductAttribute, diff --git a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml index 8e9e1076d39..1db839957a3 100644 --- a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml +++ b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml @@ -3,21 +3,46 @@
-
+
- - -
+ +
- + +
-
+
+ +
+ +
+
+
+ + +
+
+ +
+ + +
+
@@ -29,12 +54,12 @@
- @@ -49,13 +74,20 @@
  • - + - + + +
    + + + +
    +
@@ -64,15 +96,25 @@
-
-
-
-
-
- +
+
+ +
+
+ + diff --git a/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js b/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js index 5cd553a5836..30dea9d7d8e 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js +++ b/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js @@ -4,7 +4,7 @@ export function pickRadio(name) { return [ { content: `picking radio attribute with name ${name}`, - trigger: `.product-configurator-popup .attribute-name-cell label[name='${name}']`, + trigger: `.product-configurator-popup div.attribute-name-cell:contains('${name}') input`, }, ]; } diff --git a/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.js b/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.js index 187ec2e7a7c..66dbc9087a3 100644 --- a/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.js +++ b/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.js @@ -147,6 +147,7 @@ export class AttributeSelection extends Component { getfPriceExtra(value) { const priceExtra = this._getPriceExtra(value); - return this.selfOrder.formatMonetary(priceExtra); + const sign = priceExtra < 0 ? "- " : "+ "; + return sign + this.selfOrder.formatMonetary(Math.abs(priceExtra)); } } diff --git a/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.xml b/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.xml index f6ebfeb36c9..0f6e66694da 100644 --- a/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.xml +++ b/addons/pos_self_order/static/src/app/components/attribute_selection/attribute_selection.xml @@ -17,7 +17,7 @@
- + +