@@ -39,27 +39,30 @@ export class DragDropMatrixRows extends DragDropCore<QuestionMatrixDynamicModel>
3939 }
4040
4141 const matrices = [ ] ;
42- function fillMatricies ( questions : Question [ ] ) {
43- const ms = questions . filter ( q => q . isDescendantOf ( "matrixdynamic" ) && ( q as QuestionMatrixDynamicModel ) . allowRowReorder ) ;
44- ms . forEach ( ( m : QuestionMatrixDynamicModel ) => {
45- matrices . push ( m ) ;
46- if ( m . detailPanelMode !== "none" ) {
47- m . visibleRows . forEach ( r => {
48- if ( r . isDetailPanelShowing ) {
49- fillMatricies ( r . questions ) ;
50- }
51- } ) ;
52- }
53- } ) ;
54- }
55-
5642 if ( this . survey . onMatrixRowDragOver . isEmpty ) {
5743 matrices . push ( this . parentElement ) ;
5844 } else {
59- fillMatricies ( this . survey . getAllQuestions ( ) ) ;
45+ this . fillMatricies ( this . survey . getAllQuestions ( ) , matrices ) ;
6046 }
47+ this . fillMatrixRowMap ( matrices ) ;
48+ this . fromIndex = this . parentElement . visibleRows . indexOf ( this . draggedElement ) ;
49+ }
6150
62- this . matrixRowMap = { } ;
51+ private fillMatricies ( questions : Question [ ] , matrices : QuestionMatrixDynamicModel [ ] ) {
52+ const ms = questions . filter ( q => q . isDescendantOf ( "matrixdynamic" ) && ( q as QuestionMatrixDynamicModel ) . allowRowReorder ) ;
53+ ms . forEach ( ( m : QuestionMatrixDynamicModel ) => {
54+ matrices . push ( m ) ;
55+ if ( m . detailPanelMode !== "none" ) {
56+ m . visibleRows . forEach ( r => {
57+ if ( r . isDetailPanelShowing ) {
58+ this . fillMatricies ( r . questions , matrices ) ;
59+ }
60+ } ) ;
61+ }
62+ } ) ;
63+ }
64+
65+ private fillMatrixRowMap ( matrices : QuestionMatrixDynamicModel [ ] ) {
6366 matrices . forEach ( matrix => {
6467 matrix . visibleRows . forEach ( row => {
6568 this . matrixRowMap [ row . id ] = { row, matrix } ;
@@ -68,8 +71,6 @@ export class DragDropMatrixRows extends DragDropCore<QuestionMatrixDynamicModel>
6871 this . matrixRowMap [ matrix . id ] = { row : matrix , matrix } ;
6972 }
7073 } ) ;
71-
72- this . fromIndex = this . parentElement . visibleRows . indexOf ( this . draggedElement ) ;
7374 }
7475
7576 private get shortcutClass ( ) : string {
@@ -140,6 +141,34 @@ export class DragDropMatrixRows extends DragDropCore<QuestionMatrixDynamicModel>
140141 return clientY >= rect . y + rect . height / 2 ;
141142 }
142143
144+ private expandCollapseTimer = null ;
145+ private expandCollapseHandlingRow = null ;
146+ protected doDragOver ( ) {
147+ if ( this . dropTarget && typeof this . dropTarget . isDetailPanelShowing !== "undefined" && this . dropTarget . isDetailPanelShowing === false ) {
148+ const row = this . dropTarget ;
149+ const matrix = row . data ;
150+ const renderedRow = matrix . renderedTable . rows . filter ( r => r . row == row ) [ 0 ] ;
151+ const startAction = renderedRow ?. cells [ 1 ] ?. item ?. value ?. actions ?. filter ( a => a . id == "show-detail" ) [ 0 ] ;
152+ const endAction = renderedRow ?. cells [ renderedRow . cells . length - 1 ] ?. item ?. value ?. actions ?. filter ( a => a . id == "show-detail" ) [ 0 ] ;
153+
154+ if ( ( startAction ?. visible || endAction ?. visible ) ) {
155+
156+ if ( this . expandCollapseHandlingRow !== row . id ) {
157+ this . expandCollapseHandlingRow = row . id ;
158+ this . clearExpandCollapseTimeout ( ) ;
159+ this . expandCollapseTimer = setTimeout ( ( ) => {
160+ const matrices = [ ] ;
161+ row . showDetailPanel ( ) ;
162+ this . fillMatricies ( [ matrix ] , matrices ) ;
163+ this . fillMatrixRowMap ( matrices ) ;
164+ } , 500 ) ;
165+ }
166+ } else {
167+ this . clearExpandCollapseTimeout ( ) ;
168+ }
169+ }
170+ }
171+
143172 private removeGhost ( ) {
144173 const lastRenderedRows = this . lastDropTargetParentElement . renderedTable . rows ;
145174 const draggedRenderedRowIndex = lastRenderedRows . indexOf ( this . draggedRenderedRow ) ;
@@ -221,5 +250,12 @@ export class DragDropMatrixRows extends DragDropCore<QuestionMatrixDynamicModel>
221250 _body . style . userSelect = this . restoreUserSelectValue || "initial" ;
222251 }
223252 super . clear ( ) ;
253+ this . clearExpandCollapseTimeout ( ) ;
254+ }
255+
256+ private clearExpandCollapseTimeout ( ) {
257+ clearTimeout ( this . expandCollapseTimer ) ;
258+ this . expandCollapseTimer = null ;
259+ this . expandCollapseHandlingRow = null ;
224260 }
225261}
0 commit comments