0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-10-10 13:58:25 +02:00
parent a8b6dd4c1a
commit 125686307f
35 changed files with 339 additions and 266 deletions

View File

@ -14,14 +14,6 @@
ON u.id = c.user_id ON u.id = c.user_id
</db-model> </db-model>
</db-form> </db-form>
<db-model id="addresses" updatable="true">
SELECT a.id, a.consignee, p.name province,
a.zip_code, a.city, a.name, a.active, c.Pais country
FROM address_view a
LEFT JOIN vn2008.province p ON a.province_id = p.province_id
JOIN vn2008.Paises c ON c.Id = p.Paises_Id
WHERE active
</db-model>
</vn-group> </vn-group>
<h1 id="title"> <h1 id="title">
<t>Configuration</t> <t>Configuration</t>

View File

@ -107,30 +107,29 @@ Hedera.Catalog = new Class
this.hideMenu (); this.hideMenu ();
} }
,shouldRefresh: function ()
{
var params = this.params.$;
if (params.search)
return true;
var refresh = params.realm && (
params.type ||
params.color ||
params.origin ||
params.category ||
params.producer
);
return refresh;
}
,onLotChange: function () ,onLotChange: function ()
{ {
if (this.shouldRefresh ()) function shouldRefresh (params)
{
return params.search ||
params.realm && (
params.type ||
params.color ||
params.origin ||
params.category ||
params.producer
);
}
function refreshItems ()
{ {
this.$('items').refresh (); this.$('items').refresh ();
}
if (shouldRefresh (this.params.$))
{
refreshItems ();
this.hideMenu (); this.hideMenu ();
this.$('order').style.display = 'block'; this.$('order').style.display = 'block';
} }
@ -326,7 +325,7 @@ Hedera.Catalog = new Class
this.$('card').row = -1; this.$('card').row = -1;
this.$('card-item').value = undefined; this.$('card-item').value = undefined;
} }
,onStatusChange: function () ,onStatusChange: function ()
{ {
this.$('card-popup').reset (); this.$('card-popup').reset ();
@ -438,7 +437,13 @@ Vn.Filter = new Class
,_onMouseDown: function () ,_onMouseDown: function ()
{ {
if (this._model && this._model.status === Db.Model.Status.CLEAN) if (this._model && this._model.status === Db.Model.Status.CLEAN)
{
var params = {
filter: this._filter
};
this._model.refresh (); this._model.refresh ();
}
} }
,_onUnselectClick: function () ,_onUnselectClick: function ()

View File

@ -41,8 +41,8 @@
<db-model <db-model
id="items" id="items"
result-index="2" result-index="2"
lot="params"
filter="filter" 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))
@ -50,7 +50,7 @@
SELECT a.Id_Article item_id SELECT a.Id_Article item_id
FROM vn2008.Articles a FROM vn2008.Articles a
JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id JOIN vn2008.Tipos t ON t.tipo_id = a.tipo_id
WHERE $filter; WHERE #filter;
CALL bionic_calc (); CALL bionic_calc ();
SELECT a.Id_Article item_id, a.description, b.available, b.price, SELECT a.Id_Article item_id, a.description, b.available, b.price,
b.producer, a.Foto, a.Article, a.Categoria, a.Medida, b.producer, a.Foto, a.Article, a.Categoria, a.Medida,
@ -77,7 +77,6 @@
FROM basket_item FROM basket_item
GROUP BY warehouse_id GROUP BY warehouse_id
</db-query> </db-query>
<db-form id="card" model="items"/>
<db-form id="card-extend"> <db-form id="card-extend">
<db-model <db-model
property="model" property="model"
@ -212,6 +211,44 @@
<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>
@ -305,44 +342,6 @@
</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">
@ -355,6 +354,7 @@
id="card-popup" id="card-popup"
modal="true" modal="true"
on-closed="onPopupClose"> on-closed="onPopupClose">
<db-form id="card" model="items"/>
<div property="child-node" class="item-card"> <div property="child-node" class="item-card">
<div class="top"> <div class="top">
<htk-image <htk-image

View File

@ -3,6 +3,19 @@ Hedera.Invoices = new Class
({ ({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function ()
{
var params = this.params;
if (!params.$.from)
{
var from = new Date ();
from.setDate (from.getDate () - 30);
from.setHours (0, 0, 0, 0);
params.assign ({from: from});
}
}
,onDownloadClick: function (column, invoiceId) ,onDownloadClick: function (column, invoiceId)
{ {
if (!invoiceId) if (!invoiceId)

View File

@ -1,6 +1,8 @@
{ {
"Invoices": "Factures" "Invoices": "Factures"
,"Show invoices from": "Mostra factures desde"
,"Serial": "Sèrie" ,"Serial": "Sèrie"
,"Date": "Data" ,"Date": "Data"
,"Import": "Import" ,"Import": "Import"

View File

@ -1,6 +1,8 @@
{ {
"Invoices": "Invoices" "Invoices": "Invoices"
,"Show invoices from": "Show invoices from"
,"Serial": "Serial" ,"Serial": "Serial"
,"Date": "Date" ,"Date": "Date"
,"Import": "Import" ,"Import": "Import"

View File

@ -1,5 +1,7 @@
{ {
"Invoices": "Facturas" "Invoices": "Facturas"
,"Show invoices from": "Mostrar facturas desde"
,"Serial": "Serie" ,"Serial": "Serie"
,"Date": "Fecha" ,"Date": "Fecha"

View File

@ -1,5 +1,7 @@
{ {
"Invoices": "Factures" "Invoices": "Factures"
,"Show invoices from": "Afficher les factures de"
,"Serial": "Série" ,"Serial": "Série"
,"Date": "Date" ,"Date": "Date"

View File

@ -1,5 +1,7 @@
{ {
"Invoices": "Invoices" "Invoices": "Invoices"
,"Show invoices from": "Show invoices from"
,"Serial": "Serial" ,"Serial": "Serial"
,"Date": "Date" ,"Date": "Date"

View File

@ -1,5 +1,7 @@
{ {
"Invoices": "Factura" "Invoices": "Factura"
,"Show invoices from": "Mostrar facturas de"
,"Serial": "Serie" ,"Serial": "Serie"
,"Date": "Data" ,"Date": "Data"

View File

@ -1,27 +1,34 @@
<vn> <vn>
<vn-lot-query id="params">
<vn-spec name="from" type="Date"/>
</vn-lot-query>
<h1 id="title"> <h1 id="title">
<t>Invoices</t> <t>Invoices</t>
</h1> </h1>
<div id="main" class="invoices"> <div id="main" class="invoices">
<div class="card"> <div class="card form">
<div> <div>
<htk-grid show-header="false"> <label><t>Show invoices from</t></label>
<db-model property="model" id="tickets"> <htk-date-chooser lot="params" name="from"/>
SELECT invoice_id, serial_num, issued, amount </div>
FROM invoice_view
ORDER BY issued DESC
LIMIT 100
</db-model>
<htk-column-text title="_Serial" column="serial_num"/>
<htk-column-date title="_Date" column="issued" format="_%e %b %Y"/>
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
<htk-column-button
column="invoice_id"
icon="download"
tip="_Download PDF"
on-clicked="onDownloadClick"/>
</htk-grid>
</div> </div>
<div class="card">
<htk-grid show-header="false">
<db-model property="model" lot="params">
SELECT invoice_id, serial_num, issued, amount
FROM invoice_view
WHERE issued >= #from
ORDER BY issued DESC
</db-model>
<htk-column-text title="_Serial" column="serial_num"/>
<htk-column-date title="_Date" column="issued" format="_%e %b %Y"/>
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
<htk-column-button
column="invoice_id"
icon="download"
tip="_Download PDF"
on-clicked="onDownloadClick"/>
</htk-grid>
</div> </div>
</div> </div>
</vn> </vn>

View File

@ -30,10 +30,6 @@
,"Pending": "Pendent" ,"Pending": "Pendent"
,"PayOrder": "Pagar encàrrec" ,"PayOrder": "Pagar encàrrec"
,"AmountToPay:": "Quantitat a pagar (€):"
,"AmountError": "La quantitat ha de ser un nombre positiu i inferior o igual a l'import pendent"
,"PayError": "Error al realitzar el pagament"
,"An error has been in the payment": "Sembla que hi ha hagut un error en el pagament" ,"An error has been in the payment": "Sembla que hi ha hagut un error en el pagament"
,"Retry": "Reintenta" ,"Retry": "Reintenta"
,"Accept": "Acceptar" ,"Accept": "Acceptar"

View File

@ -29,10 +29,6 @@
,"TotalWithVAT": "Total with VAT" ,"TotalWithVAT": "Total with VAT"
,"Pending": "Pending" ,"Pending": "Pending"
,"PayOrder": "Pay order" ,"PayOrder": "Pay order"
,"AmountToPay:": "Amount to pay (€):"
,"AmountError": "The amount must be a positive number less than or equal to the outstanding amount"
,"PayError": "Failed to make the payment"
,"An error has been in the payment": "It seems that there has been an error in the payment" ,"An error has been in the payment": "It seems that there has been an error in the payment"
,"Retry": "Retry" ,"Retry": "Retry"

View File

@ -29,10 +29,6 @@
,"TotalWithVAT": "Total con IVA" ,"TotalWithVAT": "Total con IVA"
,"Pending": "Pendiente" ,"Pending": "Pendiente"
,"PayOrder": "Pagar pedido" ,"PayOrder": "Pagar pedido"
,"AmountToPay:": "Cantidad a pagar (€):"
,"AmountError": "La cantidad debe ser un número positivo e inferior o igual al importe pendiente"
,"PayError": "Error al realizar el pago"
,"An error has been in the payment": "Parece que ha habido un error en el pago" ,"An error has been in the payment": "Parece que ha habido un error en el pago"
,"Retry": "Reintentar" ,"Retry": "Reintentar"

View File

@ -30,10 +30,6 @@
,"Pending": "En attente" ,"Pending": "En attente"
,"PayOrder": "Payer la commande" ,"PayOrder": "Payer la commande"
,"AmountToPay:": "Montant à payer (€):"
,"AmountError": "La quantité doit être un neméro positif et inférieur ou égal à la somme restant à payer"
,"PayError": "Impossible d'effectuer le paiement"
,"An error has been in the payment": "Il semble qu'il ya eu une erreur dans le paiement" ,"An error has been in the payment": "Il semble qu'il ya eu une erreur dans le paiement"
,"Retry": "Réessayez" ,"Retry": "Réessayez"
,"Accept": "Accepter" ,"Accept": "Accepter"

View File

@ -29,10 +29,6 @@
,"TotalWithVAT": "Total with VAT" ,"TotalWithVAT": "Total with VAT"
,"Pending": "Pending" ,"Pending": "Pending"
,"PayOrder": "Pay order" ,"PayOrder": "Pay order"
,"AmountToPay:": "Amount to pay (€):"
,"AmountError": "The amount must be a positive number less than or equal to the outstanding amount"
,"PayError": "Failed to make the payment"
,"An error has been in the payment": "It seems that there has been an error in the payment" ,"An error has been in the payment": "It seems that there has been an error in the payment"
,"Retry": "Retry" ,"Retry": "Retry"

View File

@ -29,10 +29,6 @@
,"TotalWithVAT": "Total com IVA" ,"TotalWithVAT": "Total com IVA"
,"Pending": "Pendente" ,"Pending": "Pendente"
,"PayOrder": "Pagar pedido" ,"PayOrder": "Pagar pedido"
,"AmountToPay:": "Quantidade a pagar (€):"
,"AmountError": "A quantidade deve ser um número positivo e inferior ou igual ao importe pendiente"
,"PayError": "Erro ao realizar o pagamento"
,"An error has been in the payment": "Parece que não houve um erro no pagamento" ,"An error has been in the payment": "Parece que não houve um erro no pagamento"
,"Retry": "Tentar novamente" ,"Retry": "Tentar novamente"

View File

@ -11,12 +11,14 @@ Hedera.Orders = new Class
}); });
this.tpv.check (this._onTpvCheck.bind (this)); this.tpv.check (this._onTpvCheck.bind (this));
if (!this.hash.get ('from')) var params = this.params;
if (!params.$.from)
{ {
var from = new Date (); var from = new Date ();
from.setDate (from.getDate () - 30); from.setDate (from.getDate () - 30);
from.setHours (0, 0, 0, 0); from.setHours (0, 0, 0, 0);
this.hash.assign ({from: from}); params.assign ({from: from});
} }
} }
@ -60,9 +62,13 @@ Hedera.Orders = new Class
if (amount !== null) if (amount !== null)
defaultAmountStr = Vn.Value.format (amount, '%.2d'); defaultAmountStr = Vn.Value.format (amount, '%.2d');
amount = parseFloat (prompt (_('AmountToPay:'), defaultAmountStr)); amount = prompt (_('AmountToPay:'), defaultAmountStr);
this.tpv.pay (amount, null); if (amount != null)
{
amount = parseFloat (amount.replace (',', '.'));
this.tpv.pay (amount, null);
}
} }
,onDialogResponse: function (dialog, response) ,onDialogResponse: function (dialog, response)

View File

@ -60,15 +60,15 @@
<p class="important"> <p class="important">
<htk-text lot="iter" name="date" format="%D"/> <htk-text lot="iter" name="date" format="%D"/>
</p> </p>
<p>
<htk-text lot="iter" name="ticket_id"/>
</p>
<p> <p>
<htk-text lot="iter" name="consignee"/> <htk-text lot="iter" name="consignee"/>
</p> </p>
<p> <p>
<htk-text lot="iter" name="type"/> <htk-text lot="iter" name="type"/>
</p> </p>
<p>
<htk-text lot="iter" name="ticket_id"/>
</p>
</a> </a>
</custom> </custom>
</htk-repeater> </htk-repeater>

View File

@ -87,6 +87,18 @@ Connection.implement
return new Sql.String ({query: query}).render (params); return new Sql.String ({query: query}).render (params);
} }
/**
* Renders an SQL statement object.
*
* @param {string} stmt The SQL statement
* @param {Object} params The statement parameters
* @return {string} The rendered statement
*/
,renderStmt: function (stmt, params)
{
return stmt.render (params);
}
/* /*
* Parses a value to date. * Parses a value to date.
*/ */

View File

@ -278,14 +278,14 @@ Klass.implement
this.query = child.textContent; this.query = child.textContent;
} }
,_getParams: function () ,_getLotParams: function ()
{ {
if (!this._stmt) if (!this._stmt)
return null; return null;
var ids = this._stmt.findHolders (); var holders = this._stmt.findHolders ();
if (!ids) if (!holders)
return null; return null;
var lotParams = this._lot ? this._lot.params : {}; var lotParams = this._lot ? this._lot.params : {};
@ -295,17 +295,17 @@ Klass.implement
var params = {}; var params = {};
for (var i = 0; i < ids.length; i++) for (var i = 0; i < holders.length; i++)
params[ids[i]] = lotParams[ids[i]]; params[holders[i]] = lotParams[holders[i]];
return params; return params;
} }
,_onLotChange: function () ,_onLotChange: function ()
{ {
var params = this._getParams (); var lotParams = this._getLotParams ();
if (!Vn.Value.equals (params, this._lastParams)) if (!Vn.Value.equals (lotParams, this._lastLotParams))
this._autoLoad (); this._autoLoad ();
} }
@ -316,16 +316,19 @@ Klass.implement
else else
this.clean (); this.clean ();
} }
,_isReady: function (params) ,_isReady: function (params)
{ {
if (!this._stmt || !this._conn) if (!this._stmt || !this._conn)
return false; return false;
if (!params)
var holders = this._stmt.findHolders ();
if (!holders)
return true; return true;
for (var key in params) for (var i = 0; i < holders.length; i++)
if (params[key] === undefined) if (params[holders[i]] === undefined)
return false; return false;
return true; return true;
@ -334,16 +337,22 @@ Klass.implement
/** /**
* Refresh the model data reexecuting the query on the database. * Refresh the model data reexecuting the query on the database.
*/ */
,refresh: function () ,refresh: function (params)
{ {
var params = this._getParams (); var lotParams = this._getLotParams ();
if (this._isReady (params)) var myParams = {};
Object.assign (myParams, lotParams);
Object.assign (myParams, params);
if (this._filter && (!params || params.filter === undefined))
myParams.filter = this._filter;
if (this._isReady (myParams))
{ {
this._lastParams = params; this._lastLotParams = lotParams;
this._setStatus (Status.LOADING); this._setStatus (Status.LOADING);
this._conn.execStmt (this._stmt, this._selectDone.bind (this), this._conn.execStmt (this._stmt, this._selectDone.bind (this), myParams);
this._lot ? this._lot.params : null);
} }
else else
this.clean (); this.clean ();

View File

@ -60,4 +60,8 @@
,"Configuration": "Configuració" ,"Configuration": "Configuració"
,"Account": "Compte" ,"Account": "Compte"
,"Addresses": "Direccions" ,"Addresses": "Direccions"
,"AmountToPay:": "Quantitat a pagar (€):"
,"AmountError": "La quantitat ha de ser un nombre positiu"
,"PayError": "Error al realitzar el pagament"
} }

View File

@ -60,4 +60,8 @@
,"Configuration": "Configuration" ,"Configuration": "Configuration"
,"Account": "Account" ,"Account": "Account"
,"Addresses": "Addresses" ,"Addresses": "Addresses"
,"AmountToPay:": "Amount to pay (€):"
,"AmountError": "The amount must be a positive number"
,"PayError": "Failed to make the payment"
} }

View File

@ -60,4 +60,8 @@
,"Configuration": "Configuración" ,"Configuration": "Configuración"
,"Account": "Cuenta" ,"Account": "Cuenta"
,"Addresses": "Direcciones" ,"Addresses": "Direcciones"
,"AmountToPay:": "Cantidad a pagar (€):"
,"AmountError": "La cantidad debe ser un número positivo"
,"PayError": "Error al realizar el pago"
} }

View File

@ -60,4 +60,8 @@
,"Configuration": "Configuration" ,"Configuration": "Configuration"
,"Account": "Compte" ,"Account": "Compte"
,"Addresses": "Adresses" ,"Addresses": "Adresses"
,"AmountToPay:": "Montant à payer (€):"
,"AmountError": "La quantité doit être un neméro positif"
,"PayError": "Impossible d'effectuer le paiement"
} }

View File

@ -60,4 +60,8 @@
,"Configuration": "Тохиргоо" ,"Configuration": "Тохиргоо"
,"Account": "Дансны" ,"Account": "Дансны"
,"Addresses": "хаягууд" ,"Addresses": "хаягууд"
,"AmountToPay:": "Amount to pay (€):"
,"AmountError": "The amount must be a positive number"
,"PayError": "Failed to make the payment"
} }

View File

@ -60,4 +60,8 @@
,"Configuration": "Configuração" ,"Configuration": "Configuração"
,"Account": "Conta" ,"Account": "Conta"
,"Addresses": "Endereços" ,"Addresses": "Endereços"
,"AmountToPay:": "Quantidade a pagar (€):"
,"AmountError": "A quantidade deve ser um número positivo"
,"PayError": "Erro ao realizar o pagamento"
} }

View File

@ -32,7 +32,7 @@ module.exports = new Class
,_realPpay: function (amount, company) ,_realPpay: function (amount, company)
{ {
if (amount > 0) if (isNumeric (amount) && amount > 0)
{ {
var params = { var params = {
amount: parseInt (amount) amount: parseInt (amount)
@ -44,7 +44,7 @@ module.exports = new Class
this.conn.send ('tpv/transaction', params, this.conn.send ('tpv/transaction', params,
this._onTransactionStart.bind (this)); this._onTransactionStart.bind (this));
} }
else if (!isNaN (amount)) else
Htk.Toast.showError (_('AmountError')); Htk.Toast.showError (_('AmountError'));
} }
@ -52,27 +52,22 @@ module.exports = new Class
{ {
if (json) if (json)
{ {
var postValues = json.postValues;
var form = document.createElement ('form'); var form = document.createElement ('form');
form.method = 'post'; form.method = 'post';
form.action = json.url; form.action = json.url;
document.body.appendChild (form); document.body.appendChild (form);
var fieldsMap =
{
Ds_SignatureVersion: 'HMAC_SHA256_V1'
,Ds_MerchantParameters: json.params
,Ds_Signature: json.signature
};
for (var field in fieldsMap) for (var field in postValues)
{ {
var input = document.createElement ('input'); var input = document.createElement ('input');
input.type = 'hidden'; input.type = 'hidden';
input.name = field; input.name = field;
form.appendChild (input); form.appendChild (input);
if (fieldsMap[field]) if (postValues[field])
input.value = fieldsMap[field]; input.value = postValues[field];
} }
form.submit (); form.submit ();
@ -118,3 +113,7 @@ module.exports = new Class
} }
}); });
function isNumeric (n)
{
return !isNaN (parseFloat(n)) && isFinite (n);
}

View File

@ -1,12 +1,6 @@
var ColumnText = require ('../column/text'); var ColumnText = require ('../column/text');
var nativeEvents = {
'click' : 1
,'mousedown' : 1
,'focusout' : 1
};
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Field Extends: Htk.Field
@ -149,15 +143,6 @@ module.exports = new Class
button.className = 'htk-select input'; button.className = 'htk-select input';
button.addEventListener ('mousedown', this._onButtonMouseDown.bind (this)); button.addEventListener ('mousedown', this._onButtonMouseDown.bind (this));
} }
,on: function (id, callback, instance)
{
if (nativeEvents[id] !== undefined)
this.node.addEventListener (id,
callback.bind (instance, this));
else
this.parent (id, callback, instance);
}
,_setRow: function (row) ,_setRow: function (row)
{ {

View File

@ -1,6 +1,12 @@
var NodeBuilder = require ('./node-builder'); var NodeBuilder = require ('./node-builder');
var nativeEvents = {
'click' : 1
,'mousedown' : 1
,'focusout' : 1
};
module.exports = new Class module.exports = new Class
({ ({
Extends: NodeBuilder Extends: NodeBuilder
@ -45,6 +51,15 @@ module.exports = new Class
this.parent (props); this.parent (props);
} }
,on: function (id, callback, instance)
{
if (nativeEvents[id])
this.node.addEventListener (id,
callback.bind (instance, this));
else
this.parent (id, callback, instance);
}
,createRoot: function (tagName) ,createRoot: function (tagName)
{ {
return this._node = this.createElement (tagName); return this._node = this.createElement (tagName);

View File

@ -18,19 +18,19 @@ module.exports = new Class
} }
,regexp: /#\w+/g ,regexp: /#\w+/g
,replaceFunc: function (params, token)
{
var holder = new Holder ({id: token.substr (1)});
return holder.render (params);
}
,render: function (params) ,render: function (params)
{ {
if (!this.query) if (!this.query)
return null; return null;
function replaceFunc (token)
{
var holder = new Holder ({id: token.substr (1)});
return holder.render (params);
}
return this.query.replace (this.regexp, this.replaceFunc.bind (this, params)); return this.query.replace (this.regexp, replaceFunc);
} }
,findHolders: function () ,findHolders: function ()

View File

@ -1,6 +1,103 @@
var VnDate = require ('./date'); var VnDate = require ('./date');
/**
* Clones a simple value. A simple value is any value that is not an array,
* object or function. If non-simple value is passed, the same object reference
* is returned.
*
* @param {*} value The value to be copied
* @return {*} The value copy
*/
function simpleClone (value)
{
if (value instanceof Date)
return value.clone ();
return value;
}
/**
* Checks if two simple values are equal using the strict equality operator. For
* information about simple values see simpleClone() function.
*
* @param {*} a Value to compare to
* @param {*} b Value to compare with
* @return {boolean} %true if they are equal, %false otherwise
*/
function simpleEquals (a, b)
{
if (a === b)
return true;
if (a instanceof Date && b instanceof Date)
return a.getTime () === b.getTime ();
return false;
}
/**
* Calculates differences between two simple key-value objects.
*
* @param {Object} orgObject Value to compare to
* @param {Object} newObject Value to compare with
* @return {Object} The differences or %null if there are no differences
*/
function diff (orgObject, newObject)
{
var diff = {};
for (var key in orgObject)
if (!simpleEquals (orgObject[key], newObject[key]))
diff[key] = simpleClone (newObject[key]);
for (var key in newObject)
if (orgObject[key] === undefined && newObject[key] !== undefined)
diff[key] = simpleClone (newObject[key]);
if (Object.keys (diff).length > 0)
return diff;
return null;
}
/**
* Calculates new differences between two simple key-value objects.
*
* @param {Object} orgObject Value to compare to
* @param {Object} newObject Value to compare with
* @return {Object} The differences or %null if there are no differences
*/
function partialDiff (orgObject, newObject)
{
var diff = {};
for (var key in newObject)
if (!simpleEquals (orgObject[key], newObject[key]))
diff[key] = simpleClone (newObject[key]);
if (Object.keys (diff).length > 0)
return diff;
return null;
}
/**
* Clones a simple key-value object in wich properties are simple values. For
* information about simple values see simpleClone() function.
*
* @param {*} object The object to be cloned
* @return The cloned object
*/
function kvClone (object)
{
var copy = {};
for (var key in object)
copy[key] = simpleClone (object[key]);
return copy;
}
/** /**
* Checks if two values are equal, it also checks objects. Basic values are * Checks if two values are equal, it also checks objects. Basic values are
* compared using the strict equality operator. * compared using the strict equality operator.
@ -31,93 +128,6 @@ function equals (a, b)
return false; return false;
} }
/**
* Calculates differences between two key-value objects.
*
* @param {Object} orgObject Value to compare to
* @param {Object} newObject Value to compare with
* @return {Object} The differences or %null if there are no differences
*/
function diff (orgObject, newObject)
{
var diff = {};
for (var key in orgObject)
if (!simpleEquals (orgObject[key], newObject[key]))
diff[key] = simpleClone (newObject[key]);
for (var key in newObject)
if (orgObject[key] === undefined && newObject[key] !== undefined)
diff[key] = simpleClone (newObject[key]);
if (Object.keys (diff).length > 0)
return diff;
return null;
}
/**
* Calculates new differences between two key-value objects.
*
* @param {Object} orgObject Value to compare to
* @param {Object} newObject Value to compare with
* @return {Object} The differences or %null if there are no differences
*/
function partialDiff (orgObject, newObject)
{
var diff = {};
for (var key in newObject)
if (!simpleEquals (orgObject[key], newObject[key]))
diff[key] = simpleClone (newObject[key]);
if (Object.keys (diff).length > 0)
return diff;
return null;
}
function kvClone (object)
{
var copy = {};
for (var key in object)
copy[key] = simpleClone (object[key]);
return copy;
}
/**
* Copies a simple value.
*
* @param {*} value The value to be copied
* @return {*} The value copy
*/
function simpleClone (value)
{
if (value instanceof Date)
return value.clone ();
return value;
}
/**
* Checks if two simple values are equal using the strict equality operator.
*
* @param {*} a Value to compare to
* @param {*} b Value to compare with
* @return {boolean} %true if they are equal, %false otherwise
*/
function simpleEquals (a, b)
{
if (a === b)
return true;
if (a instanceof Date && b instanceof Date)
return a.getTime () === b.getTime ();
return false;
}
/** /**
* Returns a formated string. * Returns a formated string.
* *

View File

@ -15,12 +15,12 @@
"file-loader": "^0.9.0", "file-loader": "^0.9.0",
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
"style-loader": "^0.13.1", "style-loader": "^0.19.0",
"url-loader": "^0.5.7", "url-loader": "^0.5.7",
"webpack": "^3.0.0", "webpack": "^3.6.0",
"webpack-chunk-hash": "^0.4.0", "webpack-chunk-hash": "^0.5.0",
"webpack-dev-server": "^2.5.0", "webpack-dev-server": "^2.9.1",
"webpack-merge": "^3.0.0" "webpack-merge": "^4.1.0"
}, },
"dependencies": { "dependencies": {
"mootools": "^1.5.2", "mootools": "^1.5.2",

View File

@ -44,12 +44,17 @@ class Transaction extends Vn\Web\JsonRequest
$key = mcrypt_encrypt (MCRYPT_3DES, $key, $transactionId, MCRYPT_MODE_CBC, $iv); $key = mcrypt_encrypt (MCRYPT_3DES, $key, $transactionId, MCRYPT_MODE_CBC, $iv);
$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 = [
'Ds_SignatureVersion' => 'HMAC_SHA256_V1'
,'Ds_MerchantParameters' => $encodedParams
,'Ds_Signature' => $signature
];
return [ return [
'url' => $url 'url' => $url
,'params' => $encodedParams ,'postValues' => $postValues
,'signature' => $signature
]; ];
} }
} }

View File

@ -39,7 +39,10 @@ var baseConfig = {
new webpack.optimize.CommonsChunkPlugin ({ new webpack.optimize.CommonsChunkPlugin ({
names: ['vendor', 'manifest'] names: ['vendor', 'manifest']
}) })
] ],
watchOptions: {
ignored: /node_modules/
}
}; };
var prodConfig = { var prodConfig = {