@@ -778,30 +778,40 @@ class DataHarmonizer {
778
778
779
779
// Validate and process the current selection
780
780
const is1mAndHasParent = ( class_assignment ) => {
781
- console . log ( this . context . currentSelection , this . context . oneToManyAppContext . appContext [ class_assignment ] ) ;
782
- const unique_keys = this . context . oneToManyAppContext . appContext [ class_assignment ] . unique_keys ;
781
+ const unique_keys =
782
+ this . context . oneToManyAppContext . appContext [ class_assignment ]
783
+ . unique_keys ;
783
784
for ( let key in unique_keys ) {
784
785
if ( 'foreign_key' in unique_keys [ key ] ) {
785
786
return unique_keys [ key ] . foreign_key ;
786
787
}
787
788
}
788
789
return false ;
789
790
} ;
790
- const classIsForeignKeyForClassAndCurrentSelection = ( maybe_child_class , currentSelection ) => {
791
- const unique_keys = this . context . oneToManyAppContext . appContext [ maybe_child_class ] . unique_keys ;
792
- return ! isEmptyUnitVal ( unique_keys [ currentSelection . shared_key_name ] ) && maybe_child_class !== currentSelection . source ;
793
-
794
- }
791
+ const classIsForeignKeyForClassAndCurrentSelection = (
792
+ maybe_child_class ,
793
+ currentSelection
794
+ ) => {
795
+ const unique_keys =
796
+ this . context . oneToManyAppContext . appContext [ maybe_child_class ]
797
+ . unique_keys ;
798
+ return (
799
+ ! isEmptyUnitVal ( unique_keys [ currentSelection . shared_key_name ] ) &&
800
+ maybe_child_class !== currentSelection . source
801
+ ) ;
802
+ } ;
795
803
// check if the DH refers to a parent class or class with no children.
796
804
// if it has a parent, ensure a foreign key is selected in some parent
797
805
// if it doesn't have a parent, use regular add rows implementation
798
806
if ( is1mAndHasParent ( this . class_assignment ) ) {
799
807
if (
800
808
! isEmptyUnitVal ( this . context . currentSelection ) &&
801
809
! isEmptyUnitVal ( this . context . currentSelection . valueToMatch ) &&
802
- classIsForeignKeyForClassAndCurrentSelection ( this . class_assignment , this . context . currentSelection )
810
+ classIsForeignKeyForClassAndCurrentSelection (
811
+ this . class_assignment ,
812
+ this . context . currentSelection
813
+ )
803
814
) {
804
-
805
815
// Insert the new rows below the last existing row
806
816
this . hot . alter ( 'insert_row_below' , startRowIndex , numRows ) ;
807
817
// Find the nearest index after the last non-empty row in the specified column
0 commit comments