Skip to content

Commit b2e453c

Browse files
Merge pull request #631 from contentstack/feature/dropdown-field-choices
Feature/dropdown field choices
2 parents 90712ae + 8fb5f32 commit b2e453c

File tree

8 files changed

+159
-135
lines changed

8 files changed

+159
-135
lines changed

api/src/services/contentMapper.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ const updateContentMapper = async (req: Request) => {
12001200
)) as number;
12011201

12021202
try {
1203-
ProjectModelLowdb.update((data: any) => {
1203+
await ProjectModelLowdb.update((data: any) => {
12041204
data.projects[projectIndex].mapperKeys = content_mapper;
12051205
data.projects[projectIndex].updated_at = new Date().toISOString();
12061206
});

ui/package-lock.json

Lines changed: 102 additions & 90 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@types/react": "^18.2.28",
1313
"@types/react-dom": "^18.2.13",
1414
"@types/react-redux": "^7.1.33",
15-
"axios": "^1.8.2",
15+
"axios": "^1.8.3",
1616
"bootstrap": "5.1.3",
1717
"chokidar": "^3.6.0",
1818
"final-form": "^4.20.10",

ui/src/components/AdvancePropertise/index.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,10 @@
182182
font-size: 14px;
183183
color: $color-stepper-title;
184184
}
185+
.Tag {
186+
.Tag__item {
187+
span {
188+
line-height: $line-height-reset!important;
189+
}
190+
}
191+
}

ui/src/components/ContentMapper/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const Fields: MappingFields = {
169169
options: {
170170
'Reference':'reference'
171171
},
172-
type: 'reference',
172+
type: '',
173173
},
174174
'dropdown': {
175175
label:'Dropdown',
@@ -205,12 +205,12 @@ const Fields: MappingFields = {
205205
'app':{
206206
label: 'Marketplace app',
207207
options: {'Marketplace app':'app'},
208-
type:'app'
208+
type:''
209209
},
210210
'extension':{
211211
label: 'Extension',
212212
options: {'Extension':'extension'},
213-
type:'extension'
213+
type:''
214214
}
215215

216216
}
@@ -1240,7 +1240,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12401240

12411241
//utility function to map the source cms field type to content type field type
12421242
function checkConditions(fieldTypeToMatch: string | string[], value: ContentTypesSchema, data: FieldMapType) {
1243-
const fieldTypes = new Set(['number', 'isodate', 'file', 'reference', 'boolean', 'group', 'link','global_field']);
1243+
const fieldTypes = new Set(['number', 'isodate', 'file', 'reference', 'boolean', 'group', 'link','global_field','json','blocks']);
12441244
switch (fieldTypeToMatch) {
12451245
case 'text':
12461246
return (
@@ -1266,7 +1266,7 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
12661266
case 'isodate':
12671267
return value?.data_type === 'isodate';
12681268
case 'json':
1269-
return value?.data_type === 'json';
1269+
return value?.data_type === 'json' && value?.field_metadata?.allow_json_rte;
12701270
// case 'enum':
12711271
// return 'enum' in value;
12721272
case 'radio':
@@ -1586,8 +1586,8 @@ const ContentMapper = forwardRef(({handleStepChange}: contentMapperProps, ref: R
15861586
{(!OptionValue?.isDisabled || OptionValue?.label === 'Dropdown'||
15871587
(data?.backupFieldType !== 'extension' &&
15881588
data?.backupFieldType !== 'app' &&
1589-
data?.otherCmsField !== 'title' &&
1590-
data?.otherCmsField !== 'url')) && (
1589+
data?.backupFieldUid !== 'title' &&
1590+
data?.backupFieldUid !== 'url')) && (
15911591
<div className='advanced-setting-button'>
15921592
<Tooltip
15931593
content="Advanced properties"

ui/src/components/SchemaModal/index.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@
8888
padding: 0.625rem 0;
8989
svg {
9090
margin-right: 0.375rem;
91-
&.field-icon {
92-
max-width: 12px;
93-
}
9491
}
9592
}
9693
.chevron {

ui/src/components/SchemaModal/index.tsx

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,38 @@ import './index.scss';
1212
// Function for get icons
1313
const getTopLevelIcons = (field: FieldMapType) => {
1414
const icons: Icons = {
15-
title: 'StarSmall',
16-
text: 'SingleLineTextSmall',
17-
multitext: 'MultiLineTextSmall',
18-
rte: 'RichTextEditorSmall',
19-
jsonRte: 'SuperchargedRte',
20-
markdown: 'MarkdownSmall',
21-
select: 'SelectSmall',
22-
number: 'NumberSmall',
23-
boolean: 'BooleanSmall',
24-
isodate: 'DateSmall',
25-
file: 'FileSmall',
26-
reference: 'ReferenceSmall',
27-
group: 'GroupSmall',
28-
global_field: 'GlobalSmall',
29-
blocks: 'ModularBlocksSmall',
30-
link: 'LinkSmall',
15+
title: 'Title',
16+
text: 'SingleLineText',
17+
multitext: 'MultiLineText',
18+
rte: 'RichTextEditor',
19+
jsonRte: 'JsonRichTextEditor',
20+
markdown: 'Markdown',
21+
select: 'Select',
22+
number: 'Number',
23+
boolean: 'Boolean',
24+
isodate: 'Date',
25+
file: 'File',
26+
reference: 'Reference',
27+
group: 'Group',
28+
global_field: 'Global',
29+
blocks: 'ModularBlocks',
30+
link: 'Link',
3131
bullet: 'Bullet',
32-
custom: 'CustomSmall',
33-
tag: 'TagSmall',
34-
experience_container: 'PersonalizationLogoGreySmall'
32+
custom: 'Custom',
33+
tag: 'Tag',
34+
extension: 'Extension'
3535
};
3636

3737
if (
38-
field?.contentstackFieldType === 'Single Line Textbox' ||
39-
field?.contentstackFieldType === 'single_line_text'
38+
field?.contentstackFieldType === 'text'
4039
) {
4140
return icons['title'];
4241
}
4342

44-
if (field?.contentstackFieldType === 'URL' || field?.contentstackFieldType === 'url') {
43+
if (field?.contentstackFieldType === 'url') {
44+
return icons['text'];
45+
}
46+
if (field?.contentstackFieldType === 'single_line_text') {
4547
return icons['text'];
4648
}
4749

@@ -58,14 +60,11 @@ const getTopLevelIcons = (field: FieldMapType) => {
5860
return icons['select'];
5961
}
6062

61-
if (field?.contentstackFieldType === 'Date') {
63+
if (field?.contentstackFieldType === 'isodate') {
6264
return icons['isodate'];
6365
}
6466

65-
if (
66-
field?.contentstackFieldType === 'Multi Line Textbox' ||
67-
field?.contentstackFieldType === 'multi_line_text'
68-
) {
67+
if (field?.contentstackFieldType === 'multi_line_text') {
6968
return icons['multitext'];
7069
}
7170

@@ -76,12 +75,12 @@ const getTopLevelIcons = (field: FieldMapType) => {
7675
return icons['rte'];
7776
}
7877

79-
if (
80-
field?.contentstackFieldType === 'JSON Rich Text Editor' ||
81-
field?.contentstackFieldType === 'json'
82-
) {
78+
if (field?.contentstackFieldType === 'json') {
8379
return icons['jsonRte'];
8480
}
81+
if (field?.contentstackFieldType === 'file') {
82+
return icons['file'];
83+
}
8584

8685
if (field?.contentstackFieldType === 'Link') {
8786
return icons['link'];
@@ -99,6 +98,14 @@ const getTopLevelIcons = (field: FieldMapType) => {
9998
return icons['blocks'];
10099
}
101100

101+
if (field?.contentstackFieldType === 'app') {
102+
return icons['custom'];
103+
}
104+
105+
if (field?.contentstackFieldType === 'extension') {
106+
return icons['extension'];
107+
}
108+
102109
return icons[field?.contentstackFieldType as keyof Icons];
103110
};
104111

@@ -180,7 +187,7 @@ const TreeView = ({ schema = [] }: schemaType) => {
180187
{hasNestedValue(field) && (
181188
<Icon className={`chevron ${index ? '' : 'close'} `} icon="ChevronExtraSmall" />
182189
)}
183-
<Icon icon={getTopLevelIcons(field) as string} className="field-icon" />
190+
<Icon icon={getTopLevelIcons(field) as string} className="field-icon" version='v2' size='small' />
184191
</span>
185192
<span className="field-title">
186193
{getChildFieldName(field?.otherCmsField, item?.otherCmsField)}
@@ -222,7 +229,7 @@ const TreeView = ({ schema = [] }: schemaType) => {
222229
>
223230
<span className={`icons ${hasNested ? 'nested' : ''}`}>
224231
{hasNested && <Icon className={'chevron'} icon="ChevronExtraSmall" />}
225-
<Icon className={'fieldicon'} icon={getTopLevelIcons(item) as string} />
232+
<Icon className={'fieldicon'} icon={getTopLevelIcons(item) as string} version='v2' size='small' />
226233
</span>
227234
<span className={`field-title`}>{item?.otherCmsField}</span>
228235
</button>

ui/src/components/SchemaModal/schemaModal.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface Icons {
2121
custom?: string;
2222
tag?: string;
2323
experience_container?: string;
24+
extension?: string;
2425
}
2526
export interface SchemaProps {
2627
contentType?: string;

0 commit comments

Comments
 (0)