Les produits sont maintenant filtrés dans l'éditeur de mélange pour empêcher les duplications.

This commit is contained in:
FyloZ 2021-03-09 15:57:45 -05:00
parent 98e5d7f36c
commit ce2eb6fcef
2 changed files with 7 additions and 2 deletions

View File

@ -46,8 +46,8 @@
<th mat-header-cell *matHeaderCellDef>Produit</th>
<td mat-cell *matCellDef="let mixMaterial">
<mat-form-field *ngIf="materials">
<mat-select [(ngModel)]="mixMaterial.materialId">
<mat-option *ngFor="let material of materials"
<mat-select #select [(ngModel)]="mixMaterial.materialId" [value]="mixMaterial.materialId">
<mat-option *ngFor="let material of getAvailableMaterials(select)"
[value]="material.id">{{material.name}}</mat-option>
</mat-select>
</mat-form-field>

View File

@ -16,6 +16,7 @@ import {ConfirmBoxComponent} from '../../../shared/components/confirm-box/confir
import {AccountService} from '../../../accounts/services/account.service'
import {EmployeePermission} from '../../../shared/model/employee'
import {ErrorService} from '../../../shared/service/error.service'
import {MatSelect} from '@angular/material/select'
@Component({
selector: 'cre-mix-editor',
@ -131,6 +132,10 @@ export class MixEditorComponent extends SubscribingComponent {
return id ? this.materials.filter(m => m.id === id)[0] : null
}
getAvailableMaterials(selector: MatSelect): Material[] {
return this.materials.filter(m => selector.value === m.id || this.mixMaterials.filter(mm => mm.materialId === m.id).length === 0)
}
get canDeleteMix() {
return this.accountService.hasPermission(EmployeePermission.REMOVE_RECIPE)
}