@@ -163,6 +163,7 @@ class DataHarmonizer {
163
163
164
164
// Reset specify header modal values when the modal is closed
165
165
$ ( '#specify-headers-modal' ) . on ( 'hidden.bs.modal' , ( ) => {
166
+ $ ( '.mapping-row' ) . remove ( ) ;
166
167
$ ( '#specify-headers-err-msg' ) . hide ( ) ;
167
168
$ ( '#specify-headers-confirm-btn' ) . unbind ( ) ;
168
169
} ) ;
@@ -1407,23 +1408,20 @@ class DataHarmonizer {
1407
1408
let flatHeaders = this . getFlatHeaders ( ) ;
1408
1409
const self = this ;
1409
1410
if ( flatHeaders ) {
1410
- $ ( '#field-mapping' ) . prepend (
1411
- '<col></col>' . repeat ( flatHeaders [ 1 ] . length + 1 )
1412
- ) ;
1413
- $ ( '#expected-headers-tr' ) . html (
1414
- '<td><b>Expected second row</b></td> <td>' +
1415
- flatHeaders [ 1 ] . join ( '</td><td>' ) +
1416
- '</td>'
1417
- ) ;
1418
- $ ( '#actual-headers-tr' ) . html (
1419
- '<td><b>Imported second row</b></td> <td>' +
1420
- matrix [ 1 ] . join ( '</td><td>' ) +
1421
- '</td>'
1422
- ) ;
1423
- flatHeaders [ 1 ] . forEach ( function ( item , i ) {
1424
- if ( item != matrix [ 1 ] [ i ] ) {
1425
- $ ( '#field-mapping col' ) . get ( i + 1 ) . style . backgroundColor = 'orange' ;
1411
+ const $fieldMappingBody = $ ( '#field-mapping-body' ) ;
1412
+ flatHeaders [ 1 ] . forEach ( function ( expectedHeader , i ) {
1413
+ const expectedHeaderCell =
1414
+ `<td class="field-mapping-cell">${ expectedHeader } </td>`
1415
+ const actualHeaderCell =
1416
+ `<td class="field-mapping-cell">${ matrix [ 1 ] [ i ] } </td>` ;
1417
+ const rowCells = expectedHeaderCell + actualHeaderCell ;
1418
+ let row ;
1419
+ if ( expectedHeader !== matrix [ 1 ] [ i ] ) {
1420
+ row = $ ( `<tr class="table-warning mapping-row">${ rowCells } </tr>` ) ;
1421
+ } else {
1422
+ row = $ ( `<tr class="mapping-row">${ rowCells } </tr>` ) ;
1426
1423
}
1424
+ $fieldMappingBody . append ( row ) ;
1427
1425
} ) ;
1428
1426
1429
1427
$ ( '#specify-headers-modal' ) . modal ( 'show' ) ;
@@ -1552,8 +1550,16 @@ class DataHarmonizer {
1552
1550
// Map current column indices to their indices in matrix to map
1553
1551
const headerMap = { } ;
1554
1552
const unmappedHeaders = [ ] ;
1555
- for ( const [ i , expectedVal ] of expectedSecondaryHeaders . entries ( ) ) {
1553
+ for ( let [ i , expectedVal ] of expectedSecondaryHeaders . entries ( ) ) {
1556
1554
headerMap [ i ] = actualSecondaryHeaders . findIndex ( ( actualVal ) => {
1555
+ // Case insensitivity
1556
+ if ( typeof actualVal === 'string' || actualVal instanceof String ) {
1557
+ actualVal = actualVal . toLowerCase ( )
1558
+ }
1559
+ if ( typeof expectedVal === 'string' || expectedVal instanceof String ) {
1560
+ expectedVal = expectedVal . toLowerCase ( )
1561
+ }
1562
+
1557
1563
return actualVal === expectedVal ;
1558
1564
} ) ;
1559
1565
if ( headerMap [ i ] === - 1 ) {
0 commit comments