diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index a8ed89836..7397d0edf 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -456,6 +456,11 @@ sub www_loadSurvey { elsif ( $var->{type} eq 'answer' ) { $editHtml = $self->processTemplate( $var, $self->get("answerEditTemplateId") ); } + + # Generate the list of valid goto targets + my @section_vars = map {$_->{variable}} @{$self->survey->sections}; + my @question_vars = map {$_->{variable}} @{$self->survey->questions}; + my @gotoTargets = grep {$_ ne ''} (@section_vars, @question_vars); my %buttons; $buttons{question} = $$address[0]; @@ -509,7 +514,8 @@ sub www_loadSurvey { #type is the object type my $return = { "address", $address, "buttons", \%buttons, "edithtml", $editHtml, - "ddhtml", $html, "ids", \@ids, "type", $var->{type} + "ddhtml", $html, "ids", \@ids, "type", $var->{type}, + gotoTargets => \@gotoTargets, }; $self->session->http->setMimeType('application/json'); return to_json($return); diff --git a/survey_rfe_9202.wgpkg b/survey_rfe_9202.wgpkg new file mode 100644 index 000000000..739bb1699 Binary files /dev/null and b/survey_rfe_9202.wgpkg differ diff --git a/www/extras/wobject/Survey/editsurvey.js b/www/extras/wobject/Survey/editsurvey.js index f1e4c0a7f..6679696da 100644 --- a/www/extras/wobject/Survey/editsurvey.js +++ b/www/extras/wobject/Survey/editsurvey.js @@ -77,11 +77,17 @@ YAHOO.log('adding handler for '+ d.ids[x]); // } if(d.buttons['answer']){ var button = new YAHOO.widget.Button({ label:"Add Answer", id:"addanswer", container:"addAnswer" }); - button.on("click", this.addAnswer,d.buttons['answer']); + button.on("click", this.addAnswer,d.buttons['answer']); } if(showEdit == 1){ this.loadObjectEdit(d.edithtml,d.type); + + // build the goto auto-complete widget + if (d.gotoTargets && document.getElementById('goto')) { + var ds = new YAHOO.util.LocalDataSource(d.gotoTargets); + var ac = new YAHOO.widget.AutoComplete('goto', 'goto-yui-ac-container', ds); + } }else{ document.getElementById('edit').innerHTML = ""; } diff --git a/www/extras/wobject/Survey/surveyedit.css b/www/extras/wobject/Survey/surveyedit.css index 0050e6c20..46d4fe0c3 100644 --- a/www/extras/wobject/Survey/surveyedit.css +++ b/www/extras/wobject/Survey/surveyedit.css @@ -129,4 +129,7 @@ li.newAnswer { padding-left:50px; # cursor: move; } - +#goto-yui-ac { + width:15em; + margin-top:0.5em; +}