@@ -124,31 +124,37 @@ onMounted(async () => {
124
124
: mapGet (model , refInfo .selfId )
125
125
126
126
const isRefType = isComplexType (refIdValue )
127
+ console .log (' refIdValue' , refIdValue , isComplexType (refIdValue ), model , refInfo )
127
128
if (isRefType ) {
128
129
refIdValue = mapGet (model , refInfo .refId )
129
130
}
130
131
if (refIdValue == null )
131
132
return
132
133
133
134
const queryOp = metadataApi .value ?.operations .find (x => x .dataModel ?.name == refInfo .model )
134
- // console.debug('LookupInput queryOp', queryOp)
135
+ console .debug (' LookupInput queryOp' , queryOp )
135
136
if (queryOp != null ) {
136
137
const propValue = mapGet (model , prop .name )
137
138
if (isComplexType (propValue )) return
138
139
139
140
refInfoValue .value = ` ${propValue } `
140
141
refPropertyName .value = prop .name
141
142
142
- // console.debug('LookupInput refInfoValue', refInfoValue.value, refInfo.refLabel)
143
+ // console.debug('refInfoValue', refInfoValue.value)
144
+ // console.debug('refInfo', refInfo)
143
145
if (refInfo .refLabel != null ) {
144
- const colModel = typeProperties (props .metadataType ).find (x => x .type == refInfo .model )
145
- if (colModel == null ) {
146
+ const colModels = typeProperties (props .metadataType ).filter (x => x .type == refInfo .model )
147
+ if (! colModels . length ) {
146
148
console .warn (` Could not find ${refInfo .model } Property on ${props .metadataType .name } ` )
147
149
}
148
- const modelValue = colModel != null ? mapGet (model , colModel .name ) : null
150
+ const modelValues = colModels .map (x => mapGet (model , x .name )).filter (x => !! x )
151
+ const modelValue = modelValues .length <= 1
152
+ ? modelValues [0 ]
153
+ : modelValues .find (x => x [refInfo .refId ?? ' id' ] == refIdValue )
154
+ // console.log('models', modelValue, colModels, modelValues)
149
155
if (modelValue != null ) {
150
156
let label = mapGet (modelValue ,refInfo .refLabel )
151
- // console.debug('LookupInput refInfoValue (label)', label, JSON.stringify(model), refInfo.refLabel)
157
+ // console.debug('LookupInput refInfoValue (label)', label, JSON.stringify(model), refInfo.refLabel)
152
158
if (label ) {
153
159
refInfoValue .value = ` ${label } `
154
160
LookupValues .setValue (refInfo .model , refIdValue , refInfo .refLabel , label )
@@ -157,7 +163,7 @@ onMounted(async () => {
157
163
const isComputed = prop .attributes ?.some (x => x .name == ' Computed' ) == true
158
164
let label = await LookupValues .getOrFetchValue (client , metadataApi .value ! , refInfo .model , refInfo .refId , refInfo .refLabel , isComputed , refIdValue )
159
165
refInfoValue .value = label ? label : ` ${refInfo .model }: ${refInfoValue .value } `
160
- // console.debug('LookupInput refInfoValue (!label)', refInfoValue.value)
166
+ // console.debug('LookupInput refInfoValue (!label)', refInfoValue.value)
161
167
}
162
168
}
163
169
}
0 commit comments