You can now copy sections and questions. And if I correctly understand how to bundle asset packages, all the new template changes are included.
This commit is contained in:
parent
5b8a1df90e
commit
5afae6de85
4 changed files with 50 additions and 3 deletions
|
|
@ -254,6 +254,11 @@ $self->session->errorHandler->error("Submit Edit Object");
|
||||||
$self->session->errorHandler->error("Deleting ".join(',',@address));
|
$self->session->errorHandler->error("Deleting ".join(',',@address));
|
||||||
return $self->deleteObject(\@address);
|
return $self->deleteObject(\@address);
|
||||||
}
|
}
|
||||||
|
elsif($responses->{copy}){
|
||||||
|
$self->session->errorHandler->error("Copying ".join(',',@address));
|
||||||
|
return $self->copyObject(\@address);
|
||||||
|
}
|
||||||
|
|
||||||
$self->session->errorHandler->error("Updating ".join(',',@address));
|
$self->session->errorHandler->error("Updating ".join(',',@address));
|
||||||
#each object checks the ref and then either updates or passes it to the correct child. New objects will have an index of -1.
|
#each object checks the ref and then either updates or passes it to the correct child. New objects will have an index of -1.
|
||||||
my $message = $self->survey->update(\@address,$responses);
|
my $message = $self->survey->update(\@address,$responses);
|
||||||
|
|
@ -263,6 +268,19 @@ $self->session->errorHandler->error("Updating ".join(',',@address));
|
||||||
return $self->www_loadSurvey({address => \@address});
|
return $self->www_loadSurvey({address => \@address});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub copyObject{
|
||||||
|
my ($self,$address) = @_;
|
||||||
|
|
||||||
|
$self->loadSurveyJSON();
|
||||||
|
|
||||||
|
$address = $self->survey->copy($address);#each object checks the ref and then either updates or passes it to the correct child. New objects will have an index of -1.
|
||||||
|
|
||||||
|
$self->saveSurveyJSON();
|
||||||
|
#The parent address of the deleted object is returned.
|
||||||
|
|
||||||
|
return $self->www_loadSurvey({address => $address});
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub deleteObject{
|
sub deleteObject{
|
||||||
|
|
@ -274,7 +292,12 @@ sub deleteObject{
|
||||||
|
|
||||||
$self->saveSurveyJSON();
|
$self->saveSurveyJSON();
|
||||||
#The parent address of the deleted object is returned.
|
#The parent address of the deleted object is returned.
|
||||||
pop(@{$address}) unless @$address == 1 and $$address[0] == 0;
|
if(@$address == 1){
|
||||||
|
$$address[0] = 0;
|
||||||
|
}else{
|
||||||
|
pop(@{$address});# unless @$address == 1 and $$address[0] == 0;
|
||||||
|
}
|
||||||
|
$self->session->errorHandler->error("returning ".join(',',@$address));
|
||||||
|
|
||||||
return $self->www_loadSurvey({address => $address, message=>$message});
|
return $self->www_loadSurvey({address => $address, message=>$message});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,8 @@ sub update{
|
||||||
$object->{$key} = $ref->{$key} if(defined $$ref{$key});
|
$object->{$key} = $ref->{$key} if(defined $$ref{$key});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#determine what to add and add it.
|
#determine what to add and add it.
|
||||||
# ref should contain all the information for the new
|
# ref should contain all the information for the new
|
||||||
sub insertObject{
|
sub insertObject{
|
||||||
|
|
@ -193,6 +195,25 @@ $self->log("Inserting ".join(',',@$address));
|
||||||
$self->log("Finished inserting ");
|
$self->log("Finished inserting ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub copy{
|
||||||
|
my ($self,$address) = @_;
|
||||||
|
if(@$address == 1){
|
||||||
|
my %newSection = %{$self->section($address)};
|
||||||
|
push(@{$self->sections}, \%newSection);
|
||||||
|
return [$#{$self->sections}];
|
||||||
|
$self->log("copying here $$address[0] :".$#{$self->sections});
|
||||||
|
}elsif(@$address == 2){
|
||||||
|
$self->log("copying question $$address[0] $$address[1]");
|
||||||
|
my %newQuestion = %{$self->question($address)};
|
||||||
|
push( @{$self->questions($address)}, \%newQuestion);
|
||||||
|
$$address[1] = $#{$self->questions($address)};
|
||||||
|
$self->log("to $$address[0] $$address[1]");
|
||||||
|
return $address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub remove{
|
sub remove{
|
||||||
my ($self,$address,$movingOverride) = @_;
|
my ($self,$address,$movingOverride) = @_;
|
||||||
if(@$address == 1){
|
if(@$address == 1){
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -8,8 +8,11 @@ Survey.ObjectTemplate = new function(){
|
||||||
|
|
||||||
document.getElementById('edit').innerHTML = html;
|
document.getElementById('edit').innerHTML = html;
|
||||||
|
|
||||||
var butts = [ { text:"Submit", handler:function(){this.submit();}, isDefault:true }, { text:"Cancel", handler:function(){this.cancel();}},
|
var butts = [
|
||||||
{text:"Delete", handler:function(){document.getElementById('delete').value = 1; this.submit();}}
|
{ text:"Submit", handler:function(){this.submit();}, isDefault:true },
|
||||||
|
{ text:"Copy", handler:function(){document.getElementById('copy').value = 1; this.submit();}},
|
||||||
|
{ text:"Cancel", handler:function(){this.cancel();}},
|
||||||
|
{ text:"Delete", handler:function(){document.getElementById('delete').value = 1; this.submit();}}
|
||||||
];
|
];
|
||||||
|
|
||||||
var form = new YAHOO.widget.Dialog(type,
|
var form = new YAHOO.widget.Dialog(type,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue