Skip to content

Commit 28ee079

Browse files
committed
refactor:the logic and object of mapping field types with existing CT in CS
1 parent f6d97a2 commit 28ee079

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

api/src/services/contentMapper.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const putTestData = async (req: Request) => {
5757
});
5858

5959
FieldMapperModel.update((data: any) => {
60-
data.field_mapper = [...(data?.field_mapper ?? []), ...fields];
60+
data.field_mapper = [...(data?.field_mapper ?? []), ...(fields ?? [])];
6161
});
6262
contentTypes[index].fieldMapping = fieldIds;
6363
});

ui/src/components/ContentMapper/contentMapper.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export interface MappingFields {
173173
export interface MappingObj {
174174
label: string;
175175
options: Mapping;
176+
type: string
176177
}
177178

178179
export interface FieldHistoryObj {

ui/src/components/ContentMapper/index.tsx

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,101 +80,126 @@ const Fields: MappingFields = {
8080
'Single Line Textbox':'single_line_text',
8181
'Multi Line Textbox':'multi_line_text',
8282
'HTML Rich text Editor':'html',
83-
'JSON Rich Text Editor':'json'}
83+
'JSON Rich Text Editor':'json'},
84+
type : 'text'
8485
},
8586
'multi_line_text':{
8687
label : 'Multi Line Textbox',
8788
options : {
8889
'Multi Line Textbox': 'multi_line_text',
8990
'HTML Rich text Editor': 'html',
90-
'JSON Rich Text Editor':'json'}
91+
'JSON Rich Text Editor':'json'},
92+
type: 'multiline'
9193
},
9294
'json':{
9395
label:'JSON Rich Text Editor',
9496
options : {
9597
'JSON Rich Text Editor':'json',
9698
'HTML Rich text Editor': 'html'
97-
}
99+
},
100+
type: 'json',
98101
},
99102
'html':{
100103
label : 'HTML Rich text Editor',
101104
options : {
102105
'HTML Rich text Editor': 'html',
103-
'JSON Rich Text Editor':'json'}
106+
'JSON Rich Text Editor':'json'
107+
},
108+
type:'allow_rich_text'
104109

105110
},
106111
'markdown':{
107112
label : 'Markdown',
108113
options : {
109114
'Markdown':'markdown',
110115
'HTML Rich text Editor':'html',
111-
'JSON Rich Text Editor':'json'}
116+
'JSON Rich Text Editor':'json'
117+
},
118+
type: 'markdown'
112119
},
113120
'text':{
114121
label : 'Single Line Textbox',
115-
options: {'Single Line Textbox':'single_line_text'}
122+
options: {
123+
'Single Line Textbox':'single_line_text'
124+
},
125+
type:''
116126
},
117127
'url': {
118128
label: 'URL',
119-
options:{'URL':'url'}
129+
options:{'URL':'url'},
130+
type: ''
120131
},
121132
'file': {
122133
label:'File',
123134
options: {
124135
'File':'file'
125-
}
136+
},
137+
type: 'file',
126138
},
127139
'number': {
128140
label:'Number',
129141
options: {
130142
'Number':'number'
131-
}
143+
},
144+
type: 'number'
132145
},
133146
'isodate': { label :'Date',
134147
options: {
135148
'Date':'isodate'
136-
}
149+
},
150+
type: 'isodate'
137151
},
138152
'boolean': {
139153
label: 'Boolean',
140154
options: {
141155
'Boolean':'boolean'
142-
}
156+
},
157+
type: 'boolean',
143158
},
144159
'link': {
145160
label:'Link',
146161
options: {
147162
'Link':'link'
148-
}
163+
},
164+
type: 'link',
149165
},
150166
'reference':{
151167
label: 'Reference',
152168
options: {
153169
'Reference':'reference'
154-
}
170+
},
171+
type: 'reference',
155172
},
156173
'dropdown': {
157174
label:'Dropdown',
158175
options: {
159176
'Dropdown':'dropdown'
160-
}
177+
},
178+
type: 'enum',
161179
},
162180
'radio': {
163181
label :'Select',
164182
options: {
165183
'Select':'select'
166-
}
184+
},
185+
type: 'enum',
167186
},
168187
'checkbox': {
169188
label:'Select',
170-
options: {'Select':'checkbox'}
189+
options: {
190+
'Select':'checkbox'
191+
},
192+
type:'boolean'
171193
},
172194
'global_field':{
173195
label : 'Global',
174-
options: {'Global':'global_field'}},
196+
options: {'Global':'global_field'},
197+
type: ""
198+
},
175199
'group': {
176200
label: 'Group',
177-
options: {'Group':'group'}
201+
options: {'Group':'group'},
202+
type:'Group'
178203
}
179204

180205
}
@@ -1251,7 +1276,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12511276
{
12521277
// Process nested schemas within the current group
12531278
for (const item of array) {
1254-
const fieldTypeToMatch = fieldsOfContentstack[item?.otherCmsType as keyof Mapping];
1279+
const fieldTypeToMatch = Fields[item?.backupFieldType as keyof Mapping]?.type;
12551280
if (item.id === data?.id) {
12561281
for (const key of existingField[groupArray[0]?.uid]?.value?.schema || []) {
12571282

@@ -1278,7 +1303,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12781303
}
12791304
else {
12801305

1281-
const fieldTypeToMatch = fieldsOfContentstack[data?.otherCmsType as keyof Mapping];
1306+
const fieldTypeToMatch = Fields[data?.backupFieldType as keyof Mapping]?.type;
12821307
if (!array.some((item : FieldMapType) => item?.id === data?.id) && checkConditions(fieldTypeToMatch, value, data)) {
12831308
OptionsForRow.push(getMatchingOption(value, true, updatedDisplayName || '',uid ?? ''));
12841309
}
@@ -1349,8 +1374,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
13491374
}
13501375

13511376
if (contentTypeSchema && validateArray(contentTypeSchema)) {
1352-
const fieldTypeToMatch = fieldsOfContentstack[data?.otherCmsType as keyof Mapping];
1353-
1377+
const fieldTypeToMatch = Fields[data?.backupFieldType as keyof Mapping]?.type;
1378+
console.log("field type to match -----> ", fieldTypeToMatch, data?.backupFieldType)
13541379
//check if UID of souce field is matching to exsting content type field UID
13551380
for (const value of contentTypeSchema) {
13561381
if (data?.uid === value?.uid || (data?.uid === value?.uid && data?.otherCmsType === value?.data_type)) {
@@ -1452,7 +1477,6 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
14521477
option = [{ label: OptionsForEachRow, value: OptionsForEachRow }];
14531478
}
14541479

1455-
console.log("data====", data, OptionsForRow);
14561480

14571481

14581482
const OptionValue: FieldTypes =

0 commit comments

Comments
 (0)