Memory leaks solucionados, beta 3 del bionic
This commit is contained in:
parent
e78a3fdd45
commit
e8398ab5c4
|
@ -1,7 +1,7 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="address">
|
||||
<vn-hash-link key="address"/>
|
||||
<vn-hash-param key="address"/>
|
||||
</vn-param>
|
||||
<db-form id="iter" on-status-changed="onStatusChange">
|
||||
<db-param id="country" one-way="true" column="country_id"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="user">
|
||||
<vn-hash-link key="user"/>
|
||||
<vn-hash-param key="user"/>
|
||||
</vn-param>
|
||||
<db-form id="user-form">
|
||||
<db-model>
|
||||
|
|
|
@ -2,5 +2,10 @@
|
|||
Vn.Provinces = new Class
|
||||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
,onReturnClick: function ()
|
||||
{
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="agency">
|
||||
<vn-hash-link key="agency"/>
|
||||
<vn-hash-param key="agency"/>
|
||||
</vn-param>
|
||||
</vn-group>
|
||||
<div id="form" class="provinces">
|
||||
<div class="box">
|
||||
<div class="header">
|
||||
<h1><t>ByProvince</t></h1>
|
||||
<div class="action-bar">
|
||||
<button on-click="onReturnClick">
|
||||
<img src="image/dark/go-previous.svg" alt=""/>
|
||||
<t>Return</t>
|
||||
</button>
|
||||
</div>
|
||||
<htk-grid empty-message="SelectAgency">
|
||||
<div class="clear"/>
|
||||
</div>
|
||||
<htk-grid>
|
||||
<db-model>
|
||||
CALL vn2008.desglose_volume (#agency)
|
||||
<sql-batch property="batch">
|
||||
|
|
|
@ -3,44 +3,36 @@ Vn.Basket = new Class
|
|||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
,open: function ()
|
||||
{
|
||||
if (this.basketChecked)
|
||||
this.parent ();
|
||||
}
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
this.conn.execQuery ('CALL basket_check ()',
|
||||
Vn.BasketChecker.check (this.conn,
|
||||
this.onBasketCheck.bind (this));
|
||||
}
|
||||
|
||||
,onBasketCheck: function (resultSet)
|
||||
,onBasketCheck: function (isOk)
|
||||
{
|
||||
var res = resultSet.fetchResult ();
|
||||
if (!isOk)
|
||||
return;
|
||||
|
||||
if (res.next ())
|
||||
switch (res.get ('stat'))
|
||||
{
|
||||
case 'BAD_CONFIG':
|
||||
case 'NOT_EXISTS':
|
||||
this.hash.set ({'form': 'ecomerce/checkout'});
|
||||
break;
|
||||
case 'UPDATED':
|
||||
(new Htk.Toast ()).showWarning (_('OrderItemsUpdated'));
|
||||
this.$('order').value = res.get ('order_id');
|
||||
break;
|
||||
case 'OK':
|
||||
this.$('order').value = res.get ('order_id');
|
||||
break;
|
||||
}
|
||||
this.basketChecked = true;
|
||||
this.open ();
|
||||
}
|
||||
|
||||
,onConfigureClick: function ()
|
||||
{
|
||||
(new Htk.Toast ()).showWarning (_('RememberReconfiguringImpact'));
|
||||
this.hash.set ({'form': 'ecomerce/checkout'});
|
||||
}
|
||||
|
||||
,onCheckoutClick: function ()
|
||||
{
|
||||
this.hash.set ({
|
||||
'form': 'ecomerce/confirm',
|
||||
'order': this.$('order').value
|
||||
});
|
||||
this.hash.set ({'form': 'ecomerce/confirm'});
|
||||
}
|
||||
|
||||
,amountRender: function (renderer, form)
|
||||
|
@ -56,7 +48,7 @@ Vn.Basket = new Class
|
|||
|
||||
,onAmountChange: function (renderer, row, newValue)
|
||||
{
|
||||
var model = this.$('order-rows');
|
||||
var model = this.$('items');
|
||||
model.set (row, 'amount', newValue * model.get (row, 'grouping'));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="order"/>
|
||||
<db-form id="order-form">
|
||||
<db-model updatable="true">
|
||||
SELECT id, date_send, agency_id
|
||||
FROM basket
|
||||
<sql-batch property="batch">
|
||||
<item name="id" param="order"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
<db-param column="date_send" id="date"/>
|
||||
<db-param column="address_id" id="address"/>
|
||||
</db-form>
|
||||
</vn-group>
|
||||
<div id="form" class="basket">
|
||||
<div class="box">
|
||||
<div class="header">
|
||||
|
@ -31,7 +17,7 @@
|
|||
</div>
|
||||
<div>
|
||||
<htk-grid show-header="false">
|
||||
<db-model result-index="1" id="order-rows" updatable="true">
|
||||
<db-model result-index="1" id="items" updatable="true">
|
||||
CALL bionic_from_basket (@calc);
|
||||
SELECT m.id, m.amount, t.available, a.Article, a.Categoria,
|
||||
a.Medida, a.Tallos, a.Color, o.Abreviatura, m.price price, a.Foto
|
||||
|
@ -39,9 +25,6 @@
|
|||
INNER JOIN vn2008.Articles a ON a.Id_Article = m.item_id
|
||||
LEFT JOIN vn2008.Origen o ON a.id_origen = o.id
|
||||
LEFT JOIN cache.bionic t ON m.warehouse_id = t.warehouse_id AND m.item_id = t.item_id AND t.calc_id = @calc;
|
||||
<sql-batch property="batch">
|
||||
<item name="order" param="order"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
<htk-column-image column="Foto" directory="catalog" subdir="50x50" show-full="true"/>
|
||||
<htk-column-text title="_Item" column="Article"/>
|
||||
|
@ -53,7 +36,7 @@
|
|||
<p>
|
||||
<t>OrderTotal</t>
|
||||
<htk-text format="%.2d€">
|
||||
<db-calc-sum func="subtotal" model="order-rows"/>
|
||||
<db-calc-sum func="subtotal" model="items"/>
|
||||
</htk-text>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -3,10 +3,26 @@ Vn.Catalog = new Class
|
|||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
,realmColor: null
|
||||
,open: function ()
|
||||
{
|
||||
if (this.basketChecked)
|
||||
this.parent ();
|
||||
}
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
Vn.BasketChecker.check (this.conn,
|
||||
this.onBasketCheck.bind (this));
|
||||
}
|
||||
|
||||
,onBasketCheck: function (isOk)
|
||||
{
|
||||
if (!isOk)
|
||||
return;
|
||||
|
||||
this.basketChecked = true;
|
||||
this.open ();
|
||||
|
||||
this.popup = new Htk.Popup ();
|
||||
this.popup.setChildNode (this.$('lots-popup'));
|
||||
}
|
||||
|
@ -33,7 +49,7 @@ Vn.Catalog = new Class
|
|||
|
||||
,onTypeChange: function ()
|
||||
{
|
||||
if (Vn.isMobile ())
|
||||
if (Vn.isMobile () && this.$('type').value)
|
||||
this.hideMenu ();
|
||||
|
||||
var realms = this.$('realms-model');
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="realm" on-changed="onTypeChange">
|
||||
<vn-hash-link key="realm"/>
|
||||
<vn-hash-param key="realm"/>
|
||||
</vn-param>
|
||||
<vn-param id="type" on-changed="onTypeChange">
|
||||
<vn-hash-link key="type"/>
|
||||
<vn-hash-param key="type"/>
|
||||
</vn-param>
|
||||
<vn-param id="search"/>
|
||||
<sql-filter type="AND" id="filter">
|
||||
|
|
|
@ -21,7 +21,6 @@ Vn.Checkout = new Class
|
|||
|
||||
if (orderForm.numRows > 0)
|
||||
{
|
||||
(new Htk.Toast ()).showWarning (_('RememberReconfiguringImpact'));
|
||||
var i = orderForm;
|
||||
var date = i.get ('date_send');
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@
|
|||
}
|
||||
.address.selected
|
||||
{
|
||||
background-color: rgba(1, 1, 1, .05);
|
||||
background-color: rgba(1, 1, 1, .1);
|
||||
}
|
||||
.address:hover
|
||||
{
|
||||
cursor: pointer;
|
||||
background-color: rgba(1, 1, 1, .1);
|
||||
background-color: rgba(1, 1, 1, .05);
|
||||
}
|
||||
.address p.consignee
|
||||
{
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="order">
|
||||
<vn-hash-link key="order"/>
|
||||
</vn-param>
|
||||
<vn-param id="method"/>
|
||||
<vn-param id="date"/>
|
||||
<vn-param id="agency"/>
|
||||
|
|
|
@ -3,11 +3,6 @@ Vn.Confirm = new Class
|
|||
({
|
||||
Extends: Vn.Module
|
||||
|
||||
,activate: function ()
|
||||
{
|
||||
this.tpv = new Vn.Tpv (this.conn, this.hash);
|
||||
}
|
||||
|
||||
,onOrderReady: function (form)
|
||||
{
|
||||
if (form.row < 0)
|
||||
|
@ -15,12 +10,12 @@ Vn.Confirm = new Class
|
|||
|
||||
if (form.get ('method') != 'PICKUP')
|
||||
{
|
||||
this.$('address').style.display = 'block';
|
||||
Vn.Node.show (this.$('address'));
|
||||
Vn.Node.setText (this.$('method'), _('Agency'));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.$('address').style.display = 'none';
|
||||
Vn.Node.hide (this.$('address'));
|
||||
Vn.Node.setText (this.$('method'), _('Warehouse'));
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +67,7 @@ Vn.Confirm = new Class
|
|||
this.popup.hide ();
|
||||
|
||||
if (this.pay)
|
||||
this.tpv.pay (this.$('total').value,
|
||||
Vn.Tpv.pay (this.conn, this.$('total').value,
|
||||
this.$('order-form').get ('company_id'));
|
||||
else
|
||||
this.hash.set ({'form': 'ecomerce/orders'});
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="order-id">
|
||||
<vn-hash-link key="order"/>
|
||||
</vn-param>
|
||||
<db-form id="order-form" on-ready="onOrderReady">
|
||||
<db-model>
|
||||
SELECT o.id, o.date_send, o.note,
|
||||
SELECT o.id, o.date_send, o.note, o.company_id,
|
||||
ag.description agency, v.code method, c.credit,
|
||||
ad.consignee, ad.zip_code, ad.city, ad.name address
|
||||
FROM basket o
|
||||
|
@ -13,9 +10,6 @@
|
|||
LEFT JOIN address_view ad ON ad.id = o.address_id
|
||||
JOIN vn2008.Vistas v ON v.vista_id = o.delivery_method_id
|
||||
JOIN customer_view c
|
||||
<sql-batch property="batch">
|
||||
<item name="order" param="order-id"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
</db-form>
|
||||
<db-form id="total-form" on-ready="onImportReady">
|
||||
|
@ -26,17 +20,11 @@
|
|||
IFNULL(SUM(vat + surcharge), 0) vat
|
||||
FROM t_order_vat;
|
||||
DROP TEMPORARY TABLE t_order_vat;
|
||||
<sql-batch property="batch">
|
||||
<item name="order" param="order-id"/>
|
||||
</sql-batch>
|
||||
</db-model>
|
||||
</db-form>
|
||||
<db-query id="confirm-query" on-ready="onConfirm">
|
||||
CALL basket_confirm ();
|
||||
SELECT customer_get_debt();
|
||||
<sql-batch property="batch">
|
||||
<item name="order" param="order-id"/>
|
||||
</sql-batch>
|
||||
</db-query>
|
||||
</vn-group>
|
||||
<div id="form" class="confirm">
|
||||
|
|
|
@ -8,7 +8,7 @@ Vn.Orders = new Class
|
|||
this.payPopup = new Htk.Popup ();
|
||||
this.payPopup.setChildNode (this.$('balance-popup'));
|
||||
|
||||
this.tpv = new Vn.Tpv (this.conn, this.hash);
|
||||
Vn.Tpv.check (this.conn);
|
||||
}
|
||||
|
||||
,onBasketClick: function ()
|
||||
|
@ -24,14 +24,6 @@ Vn.Orders = new Class
|
|||
});
|
||||
}
|
||||
|
||||
,payRenderer: function (column, form)
|
||||
{
|
||||
if (form.get ('company_id') && form.get('total'))
|
||||
column.td.className = '';
|
||||
else
|
||||
column.td.className = 'hide';
|
||||
}
|
||||
|
||||
// TPV
|
||||
|
||||
,balanceConditionalFunc: function (field, value)
|
||||
|
@ -66,7 +58,7 @@ Vn.Orders = new Class
|
|||
|
||||
var amount = parseFloat (prompt (_('AmountToPay:'), defaultAmountStr));
|
||||
|
||||
this.tpv.pay (amount, company);
|
||||
Vn.Tpv.pay (this.conn, amount, company);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="ticket-id">
|
||||
<vn-hash-link key="ticket"/>
|
||||
<vn-hash-param key="ticket"/>
|
||||
</vn-param>
|
||||
<db-form id="ticket">
|
||||
<db-model id="ticket-data">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="new-id">
|
||||
<vn-hash-link key="new"/>
|
||||
<vn-hash-param key="new"/>
|
||||
</vn-param>
|
||||
<db-form id="iter" on-status-changed="onStatusChange">
|
||||
<db-param column="text" on-changed="onBodyChange"/>
|
||||
|
@ -28,6 +28,7 @@
|
|||
<t>Accept</t>
|
||||
</button>
|
||||
</div>
|
||||
<div class="clear"/>
|
||||
</div>
|
||||
<div class="form">
|
||||
<div class="form-group">
|
||||
|
|
|
@ -21,7 +21,8 @@ Db.Calc = new Class
|
|||
,'row-inserted': this.onRowInsert
|
||||
});
|
||||
|
||||
this.form = new Db.Form ({model: x});
|
||||
var form = new Db.Form ({model: x});
|
||||
this.link ({form: form});
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
|
|
|
@ -19,7 +19,9 @@ Htk.Grid = new Class
|
|||
,'updatable-changed': this.onUpdatableChange
|
||||
});
|
||||
|
||||
this.form = new Db.Form ({model: x});
|
||||
var form = new Db.Form ({model: x});
|
||||
this.link ({form: form});
|
||||
|
||||
this.onUpdatableChange ();
|
||||
this.onModelChange ();
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ Htk.Repeater = new Class
|
|||
|
||||
,loadXml: function (builder, node)
|
||||
{
|
||||
this.parent (builder, node);
|
||||
|
||||
var template = node.querySelector ('template:first-of-type');
|
||||
|
||||
if (template)
|
||||
|
@ -105,7 +107,7 @@ Htk.Repeater = new Class
|
|||
|
||||
this.childsData.push ({
|
||||
builder: builder,
|
||||
form, form
|
||||
form: form
|
||||
});
|
||||
|
||||
var mainNode = builder.loadXmlFromNode (this.xml);
|
||||
|
@ -122,6 +124,7 @@ Htk.Repeater = new Class
|
|||
return;
|
||||
|
||||
Vn.Node.removeChilds (this.node);
|
||||
this.freeChildsData ();
|
||||
this.childsData = [];
|
||||
|
||||
switch (this._model.status)
|
||||
|
@ -183,4 +186,20 @@ Htk.Repeater = new Class
|
|||
{
|
||||
this.buildBox (row);
|
||||
}
|
||||
|
||||
,freeChildsData: function ()
|
||||
{
|
||||
if (this.childsData)
|
||||
for (var i = 0; i < this.childsData.length; i++)
|
||||
{
|
||||
this.childsData[i].form.unref ();
|
||||
this.childsData[i].builder.unref ();
|
||||
}
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
this.freeChildsData ();
|
||||
this.parent ();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ Sql.Batch = new Class
|
|||
}
|
||||
}
|
||||
|
||||
,params: {}
|
||||
,objects: {}
|
||||
,_blocked: false
|
||||
|
||||
,loadXml: function (builder, node)
|
||||
|
@ -48,47 +48,52 @@ Sql.Batch = new Class
|
|||
|
||||
,get: function (id)
|
||||
{
|
||||
if (this.params[id])
|
||||
return this.params[id];
|
||||
if (this.objects[id])
|
||||
return this.objects[id];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
,add: function (id)
|
||||
{
|
||||
if (!this.params[id])
|
||||
this.params[id] = null;
|
||||
if (!this.objects[id])
|
||||
this.objects[id] = null;
|
||||
}
|
||||
|
||||
,remove: function (id)
|
||||
{
|
||||
if (this.params[id])
|
||||
{
|
||||
this.params[id].disconnect ('changed', this.emitChanged, this);
|
||||
delete this.params[id];
|
||||
}
|
||||
}
|
||||
|
||||
,addObject: function (id, object)
|
||||
,_addObject: function (id, object)
|
||||
{
|
||||
this.remove (id);
|
||||
this.params[id] = object;
|
||||
this.objects[id] = object;
|
||||
object.on ('changed', this.emitChanged, this);
|
||||
this.emitChanged ();
|
||||
}
|
||||
|
||||
,addObject: function (id, object)
|
||||
{
|
||||
this._addObject (id, object.ref ());
|
||||
}
|
||||
|
||||
,addValue: function (id, value)
|
||||
{
|
||||
this.addObject (id,
|
||||
this._addObject (id,
|
||||
new Sql.Value ({value: value}));
|
||||
}
|
||||
|
||||
,addParam: function (id, param)
|
||||
{
|
||||
this.addObject (id,
|
||||
this._addObject (id,
|
||||
new Sql.Value ({param: param}));
|
||||
}
|
||||
|
||||
,remove: function (id)
|
||||
{
|
||||
if (this.objects[id])
|
||||
{
|
||||
this._unrefObject (this.objects[id]);
|
||||
delete this.objects[id];
|
||||
}
|
||||
}
|
||||
|
||||
,block: function ()
|
||||
{
|
||||
this._blocked = true;
|
||||
|
@ -112,12 +117,27 @@ Sql.Batch = new Class
|
|||
|
||||
,isReady: function ()
|
||||
{
|
||||
var id;
|
||||
|
||||
for (id in this.params)
|
||||
if (!(this.params[id] && this.params[id].isReady ()))
|
||||
for (var id in this.objects)
|
||||
if (!(this.objects[id] && this.objects[id].isReady ()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
,_unrefObject: function (object)
|
||||
{
|
||||
if (object)
|
||||
{
|
||||
object.disconnect ('changed', this.emitChanged, this);
|
||||
object.unref ();
|
||||
}
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
for (var id in this.objects)
|
||||
this._unrefObject (this.objects[id]);
|
||||
|
||||
this.parent ();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -9,9 +9,9 @@ Sql.List = new Class
|
|||
|
||||
,add: function (object)
|
||||
{
|
||||
this.objects.push (object);
|
||||
object.on ('changed', this.onObjectChange, this);
|
||||
this.onObjectChange ();
|
||||
this.objects.push (object.ref ());
|
||||
object.on ('changed', this._onObjectChange, this);
|
||||
this._onObjectChange ();
|
||||
}
|
||||
|
||||
,get: function (i)
|
||||
|
@ -26,12 +26,11 @@ Sql.List = new Class
|
|||
|
||||
,remove: function (i)
|
||||
{
|
||||
var object = objects.splice (i, 1);
|
||||
object.disconnect ('changed', this.onObjectChange, this);
|
||||
this.onObjectChange ();
|
||||
this._unrefObject (this.objects.splice (i, 1));
|
||||
this._onObjectChange ();
|
||||
}
|
||||
|
||||
,onObjectChange: function ()
|
||||
,_onObjectChange: function ()
|
||||
{
|
||||
this.signalEmit ('changed');
|
||||
}
|
||||
|
@ -49,5 +48,19 @@ Sql.List = new Class
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
,_unrefObject: function (object)
|
||||
{
|
||||
object.disconnect ('changed', this._onObjectChange, this);
|
||||
object.unref ();
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
for (var i = 0; i < this.objects.length; i++)
|
||||
this._unrefObject (this.objects[i]);
|
||||
|
||||
this.parent ();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ Sql.MultiStmt = new Class
|
|||
|
||||
,addStmt: function (stmt)
|
||||
{
|
||||
stmt.on ('changed', this.stmtChanged.bind (this));
|
||||
return this.stmts.push (stmt);
|
||||
}
|
||||
|
||||
|
@ -18,11 +17,6 @@ Sql.MultiStmt = new Class
|
|||
return this.stmts[index];
|
||||
}
|
||||
|
||||
,stmtChanged: function ()
|
||||
{
|
||||
this.signalEmit ('changed');
|
||||
}
|
||||
|
||||
,isReady: function ()
|
||||
{
|
||||
if (this.stmts.length == 0)
|
||||
|
|
|
@ -3,20 +3,10 @@
|
|||
**/
|
||||
Vn.Builder = new Class
|
||||
({
|
||||
objectMap: {}
|
||||
Extends: Vn.Object
|
||||
,objectMap: {}
|
||||
,tags: {}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
for (var key in this.objectMap)
|
||||
{
|
||||
var object = this.objectMap[key];
|
||||
|
||||
if (object.destroy instanceof Function)
|
||||
this.objectMap[key].destroy ();
|
||||
}
|
||||
}
|
||||
|
||||
,loadXml: function (xmlDoc)
|
||||
{
|
||||
if (!xmlDoc)
|
||||
|
@ -322,5 +312,18 @@ Vn.Builder = new Class
|
|||
|
||||
return [];
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
for (var tag in this.tags)
|
||||
{
|
||||
var objects = this.tags[tag];
|
||||
|
||||
for (var i = 0; i < objects.length; i++)
|
||||
objects[i].unref ();
|
||||
}
|
||||
|
||||
this.parent ();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
|
||||
Vn.HashLink = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'vn-hash-link'
|
||||
,Parent: 'param'
|
||||
,Properties:
|
||||
{
|
||||
param:
|
||||
{
|
||||
type: Vn.Param
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_param: x}, {'changed': this.onParamChange});
|
||||
this.onHashChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._param;
|
||||
}
|
||||
},
|
||||
hash:
|
||||
{
|
||||
type: Vn.Hash
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_hash: x}, {'changed': this.onHashChange});
|
||||
this.onHashChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._hash;
|
||||
}
|
||||
},
|
||||
key:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this._key = x;
|
||||
this.onHashChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
,lock: false
|
||||
,value: null
|
||||
,_key: null
|
||||
|
||||
,onHashChange: function ()
|
||||
{
|
||||
if (!this._key || !this._hash)
|
||||
return;
|
||||
|
||||
var newValue = this._hash.get (this._key);
|
||||
|
||||
if (this.value != newValue)
|
||||
{
|
||||
this.value = newValue;
|
||||
this.signalEmit ('changed');
|
||||
|
||||
if (this._param && !this.lock)
|
||||
{
|
||||
this.lock = true;
|
||||
this._param.value = newValue;
|
||||
this.lock = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
,onParamChange: function ()
|
||||
{
|
||||
if (this.lock)
|
||||
return;
|
||||
|
||||
var map = {};
|
||||
map[this.key] = this._param.value;
|
||||
|
||||
this.lock = true;
|
||||
this._hash.add (map);
|
||||
this.lock = false;
|
||||
}
|
||||
});
|
||||
|
|
@ -1,24 +1,29 @@
|
|||
/**
|
||||
* Class to handle the URL.
|
||||
**/
|
||||
Vn.Hash = new Class
|
||||
({
|
||||
Extends: Vn.Object
|
||||
|
||||
,hash: null
|
||||
,hashMap: {}
|
||||
Vn.Hash =
|
||||
{
|
||||
_hash: null
|
||||
,_hashMap: {}
|
||||
,_listener: null
|
||||
|
||||
,initialize: function ()
|
||||
{
|
||||
this.hashChangedHandler = this.hashChanged.bind (this);
|
||||
window.addEventListener ('hashchange', this.hashChangedHandler);
|
||||
this.hashChanged ();
|
||||
this._listener = new Vn.HashListener ();
|
||||
|
||||
this._hashChangedHandler = this._hashChanged.bind (this);
|
||||
window.addEventListener ('hashchange', this._hashChangedHandler);
|
||||
this._hashChanged ();
|
||||
}
|
||||
|
||||
,destroy: function ()
|
||||
{
|
||||
this.parent ();
|
||||
window.removeEventListener ('hashchange', this.hashChangedHandler);
|
||||
window.removeEventListener ('hashchange', this._hashChangedHandler);
|
||||
}
|
||||
|
||||
,getListener: function ()
|
||||
{
|
||||
return this._listener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,7 +33,7 @@ Vn.Hash = new Class
|
|||
**/
|
||||
,get: function (key)
|
||||
{
|
||||
return this.hashMap[key];
|
||||
return this._hashMap[key];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +43,7 @@ Vn.Hash = new Class
|
|||
**/
|
||||
,add: function (map)
|
||||
{
|
||||
var newMap = this.hashMap;
|
||||
var newMap = this._hashMap;
|
||||
|
||||
for (var key in map)
|
||||
newMap[key] = map[key];
|
||||
|
@ -59,10 +64,16 @@ Vn.Hash = new Class
|
|||
|
||||
var newHash = this.make (map);
|
||||
|
||||
if (newHash !== this.hash)
|
||||
if (newHash !== this._hash)
|
||||
{
|
||||
this.hashMap = map;
|
||||
this.putHash (newHash);
|
||||
this._hashMap = map;
|
||||
this._hash = newHash;
|
||||
|
||||
this._blockChanged = true;
|
||||
location.hash = newHash;
|
||||
this._blockChanged = false;
|
||||
|
||||
this._listener.changed ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,9 +89,9 @@ Vn.Hash = new Class
|
|||
var hash = '#!';
|
||||
|
||||
if (add)
|
||||
for (var key in this.hashMap)
|
||||
for (var key in this._hashMap)
|
||||
if (!map[key])
|
||||
map[key] = this.hashMap[key];
|
||||
map[key] = this._hashMap[key];
|
||||
|
||||
for (var key in map)
|
||||
{
|
||||
|
@ -93,21 +104,14 @@ Vn.Hash = new Class
|
|||
return hash;
|
||||
}
|
||||
|
||||
,putHash: function (newHash)
|
||||
{
|
||||
location.hash = newHash;
|
||||
this.hash = location.hash;
|
||||
this.signalEmit ('changed');
|
||||
}
|
||||
|
||||
,hashChanged: function ()
|
||||
,_hashChanged: function ()
|
||||
{
|
||||
var newHash = location.hash;
|
||||
|
||||
if (newHash === this.hash)
|
||||
if (this._blockChanged || newHash === this._hash)
|
||||
return;
|
||||
|
||||
this.hashMap = {};
|
||||
var newMap = hashMap = {};
|
||||
var kvPairs = newHash.substr(2).split ('&');
|
||||
|
||||
for (var i = 0; i < kvPairs.length; i++)
|
||||
|
@ -115,9 +119,11 @@ Vn.Hash = new Class
|
|||
var kvPair = kvPairs[i].split ('=', 2);
|
||||
|
||||
if (kvPair[0])
|
||||
this.hashMap[kvPair[0]] = kvPair[1];
|
||||
newMap[kvPair[0]] = kvPair[1];
|
||||
}
|
||||
|
||||
this.putHash (newHash);
|
||||
this._hashMap = newMap;
|
||||
this._hash = newHash;
|
||||
this._listener.changed ();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -21,8 +21,9 @@ Js::includeLib ('vn'
|
|||
,'mutators'
|
||||
,'object'
|
||||
,'param'
|
||||
,'hash-listener'
|
||||
,'hash'
|
||||
,'hash-link'
|
||||
,'hash-param'
|
||||
,'node'
|
||||
,'builder'
|
||||
,'http-request'
|
||||
|
|
|
@ -47,6 +47,16 @@ Vn.Node =
|
|||
if (found)
|
||||
node.className = classes.join (' ');
|
||||
}
|
||||
|
||||
,hide: function (node)
|
||||
{
|
||||
node.style.display = 'none';
|
||||
}
|
||||
|
||||
,show: function (node)
|
||||
{
|
||||
node.style.display = '';
|
||||
}
|
||||
};
|
||||
|
||||
function $ (id)
|
||||
|
|
|
@ -7,7 +7,10 @@ Vn.Object = new Class
|
|||
({
|
||||
Tag: 'vn-object'
|
||||
,Properties: {}
|
||||
|
||||
,signals: {}
|
||||
,links: {}
|
||||
,refCount: 1
|
||||
|
||||
,initialize: function (props)
|
||||
{
|
||||
|
@ -15,6 +18,20 @@ Vn.Object = new Class
|
|||
this[prop] = props[prop];
|
||||
}
|
||||
|
||||
,ref: function ()
|
||||
{
|
||||
this.refCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
,unref: function ()
|
||||
{
|
||||
this.refCount--;
|
||||
|
||||
if (this.refCount === 0)
|
||||
this._destroy ();
|
||||
}
|
||||
|
||||
,loadXml: function (builder, node)
|
||||
{
|
||||
return null;
|
||||
|
@ -53,7 +70,7 @@ Vn.Object = new Class
|
|||
* @param {Function} callback The callback
|
||||
* @param {Boolean} block %true for lock the signal, %false for unlock
|
||||
**/
|
||||
,blockSignal: function (id, callback, block)
|
||||
,blockSignal: function (id, callback, block, instance)
|
||||
{
|
||||
var callbacks = this.signals[id];
|
||||
|
||||
|
@ -61,7 +78,8 @@ Vn.Object = new Class
|
|||
return;
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++)
|
||||
if (callbacks[i].callback == callback)
|
||||
if (callbacks[i].callback == callback
|
||||
&& callbacks[i].instance == instance)
|
||||
callbacks[i].blocked = block;
|
||||
}
|
||||
|
||||
|
@ -108,12 +126,35 @@ Vn.Object = new Class
|
|||
callbacks.splice (i--, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects all signals for the given instance.
|
||||
*
|
||||
* @param {Object} instance The instance
|
||||
**/
|
||||
,disconnectByInstance: function (instance)
|
||||
{
|
||||
for (var signalId in this.signals)
|
||||
{
|
||||
var callbacks = this.signals[signalId];
|
||||
|
||||
for (var i = 0; i < callbacks.length; i++)
|
||||
if (callbacks[i].instance == instance)
|
||||
callbacks.splice (i--, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object, this method should only be called before losing
|
||||
* the last reference to the object.
|
||||
**/
|
||||
,destroy: function ()
|
||||
,_destroy: function ()
|
||||
{
|
||||
var links = this.links;
|
||||
|
||||
for (var key in links)
|
||||
links[key].disconnectByInstance (this);
|
||||
|
||||
delete this.links;
|
||||
delete this.signals;
|
||||
}
|
||||
|
||||
|
@ -125,15 +166,22 @@ Vn.Object = new Class
|
|||
var oldObject = this[key];
|
||||
|
||||
if (oldObject)
|
||||
for (var signal in handlers)
|
||||
oldObject.disconnect (signal, handlers[signal], this);
|
||||
{
|
||||
oldObject.disconnectByInstance (this);
|
||||
oldObject.unref ();
|
||||
}
|
||||
|
||||
this[key] = newObject;
|
||||
|
||||
if (newObject)
|
||||
{
|
||||
this.links[key] = newObject.ref ();
|
||||
|
||||
for (var signal in handlers)
|
||||
newObject.on (signal, handlers[signal], this);
|
||||
}
|
||||
else if (oldObject)
|
||||
delete this.links[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ Vn.Param = new Class
|
|||
type: Vn.Param
|
||||
,set: function (x)
|
||||
{
|
||||
this.link ({_master: x}, {'changed': this.onMasterChange});
|
||||
this.onMasterChange ();
|
||||
this.link ({_master: x}, {'changed': this._onMasterChange});
|
||||
this._onMasterChange ();
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ Vn.Param = new Class
|
|||
,_master: null
|
||||
,masterLock: false
|
||||
|
||||
,onMasterChange: function ()
|
||||
,_onMasterChange: function ()
|
||||
{
|
||||
if (this.masterLock)
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"ByProvince": "Desglose por provincia"
|
||||
|
||||
,"Return": "Volver"
|
||||
|
||||
,"SelectAgency": "Seleccione una agencia en el listado de la izquierda"
|
||||
,"Province": "Provincia"
|
||||
,"Expeditions": "Exps."
|
||||
|
|
|
@ -25,4 +25,5 @@
|
|||
,"Subtotal": "Subtotal"
|
||||
|
||||
,"OrderItemsUpdated": "Su pedido lleva demasiado tiempo abierto y ha sido actualizado, los precios o cantidades de sus artículos pueden haber cambiado."
|
||||
,"RememberReconfiguringImpact": "Recuerde que si vuelve a configurar el pedido los precios o cantidades de sus artículos podrían cambiar."
|
||||
}
|
||||
|
|
|
@ -25,5 +25,4 @@
|
|||
|
||||
,"OrderStarted": "Pedido empezado"
|
||||
,"OrderUpdated": "Pedido actualizado"
|
||||
,"RememberReconfiguringImpact": "Recuerde que si vuelve a configurar el pedido los precios o cantidades de sus artículos podrían cambiar."
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ Vn.Locale.add
|
|||
,"NewVersionAvailable": "Hay una nueva actualización, la página se recargargará automaticamente para descargarla"
|
||||
,"ChangeLog": "Cambios recientes"
|
||||
,"CookiesNotification": "Al utilizar este sitio web aceptas el uso de cookies para la personalización de contenidos y análisis."
|
||||
,"ReturnToOldWebsite": "Ir a web antigua"
|
||||
|
||||
,"Home": "Inicio"
|
||||
,"Orders": "Pedidos"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"Welcome": "Bienvenido/a"
|
||||
,"Exit": "Salir"
|
||||
,"TestTheNewWebsite": "¡Prueba la nueva web!"
|
||||
}
|
||||
|
|
|
@ -29,7 +29,12 @@
|
|||
<div id="body">
|
||||
<div id="content">
|
||||
<div id="menu-box">
|
||||
<div id="menu-overflow">
|
||||
<a id="test-link" href="//test-www.verdnatura.es">
|
||||
<?=s('TestTheNewWebsite')?>
|
||||
</a>
|
||||
<ul id="menu"></ul>
|
||||
</div>
|
||||
<div id="links">
|
||||
<a target="_blank" href="http://verdnaturacomunicacion.blogspot.com.es/">
|
||||
<img alt="Blogger" src="image/blogger.svg" title="Blogger"/>
|
||||
|
|
|
@ -7,28 +7,6 @@ Vn.Module = new Class
|
|||
this.conn = gui.conn;
|
||||
this.hash = gui.hash;
|
||||
this.formInfo = formInfo;
|
||||
|
||||
this.builder = new Vn.Builder ();
|
||||
this.builder.signalData = this;
|
||||
this.builder.loadXml (Vn.getXml ('forms/'+ formInfo.path +'/ui.xml'));
|
||||
this.node = this.builder.get ('form');
|
||||
|
||||
var models = this.builder.getObjects ('db-model');
|
||||
|
||||
for (var i = 0; i < models.length; i++)
|
||||
models[i].conn = this.conn;
|
||||
|
||||
var queries = this.builder.getObjects ('db-query');
|
||||
|
||||
for (var i = 0; i < queries.length; i++)
|
||||
queries[i].conn = this.conn;
|
||||
|
||||
var hashLinks = this.builder.getObjects ('vn-hash-link');
|
||||
|
||||
for (var i = 0; i < hashLinks.length; i++)
|
||||
hashLinks[i].hash = this.hash;
|
||||
|
||||
gui.formHolder.appendChild (this.node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,15 +23,41 @@ Vn.Module = new Class
|
|||
/**
|
||||
* Called when the form is opened.
|
||||
**/
|
||||
,open: function ()
|
||||
{
|
||||
this.builder = new Vn.Builder ();
|
||||
this.builder.signalData = this;
|
||||
this.builder.loadXml (Vn.getXml ('forms/'+ this.formInfo.path +'/ui.xml'));
|
||||
this.node = this.builder.get ('form');
|
||||
|
||||
var models = this.builder.getObjects ('db-model');
|
||||
|
||||
for (var i = 0; i < models.length; i++)
|
||||
models[i].conn = this.conn;
|
||||
|
||||
var queries = this.builder.getObjects ('db-query');
|
||||
|
||||
for (var i = 0; i < queries.length; i++)
|
||||
queries[i].conn = this.conn;
|
||||
|
||||
this.gui.formHolder.appendChild (this.node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the form is activated.
|
||||
**/
|
||||
,activate: function () {}
|
||||
|
||||
/**
|
||||
* Called when the form is closed.
|
||||
**/
|
||||
,close: function ()
|
||||
{
|
||||
if (this.node)
|
||||
{
|
||||
Vn.Node.remove (this.node);
|
||||
this.builder.destroy ();
|
||||
this.builder.unref ();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ body
|
|||
background-color: #CE8;
|
||||
}
|
||||
|
||||
/* Menu */
|
||||
/* Left panel */
|
||||
|
||||
#menu-button
|
||||
{
|
||||
|
@ -163,18 +163,43 @@ ul.submenu
|
|||
z-index: 20;
|
||||
box-shadow: 0 0.2em 0.2em #AAA;
|
||||
}
|
||||
#menu
|
||||
#menu-overflow
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 4em;
|
||||
margin: 0;
|
||||
padding: 1em 0;
|
||||
list-style-type: none;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Test link */
|
||||
|
||||
#test-link
|
||||
{
|
||||
display: block;
|
||||
margin: 1em auto;
|
||||
max-width: 70%;
|
||||
background-color: #3f51b5;
|
||||
color: white;
|
||||
padding: 0 1em;
|
||||
line-height: 2em;
|
||||
border-radius: 0.1em;
|
||||
text-align: center;
|
||||
}
|
||||
#test-link:hover
|
||||
{
|
||||
background-color: #4f61c5;
|
||||
}
|
||||
|
||||
/* Menu */
|
||||
|
||||
#menu
|
||||
{
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
#menu > li
|
||||
{
|
||||
display: block;
|
||||
|
|
|
@ -1,26 +1,23 @@
|
|||
|
||||
Vn.Tpv = new Class
|
||||
({
|
||||
initialize: function (conn, hash)
|
||||
Vn.Tpv =
|
||||
{
|
||||
check: function (conn)
|
||||
{
|
||||
this.conn = conn;
|
||||
this.hash = hash;
|
||||
|
||||
var tpvStatus = this.hash.get ('tpv_status');
|
||||
var tpvStatus = Vn.Hash.get ('tpv_status');
|
||||
|
||||
if (tpvStatus)
|
||||
{
|
||||
var batch = new Sql.Batch ();
|
||||
batch.addValue ('transaction', this.hash.get ('tpv_order'));
|
||||
batch.addValue ('transaction', Vn.Hash.get ('tpv_order'));
|
||||
batch.addValue ('status', tpvStatus);
|
||||
|
||||
var query = 'CALL transaction_end (#transaction, #status)';
|
||||
|
||||
this.conn.execQuery (query, null, batch);
|
||||
conn.execQuery (query, null, batch);
|
||||
}
|
||||
}
|
||||
|
||||
,pay: function (amount, company)
|
||||
,pay: function (conn, amount, company)
|
||||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
|
@ -30,14 +27,14 @@ Vn.Tpv = new Class
|
|||
batch.addValue ('company', company);
|
||||
batch.addValue ('amount', parseInt (amount * 100));
|
||||
|
||||
this.conn.execQuery (query,
|
||||
this.onTransactionStart.bind (this), batch);
|
||||
conn.execQuery (query,
|
||||
this._onTransactionStart.bind (this), batch);
|
||||
}
|
||||
else if (!isNaN (amount))
|
||||
(new Htk.Toast ()).showError (_('AmountError'));
|
||||
}
|
||||
|
||||
,onTransactionStart: function (resultSet)
|
||||
,_onTransactionStart: function (resultSet)
|
||||
{
|
||||
var res = resultSet.fetchResult ();
|
||||
|
||||
|
@ -74,27 +71,53 @@ Vn.Tpv = new Class
|
|||
}
|
||||
|
||||
var transactionId = res.get ('ds_order');
|
||||
form['Ds_Merchant_UrlOK'].value = this.makeUrl ('ok', transactionId);
|
||||
form['Ds_Merchant_UrlKO'].value = this.makeUrl ('ko', transactionId);
|
||||
form['Ds_Merchant_UrlOK'].value = this._makeUrl ('ok', transactionId);
|
||||
form['Ds_Merchant_UrlKO'].value = this._makeUrl ('ko', transactionId);
|
||||
|
||||
form.submit ();
|
||||
}
|
||||
else
|
||||
alert (_('PayError'));
|
||||
(new Htk.Toast ()).showWarning (_('PayError'));
|
||||
}
|
||||
|
||||
,makeUrl: function (status, order)
|
||||
,_makeUrl: function (status, order)
|
||||
{
|
||||
var path = location.protocol +'//'+ location.host;
|
||||
path += location.port ? ':'+ location.port : '';
|
||||
path += location.pathname;
|
||||
path += location.search ? location.search : '';
|
||||
path += this.hash.make ({
|
||||
path += Vn.Hash.make ({
|
||||
'tpv_status': status,
|
||||
'tpv_order': order
|
||||
}, true);
|
||||
|
||||
return path;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Vn.BasketChecker =
|
||||
{
|
||||
check: function (conn, callback)
|
||||
{
|
||||
conn.execQuery ('CALL basket_check ()',
|
||||
this._onBasketCheck.bind (this, callback));
|
||||
}
|
||||
|
||||
,_onBasketCheck: function (callback, resultSet)
|
||||
{
|
||||
var status = resultSet.fetchValue ();
|
||||
|
||||
if (!status)
|
||||
return;
|
||||
|
||||
var isOk = status == 'UPDATED' || status == 'OK';
|
||||
|
||||
if (status == 'UPDATED')
|
||||
(new Htk.Toast ()).showWarning (_('OrderItemsUpdated'));
|
||||
if (callback)
|
||||
callback (isOk);
|
||||
if (!isOk)
|
||||
Vn.Hash.set ({'form': 'ecomerce/checkout'});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -18,18 +18,11 @@ Vn.Web =
|
|||
this.loader = $('loader');
|
||||
this.formHolder = $('form-holder');
|
||||
|
||||
this.hash = new Vn.Hash ();
|
||||
this.hashLink = new Vn.HashLink
|
||||
({
|
||||
hash: this.hash
|
||||
,key: 'form'
|
||||
});
|
||||
this.hashLink.on ('changed', this.onFormChange, this);
|
||||
Vn.Hash.initialize ();
|
||||
this.hash = Vn.Hash;
|
||||
|
||||
this.conn = new Db.Conn ();
|
||||
this.conn.on ('error', this.onConnError, this);
|
||||
this.conn.on ('loading-changed', this.onConnLoading, this);
|
||||
this.conn.open (null, null, null, this.connOpened.bind (this));
|
||||
this.hashParam = new Vn.HashParam ({key: 'form'});
|
||||
this.hashParam.on ('changed', this.onFormChange, this);
|
||||
|
||||
$('background').onclick = function () {};
|
||||
|
||||
|
@ -53,22 +46,33 @@ Vn.Web =
|
|||
Vn.Cookie.set ('hedera_cookies', true);
|
||||
(new Htk.Toast ()).showWarning (_('CookiesNotification'));
|
||||
}
|
||||
|
||||
this.conn = new Db.Conn ();
|
||||
this.conn.on ('error', this.onConnError, this);
|
||||
this.conn.on ('loading-changed', this.onConnLoading, this);
|
||||
// this.conn.open (null, null, null, this.connOpened.bind (this));
|
||||
|
||||
var sql = 'SELECT default_form, image_dir FROM config;'
|
||||
+'SELECT production_domain, test_domain FROM config;'
|
||||
+'SELECT name FROM customer_view;'
|
||||
+'CALL form_list ();';
|
||||
this.conn.execQuery (sql, this.onMainQueryDone.bind (this));
|
||||
}
|
||||
|
||||
,showBackground: function ()
|
||||
{
|
||||
$('background').style.display = 'block';
|
||||
Vn.Node.show ($('background'));
|
||||
}
|
||||
|
||||
,hideBackground: function ()
|
||||
{
|
||||
$('background').style.display = 'none';
|
||||
Vn.Node.hide ($('background'));
|
||||
}
|
||||
|
||||
,showMenu: function ()
|
||||
{
|
||||
this.showBackground ();
|
||||
$('menu-box').style.display = 'block';
|
||||
Vn.Node.show ($('menu-box'));
|
||||
this.menuShown = true;
|
||||
|
||||
this.hideMenuCallback = this.hideMenu.bind (this);
|
||||
|
@ -78,7 +82,7 @@ Vn.Web =
|
|||
,hideMenu: function ()
|
||||
{
|
||||
this.hideBackground ();
|
||||
$('menu-box').style.display = 'none';
|
||||
Vn.Node.hide ($('menu-box'));
|
||||
$('menu-button').style.display = 'initial';
|
||||
this.menuShown = false;
|
||||
|
||||
|
@ -86,14 +90,6 @@ Vn.Web =
|
|||
this.hideMenuCallback = null;
|
||||
}
|
||||
|
||||
,connOpened: function (conn, success)
|
||||
{
|
||||
var sql = 'SELECT default_form, image_dir FROM config;'
|
||||
+'SELECT name FROM customer_view;'
|
||||
+'CALL form_list ();';
|
||||
this.conn.execQuery (sql, this.onMainQueryDone.bind (this));
|
||||
}
|
||||
|
||||
,onMainQueryDone: function (resultSet)
|
||||
{
|
||||
// Retrieving configuration parameters
|
||||
|
@ -105,6 +101,23 @@ Vn.Web =
|
|||
for (var i = 0; i < res.columns.length; i++)
|
||||
Vn.Config[columns[i].name] = res.get (columns[i].name);
|
||||
|
||||
// Retrieving configuration parameters
|
||||
|
||||
var res = resultSet.fetchResult ();
|
||||
|
||||
if (res.next () && res.get ('test_domain'))
|
||||
{
|
||||
if (location.host != res.get ('production_domain'))
|
||||
{
|
||||
Vn.Node.setText ($('test-link'), _('ReturnToOldWebsite'));
|
||||
$('test-link').href = res.get ('production_domain');
|
||||
}
|
||||
else
|
||||
$('test-link').href = res.get ('test_domain');
|
||||
}
|
||||
else
|
||||
Vn.Node.hide ($('test-link'));
|
||||
|
||||
// Retrieving the user name
|
||||
|
||||
var userName = resultSet.fetchValue ();
|
||||
|
@ -221,7 +234,7 @@ Vn.Web =
|
|||
ul.appendChild (li);
|
||||
|
||||
var a = document.createElement ('a');
|
||||
a.href = this.hash.make ({'form': res.get ('path')});
|
||||
a.href = Vn.Hash.make ({'form': res.get ('path')});
|
||||
this.menuOptions[res.get ('path')] = a;
|
||||
li.appendChild (a);
|
||||
|
||||
|
@ -280,7 +293,7 @@ Vn.Web =
|
|||
|
||||
,onFormChange: function ()
|
||||
{
|
||||
var formPath = this.hashLink.value;
|
||||
var formPath = this.hashParam.value;
|
||||
this.openForm (formPath ? formPath : Vn.Config['default_form'], null);
|
||||
}
|
||||
|
||||
|
@ -399,6 +412,7 @@ Vn.Web =
|
|||
try {
|
||||
var klass = eval (formInfo.klass);
|
||||
this.activeForm = new klass (this, formInfo);
|
||||
this.activeForm.open ();
|
||||
this.activeForm.activate ();
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -420,7 +434,7 @@ Vn.Web =
|
|||
|
||||
,unload: function ()
|
||||
{
|
||||
this.hashLink.disconnect ('changed', this.onFormChange, this);
|
||||
this.hashParam.destroy ();
|
||||
this.conn.disconnect ('error', this.onConnError, this);
|
||||
this.conn.disconnect ('loading-changed', this.onConnLoading, this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue