$data['creator'] = (string)$path->creator->pseudo;
}
- $api->setCheckIfNoneMatch(true)->setBody(json_encode($data));
+ $api->setCheckIfNoneMatch(true)->setBodyJson($data);
}
}
$path->creator = $user;
$path->creatorIp = $this->getRequest()->getClientIp(true);
- return $this->save($path, $formData);
+ $this->save($path, $formData);
+ $data = array('redirect' => "idx/" . (string)$path->id);
+ $this->_helper->SyjApi->setCode(201)->setBodyJson($data);
}
public function updateAction() {
$formData = $this->_helper->SyjPostData->getPostData('Syj_Form_Geom');
- return $this->save($this->getPath(), $formData);
+ $path = $this->getPath();
+ $this->save($path, $formData);
+ $this->_helper->SyjApi->setCode(204);
}
public function deleteAction() {
throw $e;
}
}
-
- $this->_helper->SyjApi->setBody($path->id);
}
}
$this->_contentType = $contentType;
}
+ public function setBodyJson($data) {
+ $this->setBody(json_encode($data))
+ ->setContentType('application/json');
+ }
+
public function setBody($body) {
$this->_body = (string)$body;
return $this;
}
item.prototype = {
deleteSuccess: function() {
+ this.deactivate();
+ $("message").setMessage(SyjStrings.deleteSuccess, "success");
+ },
+
+ deactivate: function() {
this.elt.down('.title').update();
this.elt.down('.geom').update().setStyle({backgroundColor: 'gray'});
this.deleteHandler.stop();
this.elt.on('click', 'a', function(evt) { evt.stop(); });
this.elt.select('a').invoke('setStyle', {textDecoration: 'line-through'});
- $("message").setMessage(SyjStrings.deleteSuccess, "success");
},
deleteFailure: function(transport) {
message = SyjStrings.requestError;
break;
case 410:
+ this.deactivate();
message = SyjStrings.gonePathError;
break;
case 500:
map: null,
wkt: new OpenLayers.Format.WKT({ internalProjection: Mercator, externalProjection: WGS84 }),
needsFormResubmit: false,
- hasInitialGeom: false,
init: function() {
var externalGraphic, baseURL, baseLayer, layerOptions, extent, hidemessenger;
// XXX: ie has not guessed height of map main div yet during map
// initialisation. Now, it will read it correctly.
this.map.updateSize();
- this.hasInitialGeom = true;
} else {
extent = new OpenLayers.Bounds(gMaxExtent.minlon, gMaxExtent.minlat, gMaxExtent.maxlon, gMaxExtent.maxlat)
.transform(WGS84, Mercator);
},
saveSuccess: function(transport) {
- if (!this.hasInitialGeom) { // we have created a new path, change location
- location = "idx/" + transport.responseText;
+ if (transport.responseJSON && (typeof transport.responseJSON.redirect === "string")) {
+ location = transport.responseJSON.redirect;
return;
}