@@ -754,17 +754,13 @@ class DataHarmonizer {
754
754
afterSelection : ( row , column , row2 , column2 ) => {
755
755
// A change in selected row
756
756
if ( self . current_selection [ 0 ] != row ) {
757
- // Possibly focused key has changed child table's filter.
758
- // Issue: need to cascade this down immediately to any
759
- // subordinate table, otherwise if doing on-demand from a table's
760
- // perspective, then if such a table depends on an intermediate that
761
- // hasn't been refreshed, we'll get a wrong display.
762
-
757
+ // Row has changed so possibly values that make up some other
758
+ // table's foreign key has changed, so that table's view should
759
+ // be refreshed.
763
760
Object . entries ( this . context . getDependents ( this . template_name ) )
764
761
. forEach ( ( [ child_name , child ] ) => {
765
762
// Dependent tables determine what parent foreign key values they
766
763
// need to filter view by
767
- console . log ( "showing" , child_name )
768
764
this . showRowsByKeyVals ( child_name ) ;
769
765
} ) ;
770
766
} ;
@@ -881,12 +877,11 @@ class DataHarmonizer {
881
877
}
882
878
883
879
884
-
885
- // Here we deal with adding rows that need foreign keys.
886
- // Locate each foreign key and fetch its focused value, and copy into new
887
- // records below.
888
- // If missing key value(s), prompt user to focus appropriate tab(s) row
889
- // and try again.
880
+ /* Here we deal with adding rows that need foreign keys. Locate each foreign
881
+ * key and fetch its focused value, and copy into new records below.
882
+ * If missing key value(s) encountered, prompt user to focus appropriate
883
+ * tab(s) row and try again.
884
+ */
890
885
getForeignKeyValues ( parents ) {
891
886
let required_selections = { } ;
892
887
let errors = '' ;
@@ -1088,32 +1083,36 @@ class DataHarmonizer {
1088
1083
}
1089
1084
1090
1085
/* For given template name, show only rows that conform to that class's
1091
- * foreign key-value constraints;
1086
+ * foreign key-value constraints.
1087
+ * (Could make a touch more efficient by skipping if we can tell that a
1088
+ * given table's foreign key values haven't changed.)
1092
1089
*/
1093
1090
showRowsByKeyVals ( template_name ) {
1094
1091
const hotInstance = this . context . dhs [ template_name ] . hot ;
1095
1092
const hiddenRowsPlugin = hotInstance . getPlugin ( 'hiddenRows' ) ;
1096
1093
1097
1094
// Ensure all rows are visible
1098
- hiddenRowsPlugin . showRows ( hiddenRowsPlugin . getHiddenRows ( ) ) ;
1095
+ let oldHiddenRows = hiddenRowsPlugin . getHiddenRows ( )
1099
1096
1100
1097
//Fetch key-values to match
1101
1098
let parents = this . context . getParents ( template_name ) ;
1102
1099
let [ required_selections , errors ] = this . getForeignKeyValues ( parents ) ;
1103
1100
// arrayRange() makes [0, ... n]
1104
- let rowsToHide = arrayRange ( 0 , hotInstance . countRows ( ) )
1101
+ let rowsToHide = arrayRange ( 0 , hotInstance . countRows ( ) )
1105
1102
. filter ( ( row ) => {
1106
1103
for ( let [ slot_name , value ] of Object . entries ( required_selections ) ) {
1107
1104
const col = this . context . dhs [ template_name ] . getColumnIndexByFieldName ( slot_name ) ;
1108
1105
const cellValue = hotInstance . getDataAtCell ( row , col ) ;
1109
- console . log ( template_name , row , slot_name , col , cellValue , value )
1110
1106
if ( cellValue != value )
1111
1107
return true ;
1112
1108
}
1113
1109
} ) ;
1114
1110
1115
- hiddenRowsPlugin . hideRows ( rowsToHide ) ; // Hide the calculated rows
1116
- hotInstance . render ( ) ; // Render the table to apply changes
1111
+ if ( rowsToHide != oldHiddenRows ) {
1112
+ hiddenRowsPlugin . showRows ( oldHiddenRows ) ;
1113
+ hiddenRowsPlugin . hideRows ( rowsToHide ) ; // Hide the calculated rows
1114
+ hotInstance . render ( ) ; // Render the table to apply changes
1115
+ }
1117
1116
}
1118
1117
1119
1118
renderSemanticID ( curieOrURI , as_markup = false ) {
0 commit comments