@@ -10,6 +10,7 @@ function WOQLChooser(client, config){
1010 this . client = client ;
1111 this . config = ( config ? config : new WOQLChooserConfig ( ) ) ;
1212 this . selected = false ;
13+ this . cursor = 0 ;
1314 return this ;
1415}
1516
@@ -36,6 +37,7 @@ WOQLChooser.prototype.setResult = function(result){
3637 const variables = result . getVariableList ( ) ;
3738 if ( ! this . config . values ( ) && variables . length ) {
3839 this . config . values ( variables [ 0 ] ) ;
40+ alert ( variables [ 0 ] ) ;
3941 }
4042 //sort it
4143 if ( this . config . sort ( ) ) {
@@ -44,7 +46,7 @@ WOQLChooser.prototype.setResult = function(result){
4446 while ( row = this . result . next ( ) ) {
4547 if ( row && this . includeRow ( row , this . result . cursor ) ) {
4648 this . choices . push ( this . rowToChoice ( row , rows ++ ) ) ;
47- }
49+ }
4850 }
4951 return this ;
5052}
@@ -126,7 +128,7 @@ WOQLChooser.prototype.getSpecialRenderer = function(row, index, type){
126128
127129WOQLChooser . prototype . renderSpecial = function ( rule , row , rownum ) {
128130 if ( rule && typeof rule == "function" ) {
129- return render ( row ) ;
131+ return rule ( row ) ;
130132 }
131133 if ( rule && typeof rule == "string" ) {
132134 return rule ;
@@ -142,15 +144,17 @@ WOQLChooser.prototype.first = function(){
142144 return this . choices [ this . cursor ] ;
143145}
144146
145- WOQLChooser . prototype . prev = function ( ) {
146- if ( this . cursor > 0 ) {
147- return this . choices [ -- this . cursor ] ;
148- }
149- }
150-
151- WOQLChooser . prototype . next = function ( ) {
152- return this . choices [ this . cursor ++ ] ;
153- }
147+ WOQLChooser . prototype . next = function ( ) {
148+ const res = this . choices [ this . cursor ] ;
149+ this . cursor ++ ;
150+ return res ;
151+ } ;
154152
153+ WOQLChooser . prototype . prev = function ( ) {
154+ if ( this . cursor > 0 ) {
155+ this . cursor -- ;
156+ return this . choices [ this . cursor ] ;
157+ }
158+ } ;
155159
156160module . exports = WOQLChooser ;
0 commit comments