From a8b6dd4c1a50ec8ddb2f85f2bd849ad692f4be22 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 12 Sep 2017 13:31:15 +0200 Subject: [PATCH] Backup --- forms/ecomerce/basket/basket.js | 2 +- forms/ecomerce/catalog/catalog.js | 41 +++++++++++-------------------- forms/ecomerce/catalog/ui.xml | 27 +++++++++++--------- js/db/model.js | 20 +++++++++++++-- js/hedera/form.js | 4 +++ 5 files changed, 54 insertions(+), 40 deletions(-) diff --git a/forms/ecomerce/basket/basket.js b/forms/ecomerce/basket/basket.js index ff7a5ce5..f8e331f0 100644 --- a/forms/ecomerce/basket/basket.js +++ b/forms/ecomerce/basket/basket.js @@ -52,7 +52,7 @@ Hedera.Basket = new Class ,subtotal: function (form) { - return form.get ('amount') * form.get ('price'); + return form.$.amount * form.$.price; } }); diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index 31ead49a..34636feb 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -18,7 +18,7 @@ Hedera.Catalog = new Class if (!localStorage.getItem ('hederaGuest')) { - Hedera.BasketChecker.check (this.conn, this.hash, + Hedera.BasketChecker.check (this.conn, this.params, this.onBasketCheck.bind (this)); } else @@ -37,12 +37,6 @@ Hedera.Catalog = new Class ,activate: function () { this.$('items').setInfo ('a', 'Articles', 'vn2008', ['item_id']); - this.$('lot').assign ({filter: this.$('filter')}); - this.$('lot').setProperties ({ - type: Vn.LotQuery.Type.EXCLUDE, - fields: [] - }); - document.body.appendChild (this.$('right-panel')); if (localStorage.getItem ('hederaView')) @@ -53,14 +47,14 @@ Hedera.Catalog = new Class this.onRealmChange (); this.refreshTitle (); } - + ,deactivate: function () { this.hideMenu (); this.gui.$('top-bar').style.backgroundColor = ''; Vn.Node.remove (this.$('right-panel')); } - + ,setView: function (view) { if (view === View.GRID) @@ -116,7 +110,7 @@ Hedera.Catalog = new Class ,shouldRefresh: function () { - var params = this.$('lot').params; + var params = this.params.$; if (params.search) return true; @@ -151,33 +145,28 @@ Hedera.Catalog = new Class { var link = builder.$('link'); link.href = this.hash.make ({ - form: this.hash.get ('form'), - realm: form.get ('id') + form: this.hash.$.form, + realm: form.$.id }); var img = builder.$('image'); - img.src = 'image/family/light/'+ form.get ('id') +'.svg'; - img.title = form.get ('name'); + img.src = 'image/family/light/'+ form.$.id +'.svg'; + img.title = form.$.name; img.alt = img.title; } ,onRealmChange: function () { - var newValue = this.hash.get ('realm'); + var newValue = this.params.$.realm; this.$('filters').style.display = newValue ? 'block' : 'none'; this.$('realm-msg').style.display = newValue ? 'none' : 'block'; - this.refreshTitleColor (); - this.hash.params = { - form: this.hash.get ('form'), - realm: newValue, - }; } ,refreshTitleColor: function () { var realms = this.$('realms'); - var realm = this.hash.get ('realm'); + var realm = this.params.$.realm; var color = null; if (realm) @@ -194,7 +183,7 @@ Hedera.Catalog = new Class ,refreshTitle: function () { var types = this.$('types'); - var type = this.hash.get ('type'); + var type = this.params.$.type; var title = _('Catalog'); if (type) @@ -250,7 +239,7 @@ Hedera.Catalog = new Class if (this.isGuest ()) return; - this.hash.params = {form: 'ecomerce/basket'}; + this.hash.$ = {form: 'ecomerce/basket'}; } ,onConfigureClick: function () @@ -258,7 +247,7 @@ Hedera.Catalog = new Class if (this.isGuest ()) return; - this.hash.params = {form: 'ecomerce/checkout'}; + this.hash.$ = {form: 'ecomerce/checkout'}; } ,onAddItemClick: function (button, form) @@ -268,7 +257,7 @@ Hedera.Catalog = new Class this.onEraseClick (); this.$('card').row = form.row; - this.$('card-lot').assign ({item: form.get ('item_id')}); + this.$('card-lot').assign ({item: form.$.item_id}); this.$('card-popup').show (button.node); } @@ -317,7 +306,7 @@ Hedera.Catalog = new Class { this.conn.execQuery (sql); - var itemName = this.$('card').get ('Article'); + var itemName = this.$('card').$.Article; Htk.Toast.showMessage ( sprintf (_('Added%dOf%s'), amountSum, itemName)); } diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index df4c21ca..c13684eb 100755 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -8,39 +8,41 @@ + - - - + CREATE TEMPORARY TABLE tmp.bionic_calc (INDEX (item_id)) @@ -48,7 +50,7 @@ SELECT a.Id_Article item_id FROM vn2008.Articles a JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id - WHERE #filter; + WHERE $filter; CALL bionic_calc (); SELECT a.Id_Article item_id, a.description, b.available, b.price, b.producer, a.Foto, a.Article, a.Categoria, a.Medida, @@ -99,6 +101,9 @@ JOIN vn2008.warehouse w ON w.id = p.warehouse_id ORDER BY warehouse_id, grouping; + + +

Catalog diff --git a/js/db/model.js b/js/db/model.js index d78dcdab..21886425 100644 --- a/js/db/model.js +++ b/js/db/model.js @@ -101,6 +101,22 @@ Klass.implement return this._lot; } }, + /** + * The remote filter used for query. + */ + filter: + { + type: Sql.Filter + ,set: function (x) + { + this._filter = x; + this.refresh (); + } + ,get: function () + { + return this._filter; + } + }, /** * The model select statement. */ @@ -309,7 +325,7 @@ Klass.implement return true; for (var key in params) - if (params[key] == null) + if (params[key] === undefined) return false; return true; @@ -321,7 +337,7 @@ Klass.implement ,refresh: function () { var params = this._getParams (); - + if (this._isReady (params)) { this._lastParams = params; diff --git a/js/hedera/form.js b/js/hedera/form.js index 589f59bd..c513da48 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -45,7 +45,10 @@ module.exports = new Class var paramsLot = res.$('params'); if (paramsLot) + { paramsLot.source = this.hash; + this.params = paramsLot; + } var models = res.getByTagName ('db-model'); @@ -81,6 +84,7 @@ module.exports = new Class this.gui.setForm (null); this.deactivate (); this.node = null; + this.params = null; } if (this.builder) {