@@ -32,7 +32,6 @@ type CreateMetadataFieldType = {
3232 metadataModelFieldList ?: MetadataModelField [ ]
3333 onComplete ?: ( ) => void
3434 organisationId : string
35- projectId : string
3635}
3736
3837type QueryBody = Omit < MetadataModelField , 'id' >
@@ -54,13 +53,17 @@ type metadataFieldUpdatedSelectListType = MetadataModelField & {
5453 new : boolean
5554}
5655
56+ export enum MetadataContentType {
57+ ORGANISATION = 'organisation' ,
58+ PROJECT = 'project' ,
59+ }
60+
5761const CreateMetadataField : FC < CreateMetadataFieldType > = ( {
5862 id,
5963 isEdit,
6064 metadataModelFieldList,
6165 onComplete,
6266 organisationId,
63- projectId,
6467} ) => {
6568 const metadataTypes : MetadataType [ ] = [
6669 { id : 1 , label : 'int' , value : 'int' } ,
@@ -88,9 +91,10 @@ const CreateMetadataField: FC<CreateMetadataFieldType> = ({
8891 const [ updateMetadataModelField ] = useUpdateMetadataModelFieldMutation ( )
8992
9093 const [ deleteMetadataModelField ] = useDeleteMetadataModelFieldMutation ( )
91- const projectContentType : ContentType =
92- supportedContentTypes &&
93- Utils . getContentType ( supportedContentTypes , 'model' , 'project' )
94+ const metadataContentType : ContentType =
95+ supportedContentTypes &&
96+ Utils . getContentType ( supportedContentTypes , 'model' , MetadataContentType . ORGANISATION )
97+
9498 useEffect ( ( ) => {
9599 if ( data && ! isLoading ) {
96100 setName ( data . name )
@@ -142,8 +146,8 @@ const CreateMetadataField: FC<CreateMetadataFieldType> = ({
142146 is_required_for : isRequiredFor
143147 ? ( [
144148 {
145- content_type : projectContentType . id ,
146- object_id : parseInt ( projectId ) ,
149+ content_type : metadataContentType . id ,
150+ object_id : parseInt ( organisationId ) ,
147151 } as isRequiredFor ,
148152 ] as isRequiredFor [ ] )
149153 : [ ] ,
@@ -191,8 +195,8 @@ const CreateMetadataField: FC<CreateMetadataFieldType> = ({
191195 const query = generateDataQuery (
192196 m . content_type ,
193197 m . field ,
194- m . is_required_for ,
195- m . id ,
198+ ! ! m . is_required_for ,
199+ parseInt ( m . id ) ,
196200 m . new ,
197201 )
198202 if ( ! m . removed && ! m . new ) {
0 commit comments