@@ -136,9 +136,23 @@ define([
136136 {
137137 title : ko . i18n ( 'columns.code' , 'Code' ) ,
138138 render : ( s , p , d ) => {
139- if ( d . vocab1ConceptCode !== null || d . vocab2ConceptCode !== null ) {
140- return this . renderFieldComparison ( d . vocab1ConceptCode , d . vocab2ConceptCode , d . conceptCodeMismatch ) ;
139+ // Check if this is a cross-vocabulary comparison
140+ const isCrossVocab = d . vocab1ConceptCode !== null || d . vocab2ConceptCode !== null ;
141+
142+ if ( isCrossVocab ) {
143+ // Use the vocab-specific values, falling back to the merged value
144+ const code1 = d . vocab1ConceptCode ;
145+ const code2 = d . vocab2ConceptCode ;
146+
147+ // If both exist and there's a mismatch, or if only one exists
148+ if ( d . conceptCodeMismatch || ( code1 === null || code2 === null ) ) {
149+ return this . renderFieldComparison ( code1 , code2 , d . conceptCodeMismatch , d . conceptCode ) ;
150+ } else {
151+ // Both exist and are the same
152+ return this . escapeHtml ( code1 || code2 || d . conceptCode || '' ) ;
153+ }
141154 } else {
155+ // Not a cross-vocab comparison, use the fallback value
142156 return this . escapeHtml ( d . conceptCode || '' ) ;
143157 }
144158 } ,
@@ -152,24 +166,41 @@ define([
152166 INVALID_REASON_CAPTION : d . invalidReason ,
153167 STANDARD_CONCEPT : d . standardConcept ,
154168 } ) ;
155-
156- const isCrossVocab = d . vocab1ConceptName !== null && d . vocab2ConceptName !== null ;
157-
169+
170+ const isCrossVocab = d . vocab1ConceptName !== null || d . vocab2ConceptName !== null ;
171+
158172 if ( isCrossVocab ) {
159- if ( d . nameMismatch ) {
160- const link1 = commonUtils . renderLink ( d . vocab1ConceptName , p , buildConceptForLink ( d . vocab1ConceptName ) ) ;
161- const link2 = commonUtils . renderLink ( d . vocab2ConceptName , p , buildConceptForLink ( d . vocab2ConceptName ) ) ;
162-
173+ const name1 = d . vocab1ConceptName ;
174+ const name2 = d . vocab2ConceptName ;
175+
176+ if ( d . nameMismatch || ( name1 === null || name2 === null ) ) {
177+ // There's a mismatch or only one vocabulary has this concept
178+ const link1 = name1 ? commonUtils . renderLink ( name1 , p , buildConceptForLink ( name1 ) ) : '' ;
179+ const link2 = name2 ? commonUtils . renderLink ( name2 , p , buildConceptForLink ( name2 ) ) : '' ;
180+
163181 let html = '<div class="vocab-concept-names">' ;
164- html += `<div class="vocab-name-row">${ link1 } </div>` ;
165- html += `<div class="vocab-name-row">${ link2 } </div>` ;
182+ if ( name1 ) {
183+ html += `<div class="vocab-name-row">` ;
184+ if ( d . nameMismatch ) {
185+ html += `<i class="fa fa-exclamation-triangle name-mismatch"></i> ` ;
186+ }
187+ html += `${ link1 } </div>` ;
188+ }
189+ if ( name2 ) {
190+ html += `<div class="vocab-name-row">` ;
191+ if ( d . nameMismatch ) {
192+ html += `<i class="fa fa-exclamation-triangle name-mismatch"></i> ` ;
193+ }
194+ html += `${ link2 } </div>` ;
195+ }
166196 html += '</div>' ;
167197 return html ;
168198 } else {
169- return commonUtils . renderLink ( d . vocab1ConceptName , p , buildConceptForLink ( d . vocab1ConceptName ) ) ;
199+ // Both exist and are the same
200+ return commonUtils . renderLink ( name1 , p , buildConceptForLink ( name1 ) ) ;
170201 }
171202 } else {
172- const conceptName = d . vocab1ConceptName || d . vocab2ConceptName || d . conceptName ;
203+ const conceptName = d . conceptName ;
173204 if ( ! conceptName ) return '' ;
174205 return commonUtils . renderLink ( conceptName , p , buildConceptForLink ( conceptName ) ) ;
175206 }
@@ -318,20 +349,37 @@ define([
318349 }
319350
320351 renderFieldComparison ( value1 , value2 , hasMismatch , fallbackValue ) {
321- const isCrossVocab = value1 !== null && value2 !== null ;
322-
323- if ( isCrossVocab ) {
324- if ( hasMismatch ) {
325- let html = '<div class="vocab-field-values">' ;
326- html += `<div class="vocab-field-row"><i class="fa fa-exclamation-triangle field-mismatch"></i> ${ this . escapeHtml ( value1 || '' ) } </div>` ;
327- html += `<div class="vocab-field-row"><i class="fa fa-exclamation-triangle field-mismatch"></i> ${ this . escapeHtml ( value2 || '' ) } </div>` ;
328- html += '</div>' ;
329- return html ;
330- } else {
331- return this . escapeHtml ( value1 || value2 || '' ) ;
352+ const hasValue1 = value1 !== null && value1 !== undefined ;
353+ const hasValue2 = value2 !== null && value2 !== undefined ;
354+
355+ // If neither vocabulary has a value, use fallback
356+ if ( ! hasValue1 && ! hasValue2 ) {
357+ return this . escapeHtml ( fallbackValue || '' ) ;
358+ }
359+
360+ // If only one vocabulary has a value (CS1 Only or CS2 Only case)
361+ if ( ! hasValue1 || ! hasValue2 ) {
362+ let html = '<div class="vocab-field-values">' ;
363+ if ( hasValue1 ) {
364+ html += `<div class="vocab-field-row">${ this . escapeHtml ( value1 ) } </div>` ;
365+ }
366+ if ( hasValue2 ) {
367+ html += `<div class="vocab-field-row">${ this . escapeHtml ( value2 ) } </div>` ;
332368 }
369+ html += '</div>' ;
370+ return html ;
371+ }
372+
373+ // Both vocabularies have values
374+ if ( hasMismatch ) {
375+ let html = '<div class="vocab-field-values">' ;
376+ html += `<div class="vocab-field-row"><i class="fa fa-exclamation-triangle field-mismatch"></i> ${ this . escapeHtml ( value1 ) } </div>` ;
377+ html += `<div class="vocab-field-row"><i class="fa fa-exclamation-triangle field-mismatch"></i> ${ this . escapeHtml ( value2 ) } </div>` ;
378+ html += '</div>' ;
379+ return html ;
333380 } else {
334- return this . escapeHtml ( fallbackValue || '' ) ;
381+ // Same value in both
382+ return this . escapeHtml ( value1 ) ;
335383 }
336384 }
337385
0 commit comments