This commit is contained in:
Juan Ferrer Toribio 2017-09-12 13:31:15 +02:00
parent b8c83df08f
commit a8b6dd4c1a
5 changed files with 54 additions and 40 deletions

View File

@ -52,7 +52,7 @@ Hedera.Basket = new Class
,subtotal: function (form)
{
return form.get ('amount') * form.get ('price');
return form.$.amount * form.$.price;
}
});

View File

@ -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'))
@ -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));
}

View File

@ -8,39 +8,41 @@
<vn-spec name="origin" type="Number"/>
<vn-spec name="category" type="String"/>
<vn-spec name="producer" type="Number"/>
<vn-spec name="itemId" type="Number"/>
</vn-lot-query>
<vn-lot id="card-lot"/>
<vn-param lot="params" name="realm" on-changed="onRealmChange"/>
<vn-param lot="params" name="type" on-changed="refreshTitle"/>
<sql-filter type="AND" id="filter">
<sql-filter-item type="EQUAL"
field="tipo_id" target="a"
target="a" field="tipo_id"
param="type"/>
<sql-filter type="OR">
<sql-filter-item type="LIKE"
field="Article" target="a"
target="a" field="Article"
param="search"/>
<sql-filter-item type="EQUAL"
field="Id_Article" target="a"
target="a" field="Id_Article"
param="search"/>
<sql-filter-item type="EQUAL"
target="a" field="Id_Article"
param="itemId"/>
</sql-filter>
<sql-filter-item type="EQUAL"
field="Color" target="a"
target="a" field="Color"
param="color"/>
<sql-filter-item type="EQUAL"
field="id_origen" target="a"
target="a" field="id_origen"
param="origin"/>
<sql-filter-item type="EQUAL"
field="Categoria" target="a"
target="a" field="Categoria"
param="category"/>
<sql-filter-item type="EQUAL"
field="producer_id" target="a"
target="a" field="producer_id"
param="producer"/>
</sql-filter>
<db-model
id="items"
result-index="2"
lot="params"
filter="filter"
auto-load="false">
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;
</db-model>
<vn-lot id="card-lot"/>
<vn-param lot="params" name="realm" on-changed="onRealmChange"/>
<vn-param lot="params" name="type" on-changed="refreshTitle"/>
</vn-group>
<h1 id="title">
<t>Catalog</t>

View File

@ -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;

View File

@ -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)
{