From 651ef7067ee40e4565c3e170f2e291b99be485fa Mon Sep 17 00:00:00 2001 From: steve wirts Date: Tue, 17 Feb 2015 17:41:13 -0500 Subject: [PATCH] fixed small column reordering bug --- behaviors/fin-hypergrid-behavior-default.html | 3 ++ behaviors/fin-hypergrid-behavior-qtree.html | 48 +++++++++--------- .../fin-hypergrid-feature-column-moving.html | 1 + fin-hypergrid-renderer.html | 2 +- fin-hypergrid.min.html | 2 +- q/s3.zip | Bin 7115 -> 7112 bytes q/s3/w.q | 2 +- 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/behaviors/fin-hypergrid-behavior-default.html b/behaviors/fin-hypergrid-behavior-default.html index 557532f29..1a1f654fe 100644 --- a/behaviors/fin-hypergrid-behavior-default.html +++ b/behaviors/fin-hypergrid-behavior-default.html @@ -478,6 +478,9 @@ //return true to close the editor //anything else will leave the editor open return true; + }, + endDragColumnNotification: function() { + console.log('end drag column notification'); } }); diff --git a/behaviors/fin-hypergrid-behavior-qtree.html b/behaviors/fin-hypergrid-behavior-qtree.html index f241c2634..a123c58cb 100644 --- a/behaviors/fin-hypergrid-behavior-qtree.html +++ b/behaviors/fin-hypergrid-behavior-qtree.html @@ -93,7 +93,8 @@ this.reconnect(); this.msgCounter = Date.now(); this.msgResponsesActions = {}; - }, + +}, getFixedRowCount: function() { return 2; }, @@ -490,18 +491,17 @@ } return id; }, - swapColumns: function(src, tar) { + endDragColumnNotification: function() { var self = this; - var tmp = this.columnIndexes[src]; - this.columnIndexes[src] = this.columnIndexes[tar]; - this.columnIndexes[tar] = tmp; var visible = this.block.F.slice(0); - var t = visible[src]; - visible[src] = visible[tar]; - visible[tar] = t; - var msgId = this.getNextMessageId(function() { + for (var i = 0; i < visible.length; i++) { + visible[i] = this.getColumnId(i); + } + var msgId = this.getNextMessageId(function(message) { + //ignore any predecessor column swap results if a new one has been posted self.initColumnIndexes(); + self.handleMessage(message); }); var changeCols = { id: msgId, @@ -523,11 +523,23 @@ style.height = '90%'; style.whiteSpace = 'nowrap'; }, + handleMessage: function(d) { + this.block = d; + + if (d.rows !== this.block.N - 1) { + if (this.sizeChanged) { + this.sizeChanged(); + } + } + if (!this.columnIndexes || this.columnIndexes.length === 0) { + this.initColumnIndexes(); + } + this.changed(); + }, //websocket connection to Q. try and do a reconnect after 2 seconds if we fail connect: function() { var d = {}; var self = this; - var oldSize = 0; if ('WebSocket' in window) { try { this.ws = new WebSocket(this.url); @@ -554,25 +566,15 @@ }; this.ws.onmessage = function(e) { d = JSON.parse(e.data); - self.block = d; var msgId = d.id; var action = self.msgResponsesActions[msgId]; if (action) { action(d); - self.msgResponsesActions[id] = "done"; + self.msgResponsesActions[msgId] = undefined; + } else { + self.handleMessage(d); } - oldSize = self.block.N - 1; - if (d.rows !== oldSize) { - if (self.sizeChanged) { - self.sizeChanged(); - } - } - if (!self.columnIndexes || self.columnIndexes.length === 0) { - self.initColumnIndexes(); - } - self.changed(); - //console.dir(self.block); }; this.ws.onerror = function(e) { self.clearData(); diff --git a/features/fin-hypergrid-feature-column-moving.html b/features/fin-hypergrid-feature-column-moving.html index d0e274fa3..cc0370492 100644 --- a/features/fin-hypergrid-feature-column-moving.html +++ b/features/fin-hypergrid-feature-column-moving.html @@ -462,6 +462,7 @@ grid.repaint(); requestAnimationFrame(function() { d.style.display = 'none'; + grid.getBehavior().endDragColumnNotification(); }); }, columnAnimationTime + 50); diff --git a/fin-hypergrid-renderer.html b/fin-hypergrid-renderer.html index be2e9ec59..366387bdb 100644 --- a/fin-hypergrid-renderer.html +++ b/fin-hypergrid-renderer.html @@ -545,7 +545,7 @@ for (var r = 0; r < numRows; r++) { var height = this.getFixedRowHeight(r); - var align = behavior.getFixedRowAlignment(c, r); + var align = behavior.getFixedRowAlignment(c + scrollLeft, r); var value = behavior.getFixedRowValue(c + scrollLeft, r); //translatedX allows us to reorder columns diff --git a/fin-hypergrid.min.html b/fin-hypergrid.min.html index a7ea3aa17..d1210a5b9 100644 --- a/fin-hypergrid.min.html +++ b/fin-hypergrid.min.html @@ -24,4 +24,4 @@ ⬤ {{item}} -
  • \ No newline at end of file +
  • \ No newline at end of file diff --git a/q/s3.zip b/q/s3.zip index 40b614e20d281afa4ff932baea08688b7033b28f..75e5be42f1ba578342586df9e833462bd17f0fef 100644 GIT binary patch delta 949 zcmX?Ye!_f$D%0XU6V)x4xHe8qyv8)WbFw9)yu{r-k3&HCE29WQfHyM>7Xt_YB?}mp z*dUS|z4Mb|chifd|AYpY}`*yeM%Ws!*^i{Lj7`Z3Dj>=ke#=~t=bh_IA zecHFZ&z|T`om>6R(mgy%M{J47*Ndy}-V=WQG<%_EV0Grn+*x)1DrVRH5^|lbQyUUE z<&S69t%B{O)ZJ> zl%BsR!*R*CZys5Tx0Ju=am{UUF+8|FvMPL*TlFGiM#g1L-xyB+oO`y2t?Kl9(?vXC zdkY`c230KURgW-@&U@LVxAR>rvtvQstJpak?|n7f@GhFQ`BF&Vd6qAxt2Qloc9`w& zHIx7KvovSrA2#Q>alts_?V8M2fo~Y6IlgOd2!DE|ST%9QCC@{zURD`Cd@aU;%5Dg zd->0O@=cldv$yPjI`N6&Cl$WO@&yk)-n!ab zfBelI;LXl)VwHFORz?N}QDz2k!V+QN0776S=ZdMbK_VFx_mk)IKbbsN+!&ZPCtnhG z5rZbOkN|H+CQ)X1YSfX?6@w*JG^uyi~#)n7Su_l5hkiN>fQ65Y;Sc2TYTb z4@-K2C_X7Wkf5KGCy1H}YZd@A;#fIc-{3WwzYd8U*HmjM2dunxVS?lQ!%CmCuEo!} zFD1Ue-l(yA?f)vqx0cP<{8n$1Jo;=x^-g`BxK=@b({{yfby2gWwT3C4pZhntDdw?H zoqD`!KN#(;o^k0vYFx0_vAnoW z!g)(>M48C>ziuhf*E5>+Z8^e2McM;p=4U=L&Rt{6tGvDR%HOB#AxHR*-}U&%u4i&B z_RD4A{pA7P>>LMH%n#qe$iN`Y%m7YXA`Bcr2#jZLVFliDy~5B49tKEsgHpld`TS2N z&k{EVrqaph#a+ap$t@(nn~_PB8J;dRC3MALi55*NN5TM_WG63@@CK&y$?qi`LCMod z(g#E}NZJ8Y=i~#Do*;@_$_^yxE#(QKrU7}MH%z`J<*5isn2(_r!yFyx2KUZn2Wfdx zSUQEc0jg?poRqA2q8I~1e7vutvwv`eezCE>UOd>Z98kZ43}$5m