From 085f90d989d587c0260780e7cc69ee84ccc5f495 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 4 Nov 2011 16:43:12 +0100 Subject: [PATCH 1/3] [imp] added back button + removed backbone history bzr revid: nicolas.vanhoren@openerp.com-20111104154312-uolo3j36lg1zwfxh --- addons/point_of_sale/static/src/js/pos.js | 22 +++++++++------------ addons/point_of_sale/static/src/xml/pos.xml | 3 +++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 086bc38cf65..2964ad75991 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -1131,22 +1131,20 @@ openerp.point_of_sale = function(db) { return ShopView; })(); App = (function() { - __extends(App, Backbone.Router); - function App() { - App.__super__.constructor.apply(this, arguments); + function App($element) { + this.initialize($element); } - App.prototype.routes = { - '': 'category', - 'category/:id': 'category' - }; App.prototype.initialize = function($element) { this.shop = new Shop; this.shopView = new ShopView({ shop: this.shop, el: $element }); - return this.categoryView = new CategoryView; + this.categoryView = new CategoryView; + this.categoryView.bind("changeCategory", this.category, this); + this.category(); + return this.categoryView; }; App.prototype.category = function(id) { var c, products; @@ -1188,11 +1186,10 @@ openerp.point_of_sale = function(db) { db.point_of_sale.PointOfSale = db.web.Widget.extend({ template: "PointOfSale", start: function() { - // FIXME: absolutely horrible hack to avoid conflict - // between backbone's history and al's action - // thingie - window.location.hash = ''; var self = this; + this.$element.find("#loggedas button").click(function() { + self.stop(); + }); if (pos) throw "It is not possible to instantiate multiple instances"+ @@ -1203,7 +1200,6 @@ openerp.point_of_sale = function(db) { return pos.ready.then( function() { pos.app = new App(self.$element); - return Backbone.history.start(); }); }, stop: function() { diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 32994b01c98..d4962a62084 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -24,6 +24,9 @@
    +
    + +
    From db36bc97b4d6e12478830d47c820b183e697687b Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Mon, 7 Nov 2011 15:13:23 +0100 Subject: [PATCH 2/3] [fix] categories were broken bzr revid: nicolas.vanhoren@openerp.com-20111107141323-zmariwqu0qns3bcm --- addons/point_of_sale/static/src/js/pos.js | 9 +++++++++ addons/point_of_sale/static/src/xml/pos.xml | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/static/src/js/pos.js b/addons/point_of_sale/static/src/js/pos.js index 2964ad75991..5835f1e35e1 100644 --- a/addons/point_of_sale/static/src/js/pos.js +++ b/addons/point_of_sale/static/src/js/pos.js @@ -751,6 +751,10 @@ openerp.point_of_sale = function(db) { function CategoryView() { CategoryView.__super__.constructor.apply(this, arguments); } + + CategoryView.prototype.events = { + 'click .oe-pos-categories-list a': 'changeCategory' + }; CategoryView.prototype.template = qweb_template('pos-category-template'); CategoryView.prototype.render = function(ancestors, children) { @@ -776,6 +780,10 @@ openerp.point_of_sale = function(db) { })() })); }; + CategoryView.prototype.changeCategory = function(a) { + var id = $(a.target).data("category-id"); + this.trigger("changeCategory", id); + }; return CategoryView; })(); ProductView = (function() { @@ -1153,6 +1161,7 @@ openerp.point_of_sale = function(db) { } c = pos.categories[id]; $('#products-screen').html(this.categoryView.render(c.ancestors, c.children)); + this.categoryView.delegateEvents(); products = pos.store.get('product.product').filter( function(p) { var _ref; return _ref = p.pos_categ_id[0], __indexOf.call(c.subtree, _ref) >= 0; diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index d4962a62084..b9148395cbe 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -143,15 +143,15 @@