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)
}
}