@@ -685,7 +685,31 @@ class DataHarmonizer {
685
685
colHeaders : true ,
686
686
rowHeaders : true ,
687
687
copyPaste : true ,
688
- contextMenu : [ 'remove_row' , 'row_above' , 'row_below' ] ,
688
+ contextMenu : [
689
+
690
+ {
691
+ key : 'remove_row' ,
692
+ name : 'Remove row' ,
693
+ callback : function ( ) {
694
+ //Enables removal of a row and all subordinate rows in other DH tables.
695
+ self . hot . alter ( 'remove_row' , self . hot . getSelected ( ) [ 0 ] [ 0 ] ) ; //, numRows
696
+ } ,
697
+ } ,
698
+ {
699
+ key : 'row_above' ,
700
+ name : 'Insert row above' ,
701
+ callback : function ( ) {
702
+ self . addRows ( 'insert_row_above' , 1 , self . hot . getSelected ( ) [ 0 ] [ 0 ] ) ;
703
+ } ,
704
+ } ,
705
+ {
706
+ key : 'row_below' ,
707
+ name : 'Insert row below' ,
708
+ callback : function ( ) {
709
+ self . addRows ( 'insert_row_above' , 1 , parseInt ( self . hot . getSelected ( ) [ 0 ] [ 0 ] ) + 1 ) ;
710
+ } ,
711
+ } ,
712
+ ] ,
689
713
outsideClickDeselects : false , // for maintaining selection between tabs
690
714
manualColumnResize : true ,
691
715
//colWidths: [100], //Just fixes first column width
@@ -728,13 +752,18 @@ class DataHarmonizer {
728
752
} ,
729
753
afterSelection : ( row , column , row2 , column2 ) => {
730
754
self . current_selection = [ row , column , row2 , column2 ] ;
755
+ // Two possible actions:
756
+ // - For each subordinate table send a message to refilter
757
+ // - See if sidebar info is required for top column click.
758
+
731
759
if ( this . helpSidebar ) {
732
760
if ( column > - 1 ) {
733
761
const field = self . slots [ column ] ;
734
762
const helpContent = self . getComment ( field ) ;
735
763
self . helpSidebar . setContent ( helpContent ) ;
736
764
} else self . helpSidebar . close ( ) ;
737
765
}
766
+ return false ;
738
767
} ,
739
768
// Bit of a hackey way to RESTORE classes to secondary headers. They are
740
769
// removed by Handsontable when re-rendering main table.
@@ -791,22 +820,26 @@ class DataHarmonizer {
791
820
this . hot . updateSettings ( { columns : currentColumns } ) ;
792
821
}
793
822
794
- /* Currently only called via Footer.js
795
- * numRows is (usually) user specified number of rows to add at bottom
796
- * of current dh table. However, if table has foreign key(s) to another
797
- * table, the other table's focused row will control foreign key values
798
- * added to this table.
823
+ /* Called via Footer.js, and also in right click menu DH contextMenu click
824
+ * row_above, row_below.
825
+ * numRows is specified number of rows to add to current dh table. If table
826
+ * has foreign key(s) to another table, the other table's focused row will
827
+ * control foreign key values added to this table.
828
+ * row_where = 'insert_row_below' | 'insert_row_above'
799
829
*/
800
- addRowsToBottom ( numRows ) {
830
+ addRows ( row_where , numRows , startRowIndex = false ) {
801
831
802
832
numRows = parseInt ( numRows ) ; // Coming from form string input.
803
833
// Get the starting row index where the new rows will be added
804
- const startRowIndex = this . hot . countRows ( ) ;
834
+ if ( startRowIndex === false )
835
+ startRowIndex = this . hot . countRows ( ) ;
836
+
837
+ console . log ( "menu" , this . template_name , this . context . relations ?. [ this . template_name ] ?. parent )
805
838
806
839
// If this has no foreign key parent table(s) then go ahead and add x rows.
807
840
if ( ! this . context . relations ?. [ this . template_name ] ?. parent ) {
808
841
// Insert the new rows below the last existing row
809
- this . hot . alter ( 'insert_row_below' , startRowIndex , numRows ) ;
842
+ this . hot . alter ( row_where , startRowIndex , numRows ) ;
810
843
return ;
811
844
}
812
845
@@ -853,7 +886,7 @@ class DataHarmonizer {
853
886
return ;
854
887
}
855
888
856
- this . hot . alter ( 'insert_row_below' , startRowIndex , numRows ) ;
889
+ this . hot . alter ( row_where , startRowIndex , numRows ) ;
857
890
858
891
// Populate new rows with selected value(s)
859
892
this . hot . batch ( ( ) => {
0 commit comments