add product one time issue fix
This commit is contained in:
parent
b71e5a3904
commit
7235eb597d
Binary file not shown.
@ -163,7 +163,7 @@
|
||||
<nb-select placeholder="Select Product" [(ngModel)]="fieldGroup.id" style="width: 100% !important;margin-right: 1rem;" [disabled]="fieldTitle == 'Edit Order' ? !fieldGroup.isNew : false">
|
||||
<!-- <nb-option value="">Select Drivers</nb-option> -->
|
||||
<!-- (click)="onProductSelect(user.id,user.productName)" -->
|
||||
<nb-option *ngFor="let user of product; index as i; first as isFirst" [value]="user.id"
|
||||
<nb-option *ngFor="let user of checkProductArray(); index as i; first as isFirst" [value]="user.id"
|
||||
>{{user.productName }}({{user.skuId }} )</nb-option>
|
||||
|
||||
|
||||
|
||||
@ -250,6 +250,8 @@ fieldTitle:any ='New Order'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
getUniqueProducts(products: any[], propertyName: string): any[] {
|
||||
const uniqueProducts = [];
|
||||
const seen = new Set();
|
||||
@ -903,6 +905,28 @@ this.onCreateConfirm()
|
||||
// }
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
checkProductArray() {
|
||||
console.log(this.inputFieldGroups)
|
||||
const hasNullId = this.inputFieldGroups.some((group) => group.id === null);
|
||||
console.log(hasNullId)
|
||||
if (!hasNullId) {
|
||||
// There's an object with id = null in the inputFieldGroups array
|
||||
console.log('There is an object with id = null');
|
||||
return this.product;
|
||||
} else {
|
||||
// There is no object with id = null in the inputFieldGroups array
|
||||
// Filter products based on the condition (productName !== 'Mixed Gas' in inputFieldGroups)
|
||||
const filteredProducts = this.product.filter((product) => {
|
||||
const isSelected = this.inputFieldGroups.some((group) => group.id === product.id);
|
||||
return product.productName === 'Mixed Gas' || !isSelected;
|
||||
});
|
||||
|
||||
return filteredProducts;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
addInputFieldGroup() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user