Browse Source

[Boutique] Gestion des accessoires

feature/rotating_product
Guillaume Bourgeois 4 months ago
parent
commit
c3517b8736
3 changed files with 26 additions and 8 deletions
  1. +2
    -1
      domain/Order/Order/OrderResolver.php
  2. +1
    -1
      producer/views/order/order.php
  3. +23
    -6
      producer/web/js/vuejs/order-order.js

+ 2
- 1
domain/Order/Order/OrderResolver.php View File

@@ -93,7 +93,8 @@ class OrderResolver extends AbstractResolver

public function getProductQuantityMaxOrderable(Product $product, Distribution $distribution, Order $orderCurrent = null): ?float
{
return $this->getProductQuantityRemaining($product, $distribution, $orderCurrent, true);
return $this->orderSolver->getProductQuantity($product, $orderCurrent ? [$orderCurrent] : [])
+ $this->getProductQuantityRemaining($product, $distribution, $orderCurrent);
}

public function getQuantityOfAccessoryAvailableInDistribution(

+ 1
- 1
producer/views/order/order.php View File

@@ -412,7 +412,7 @@ $this->setMeta('description', $producerModule->getSeoGenerator()->generateMetaDe
<button class="btn btn-secondary btn-plus"
type="button"
@click="productQuantityClick(product, product.unit == 'piece' ? 1 : parseFloat(product.step))"
:disabled="product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max || loadingProducts">
:disabled="loadingProducts || product.quantity_remaining <= 0 || product.quantity_form >= product.quantity_max * product.coefficient_unit">
<i class="bi bi-plus-lg"></i></button>
</span>
</div>

+ 23
- 6
producer/web/js/vuejs/order-order.js View File

@@ -5,6 +5,8 @@ var app = new Vue({
data() {
return Object.assign({
order: null,
timerAjaxInfosProducts: false,
xhr: false,
loading: false,
loadingProducts: false,
loadingInit: true,
@@ -132,9 +134,26 @@ var app = new Vue({
var app = this ;

if(loadingProducts) {
if(app.cancelTokenSource !== null) {
app.cancelTokenSource.cancel();
if (app.timerAjaxInfosProducts) {
clearTimeout(app.timerAjaxInfosProducts);
}
app.timerAjaxInfosProducts = setTimeout(function(app) {
app.loadingProducts = true ;
if(app.xhr) {
app.xhr.abort();
}
app.xhr = $.get('ajax-infos', {
date : app.getDate(),
pointSaleId: app.pointSaleActiveId ? app.pointSaleActiveId : (app.pointSaleActive ? app.pointSaleActive.id : 0),
productsJson: JSON.stringify(app.getProductsArray()),
loadingProducts: loadingProducts
}, function(response) {
app.products = response.products;
app.loadingProducts = false;
}, 'json');
}.bind(this, app), 300);

return;
}
else {
this.loading = true ;
@@ -145,9 +164,9 @@ var app = new Vue({
app.products = [] ;
}

app.cancelTokenSource = axios.CancelToken.source();
//app.cancelTokenSource = axios.CancelToken.source();
axios.get("ajax-infos",{
cancelToken: app.cancelTokenSource.token,
//cancelToken: app.cancelTokenSource.token,
params: {
date : this.getDate(),
pointSaleId: this.pointSaleActiveId ? this.pointSaleActiveId : (this.pointSaleActive ? this.pointSaleActive.id : 0),
@@ -156,8 +175,6 @@ var app = new Vue({
}})
.catch(function (thrown) {
if (axios.isCancel(thrown)) {
//console.log('Request canceled', thrown.message);
//return Promise.reject(thrown);
}
})
.then(function(response) {

Loading…
Cancel
Save