Loading src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.html +1 −1 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ <mat-expansion-panel-header> <div class="d-flex align-items-center w-100"> <mat-checkbox color="primary" class="mr-3" class="mr-3 mt-2" [checked]="isCharacteristicSelected(char)" (click)="$event.stopPropagation()" (change)="onCharacteristicToggle(char, $event)"> Loading src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.ts +36 −18 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ export class EditProductOfferingsComponent implements OnInit { availableSpecCharacteristics: ProductSpecificationCharacteristicRes[] = []; selectedCharacteristics: Set<string> = new Set(); selectedCharValues: Map<string, Set<string>> = new Map(); selectedCharValues: Map<string, Set<any>> = new Map(); listItems = ["Main Properties", "Linked Product Specification Characteristics"] activeListItem = "Main Properties" Loading Loading @@ -142,9 +142,9 @@ export class EditProductOfferingsComponent implements OnInit { this.offering.prodSpecCharValueUse.forEach(charUse => { this.selectedCharacteristics.add(charUse.name); const valueSet = new Set<string>(); const valueSet = new Set<any>(); if (charUse.productSpecCharacteristicValue) { charUse.productSpecCharacteristicValue.forEach(v => valueSet.add(v.value.value)); charUse.productSpecCharacteristicValue.forEach(v => valueSet.add(v.value)); } this.selectedCharValues.set(charUse.name, valueSet); }); Loading Loading @@ -195,9 +195,20 @@ export class EditProductOfferingsComponent implements OnInit { } isValueSelected(char: ProductSpecificationCharacteristicRes, val: any): boolean { if (!val || !val.value) return false; // Guard if (!val || !val.value) return false; // Get the Set of selected objects for this characteristic name const selectedSet = this.selectedCharValues.get(char.name); return selectedSet ? selectedSet.has(val.value.value) : false; if (!selectedSet) return false; for (const storedObj of selectedSet) { if (storedObj.alias === val.value.alias && storedObj.value === val.value.value) { return true; } } return false; } getSelectedValuesCount(char: ProductSpecificationCharacteristicRes): number { Loading @@ -206,16 +217,17 @@ export class EditProductOfferingsComponent implements OnInit { } onValueToggle(char: ProductSpecificationCharacteristicRes, val: any, event: MatCheckboxChange) { // FIX: Only guard against missing wrapper. Allow empty strings inside val.value.value. if (!val || !val.value) return; let selectedSet = this.selectedCharValues.get(char.name); if (!selectedSet) { selectedSet = new Set<string>(); selectedSet = new Set<any>(); this.selectedCharValues.set(char.name, selectedSet); } const valueToStore = val.value.value; console.log(selectedSet); const valueToStore = val.value; if (event.checked) { selectedSet.add(valueToStore); Loading @@ -240,16 +252,15 @@ export class EditProductOfferingsComponent implements OnInit { } selectAllValues(char: ProductSpecificationCharacteristicRes) { const allValues = new Set<string>(); const allValues = new Set<any>(); if (char.productSpecCharacteristicValue && Array.isArray(char.productSpecCharacteristicValue)) { char.productSpecCharacteristicValue.forEach(v => { if (v && v.value) { allValues.add(v.value.value); allValues.add(v.value); } }); } this.selectedCharValues.set(char.name, allValues); this.editForm.markAsDirty(); } Loading @@ -259,8 +270,7 @@ export class EditProductOfferingsComponent implements OnInit { if (selectedSet) { selectedSet.clear(); } else { // Create empty set if none existed to ensure state is clean this.selectedCharValues.set(char.name, new Set<string>()); this.selectedCharValues.set(char.name, new Set<any>()); } this.editForm.markAsDirty(); } Loading @@ -278,7 +288,6 @@ export class EditProductOfferingsComponent implements OnInit { if (linkedSpec.version) productSpecRef.version = linkedSpec.version; } const updateObj: ProductOfferingCreate | ProductOfferingUpdate = { name: formValue.name, description: formValue.description, Loading Loading @@ -402,7 +411,7 @@ export class EditProductOfferingsComponent implements OnInit { mappedValues = char.productSpecCharacteristicValue .filter(val => { return val.value && selectedSet && selectedSet.has(val.value.value); return val.value && selectedSet && selectedSet.has(val.value); }) .map(val => { const { uuid, ...rest } = val as any; Loading @@ -411,7 +420,7 @@ export class EditProductOfferingsComponent implements OnInit { } const charId = char.uuid; const charUuid = char.uuid; // const charUuid = char.uuid; let charVersion = char.version; if (!charVersion && linkedSpec) charVersion = linkedSpec.version; Loading @@ -421,7 +430,7 @@ export class EditProductOfferingsComponent implements OnInit { '@type': 'ProductSpecificationCharacteristic', '@referredType': 'ProductSpecificationCharacteristic' }; if (charUuid) charRef.uuid = charUuid; // if (charUuid) charRef.uuid = charUuid; if (charVersion) charRef.version = charVersion; let parentSpecRef: any = undefined; Loading @@ -436,14 +445,23 @@ export class EditProductOfferingsComponent implements OnInit { } return { uuid: char.uuid, lastUpdate: char.lastUpdate, lifecyclestatusEnum: 'In Study', '@baseType': 'ProductSpecCharacteristicUse', '@type': 'ProductSpecCharacteristicUse', '@schemaLocation': char['@schemaLocation'], href: char.href, name: char.name, description: char.description, lifecycleStatus: char.lifecycleStatus, version: char.version, minCardinality: char.minCardinality, maxCardinality: char.maxCardinality, valueType: char.valueType, validFor: char.validFor, productSpecCharacteristicValue: mappedValues, productSpecificationCharacteristic: charRef, // productSpecificationCharacteristic: charRef, productSpecification: parentSpecRef }; }); Loading Loading
src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.html +1 −1 Original line number Diff line number Diff line Loading @@ -185,7 +185,7 @@ <mat-expansion-panel-header> <div class="d-flex align-items-center w-100"> <mat-checkbox color="primary" class="mr-3" class="mr-3 mt-2" [checked]="isCharacteristicSelected(char)" (click)="$event.stopPropagation()" (change)="onCharacteristicToggle(char, $event)"> Loading
src/app/p_product/admin/productCatalogManagement/edit-product-offerings/edit-product-offerings.component.ts +36 −18 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ export class EditProductOfferingsComponent implements OnInit { availableSpecCharacteristics: ProductSpecificationCharacteristicRes[] = []; selectedCharacteristics: Set<string> = new Set(); selectedCharValues: Map<string, Set<string>> = new Map(); selectedCharValues: Map<string, Set<any>> = new Map(); listItems = ["Main Properties", "Linked Product Specification Characteristics"] activeListItem = "Main Properties" Loading Loading @@ -142,9 +142,9 @@ export class EditProductOfferingsComponent implements OnInit { this.offering.prodSpecCharValueUse.forEach(charUse => { this.selectedCharacteristics.add(charUse.name); const valueSet = new Set<string>(); const valueSet = new Set<any>(); if (charUse.productSpecCharacteristicValue) { charUse.productSpecCharacteristicValue.forEach(v => valueSet.add(v.value.value)); charUse.productSpecCharacteristicValue.forEach(v => valueSet.add(v.value)); } this.selectedCharValues.set(charUse.name, valueSet); }); Loading Loading @@ -195,9 +195,20 @@ export class EditProductOfferingsComponent implements OnInit { } isValueSelected(char: ProductSpecificationCharacteristicRes, val: any): boolean { if (!val || !val.value) return false; // Guard if (!val || !val.value) return false; // Get the Set of selected objects for this characteristic name const selectedSet = this.selectedCharValues.get(char.name); return selectedSet ? selectedSet.has(val.value.value) : false; if (!selectedSet) return false; for (const storedObj of selectedSet) { if (storedObj.alias === val.value.alias && storedObj.value === val.value.value) { return true; } } return false; } getSelectedValuesCount(char: ProductSpecificationCharacteristicRes): number { Loading @@ -206,16 +217,17 @@ export class EditProductOfferingsComponent implements OnInit { } onValueToggle(char: ProductSpecificationCharacteristicRes, val: any, event: MatCheckboxChange) { // FIX: Only guard against missing wrapper. Allow empty strings inside val.value.value. if (!val || !val.value) return; let selectedSet = this.selectedCharValues.get(char.name); if (!selectedSet) { selectedSet = new Set<string>(); selectedSet = new Set<any>(); this.selectedCharValues.set(char.name, selectedSet); } const valueToStore = val.value.value; console.log(selectedSet); const valueToStore = val.value; if (event.checked) { selectedSet.add(valueToStore); Loading @@ -240,16 +252,15 @@ export class EditProductOfferingsComponent implements OnInit { } selectAllValues(char: ProductSpecificationCharacteristicRes) { const allValues = new Set<string>(); const allValues = new Set<any>(); if (char.productSpecCharacteristicValue && Array.isArray(char.productSpecCharacteristicValue)) { char.productSpecCharacteristicValue.forEach(v => { if (v && v.value) { allValues.add(v.value.value); allValues.add(v.value); } }); } this.selectedCharValues.set(char.name, allValues); this.editForm.markAsDirty(); } Loading @@ -259,8 +270,7 @@ export class EditProductOfferingsComponent implements OnInit { if (selectedSet) { selectedSet.clear(); } else { // Create empty set if none existed to ensure state is clean this.selectedCharValues.set(char.name, new Set<string>()); this.selectedCharValues.set(char.name, new Set<any>()); } this.editForm.markAsDirty(); } Loading @@ -278,7 +288,6 @@ export class EditProductOfferingsComponent implements OnInit { if (linkedSpec.version) productSpecRef.version = linkedSpec.version; } const updateObj: ProductOfferingCreate | ProductOfferingUpdate = { name: formValue.name, description: formValue.description, Loading Loading @@ -402,7 +411,7 @@ export class EditProductOfferingsComponent implements OnInit { mappedValues = char.productSpecCharacteristicValue .filter(val => { return val.value && selectedSet && selectedSet.has(val.value.value); return val.value && selectedSet && selectedSet.has(val.value); }) .map(val => { const { uuid, ...rest } = val as any; Loading @@ -411,7 +420,7 @@ export class EditProductOfferingsComponent implements OnInit { } const charId = char.uuid; const charUuid = char.uuid; // const charUuid = char.uuid; let charVersion = char.version; if (!charVersion && linkedSpec) charVersion = linkedSpec.version; Loading @@ -421,7 +430,7 @@ export class EditProductOfferingsComponent implements OnInit { '@type': 'ProductSpecificationCharacteristic', '@referredType': 'ProductSpecificationCharacteristic' }; if (charUuid) charRef.uuid = charUuid; // if (charUuid) charRef.uuid = charUuid; if (charVersion) charRef.version = charVersion; let parentSpecRef: any = undefined; Loading @@ -436,14 +445,23 @@ export class EditProductOfferingsComponent implements OnInit { } return { uuid: char.uuid, lastUpdate: char.lastUpdate, lifecyclestatusEnum: 'In Study', '@baseType': 'ProductSpecCharacteristicUse', '@type': 'ProductSpecCharacteristicUse', '@schemaLocation': char['@schemaLocation'], href: char.href, name: char.name, description: char.description, lifecycleStatus: char.lifecycleStatus, version: char.version, minCardinality: char.minCardinality, maxCardinality: char.maxCardinality, valueType: char.valueType, validFor: char.validFor, productSpecCharacteristicValue: mappedValues, productSpecificationCharacteristic: charRef, // productSpecificationCharacteristic: charRef, productSpecification: parentSpecRef }; }); Loading