Skip to content

Commit a19cc41

Browse files
committed
fix:refactored the bug [CMG-639] When uid of the field is title and then for existing case it is getting mapped to title of existing content type
1 parent 65d2ef6 commit a19cc41

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

ui/src/components/AdvancePropertise/advanceProperties.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface SchemaProps {
2525
* @param value - The advanced settings.
2626
* @param checkBoxChanged - Indicates whether the checkbox has changed.
2727
*/
28-
updateFieldSettings: (rowId: string, value: Advanced, checkBoxChanged: boolean) => void;
28+
updateFieldSettings: (rowId: string, value: Advanced, checkBoxChanged: boolean, rowContentstackFieldUid: string) => void;
2929

3030
/**
3131
* Indicates whether the field is localized.

ui/src/components/AdvancePropertise/index.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ const AdvancePropertise = (props: SchemaProps) => {
147147
title: currentToggleStates?.title,
148148
url: currentToggleStates?.url
149149
},
150-
checkBoxChanged
150+
checkBoxChanged,
151+
props?.data?.contentstackFieldUid
152+
151153
);
152154
};
153155

@@ -189,7 +191,8 @@ const AdvancePropertise = (props: SchemaProps) => {
189191
title: currentToggleStates?.title,
190192
url: currentToggleStates?.url
191193
},
192-
checkBoxChanged
194+
checkBoxChanged,
195+
props?.data?.contentstackFieldUid
193196
);
194197
};
195198

@@ -215,7 +218,8 @@ const AdvancePropertise = (props: SchemaProps) => {
215218
embedObject: currentToggleStates?.embedObject,
216219
embedObjects: embedObjectsLabels
217220
},
218-
true
221+
true,
222+
props?.data?.contentstackFieldUid
219223
);
220224
};
221225

@@ -251,7 +255,8 @@ const AdvancePropertise = (props: SchemaProps) => {
251255
embedObjects: embedObjectsLabels,
252256
options: options
253257
},
254-
true
258+
true,
259+
props?.data?.contentstackFieldUid
255260
);
256261
};
257262
const handleRemoveDefalutValue = (index: number) => {
@@ -280,7 +285,8 @@ const AdvancePropertise = (props: SchemaProps) => {
280285
embedObjects: embedObjectsLabels,
281286
options: options
282287
},
283-
true
288+
true,
289+
props?.data?.contentstackFieldUid
284290
);
285291
};
286292

@@ -583,7 +589,8 @@ const AdvancePropertise = (props: SchemaProps) => {
583589
validationRegex: toggleStates?.validationRegex ?? '',
584590
embedObjects: embedObject
585591
},
586-
true
592+
true,
593+
props?.data?.contentstackFieldUid
587594
);
588595
}}
589596
options={option}

ui/src/components/ContentMapper/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -766,11 +766,11 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
766766
});
767767
}
768768

769-
const updateFieldSettings = (rowId: string, updatedSettings: Advanced, checkBoxChanged: boolean) => {
769+
const updateFieldSettings = (rowId: string, updatedSettings: Advanced, checkBoxChanged: boolean, rowContentstackFieldUid: string) => {
770770
setIsDropDownChanged(checkBoxChanged);
771771

772772
const newTableData = tableData?.map?.((row) => {
773-
if (row?.uid === rowId) {
773+
if (row?.uid === rowId && row?.contentstackFieldUid === rowContentstackFieldUid) {
774774

775775
return { ...row, advanced: { ...row?.advanced, ...updatedSettings } };
776776
}
@@ -985,11 +985,11 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
985985
};
986986

987987
// Method for change select value
988-
const handleValueChange = (value: FieldTypes, rowIndex: string) => {
988+
const handleValueChange = (value: FieldTypes, rowIndex: string, rowContentstackFieldUid: string) => {
989989
setIsDropDownChanged(true);
990990
setFieldValue(value);
991991
const updatedRows: FieldMapType[] = selectedEntries?.map?.((row) => {
992-
if (row?.uid === rowIndex) {
992+
if (row?.uid === rowIndex && row?.contentstackFieldUid === rowContentstackFieldUid) {
993993
return { ...row, contentstackFieldType: value?.value };
994994
}
995995
return row;
@@ -1069,7 +1069,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
10691069
<Select
10701070
id={data?.uid}
10711071
value={initialOption || fieldValue}
1072-
onChange={(selectedOption: FieldTypes) => handleValueChange(selectedOption, data?.uid)}
1072+
onChange={(selectedOption: FieldTypes) => handleValueChange(selectedOption, data?.uid, data?.contentstackFieldUid)}
10731073
placeholder="Select Field"
10741074
version={'v2'}
10751075
maxWidth="290px"
@@ -1129,7 +1129,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11291129
);
11301130
};
11311131

1132-
const handleFieldChange = (selectedValue: FieldTypes, rowIndex: string) => {
1132+
const handleFieldChange = (selectedValue: FieldTypes, rowIndex: string, contentstackFieldUid: string) => {
11331133
setIsDropDownChanged(true);
11341134
const previousSelectedValue = existingField[rowIndex]?.label;
11351135
const groupArray = nestedList?.filter(item =>
@@ -1156,7 +1156,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11561156
else {
11571157
setIsFieldDeleted(false);
11581158
}
1159-
1159+
console.info("row index ---> ", rowIndex)
11601160
setExistingField((prevOptions: ExistingFieldType) => ({
11611161
...prevOptions,
11621162
[rowIndex]: { label: selectedValue?.label, value: selectedValue?.value }
@@ -1176,7 +1176,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
11761176

11771177

11781178
const updatedRows: FieldMapType[] = tableData.map((row) => {
1179-
if (row?.uid === rowIndex) {
1179+
if (row?.uid === rowIndex && row?.contentstackFieldUid === contentstackFieldUid) {
11801180
return {
11811181
...row,
11821182
contentstackField: selectedValue?.label,
@@ -1569,9 +1569,9 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15691569
value={(OptionsForRow?.length === 0 || existingField?.[data?.uid]?.label === undefined) ? OptionValue : existingField[data?.uid]}
15701570
onChange={(selectedOption: FieldTypes) => {
15711571
if (OptionsForRow?.length === 0) {
1572-
handleValueChange(selectedOption, data?.uid)
1572+
handleValueChange(selectedOption, data?.uid, data?.contentstackFieldUid)
15731573
} else {
1574-
handleFieldChange(selectedOption, data?.uid)
1574+
handleFieldChange(selectedOption, data?.uid, data?.contentstackFieldUid)
15751575
}
15761576
}}
15771577
placeholder="Select Field"

0 commit comments

Comments
 (0)