partkeepr

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

commit 98160a55218ae5c1930b11bdfd3240e518fb7d68
parent 44bccdb4bd5af64dd31d96ae2bee8d1d9e4be581
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 16 Sep 2015 18:36:33 +0200

Fixed add/remove stock methods

Diffstat:
Msrc/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js | 38++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartDisplay.js @@ -177,7 +177,8 @@ Ext.define('PartKeepr.PartDisplay', { this.attachmentDisplay.bindStore(this.record.attachments()); this.infoGrid.setSource(values); - this.infoGrid.setTitle("<div>" + this.record.get("name") + "</div><small>" + this.record.get("description") + "</small>"); + this.infoGrid.setTitle( + "<div>" + this.record.get("name") + "</div><small>" + this.record.get("description") + "</small>"); this.imageDisplay.setStore(this.record.attachments()); // Scroll the container to top in case the user scrolled the part, then switched to another part @@ -197,15 +198,11 @@ Ext.define('PartKeepr.PartDisplay', { */ addPartHandler: function (quantity, price, comment) { - var call = new PartKeepr.ServiceCall( - "Part", - "addStock"); - call.setParameter("stock", quantity); - call.setParameter("price", price); - call.setParameter("comment", comment); - call.setParameter("part", this.record.get("id")); - call.setHandler(Ext.bind(this.reloadPart, this)); - call.doCall(); + this.record.callAction("addStock", { + quantity: quantity, + price: price, + comment: comment + }, Ext.bind(this.reloadPart, this)); }, /** * Prompts the user for the stock level to decrease for the item. @@ -220,27 +217,26 @@ Ext.define('PartKeepr.PartDisplay', { */ deletePartHandler: function (quantity) { - var call = new PartKeepr.ServiceCall( - "Part", - "deleteStock"); - call.setParameter("stock", quantity); - call.setParameter("part", this.record.getId()); - call.setHandler(Ext.bind(this.reloadPart, this)); - call.doCall(); + this.record.callAction("removeStock", { + quantity: quantity, + }, Ext.bind(this.reloadPart, this)); }, /** * Reloads the current part */ reloadPart: function () { - this.loadPart(this.record.getId()); + this.record.load({ + scope: this, + success: this.onPartLoaded + }); }, /** * Load the part from the database. */ - loadPart: function (id) + loadPart: function () { - PartKeepr.Part.load(id, { + this.record.load({ scope: this, success: this.onPartLoaded }); @@ -250,8 +246,6 @@ Ext.define('PartKeepr.PartDisplay', { */ onPartLoaded: function (record) { - this.record = record; this.setValues(this.record); - this.record.commit(); } });