From 2a55e3d2f93ab04dc11fdf1a4b8f547f3b1d36bc Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 20 Mar 2021 16:52:49 -0400 Subject: [PATCH 1/2] Correction des URLs de l'inventaire. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout d'une confirmation avant de déduire l'inventaire. --- .../mix-table/mix-table.component.html | 4 ++-- .../pages/explore/explore.component.html | 8 +++++++- .../colors/pages/explore/explore.component.ts | 19 +++++++++++++------ .../modules/colors/services/recipe.service.ts | 9 --------- .../material/service/inventory.service.ts | 13 +++++++++++-- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/app/modules/colors/components/mix-table/mix-table.component.html b/src/app/modules/colors/components/mix-table/mix-table.component.html index 7b0738c..10f11c0 100644 --- a/src/app/modules/colors/components/mix-table/mix-table.component.html +++ b/src/app/modules/colors/components/mix-table/mix-table.component.html @@ -57,7 +57,7 @@ step="0.001" [value]="getComputedQuantityRounded(mixMaterial)" [disabled]="mixMaterial.material.materialType.usePercentages" - (change)="changeQuantity($event, mixMaterial)"/> + (keyup)="changeQuantity($event, mixMaterial)"/> @@ -69,7 +69,7 @@ min="0.001" step="0.001" [value]="round(getTotalQuantity())" - (change)="changeQuantity($event, null, true)"/> + (keyup)="changeQuantity($event, null, true)"/> diff --git a/src/app/modules/colors/pages/explore/explore.component.html b/src/app/modules/colors/pages/explore/explore.component.html index eadbe1e..39adb75 100644 --- a/src/app/modules/colors/pages/explore/explore.component.html +++ b/src/app/modules/colors/pages/explore/explore.component.html @@ -30,7 +30,7 @@ [units$]="units$" (quantityChange)="changeQuantity($event)" (locationChange)="changeMixLocation($event)" - (deduct)="deductMix($event)"> + (deduct)="showDeductMixConfirm($event, deductConfirmBox)"> @@ -45,3 +45,9 @@ + + + diff --git a/src/app/modules/colors/pages/explore/explore.component.ts b/src/app/modules/colors/pages/explore/explore.component.ts index e54310c..46bf6b9 100644 --- a/src/app/modules/colors/pages/explore/explore.component.ts +++ b/src/app/modules/colors/pages/explore/explore.component.ts @@ -7,6 +7,8 @@ import {Observable, Subject} from 'rxjs' import {ErrorModel, ErrorService} from '../../../shared/service/error.service' import {AlertService} from '../../../shared/service/alert.service' import {GlobalAlertHandlerComponent} from '../../../shared/components/global-alert-handler/global-alert-handler.component' +import {InventoryService} from '../../../material/service/inventory.service' +import {ConfirmBoxComponent} from '../../../shared/components/confirm-box/confirm-box.component' @Component({ selector: 'cre-explore', @@ -32,6 +34,7 @@ export class ExploreComponent extends ErrorHandlingComponent { constructor( private recipeService: RecipeService, + private inventoryService: InventoryService, private alertService: AlertService, errorService: ErrorService, router: Router, @@ -94,15 +97,19 @@ export class ExploreComponent extends ErrorHandlingComponent { ) } - deductMix(mixId: number) { + showDeductMixConfirm(mixId: number, confirmBox: ConfirmBoxComponent) { this.deductedMixId = mixId - const firstMixMaterial = this.recipe.mixes.filter(m => m.id === mixId)[0].mixMaterials[0] - if (this.quantitiesChanges.has(mixId) && this.quantitiesChanges.get(mixId).has(firstMixMaterial.material.id)) { + confirmBox.show() + } + + deductMix() { + const firstMixMaterial = this.recipe.mixes.filter(m => m.id === this.deductedMixId)[0].mixMaterials[0] + if (this.quantitiesChanges.has(this.deductedMixId) && this.quantitiesChanges.get(this.deductedMixId).has(firstMixMaterial.material.id)) { const originalQuantity = firstMixMaterial.quantity - const currentQuantity = this.quantitiesChanges.get(mixId).get(firstMixMaterial.material.id) - this.subscribeDeductMix(this.recipeService.deductMixFromQuantities(mixId, originalQuantity, currentQuantity)) + const currentQuantity = this.quantitiesChanges.get(this.deductedMixId).get(firstMixMaterial.material.id) + this.subscribeDeductMix(this.inventoryService.deductMixFromQuantities(this.deductedMixId, originalQuantity, currentQuantity)) } else { - this.subscribeDeductMix(this.recipeService.deductMix(mixId, 1)) + this.subscribeDeductMix(this.inventoryService.deductMix(this.deductedMixId, 1)) } } diff --git a/src/app/modules/colors/services/recipe.service.ts b/src/app/modules/colors/services/recipe.service.ts index 32c6bb7..3f847d1 100644 --- a/src/app/modules/colors/services/recipe.service.ts +++ b/src/app/modules/colors/services/recipe.service.ts @@ -67,13 +67,4 @@ export class RecipeService { delete(id: number): Observable { return this.api.delete(`/recipe/${id}`) } - - deductMixFromQuantities(mixId: number, originalQuantity: number, currentQuantity: number): Observable { - return this.deductMix(mixId, currentQuantity / originalQuantity) - } - - deductMix(mixId: number, ratio: number): Observable { - const body = {id: mixId, ratio} - return this.api.put('/inventory/deduct/mix', body) - } } diff --git a/src/app/modules/material/service/inventory.service.ts b/src/app/modules/material/service/inventory.service.ts index 2429fce..5132fa2 100644 --- a/src/app/modules/material/service/inventory.service.ts +++ b/src/app/modules/material/service/inventory.service.ts @@ -12,11 +12,20 @@ export class InventoryService { } add(material: number, quantity: number): Observable { - return this.api.put('/material/inventory/add', [{material, quantity}]) + return this.api.put('/inventory/add', [{material, quantity}]) + } + + deductMixFromQuantities(mixId: number, originalQuantity: number, currentQuantity: number): Observable { + return this.deductMix(mixId, currentQuantity / originalQuantity) + } + + deductMix(mixId: number, ratio: number): Observable { + const body = {id: mixId, ratio} + return this.api.put('/inventory/deduct/mix', body) } deduct(materialQuantities: [{material: number, quantity: number}]): Observable { - return this.api.put('/material/inventory/deduct', materialQuantities) + return this.api.put('/inventory/deduct', materialQuantities) } } From 84457d37886325dd43e4eca9f4e9f07b3dfb67aa Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sat, 20 Mar 2021 17:03:36 -0400 Subject: [PATCH 2/2] =?UTF-8?q?Am=C3=A9lioration=20de=20l'interface=20de?= =?UTF-8?q?=20l'inventaire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La valeur entrée dans l'ajout de produit ne sera plus supprimée lorsque la souris ne survole plus le produit. --- .../material/pages/inventory/inventory.component.html | 7 +++++-- .../material/pages/inventory/inventory.component.ts | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/modules/material/pages/inventory/inventory.component.html b/src/app/modules/material/pages/inventory/inventory.component.html index 6b05a5a..2c4f175 100644 --- a/src/app/modules/material/pages/inventory/inventory.component.html +++ b/src/app/modules/material/pages/inventory/inventory.component.html @@ -68,13 +68,16 @@ -
+
+ placeholder="0" + (click)="selectedMaterial = material"/>