@@ -355,14 +355,14 @@ class DataHarmonizer {
355
355
columns : this . getColumns ( ) ,
356
356
colHeaders : true ,
357
357
rowHeaders : true ,
358
- // renderallrows: false, // working?
358
+ renderallrows : false , // working?
359
359
manualRowMove : true ,
360
360
copyPaste : true ,
361
361
outsideClickDeselects : false , // for maintaining selection between tabs
362
362
manualColumnResize : true ,
363
363
//colWidths: [100], //Just fixes first column width
364
- minRows : 10 ,
365
- minSpareRows : 10 ,
364
+ minRows : 5 ,
365
+ minSpareRows : 5 ,
366
366
width : '100%' ,
367
367
// Future: For empty dependent tables, tailor to minimize height.
368
368
height : '75vh' ,
@@ -513,11 +513,11 @@ class DataHarmonizer {
513
513
* # rows, this event can be triggered "silently" on update of fields likedata
514
514
* empty provenance field.
515
515
* @param {Array } grid_changes array of [row, column, old value (incl. undefined), new value (incl. null)].
516
- * @param {String } action can be CopyPaste.paste, ...
516
+ * @param {String } action can be CopyPaste.paste, ... thisChange
517
517
*/
518
518
beforeChange : function ( grid_changes , action ) {
519
519
// Ignore addition of new records to table.
520
- if ( action == 'add_row' || action == 'upload' ) return ;
520
+ if ( action == 'add_row' || action == 'upload' || action == 'thisChange' ) return ;
521
521
if ( ! grid_changes ) return ; // Is this ever the case?
522
522
523
523
console . log ( 'beforeChange' , grid_changes , action ) ;
@@ -698,17 +698,31 @@ class DataHarmonizer {
698
698
// change selection, e.g. just edits 1 cell content, then
699
699
// an afterSelection isn't triggered. THEREFORE we have to
700
700
// trigger a crudFilterDependentViews() call.
701
- // action e.g. edit, updateData
701
+ // action e.g. edit, updateData, CopyPaste.paste
702
702
afterChange : function ( grid_changes , action ) {
703
-
704
- //Ignore if partial key left by change. For full dependent key,
705
- // ISSUE: "updateData" event getting triggered.
703
+ if ( action == 'upload' || action == 'updateData' ) {
704
+ // This is being called for every cell change in an 'upload'
705
+ // Must block them or it somehow triggers stack overload of new
706
+ // afterChange events.
707
+ this . counter ??= 0 ;
708
+ this . counter ++ ;
709
+ return ;
710
+ }
711
+ // ISSUE: Thousands of upload actions for uploaded schema
712
+ // Note: https://github.com/handsontable/handsontable/discussions/9275
713
+ //console.log ("upload actions", this.counter)
706
714
707
715
// Trigger only if change to some key slot child needs.
708
716
if ( grid_changes ) {
709
717
let row_changes = self . getRowChanges ( grid_changes ) ;
710
718
if ( self . hasRowKeyChange ( self . template_name , row_changes ) ) {
711
719
self . context . crudFilterDependentViews ( self . template_name ) ;
720
+ // If in schema editor mode, update or insert to name field (a
721
+ // key field) of class, slot or enum (should cause update in
722
+ // compiled enums and slot flatVocabularies.
723
+ if ( [ 'Type' , 'Class' , 'Enum' ] . includes ( self . template_name ) ) {
724
+ self . context . refreshSchemaEditorMenus ( [ 'Schema' + self . template_name + 'Menu' ] ) ;
725
+ }
712
726
}
713
727
}
714
728
} ,
@@ -721,13 +735,18 @@ class DataHarmonizer {
721
735
* foreign key values that make up some dependent table's record(s)
722
736
* have changed, so that table's view should be refreshed. Dependent
723
737
* tables determine what parent foreign key values they need to filter view by.
724
- * This event is not involved in row content change.
738
+ * This event is not directly involved in row content change.
725
739
*
740
+ * As well, refresh schema menus if selected schema has changed.
726
741
*/
727
742
728
743
//console.log("afterSelectionEnd",row, column, row2, column2, selectionLayerLevel)
729
744
if ( self . current_selection [ 0 ] != row || self . current_selection [ 1 ] != column ) {
730
745
self . context . crudFilterDependentViews ( self . template_name ) ;
746
+ if ( self . template_name == 'Schema' && self . current_selection [ 0 ] != row ) {
747
+ self . context . refreshSchemaEditorMenus ( ) ;
748
+ }
749
+
731
750
}
732
751
733
752
self . current_selection = [ row , column ] ; //, row2, column2];
@@ -943,6 +962,7 @@ class DataHarmonizer {
943
962
}
944
963
945
964
// Classes & slots (tables & fields) in loaded schema editor schema guide what can be imported.
965
+ // TRY SWITCHING TO hot.updateData()
946
966
loadSchemaYAML ( text ) {
947
967
let schema = null ;
948
968
try {
@@ -1158,14 +1178,15 @@ class DataHarmonizer {
1158
1178
//dh.hot.resumeExecution();
1159
1179
//dh.hot.updateSettings({hiddenRows: true});
1160
1180
dh . hot . resumeRender ( ) ;
1181
+ dh . hot . render ( ) ;
1161
1182
//hot.updateSettings({hiddenRows: { rows: myRows}});
1162
1183
1163
1184
}
1164
1185
1165
1186
// New data type, class & enumeration items need to be reflected in DH
1166
1187
// schema editor SchemaTypeMenu, SchemaClassMenu and SchemaEnumMenu menus
1167
1188
1168
- // NEED TO DO THIS EACH TIME NEW SCHEMA ROW IS CALCULATED .
1189
+ // Done each time a schema is uploaded or focused on .
1169
1190
this . context . refreshSchemaEditorMenus ( ) ;
1170
1191
1171
1192
console . table ( "LOADED SCHEMA" , schema ) ;
0 commit comments