partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 1651bcd0429556b2d3918068a2e9c784d008e3ae
parent 7edcc801f599cdce8b5da91bcfed196184f47121
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 14 Sep 2011 15:17:54 +0200

Refactored category deleting to support RESTful methods

Diffstat:
Mfrontend/js/Components/CategoryEditor/CategoryEditorTree.js | 11++---------
Mfrontend/rest.php | 2++
Msrc/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryService.php | 4++++
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/frontend/js/Components/CategoryEditor/CategoryEditorTree.js b/frontend/js/Components/CategoryEditor/CategoryEditorTree.js @@ -195,15 +195,8 @@ Ext.define("PartKeepr.CategoryEditorTree", { }, onCategoryDelete: function (btn) { if (btn == "yes") { - var call = new PartKeepr.ServiceCall(this.categoryService, "deleteCategory"); - call.setLoadMessage(sprintf(i18n("Deleting category %s..."), this.menu.record.get("name"))); - call.setParameter("id", this.menu.record.get("id")); - call.setHandler(Ext.bind(this.onCategoryDeleted, this)); - call.doCall(); + var del = this.getStore().getRootNode().findChild("id", this.menu.record.get("id"), true); + del.destroy(); } - }, - onCategoryDeleted: function (response) { - var del = this.getStore().getRootNode().findChild("id", response.id, true); - del.destroy(); } }); \ No newline at end of file diff --git a/frontend/rest.php b/frontend/rest.php @@ -59,12 +59,14 @@ try { header('HTTP/1.0 400 Exception', false, 400); $response = array(); $response["status"] = "error"; + $response["success"] = false; $response["exception"] = $e->serialize(); echo json_encode($response); } catch (\Exception $e) { header('HTTP/1.0 400 Exception', false, 400); $response = array(); $response["status"] = "systemerror"; + $response["success"] = false; $response["exception"] = array( "message" => $e->getMessage(), "exception" => get_class($e), diff --git a/src/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryService.php b/src/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryService.php @@ -84,6 +84,10 @@ abstract class AbstractCategoryService extends Service { return array("data" => $this->serializeCategory($category)); } + public function destroy () { + return $this->deleteCategory(); + } + private function serializeCategory ($category) { $data = $category->getNode()->serialize();