Thingy add/edit via AJAX returned nothing useful, and lied about error status. Fixes bug #11781.

This commit is contained in:
Colin Kuskie 2010-08-15 23:16:53 -07:00
parent 04c49fb48e
commit 05c287cfc7
3 changed files with 30 additions and 5 deletions

View file

@ -2645,9 +2645,10 @@ sub www_editThingDataSaveViaAjax {
}
my $thingProperties = $self->getThing($thingId);
use Data::Dumper;
warn $thingId;
warn Dumper $thingProperties;
if ($thingProperties->{thingId}){
my ($privilegedGroup,$workflowId);
return $session->privilege->insufficient() unless $self->canEditThingData($thingId, $thingDataId
,$thingProperties);
@ -2658,12 +2659,15 @@ sub www_editThingDataSaveViaAjax {
my ($newThingDataId,$errors) = $self->editThingDataSave($thingId,$thingDataId);
if ($errors){
$session->http->setStatus("400", "Bad Request");
if (@{ $errors }) {
$session->http->setStatus("400", "Bad Request");
return JSON->new->encode($errors);
}
$session->http->setStatus("200");
return '{}';
}
else {
warn "thingId not found in thingProperties\n";
$session->http->setStatus("404", "Not Found");
return JSON->new->encode({message => "The thingId you requested can not be found."});
}