@@ -8,8 +8,7 @@ import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
88import { postMetadataDefinitions } from "../../actions/metadata" ;
99import Layout from "../Layout" ;
1010
11- import widgetTypes from "../../../../scripts/metadata/config/widgetTypes.json" ;
12- import inputTypes from "../../../../scripts/metadata/config/inputTypes.json" ;
11+ import { widgetTypes , inputTypes } from "../../metadata.config" ;
1312
1413export const CreateMetadataDefinitionPage = ( ) : JSX . Element => {
1514 return (
@@ -24,7 +23,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
2423 const dispatch = useDispatch ( ) ;
2524 // @ts -ignore
2625 const saveMetadataDefinitions = ( metadata : object ) => dispatch ( postMetadataDefinitions ( metadata ) ) ;
27-
26+
2827 const [ activeStep , setActiveStep ] = React . useState ( 0 ) ;
2928 const [ parsedInput , setParsedInput ] = React . useState ( "" ) ;
3029 const [ formInput , setFormInput ] = React . useState ( {
@@ -49,14 +48,14 @@ export const CreateMetadataDefinition = (): JSX.Element => {
4948 // Handle input change of name, description, context high level fields
5049 if ( idx == - 1 ) {
5150 data [ key ] = value
52-
51+
5352 } else {
5453 if ( key == "list" || key == "required" ) {
5554 data [ "fields" ] [ idx ] [ key ] = ! data [ "fields" ] [ idx ] [ key ]
56-
55+
5756 } else if ( key == "type" || key == "options" ) {
5857 data [ "fields" ] [ idx ] . config [ key ] = value
59-
58+
6059 } else if ( key == "name" || key == "widgetType" ) {
6160 data [ "fields" ] [ idx ] [ key ] = value
6261 }
@@ -78,7 +77,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
7877 }
7978
8079 let newfield = formInput [ "fields" ]
81-
80+
8281 // Add newfield to ith idx of list
8382 newfield . splice ( idx + 1 , 0 , newitem )
8483
@@ -270,10 +269,10 @@ export const CreateMetadataDefinition = (): JSX.Element => {
270269
271270 { formInput . fields . map ( ( input , idx ) => {
272271 return ( < Step key = { idx } >
273- { idx == 0 ?
272+ { idx == 0 ?
274273 < StepButton color = "inherit" onClick = { ( ) => { setActiveStep ( idx + 1 ) } } >
275274 < StepLabel > Add metadata entry*
276- { idx == activeStep - 1 ?
275+ { idx == activeStep - 1 ?
277276 < IconButton color = "primary" size = "small" onClick = { ( ) => addNewField ( idx ) } >
278277 < AddBoxIcon />
279278 </ IconButton >
@@ -283,7 +282,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
283282 :
284283 < StepButton color = "inherit" onClick = { ( ) => { setActiveStep ( idx + 1 ) } } >
285284 < StepLabel > Add additional entry
286- { idx == activeStep - 1 ?
285+ { idx == activeStep - 1 ?
287286 < >
288287 < IconButton color = "primary" size = "small" onClick = { ( ) => addNewField ( idx ) } >
289288 < AddBoxIcon />
@@ -292,7 +291,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
292291 < DeleteOutlineIcon />
293292 </ IconButton >
294293 </ >
295- :
294+ :
296295 < IconButton size = "small" onClick = { ( ) => removeField ( idx ) } >
297296 < DeleteOutlineIcon />
298297 </ IconButton > }
@@ -303,11 +302,11 @@ export const CreateMetadataDefinition = (): JSX.Element => {
303302 < Grid container >
304303 < Grid xs = { 4 } md = { 4 } >
305304 < FormGroup row >
306- < FormControlLabel control = { < Checkbox
305+ < FormControlLabel control = { < Checkbox
307306 checked = { input . list }
308307 onChange = { ( event ) => { handleInputChange ( idx , "list" , event . target . value ) ; } }
309308 /> } label = "Contains List" />
310- < FormControlLabel control = { < Checkbox
309+ < FormControlLabel control = { < Checkbox
311310 checked = { input . required }
312311 onChange = { ( event ) => { handleInputChange ( idx , "required" , event . target . value ) ; } }
313312 /> } label = "Required" />
@@ -364,7 +363,7 @@ export const CreateMetadataDefinition = (): JSX.Element => {
364363 } ) }
365364 </ TextField >
366365 { /*
367- * TODO: Expand to support different config data type actions
366+ * TODO: Expand to support different config data type actions
368367 * https://github.com/clowder-framework/clowder2/issues/169
369368 */ }
370369 { ( input . config . type == "enum" ) ? < >
0 commit comments