0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-10-16 09:58:12 +02:00
parent 125686307f
commit e178c74f25
9 changed files with 85 additions and 76 deletions

View File

@ -18,7 +18,7 @@ Hedera.Catalog = new Class
if (!localStorage.getItem ('hederaGuest')) if (!localStorage.getItem ('hederaGuest'))
{ {
Hedera.BasketChecker.check (this.conn, this.params, Hedera.BasketChecker.check (this.conn, this.hash,
this.onBasketCheck.bind (this)); this.onBasketCheck.bind (this));
} }
else else
@ -46,6 +46,7 @@ Hedera.Catalog = new Class
this.onRealmChange (); this.onRealmChange ();
this.refreshTitle (); this.refreshTitle ();
this.onParamsChange ();
} }
,deactivate: function () ,deactivate: function ()
@ -108,28 +109,26 @@ Hedera.Catalog = new Class
this.hideMenu (); this.hideMenu ();
} }
,onLotChange: function () ,onParamsChange: function ()
{ {
function shouldRefresh (params) var params = this.params.$;
{ var shouldRefresh = params.search ||
return params.search || params.realm && (
params.realm && ( params.type ||
params.type || params.color ||
params.color || params.origin ||
params.origin || params.category ||
params.category || params.producer
params.producer );
);
}
function refreshItems () if (shouldRefresh)
{ {
this.$('items').refresh (); var filterSql = this.$('filter').render (params);
} var modelParams = {
filter: new Sql.String ({query: filterSql})
};
this.$('items').refresh (modelParams);
if (shouldRefresh (this.params.$))
{
refreshItems ();
this.hideMenu (); this.hideMenu ();
this.$('order').style.display = 'block'; this.$('order').style.display = 'block';
} }

View File

@ -275,15 +275,15 @@
position: relative; position: relative;
width: 100%; width: 100%;
margin: 0; margin: 0;
height: 5.5em; height: 6.5em;
overflow: visible; overflow: visible;
border-bottom: 1px solid #DDD; border-bottom: 1px solid #DDD;
} }
.list-view .item-box > .htk-image .list-view .item-box > .htk-image
{ {
margin: 1em; margin: 1em;
width: 3.5em; width: 4.5em;
height: 3.5em; height: 4.5em;
float: left; float: left;
overflow: hidden; overflow: hidden;
} }
@ -294,7 +294,7 @@
.list-view .item-info .list-view .item-info
{ {
position: absolute; position: absolute;
left: 5.5em; left: 6.5em;
right: 0; right: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;

View File

@ -1,6 +1,6 @@
<vn> <vn>
<vn-group> <vn-group>
<vn-lot-query id="params" on-change="onLotChange"> <vn-lot-query id="params" on-change="onParamsChange">
<vn-spec name="realm" type="Number"/> <vn-spec name="realm" type="Number"/>
<vn-spec name="type" type="Number"/> <vn-spec name="type" type="Number"/>
<vn-spec name="search" type="String"/> <vn-spec name="search" type="String"/>
@ -41,8 +41,6 @@
<db-model <db-model
id="items" id="items"
result-index="2" result-index="2"
filter="filter"
lot="lot"
auto-load="false"> auto-load="false">
CREATE TEMPORARY TABLE tmp.bionic_calc CREATE TEMPORARY TABLE tmp.bionic_calc
(INDEX (item_id)) (INDEX (item_id))
@ -151,6 +149,9 @@
<p class="producer"> <p class="producer">
<htk-text lot="item" name="producer"/> <htk-text lot="item" name="producer"/>
</p> </p>
<p>
<htk-text lot="item" name="item_id"/>
</p>
<p> <p>
<t>Size</t> <htk-text lot="item" name="Medida"/>, <t>Size</t> <htk-text lot="item" name="Medida"/>,
<t>Category</t> <htk-text lot="item" name="Categoria"/> <t>Category</t> <htk-text lot="item" name="Categoria"/>
@ -211,44 +212,6 @@
<div class="clear"/> <div class="clear"/>
</div> </div>
</div> </div>
<div id="order" class="order">
<h2><t>Order by</t></h2>
<select on-change="onOrderChange">
<option value="D|relevancy" selected="true">
<t>Relevancy</t>
</option>
<option value="A|Article">
<t>Name</t>
</option>
<option value="A|price">
<t>Lower price</t>
</option>
<option value="D|price">
<t>Higher price</t>
</option>
<option value="A|available">
<t>Available</t>
</option>
<option value="A|Medida">
<t>Lower size</t>
</option>
<option value="D|Medida">
<t>Higher size</t>
</option>
<option value="A|color">
<t>Color</t>
</option>
<option value="A|producer">
<t>Producer</t>
</option>
<option value="A|Abreviatura">
<t>Origin</t>
</option>
<option value="A|Categoria">
<t>Category</t>
</option>
</select>
</div>
<div id="realm-msg" class="realm-msg"> <div id="realm-msg" class="realm-msg">
<h1><t>Choose a realm</t></h1> <h1><t>Choose a realm</t></h1>
</div> </div>
@ -342,6 +305,44 @@
</db-model> </db-model>
</vn-filter> </vn-filter>
</div> </div>
<div id="order" class="order">
<h2><t>Order by</t></h2>
<select on-change="onOrderChange">
<option value="D|relevancy" selected="true">
<t>Relevancy</t>
</option>
<option value="A|Article">
<t>Name</t>
</option>
<option value="A|price">
<t>Lower price</t>
</option>
<option value="D|price">
<t>Higher price</t>
</option>
<option value="A|available">
<t>Available</t>
</option>
<option value="A|Medida">
<t>Lower size</t>
</option>
<option value="D|Medida">
<t>Higher size</t>
</option>
<option value="A|color">
<t>Color</t>
</option>
<option value="A|producer">
<t>Producer</t>
</option>
<option value="A|Abreviatura">
<t>Origin</t>
</option>
<option value="A|Categoria">
<t>Category</t>
</option>
</select>
</div>
</div> </div>
</div> </div>
<htk-popup id="desc-popup"> <htk-popup id="desc-popup">

View File

@ -47,6 +47,9 @@ Connection.implement
*/ */
,execSql: function (sql, callback) ,execSql: function (sql, callback)
{ {
if (enableDebug)
console.log (sql);
this.send ('core/query', {'sql': sql}, this.send ('core/query', {'sql': sql},
this._onExec.bind (this, callback)); this._onExec.bind (this, callback));
} }

View File

@ -22,6 +22,6 @@ module.exports =
if (callback) if (callback)
callback (isOk); callback (isOk);
if (!isOk) if (!isOk)
this.hash.setAll ({'form': 'ecomerce/checkout'}); this.hash.$ = {form: 'ecomerce/checkout'};
} }
}; };

View File

@ -40,7 +40,8 @@ module.exports = new Class
builder.add ('hash', this.hash); builder.add ('hash', this.hash);
builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml'); builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
var res = this.builderResultInit (builder); var res = this.builder = builder.load ();
this._node = res.$('main');
var paramsLot = res.$('params'); var paramsLot = res.$('params');
@ -49,6 +50,8 @@ module.exports = new Class
paramsLot.source = this.hash; paramsLot.source = this.hash;
this.params = paramsLot; this.params = paramsLot;
} }
res.link ();
var models = res.getByTagName ('db-model'); var models = res.getByTagName ('db-model');
@ -79,10 +82,10 @@ module.exports = new Class
if (this.node) if (this.node)
{ {
this.deactivate (); this.deactivate ();
this.builder.unref ();
this.gui.setTitle (null); this.gui.setTitle (null);
this.gui.setActions (null); this.gui.setActions (null);
this.gui.setForm (null); this.gui.setForm (null);
this.deactivate ();
this.node = null; this.node = null;
this.params = null; this.params = null;
} }

View File

@ -55,6 +55,7 @@ module.exports = new Class
throw new Error ('VnLotQuery: Child must be a Vn.Spec instance'); throw new Error ('VnLotQuery: Child must be a Vn.Spec instance');
this._specs[child.name] = child; this._specs[child.name] = child;
this._onSourceChange ();
} }
,_onSourceChange: function () ,_onSourceChange: function ()

View File

@ -3,6 +3,8 @@ require ('mootools');
require ('./mutators'); require ('./mutators');
require ('./polyfills'); require ('./polyfills');
enableDebug = false;
Vn = module.exports = { Vn = module.exports = {
Locale : require ('./locale') Locale : require ('./locale')
,Enum : require ('./enum') ,Enum : require ('./enum')

View File

@ -12,24 +12,24 @@ class Transaction extends Vn\Web\JsonRequest
$amount = (int) $_REQUEST['amount']; $amount = (int) $_REQUEST['amount'];
$companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company']; $companyId = empty ($_REQUEST['company']) ? NULL : $_REQUEST['company'];
$row = $db->getRow ('CALL transactionStart (#, #)', $row = $db->getObject ('CALL transactionStart (#, #)',
[$amount, $companyId]); [$amount, $companyId]);
if (!isset ($row)) if (!isset ($row))
throw new Exception ('Transaction error'); throw new Exception ('Transaction error');
$transactionId = str_pad ($row['transactionId'], 12, '0', STR_PAD_LEFT); $transactionId = str_pad ($row->transactionId, 12, '0', STR_PAD_LEFT);
$urlOk = empty ($_REQUEST['urlOk']) ? '' : sprintf ($_REQUEST['urlOk'], $transactionId); $urlOk = empty ($_REQUEST['urlOk']) ? '' : sprintf ($_REQUEST['urlOk'], $transactionId);
$urlKo = empty ($_REQUEST['urlKo']) ? '' : sprintf ($_REQUEST['urlKo'], $transactionId); $urlKo = empty ($_REQUEST['urlKo']) ? '' : sprintf ($_REQUEST['urlKo'], $transactionId);
$merchantUrl = $row['merchantUrl'] ? $row['merchantUrl'] : ''; $merchantUrl = $row->merchantUrl ? $row->merchantUrl : '';
$params = [ $params = [
'Ds_Merchant_Amount' => $amount 'Ds_Merchant_Amount' => $amount
,'Ds_Merchant_Order' => $transactionId ,'Ds_Merchant_Order' => $transactionId
,'Ds_Merchant_MerchantCode' => $row['merchant'] ,'Ds_Merchant_MerchantCode' => $row->merchant
,'Ds_Merchant_Currency' => $row['currency'] ,'Ds_Merchant_Currency' => $row->currency
,'Ds_Merchant_TransactionType' => $row['transactionType'] ,'Ds_Merchant_TransactionType' => $row->transactionType
,'Ds_Merchant_Terminal' => $row['terminal'] ,'Ds_Merchant_Terminal' => $row->terminal
,'Ds_Merchant_MerchantURL' => $merchantUrl ,'Ds_Merchant_MerchantURL' => $merchantUrl
,'Ds_Merchant_UrlOK' => $urlOk ,'Ds_Merchant_UrlOK' => $urlOk
,'Ds_Merchant_UrlKO' => $urlKo ,'Ds_Merchant_UrlKO' => $urlKo
@ -37,7 +37,7 @@ class Transaction extends Vn\Web\JsonRequest
$encodedParams = base64_encode (json_encode ($params)); $encodedParams = base64_encode (json_encode ($params));
$key = base64_decode ($row['secretKey']); $key = base64_decode ($row->secretKey);
$bytes = [0, 0, 0, 0, 0, 0, 0, 0]; $bytes = [0, 0, 0, 0, 0, 0, 0, 0];
$iv = implode (array_map ('chr', $bytes)); $iv = implode (array_map ('chr', $bytes));
@ -45,7 +45,7 @@ class Transaction extends Vn\Web\JsonRequest
$signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE)); $signature = base64_encode (hash_hmac ('sha256', $encodedParams, $key, TRUE));
$url = $row['url']; $url = $row->url;
$postValues = [ $postValues = [
'Ds_SignatureVersion' => 'HMAC_SHA256_V1' 'Ds_SignatureVersion' => 'HMAC_SHA256_V1'
,'Ds_MerchantParameters' => $encodedParams ,'Ds_MerchantParameters' => $encodedParams