From 234914c3e268ededddcc26bb51e8b75d5f59ebf7 Mon Sep 17 00:00:00 2001 From: Kaleb Murphy Date: Fri, 10 Apr 2009 20:03:29 +0000 Subject: [PATCH] Survey drag-and-drop now returns the edit box for the item just drug. --- lib/WebGUI/Asset/Wobject/Survey.pm | 10 +++++----- lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index cd6d42881..b96076949 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -677,7 +677,7 @@ sub www_dragDrop { #If target is being moved down, then before has just moved up do to the target being deleted $bid[0]-- if($tid[0] < $bid[0]); - $self->surveyJSON->insertObject( $target, [ $bid[0] ] ); + $address = $self->surveyJSON->insertObject( $target, [ $bid[0] ] ); } elsif ( @tid == 2 ) { #questions can be moved to any section, but a pushed to the end of a new section. if ( $bid[0] !~ /\d/ ) { @@ -701,21 +701,21 @@ sub www_dragDrop { else{ #Moved within the same section $bid[1]-- if($tid[1] < $bid[1]); } - $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1] ] ); + $address = $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1] ] ); } ## end elsif ( @tid == 2 ) elsif ( @tid == 3 ) { #answers can only be rearranged in the same question if ( @bid == 2 and $bid[1] == $tid[1] ) {#moved to the top of the question $bid[2] = -1; - $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1], $bid[2] ] ); + $address = $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1], $bid[2] ] ); } elsif ( @bid == 3 ) { #If target is being moved down, then before has just moved up do to the target being deleted $bid[2]-- if($tid[2] < $bid[2]); - $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1], $bid[2] ] ); + $address = $self->surveyJSON->insertObject( $target, [ $bid[0], $bid[1], $bid[2] ] ); } else { #else put it back where it was - $self->surveyJSON->insertObject( $target, \@tid ); + $address = $self->surveyJSON->insertObject( $target, \@tid ); } } diff --git a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm index 0b4e8896f..0f12e11d8 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm @@ -725,15 +725,18 @@ sub insertObject { # Use splice to rearrange the relevant array of objects.. if ( $count == 1 ) { splice @{ $self->sections($address) }, sIndex($address) +1, 0, $object; + $address->[0]++; } elsif ( $count == 2 ) { splice @{ $self->questions($address) }, qIndex($address) + 1, 0, $object; + $address->[1]++; } elsif ( $count == 3 ) { splice @{ $self->answers($address) }, aIndex($address) + 1, 0, $object; + $address->[2]++; } - return; + return $address; } =head2 copy ( $address )