From 0dc0e24e55a49a0954f038e11c0d9a900598c1cb Mon Sep 17 00:00:00 2001 From: soufiane Date: Wed, 5 Apr 2023 19:07:15 +0200 Subject: [PATCH] wip #5850 @7:30 --- .../Admin/ProductBaseController.php | 2 +- app/Http/Controllers/ProductController.php | 5 -- app/Models/Product.php | 28 +++++----- resources/js/app.js | 34 ++++++++++++- resources/js/components/Configurator.vue | 13 +++++ .../styles/components/product-details.styl | 22 ++++++++ resources/views/components/cart-add.blade.php | 8 ++- resources/views/pages/category.blade.php | 4 ++ .../views/pages/product-detail.blade.php | 51 ++++++++++++++++++- resources/views/pages/products.blade.php | 2 +- tailwind.config.js | 2 + 11 files changed, 146 insertions(+), 25 deletions(-) create mode 100644 resources/js/components/Configurator.vue diff --git a/app/Http/Controllers/Admin/ProductBaseController.php b/app/Http/Controllers/Admin/ProductBaseController.php index 31c547c..c557d65 100644 --- a/app/Http/Controllers/Admin/ProductBaseController.php +++ b/app/Http/Controllers/Admin/ProductBaseController.php @@ -208,7 +208,7 @@ class ProductBaseController extends CubistMagicController { $contents = $datas['resume']. "\n"; $contents .= "Details : \r\n\n"; foreach ($datas['details'] as $filename => $values ) { - $contents .= $filename."\r\n"; + $contents .= "Fichier $filename \r\n"; foreach ($values as $product => $value) { $contents .= "> $product : $value \r\n"; } diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index dc8481c..3527e3a 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -59,9 +59,4 @@ class ProductController extends CubistFrontController } return view('pages.product-detail', $this->data); } - - - public function excelToJson($file){ - - } } diff --git a/app/Models/Product.php b/app/Models/Product.php index 3cd479b..8c8bf97 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -548,7 +548,6 @@ class Product extends CubistMagicPageModel $values = []; foreach ($products as $product) { - $pv = $product->get($spec_name); if (is_array($pv) && $data->type === 'list') { @@ -598,17 +597,21 @@ class Product extends CubistMagicPageModel } $f['options'] = $options; } else if ($data->type === 'numeric' || $data->type === 'range' || $data->type === 'numeric_list') { - $f['min'] = INF; - $f['max'] = -INF; - $f['unit'] = $data->unit; - $f['type'] = 'range'; - $f['scale'] = $data->logarithmic_scale ? 'log' : 'linear'; - - if ($data->type === 'numeric' || $data->type === 'numeric_list') { - $f['prefix'] = $data['prefix']; - } else { - $f['prefix'] = ''; - } + //$checkV = array_filter($products, function($n) use($spec_name) { return $n->get($spec_name) !== null; }); + + //if($checkV) { + $f['min'] = INF; + $f['max'] = -INF; + $f['unit'] = $data->unit; + $f['type'] = 'range'; + $f['scale'] = $data->logarithmic_scale ? 'log' : 'linear'; + + if ($data->type === 'numeric' || $data->type === 'numeric_list') { + $f['prefix'] = $data['prefix']; + } else { + $f['prefix'] = ''; + } + //} foreach ($products as $product) { $v = $product->get($spec_name); @@ -618,7 +621,6 @@ class Product extends CubistMagicPageModel continue; } - if (null !== $filter_value) { $fvmax = $filter_value[1]; $fvmin = $filter_value[0]; diff --git a/resources/js/app.js b/resources/js/app.js index 472fa79..ac305c0 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -76,7 +76,12 @@ const app = new Vue({ errorsForm: {}, user: '', default_billing_address: null, - default_delivery_address: null + default_delivery_address: null, + // + price: '', + ref: '', + statusConfig: false, + statusText: '' }, beforeMount() { @@ -102,6 +107,9 @@ const app = new Vue({ id: id }); }); + + this.price = this.$refs.optprice ?.dataset.default + this.statusText = this.$refs.statusConfig ?.dataset.incomplete }, watch: { @@ -402,6 +410,30 @@ const app = new Vue({ .catch(function (error) { } ) + }, + /** + * + */ + changePrice() { + let options = []; + const selectOptions = document.querySelectorAll(".opt-select") + + selectOptions.forEach(function(e, i) { + options.push(e.selectedOptions[0]) + }) + + let prices = options.map(opt => parseFloat(opt.dataset.price)).filter(n => !isNaN(n)), + refs = options.map(opt => opt.dataset.ref).filter(n => n !== undefined).join("/") + + if(prices.length === selectOptions.length) { + this.statusConfig = true + this.statusText = this.$refs.statusConfig.dataset.completed + } + + let total = prices.reduce((init, current) => init + current) + + this.ref = refs + this.price = total + parseFloat(this.$refs.optprice.dataset.default) } }, /** diff --git a/resources/js/components/Configurator.vue b/resources/js/components/Configurator.vue new file mode 100644 index 0000000..fa35921 --- /dev/null +++ b/resources/js/components/Configurator.vue @@ -0,0 +1,13 @@ + diff --git a/resources/styles/components/product-details.styl b/resources/styles/components/product-details.styl index 5b2ef4c..8a27bec 100644 --- a/resources/styles/components/product-details.styl +++ b/resources/styles/components/product-details.styl @@ -1,5 +1,9 @@ .product-detail + .text-block-body + max-width: 570px + width: 100% + &-specifications display: block width: 100% @@ -18,3 +22,21 @@ dd width: 40% max-width: 400px + +.opt + &-group:not(:last-of-type) + margin-bottom: 12px + + &-select + display: block + width: 100% + outline: 2px solid transparent + outline-offset: 2px + border-width: 1px + border-color: rgba(247, 248, 252, 1) + color: theme('colors.grey.dark') + border-radius: 0.25rem + padding: 15px 20px + appearance: none + background: url(/images/icon-angle-down.svg) no-repeat right #fff + background-position-x: calc(100% - 20px) diff --git a/resources/views/components/cart-add.blade.php b/resources/views/components/cart-add.blade.php index dc5aa01..61591be 100644 --- a/resources/views/components/cart-add.blade.php +++ b/resources/views/components/cart-add.blade.php @@ -1,7 +1,11 @@ -