@@ -55,34 +55,29 @@ export const ClassFieldsEditor = (props) => {
55
55
setState ( ( state ) => ( { ...state , isSchemaModified : ! state . isSchemaModified } ) ) ;
56
56
} , [ state . rows ] ) ;
57
57
58
- // const editClassField = (selectedRow) => {
59
- // const rowId = selectedRow.id;
60
- // setState((state) => ({
61
- // ...state,
62
- // selectedRowId: rowId,
63
- // isModalOpen: true,
64
- // formKey: !state.formKey,
65
- // }));
66
- // };
67
-
68
- // const deleteClassField = (selectedRow) => {
69
- // setState((prevState) => ({
70
- // ...prevState,
71
- // rows: prevState.rows.filter((field) => field.id !== selectedRow.id),
72
- // }));
73
- // };
74
-
75
58
const handleModalClose = ( ) => {
76
- // setModalOpen(false);
77
59
setState ( ( state ) => ( { ...state , isModalOpen : false } ) ) ;
78
60
} ;
79
61
80
62
const formatFieldValues = ( field , id , data = { } ) => {
81
63
if ( ! field || typeof field !== 'object' ) return [ ] ;
64
+ const getFieldName = ( ) => `${ field . display_name } (${ field . name } )` ;
65
+ const getIconForValue = ( ) => {
66
+ const aeMatch = aeTypeOptions . find ( ( option ) => option [ 1 ] === field . aetype ) ;
67
+ const aeTypeIcon = ( aeMatch && aeMatch [ 2 ] && aeMatch [ 2 ] [ 'data-icon' ] ) || '' ;
68
+
69
+ const dtypeMatch = dTypeOptions . find ( ( option ) => option [ 1 ] === field . datatype ) ;
70
+ const dTypeIcon = ( dtypeMatch && dtypeMatch [ 2 ] && dtypeMatch [ 2 ] [ 'data-icon' ] ) || '' ;
71
+
72
+ return [ aeTypeIcon , dTypeIcon ] ;
73
+ } ;
82
74
83
75
const row = {
84
76
id : ( field . id || id ) . toString ( ) ,
85
- name : { text : field . name , icon : data . icons || [ ] } ,
77
+ name : {
78
+ text : getFieldName ( ) ,
79
+ icon : getIconForValue ( ) || [ ] ,
80
+ } ,
86
81
aetype : { text : field . aetype } ,
87
82
datatype : { text : field . datatype } ,
88
83
default_value : { text : field . default_value || '' } ,
@@ -146,8 +141,7 @@ export const ClassFieldsEditor = (props) => {
146
141
const updateFieldValueInState = ( fieldName , newValue ) => {
147
142
// Update existing field in rows
148
143
setState ( ( prevState ) => {
149
- debugger
150
- const updatedRows = prevState . rows . map ( ( row ) => {
144
+ const updatedRow = prevState . rows . map ( ( row ) => {
151
145
if ( row . id === prevState . selectedRowId ) {
152
146
return {
153
147
...row ,
@@ -159,11 +153,11 @@ export const ClassFieldsEditor = (props) => {
159
153
}
160
154
return row ;
161
155
} ) ;
156
+ debugger
162
157
163
158
return {
164
159
...prevState ,
165
- rows : updatedRows ,
166
- isSchemaModified : ! prevState . isSchemaModified ,
160
+ rows : updatedRow ,
167
161
} ;
168
162
} ) ;
169
163
} ;
@@ -212,7 +206,6 @@ export const ClassFieldsEditor = (props) => {
212
206
} ;
213
207
214
208
const onSchemaSave = ( values ) => {
215
- debugger
216
209
http . post ( `/miq_ae_class/update_fields/${ aeClassId } ?button=save` , { skipErrors : [ 400 ] } )
217
210
. then ( ( response ) => {
218
211
console . log ( response ) ;
@@ -237,7 +230,6 @@ export const ClassFieldsEditor = (props) => {
237
230
const onCancel = ( ) => {
238
231
http . post ( `/miq_ae_class/update_fields/${ aeClassId } ?button=cancel` , { skipErrors : [ 400 ] } )
239
232
. then ( ( response ) => {
240
- debugger
241
233
console . log ( response ) ;
242
234
} ) . catch ( ( error ) => {
243
235
console . error ( 'Failed to cancel schema updates:' , error ) ;
0 commit comments