0
1
Fork 0

Various fixes

This commit is contained in:
Juan Ferrer Toribio 2017-10-28 17:13:00 +02:00
parent fe68eb5ce0
commit 37236b6bb0
32 changed files with 543 additions and 610 deletions

View File

@ -6,6 +6,19 @@ Hedera.Conf = new Class
,activate: function ()
{
this.$.userModel.setInfo ('c', 'customer_view', 'hedera');
if (this.hash.$.changePass)
this.onPassChangeClick ();
}
,onChangePassOpen: function ()
{
this.hash.assign ({changePass: true});
}
,onChangePassClose: function ()
{
this.hash.assign ({changePass: undefined});
}
,onPassChangeClick: function ()
@ -17,11 +30,16 @@ Hedera.Conf = new Class
var recoverPass = this.$.user.get ('recoverPass');
this.$.oldPassword.style.display = recoverPass ? 'none' : 'block';
this.$.changePassword.show ();
var focusInput;
if (recoverPass)
this.$.newPassword.focus ();
focusInput = this.$.newPassword;
else
this.$.oldPassword.focus ();
focusInput = this.$.oldPassword;
focusInput.focus ();
focusInput.select ();
}
,onPassModifyClick: function ()

View File

@ -11,9 +11,10 @@
.pass-info
{
width: 15em;
max-width: 17em;
}
.pass-info ul
{
list-style-type: none;
padding-left: 1.5em;
}

View File

@ -39,13 +39,17 @@
<htk-entry lot="user" name="email"></htk-entry>
</div>
<div>
<label for="mail">_Receive invoices by email</label>
<htk-check lot="user" name="mail"/>
<span>
<htk-check id="mail" lot="user" name="mail"/>
<label for="mail">_Receive invoices by email</label>
</span>
</div>
</div>
</div>
<htk-popup
id="change-password"
on-open="onChangePassOpen"
on-closed="onChangePassClose"
modal="true">
<div property="child-node" class="htk-dialog pass-change">
<div>
@ -82,19 +86,19 @@
</h3>
<ul>
<li>
<htk-text lot="password-form" name="length"/> _characters long
{{passwordForm.length}} <span>_characters long</span>
</li>
<li>
<htk-text lot="password-form" name="nAlpha"/> _alphabetic characters
{{passwordForm.nAlpha}} <span>_alphabetic characters</span>
</li>
<li>
<htk-text lot="password-form" name="nUpper"/> _capital letters
{{passwordForm.nUpper}} <span>_capital letters</span>
</li>
<li>
<htk-text lot="password-form" name="nDigits"/> _digits
{{passwordForm.nDigits}} <span>_digits</span>
</li>
<li>
<htk-text lot="password-form" name="nPunct"/> _symbols
{{passwordForm.nPunct}} <span>_symbols</span>
</li>
</ul>
</div>

View File

@ -11,7 +11,7 @@
</div>
<div id="main" class="home">
<div class="column mansonry">
<htk-repeater>
<htk-repeater form-id="new">
<db-model property="model">
SELECT title, text, image, id FROM news
WHERE tag != 'course'
@ -21,15 +21,15 @@
<div class="masonry-box">
<div class="new">
<div class="top">
<h2>{{title}}</h2>
<h2>{{new.title}}</h2>
<div class="new-text">
<htk-html value="{{text}}"/>
<htk-html value="{{new.text}}"/>
</div>
</div>
<htk-image
directory="news"
subdir="full"
value="{{image}}"
value="{{new.image}}"
editable="false"
full-dir="full"/>
</div>

View File

@ -0,0 +1,15 @@
<div>
<h3 class="marker">{{title}}</h3>
<p>
{{address}}
</p>
<p>
{{postcode}} {{city}}
</p>
<p>
{{province}}
</p>
<p>
{{phone}}
</p>
</div>

View File

@ -1,5 +1,8 @@
var infoTpl = require (__dirname +'/info.xml');
var gmapsIsLoaded = false;
var gmapsLoadedCallback;
Hedera.Location = new Class
({
@ -10,6 +13,9 @@ Hedera.Location = new Class
,activate: function ()
{
this.gui.loaderPush ();
this.infoBuilder = new Vn.Builder();
this.infoBuilder.compileString (infoTpl);
var sql = 'SELECT lat, lng, title, address, postcode, city, province, phone, language FROM location';
this.conn.execQuery (sql, this.onLocationsDone.bind (this));
@ -26,7 +32,7 @@ Hedera.Location = new Class
,onLocationsDone: function (resultSet)
{
this.locations = resultSet.fetchResult ();
this.locations = resultSet.fetchArray ();
this.allLoaded ();
}
@ -50,40 +56,20 @@ Hedera.Location = new Class
var div = this.$.form;
var gmap = new google.maps.Map (div, options);
var row;
while (row = this.locations.fetchObject ())
this.createMarker (row, gmap);
locations.forEach (function (location) {
this.createMarker (location, gmap);
}, this);
}
,createMarker: function (row, gmap)
,createMarker: function (location, gmap)
{
var div = document.createElement ('div');
div.className = 'marker';
var h = document.createElement ('h3');
h.appendChild (document.createTextNode (row.title));
div.appendChild (h);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (row.address));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (row.postcode +' '+ row.city));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (row.province));
div.appendChild (p);
var p = document.createElement ('p');
p.appendChild (document.createTextNode (row.phone));
div.appendChild (p);
var scope = this.infoBuilder.load (this.doc, this, null, null, location);
var div = scope.getMain ();
var lat = new google.maps.LatLng (
row.lat,
row.lng
location.lat,
location.lng
);
var marker = new google.maps.Marker ({
@ -100,7 +86,7 @@ Hedera.Location = new Class
this.openInfoWindow.bind (this, infoWindow, gmap, marker));
if (Vn.Locale.language
&& Vn.Locale.language == row.language)
&& Vn.Locale.language == location.language)
this.openInfoWindow (infoWindow, gmap, marker);
}

View File

@ -26,17 +26,17 @@ Hedera.Basket = new Class
,onConfigureClick: function ()
{
Htk.Toast.showWarning (_('RememberReconfiguringImpact'));
this.hash.setAll ({'form': 'ecomerce/checkout'});
this.hash.setAll ({form: 'ecomerce/checkout'});
}
,onCatalogClick: function ()
{
this.hash.setAll ({'form': 'ecomerce/catalog'});
this.hash.setAll ({form: 'ecomerce/catalog'});
}
,onCheckoutClick: function ()
{
this.hash.setAll ({'form': 'ecomerce/confirm'});
this.hash.setAll ({form: 'ecomerce/confirm'});
}
,repeaterFunc: function (res, form)

View File

@ -52,7 +52,7 @@ Hedera.Catalog = new Class
,deactivate: function ()
{
this.hideMenu ();
this.gui.$.topBar.style.backgroundColor = '';
this.gui.$.navbar.style.backgroundColor = '';
Vn.Node.remove (this.$.rightPanel);
}
@ -161,7 +161,7 @@ Hedera.Catalog = new Class
color = '#'+ realms.get (row, 'color');
}
this.gui.$.topBar.style.backgroundColor = color;
this.gui.$.navbar.style.backgroundColor = color;
}
,refreshTitle: function ()

View File

@ -137,29 +137,28 @@
full-dir="900x900"/>
<div class="item-info">
<htk-button
lot="item"
name="id"
value="{{item.item_id}}"
tip="_AddToBasket"
icon="add"
on-click="onAddItemClick"
on-click="onAddItemClick(item.item_id)"
class="add-button"/>
<h2>{{Article}}</h2>
<h2>{{item.Article}}</h2>
<p class="producer">
{{producer}}
{{item.producer}}
</p>
<p>
@{{item_id}}
@{{item.item_id}}
</p>
<p>
_Size <htk-text lot="item" name="Medida"/>
_Category <htk-text lot="item" name="Categoria"/>
<span>_Size</span> {{item.Medida}}
<span>_Category</span> {{item.Categoria}}
</p>
<p class="color">
_Color <htk-text lot="item" name="color"/>
<span>_Color</span> {{item.color}}
<htk-text lot="item" name="Tallos" format="_, %.0d Units"/>
</p>
<div class="aval-price">
<htk-text lot="item" name="available"/>
{{item.available}}
<span class="from">
_from
</span>
@ -201,7 +200,7 @@
ORDER BY name
</db-model>
<custom>
<a class="clickable" href="#!form={{form}}&amp;realm={{id}}">
<a class="clickable" href="#!form={{hash.form}}&amp;realm={{id}}">
<img
src="image/family/light/{{id}}.svg"
title="{{name}}"
@ -367,25 +366,25 @@
editable="true"/>
<div class="item-info">
<h2>
<htk-text lot="card" name="Article"/>
{{card.Article}}
</h2>
<p class="producer">
<htk-text lot="card" name="producer"/>
{{card.producer}}
</p>
<p>
_Size <htk-text lot="card" name="Medida"/>,
_Category <htk-text lot="card" name="Categoria"/>
<span>_Size</span> {{card.Medida}},
<span>_Category</span> {{card.categoria}}
</p>
<p class="color">
_Color <htk-text lot="card" name="color"/>
<span>_Color</span> {{card.color}}
<htk-text lot="card" name="Tallos" format="_, %.0d Units"/>
</p>
<p>
_Origin <htk-text lot="card-extend" name="origin"/>
<span>_Origin</span> {{card.origin}}
</p>
</div>
<p class="desc">
<htk-text lot="card-extend" name="description" id="desc"/>
{{cardExtend.description}}
</p>
</div>
<htk-grid class="lots-grid" model="item-lots" show-header="false">

View File

@ -1,3 +1,22 @@
(function () {
var methodsData = {
AGENCY: {
steps: ['method', 'date', 'address', 'agency', 'confirm'],
isDelivery: true,
textId: 'agencyText'
},
DELIVERY: {
steps: ['method', 'date', 'address', null, 'confirm'],
isDelivery: true,
textId: 'deliveryText'
},
PICKUP: {
steps: ['method', 'date', 'address', 'pickup', 'confirm'],
isDelivery: false,
textId: 'pickupText'
}
};
Hedera.Checkout = new Class
({
@ -28,7 +47,7 @@ Hedera.Checkout = new Class
if (orderForm.numRows > 0)
{
var i = orderForm;
date = i.get ('date_send');
date = i.$.date_send;
}
else
var i = defaultsForm;
@ -37,7 +56,7 @@ Hedera.Checkout = new Class
{
date = new Date ();
if (i.get('delivery_method') != 'PICKUP')
if (i.$.delivery_method != 'PICKUP')
date.setDate (date.getDate () + 1);
date.setHours (0, 0, 0, 0);
@ -45,18 +64,16 @@ Hedera.Checkout = new Class
this.$.lot.assign ({
date: date,
method: i.get ('delivery_method'),
agency: i.get ('agency_id'),
address: i.get ('address_id')
method: i.$.delivery_method,
agency: i.$.agency_id,
address: i.$.address_id
});
this.autoStepLocked = false;
}
,disableButtons: function (disable)
{
this.$.confirmAgency.disabled = disable;
this.$.confirmDelivery.disabled = disable;
this.$.confirmPickup.disabled = disable;
this.$.confirmButton.disabled = disable;
}
,onConfirmClick: function ()
@ -75,10 +92,8 @@ Hedera.Checkout = new Class
if (!resultSet.fetchResult ())
return;
if (this.$.orderForm.numRows > 0)
Htk.Toast.showMessage (_('OrderUpdated'));
else
Htk.Toast.showMessage (_('OrderStarted'));
var isUpdated = this.$.orderForm.numRows > 0;
Htk.Toast.showMessage (_(isUpdated ? 'OrderUpdated' : 'OrderStarted'));
this.hash.setAll ({form: 'ecomerce/catalog'});
}
@ -88,55 +103,45 @@ Hedera.Checkout = new Class
if (this.$.orderForm.numRows > 0)
window.history.back();
else
this.hash.setAll ({'form': 'ecomerce/orders'});
this.hash.setAll ({form: 'ecomerce/orders'});
}
,agencySteps: ['method', 'date', 'address', 'agency', 'confirm-agency']
,deliverySteps: ['method', 'date', 'address', null, 'confirm-delivery']
,pickupSteps: ['method', 'date', 'address', 'pickup', 'confirm-pickup']
,stepFunc: function (stepIndex)
{
var steps;
var isDelivery;
switch (this.$.rgMethod.value)
{
case 'AGENCY':
steps = this.agencySteps;
isDelivery = true;
break;
case 'DELIVERY':
steps = this.deliverySteps;
isDelivery = true;
break;
case 'PICKUP':
default:
steps = this.pickupSteps;
isDelivery = false;
break;
}
var method = this.$.rgMethod.value;
var methodData = methodsData[method];
var stepName;
var stepId = steps[stepIndex];
if (!stepId)
if (methodData !== undefined)
stepName = methodData.steps[stepIndex];
else
stepName = 'method';
if (!stepName)
return null;
switch (stepId)
switch (stepName)
{
case 'date':
Vn.Node.setText (this.$.dateQuestion, isDelivery ?
_('OrderDateDeliveryQuestion'):
_('OrderDatePickupQuestion'));
var dateQuestion = methodData.isDelivery ?
'OrderDateDeliveryQuestion' : 'OrderDatePickupQuestion';
Vn.Node.setText (_(dateQuestion));
this.$.calendar.goToSelectedMonth ();
break;
case 'agency':
case 'pickup':
this.$.agencies.refresh ();
break;
case 'confirm':
for (var myMethod in methodsData)
{
var display = myMethod == method ? 'block': 'none';
this.$[methodsData[myMethod].textId].style.display = display;
}
break;
}
return this.$[stepId +'Step'];
return stepName;
}
,onFieldChange: function ()
@ -153,7 +158,7 @@ Hedera.Checkout = new Class
,addressRenderer: function (builder, form)
{
builder.$.address.addEventListener ('click',
this.onAddressClick.bind (this, form.get ('id')));
this.onAddressClick.bind (this, form.$.id));
}
,onAddressClick: function (addressId)
@ -167,7 +172,7 @@ Hedera.Checkout = new Class
if (this.selectedNode)
Vn.Node.removeClass (this.selectedNode, 'selected');
var row = this.$.addresses.search ('id', this.$.lot.get ('address'));
var row = this.$.addresses.search ('id', this.$.lot.$.address);
if (row != -1)
{
@ -198,3 +203,4 @@ Hedera.Checkout = new Class
}
});
})();

View File

@ -71,15 +71,11 @@
.thin-calendar
{
width: inherit;
max-width: 24em;
max-width: 22em;
margin: 0 auto;
box-shadow: 0 0.1em 0.3em #ccc;
font-size: .7em;
}
.thin-calendar tr > th
{
color: white;
}
.htk-assistant .thin
{
float: right;

View File

@ -14,6 +14,15 @@
JOIN vn.deliveryMethod d ON d.id = o.delivery_method_id
</db-model>
</db-form>
<db-form id="address-form" model="addresses">
<db-model property="model" id="addresses">
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 != FALSE
</db-model>
</db-form>
<db-model
id="agencies"
lot="lot"
@ -36,10 +45,8 @@
<htk-assistant
id="assistant"
step-count="5"
step-func="stepFunc"
node="assistant-node"/>
<div id="assistant-node">
<div id="method-step">
step-func="stepFunc">
<htk-step name="method">
<h2>_DeliveryOrPickupQuestion</h2>
<div class="answers radio">
<htk-radio-group
@ -60,8 +67,8 @@
<label for="r-pickup">_PickupInStore</label>
</div>
</div>
</div>
<div id="date-step">
</htk-step>
<htk-step name="date">
<h2 id="date-question">_OrderDateDeliveryQuestion</h2>
<div class="answers">
<htk-calendar
@ -72,110 +79,76 @@
restrict-func="calendarRestrict"
on-pick="onFieldChange"/>
</div>
</div>
<div id="address-step">
</htk-step>
<htk-step name="address">
<h2>_AddressQuestion</h2>
<db-form id="address-form" model="addresses"/>
<div class="answers target">
<htk-repeater
id="repeater"
form-id="iter"
on-change="onAddressChange"
renderer="addressRenderer">
<db-model property="model" id="addresses">
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 != FALSE
</db-model>
renderer="addressRenderer"
model="addresses">
<custom>
<div class="address" id="address">
<p class="consignee">
<htk-text lot="iter" name="consignee"/>
{{consignee}}
</p>
<p>
<htk-text lot="iter" name="name"/>
{{name}}
</p>
</div>
</custom>
</htk-repeater>
</div>
</div>
<div id="agency-step">
</htk-step>
<htk-step name="agency">
<h2>_AgencyQuestion</h2>
<div class="answers target">
<htk-combo
id="agency-combo"
id="agency"
lot="lot"
name="agency"
on-changed="onFieldChange"
model="agencies"/>
</div>
</div>
<div id="pickup-step">
</htk-step>
<htk-step name="pickup">
<h2>_PickupWarehouseQuestion</h2>
<div class="answers target">
<htk-combo
id="warehouse-combo"
id="warehouse"
lot="lot"
name="agency"
on-changed="onFieldChange"
model="agencies"/>
</div>
</div>
<div id="confirm-agency-step" class="confirm">
</htk-step>
<htk-step name="confirm" class="confirm">
<h2>_ConfirmToAccessCatalog</h2>
<div class="answers target">
<p>
_Arrival <htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
<htk-text lot="address-form" name="name"/>
{{addressForm.name}}
</p>
<p>
_Agency <htk-text lot="agency-combo" name="description"/>
<p id="agency-text">
<span>_Agency</span> {{agency.description}}
</p>
<button id="confirm-agency" class="thin" on-click="onConfirmClick">
_Confirm
</button>
<div class="clear"/>
</div>
</div>
<div id="confirm-delivery-step" class="confirm">
<h2>_ConfirmToAccessCatalog</h2>
<div class="answers target">
<p>
_Arrival <htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
<htk-text lot="address-form" name="name"/>
</p>
<p>
<p id="delivery-text">
_ReceiveThroughtRoute
</p>
<button id="confirm-delivery" class="thin" on-click="onConfirmClick">
<p id="pickup-text">
<span>_Warehouse</span> {{warehouse.description}}
</p>
<button id="confirm-button" class="thin" on-click="onConfirmClick">
_Confirm
</button>
<div class="clear"/>
</div>
</div>
<div id="confirm-pickup-step" class="confirm">
<h2>_ConfirmToAccessCatalog</h2>
<div class="answers target">
<p>
_Pickup <htk-text format="%D" lot="lot" name="date"/>
</p>
<p>
_Warehouse <htk-text lot="warehouse-combo" name="description"/>
</p>
<button id="confirm-pickup" class="thin" on-click="onConfirmClick">
_Confirm
</button>
<div class="clear"/>
</div>
</div>
</div>
</htk-step>
</htk-assistant>
<htk-assistant-bar assistant="assistant"/>
</div>
</div>

View File

@ -38,20 +38,18 @@
<htk-text format="%D" lot="order" name="sendDate"/>
</p>
<p>
<span id="method">_Agency</span>
<htk-text lot="order" name="agency"/>
<span id="method">_Agency</span> {{order.agency}}
</p>
</div>
<div id="address" class="address">
<p>
<htk-text lot="order" name="consignee"/>
{{order.consignee}}
</p>
<p>
<htk-text lot="order" name="address"/>
{{order.address}}
</p>
<p>
<htk-text lot="order" name="zipCode"/>,
<htk-text lot="order" name="city"/>
{{order.zipCode}}, {{order.city}}
</p>
</div>
</div>
@ -147,29 +145,29 @@
name="payMethod"
on-changed="onPayMethodChange"/>
<div id="balance-method">
<htk-radio radio-group="pay-method" value="BALANCE"/>
<label>_Use my balance</label>
<htk-radio id="r-balance" radio-group="pay-method" value="BALANCE"/>
<label for="r-balance">_Use my balance</label>
<div class="pay-info">
_You have a favorable balance.
</div>
</div>
<div id="credit-method">
<htk-radio radio-group="pay-method" value="CREDIT"/>
<label>_Use my credit</label>
<htk-radio id="r-credit" radio-group="pay-method" value="CREDIT"/>
<label for="r-credit">_Use my credit</label>
<div class="pay-info">
_You have a favorable credit.
</div>
</div>
<div id="card-method">
<htk-radio radio-group="pay-method" value="CARD"/>
<label>_Credit card</label>
<htk-radio id="r-card" radio-group="pay-method" value="CARD"/>
<label for="r-card">_Credit card</label>
<div class="pay-info">
_You will be redirected to the payment.
</div>
</div>
<div id="transfer-method">
<htk-radio radio-group="pay-method" value="TRANSFER"/>
<label>_Bank Transfer</label>
<htk-radio id="r-transfer" radio-group="pay-method" value="TRANSFER"/>
<label for="r-transfer">_Bank Transfer</label>
<div class="pay-info">
_Make a transfer to one account.
<htk-repeater form-id="iter">
@ -195,8 +193,8 @@
</div>
</div>
<div id="later-method">
<htk-radio radio-group="pay-method" value="LATER"/>
<label>_Pay later</label>
<htk-radio id="r-later" radio-group="pay-method" value="LATER"/>
<label for="r-later">_Pay later</label>
</div>
</div>
</div>

View File

@ -334,7 +334,11 @@ Klass.implement
this.result = result;
this.tables = result.tables;
this.columns = result.columns;
this.columnMap = result.columnMap;
this.columnMap = {};
for (var i = 0; i < this.columns.length; i++)
this.columnMap[this.columns[i].name] = i;
this._repairColumns ();
this._refreshMainTable ();
@ -348,19 +352,6 @@ Klass.implement
this._setData (result.data);
}
,_refreshRowIndexes: function (start)
{
this.parent (start);
if (this._operationsMap)
{
this._operationsMap = {};
for (var i = 0; i < this._operations.length; i++)
this._operationsMap[i] = this._operations[i];
}
}
,_cleanData: function ()
{
@ -402,58 +393,6 @@ Klass.implement
this._refreshUpdatable ();
}
/**
* Sets the default value for inserted rows.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {Sql.Expr} expr The default value expression
*/
,setDefault: function (column, table, expr)
{
this._defaults.push
({
column: column
,table: table
,expr: expr
});
}
/**
* Sets the default value for inserted rows.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {*} value The default value
*/
,setDefaultFromValue: function (column, table, value)
{
this._defaults.push
({
column: column
,table: table
,value: value
});
}
/**
* Sets the default value for inserted rows from another column in the
* model.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {String} srcColumn The source column
*/
,setDefaultFromColumn: function (column, table, srcColumn)
{
this._defaults.push
({
column: column
,table: table
,srcColumn: srcColumn
});
}
/**
* Checks if the column index exists.
*
@ -621,6 +560,58 @@ Klass.implement
return this.ready ?
Object.keys (this._model.columnMap) : null;
}
/**
* Sets the default value for inserted rows.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {Sql.Expr} expr The default value expression
*/
,setDefault: function (column, table, expr)
{
this._defaults.push
({
column: column
,table: table
,expr: expr
});
}
/**
* Sets the default value for inserted rows.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {*} value The default value
*/
,setDefaultFromValue: function (column, table, value)
{
this._defaults.push
({
column: column
,table: table
,value: value
});
}
/**
* Sets the default value for inserted rows from another column in the
* model.
*
* @param {String} column The destination column name
* @param {String} table The destination table name
* @param {String} srcColumn The source column
*/
,setDefaultFromColumn: function (column, table, srcColumn)
{
this._defaults.push
({
column: column
,table: table
,srcColumn: srcColumn
});
}
/**
* Deletes a row from the model.
@ -719,6 +710,22 @@ Klass.implement
this._sort (columnName, way);
}
/**
* Searchs a value on the model and returns the row index of the first
* ocurrence.
* If an index have been built on that column, it will be used, for more
* information see the indexColumn() method.
*
* @param {String} columnIndex The column index
* @param {Object} value The value to search
* @return {Number} The column index
*/
,searchByIndex: function (columnIndex, value)
{
var columnName = this.getColumnName (columnIndex);
return this.search (columnName, value);
}
/**
* Performs all model changes on the database.
*/
@ -926,51 +933,6 @@ Klass.implement
this.emit ('operations-done');
}
/**
* Undoes all unsaved changes made to the model.
*/
,reverseOperations: function ()
{
for (var i = 0; i < this._operations.length; i++)
{
var op = this._operations[i];
var row = op.row;
if (op.type & Operation.DELETE
&& !(op.type & Operation.INSERT))
{
this._data.splice (row.index, 0, row);
this.emit ('row-inserted', row.index);
}
else if (op.type & Operation.UPDATE)
{
this.emit ('row-updated-before', row.index);
var updatedCols = [];
var cols = this.columns;
for (var i = 0; i < cols.length; i++)
if (op.oldValues[cols[i].name] !== undefined)
{
var columnName = cols[i].name;
row[columnName] = op.oldValues[columnName];
updatedCols.push (columnName);
}
this.emit ('row-updated', row.index, updatedCols);
}
}
this._resetOperations ();
this._refreshRowIndexes (0);
}
,_resetOperations: function ()
{
this._operations = [];
this._operationsMap = {};
}
,_createTarget: function (tableIndex)
{
var table = this.tables[tableIndex];
@ -1033,6 +995,64 @@ Klass.implement
return op;
}
/**
* Undoes all unsaved changes made to the model.
*/
,reverseOperations: function ()
{
for (var i = 0; i < this._operations.length; i++)
{
var op = this._operations[i];
var row = op.row;
if (op.type & Operation.DELETE
&& !(op.type & Operation.INSERT))
{
this._data.splice (row.index, 0, row);
this.emit ('row-inserted', row.index);
}
else if (op.type & Operation.UPDATE)
{
this.emit ('row-updated-before', row.index);
var updatedCols = [];
var cols = this.columns;
for (var i = 0; i < cols.length; i++)
if (op.oldValues[cols[i].name] !== undefined)
{
var columnName = cols[i].name;
row[columnName] = op.oldValues[columnName];
updatedCols.push (columnName);
}
this.emit ('row-updated', row.index, updatedCols);
}
}
this._resetOperations ();
this._refreshRowIndexes (0);
}
,_resetOperations: function ()
{
this._operations = [];
this._operationsMap = {};
}
,_refreshRowIndexes: function (start)
{
this.parent (start);
if (this._operationsMap)
{
this._operationsMap = {};
for (var i = 0; i < this._operations.length; i++)
this._operationsMap[i] = this._operations[i];
}
}
/**
* Overrides information about a table and its columns. If a parameter is

View File

@ -43,7 +43,7 @@ module.exports = new Class
/**
* Fetchs the next result from the resultset.
*
* @return {Db.Result} the result or %null if error or there are no more results
* @return {Db.Result} The result or %null if error or there are no more results
*/
,fetchResult: function ()
{
@ -59,18 +59,23 @@ module.exports = new Class
return null;
}
/**
* Fetchs the first row from the next resultset as an object.
* Fetchs the next result from the resultset.
*
* @return {Object} the row if success, %null otherwise
* @return {Array} The result or %null if error or there are no more results
*/
,fetchObject: function ()
,fetchArray: function ()
{
var result = this.fetchResult ();
if (result instanceof Result)
return result.fetchObject ();
var result = this.fetch ();
if (result !== null)
{
if (result.data instanceof Array)
return result.data;
else
return true;
}
return null;
}
@ -82,14 +87,12 @@ module.exports = new Class
*/
,fetchRow: function ()
{
var result = this.fetch ();
var result = this.fetchArray ();
if (result !== null
&& result.data instanceof Array
&& result.data.length > 0)
return result.data[0];
if (result === null || result.length === 0)
return null;
return null;
return result[0];
}
/**
@ -99,12 +102,13 @@ module.exports = new Class
*/
,fetchValue: function ()
{
var row = this.fetchRow ();
var result = this.fetchResult ();
if (row instanceof Object && row.length > 0)
return row[0];
return null;
if (result === null
|| result.data.length === 0
|| result.columns.length === 0)
return undefined;
return result.data[0][result.columns[0].name];
}
});

View File

@ -10,31 +10,10 @@ module.exports = new Class
{
Object.assign (this, {
data: result.data,
tables: result.tables,
result: result.tables,
columns: result.columns,
row: -1
});
if (this.columns)
{
this.columnMap = {};
for (var i = 0; i < this.columns.length; i++)
this.columnMap[this.columns[i].name] = i;
}
else
this.columnMap = null;
}
/**
* Gets a value from de result.
*
* @param {String} columnName The column name
* @return {Object} The cell value
*/
,get: function (columnName)
{
return this.data[this.row][columnName];
}
/**
@ -42,7 +21,7 @@ module.exports = new Class
*
* @return {Object} The row or %null if there are no more rows
*/
,fetchObject: function ()
,fetchRow: function ()
{
if (!this.next ())
return null;
@ -56,7 +35,7 @@ module.exports = new Class
* @param {number} rowIndex The row index
* @return {Object} The row or %null if there are no more rows
*/
,getObject: function (rowIndex)
,getRow: function (rowIndex)
{
return this.data[rowIndex];
}

View File

@ -118,7 +118,7 @@ module.exports = new Class
case 'OutdatedVersion':
this._newVersion ();
break;
case 'User':
case 'Vn.Lib.User':
Htk.Toast.showError (error.message);
break;
default:

View File

@ -139,11 +139,11 @@ module.exports = new Class
{
// Retrieving configuration parameters
Object.assign (Vn.Config, resultSet.fetchObject ());
Object.assign (Vn.Config, resultSet.fetchRow ());
// Retrieving configuration parameters
var row = resultSet.fetchObject ();
var row = resultSet.fetchRow ();
if (row && row.test_domain)
{
@ -181,56 +181,48 @@ module.exports = new Class
{
// Retrieving menu sections
var row;
var res = resultSet.fetchResult ();
var sections = resultSet.fetchArray ();
var sectionMap = {};
if (res)
for (var i = 0; row = res.fetchObject (); i++)
{
var parent = row.parent;
if (!sectionMap[parent])
sectionMap[parent] = [];
if (sections)
sections.forEach (function (section) {
var parent = section.parent;
sectionMap[parent].push (i);
}
if (!sectionMap[parent])
sectionMap[parent] = [];
sectionMap[parent].push (section);
});
Vn.Node.removeChilds (this.$.mainMenu);
this.createMenu (res, sectionMap, null, this.$.mainMenu);
this.createMenu (sectionMap, null, this.$.mainMenu);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Menu
,createMenu: function (res, sectionMap, parent, ul)
,createMenu: function (sectionMap, parent, ul)
{
var sections = sectionMap[parent];
for (var i = 0; i < sections.length; i++)
{
res.row = sections[i];
var row = res.getObject (res.row);
sections.forEach (function (section) {
var li = this.createElement ('li');
ul.appendChild (li);
var text = this.createTextNode (_(row.description));
var text = this.createTextNode (_(section.description));
var a = this.createElement ('a');
a.className = 'clickable';
if (row.path)
if (section.path)
{
a.href = this.hash.make ({'form': row.path});
this._menuOptions[row.path] = a;
a.href = this.hash.make ({form: section.path});
this._menuOptions[section.path] = a;
}
a.appendChild (text);
li.appendChild (a);
var formId = row.id;
if (sectionMap[formId])
if (sectionMap[section.id])
{
var submenu = this.createElement ('ul');
submenu.className = 'submenu';
@ -241,9 +233,9 @@ module.exports = new Class
li.addEventListener ('mouseout',
this._onLiMouseOut.bind (this));
this.createMenu (res, sectionMap, formId, submenu);
this.createMenu (sectionMap, section.id, submenu);
}
}
}, this);
}
,_onLiMouseHover: function (submenu, parent)

View File

@ -55,23 +55,21 @@ module.exports = new Class
,_onQueryDone: function (resultSet)
{
Vn.Node.removeChilds (this._node);
var res = resultSet.fetchResult ();
var row;
var socials = resultSet.fetchArray ();
while (row = res.fetchObject ())
{
socials.forEach (function (social) {
var a = this.createElement ('a');
a.href = row.link;
a.href = social.link;
a.target = '_blank';
a.className = 'clickable-img';
this._node.appendChild (a);
var img = this.createElement ('img');
img.src = 'image/social/'+ row.icon;
img.alt = row.title;
img.title = row.title;
img.src = 'image/social/'+ social.icon;
img.alt = social.title;
img.title = social.title;
a.appendChild (img);
}
}, this);
}
});

View File

@ -89,7 +89,7 @@ module.exports = new Class
,_onRetryPayDone: function (resultSet)
{
var row = resultSet.fetchObject ();
var row = resultSet.fetchRow ();
if (row)
this._realPpay (row.amount, row.company_id);

View File

@ -1,7 +1,9 @@
var Step = require ('./step');
module.exports = new Class
({
Extends: Vn.Object
Extends: Vn.Component
,Tag: 'htk-assistant'
,Properties:
{
@ -57,11 +59,30 @@ module.exports = new Class
},
}
,_steps: []
,_stepNode: null
,_stepIndex: -1
,_stepName: null
,_stepCount: 0
,_stepFunc: null
,appendChild: function (step)
{
if (!(step instanceof Step))
return;
this._node.appendChild (step.node);
this._steps[step.name] = step;
if (step.name === this._stepName)
this._showStepNode ();
}
,render: function ()
{
var node = this.createRoot ('div');
node.className = 'htk-assistant';
}
,setStep: function (stepIndex)
{
if (!(stepIndex >= -1 && stepIndex < this.stepCount))
@ -69,16 +90,15 @@ module.exports = new Class
if (this._stepFunc && stepIndex != -1)
{
var stepNode = this._stepFunc (stepIndex);
var stepName = this._stepFunc (stepIndex);
if (stepNode)
if (stepName)
{
if (this._stepNode)
this._stepNode.style.display = 'none';
this._stepNode = stepNode;
stepNode.style.display = 'block';
if (this._step)
this._step.node.style.display = 'none';
this._stepName = stepName;
this._showStepNode ()
this._setStepIndex (stepIndex);
}
else if (this._stepIndex < stepIndex)
@ -87,9 +107,26 @@ module.exports = new Class
this.setStep (stepIndex - 1);
}
else
{
if (this._step)
this._step.node.style.display = 'none';
this._stepName = null;
this._setStepIndex (stepIndex);
}
}
,_showStepNode: function ()
{
var step = this._steps[this._stepName];
if (step)
{
this._step = step;
step.node.style.display = 'block';
}
}
,_setStepIndex: function (stepIndex)
{
this._stepIndex = stepIndex;

View File

@ -141,13 +141,15 @@ module.exports = new Class
var button = this.createRoot ('button');
button.type = 'button';
button.className = 'htk-select input';
button.addEventListener ('mousedown', this._onButtonMouseDown.bind (this));
button.addEventListener ('mousedown',
this._onButtonMouseDown.bind (this));
}
,_setRow: function (row)
{
this._row = row;
this._refreshShowText ();
this.rowChanged ();
this.changed ();
}
@ -168,7 +170,8 @@ module.exports = new Class
menu.appendChild (grid.node);
var gridNode = grid.node;
gridNode.addEventListener ('click', this._onGridClicked.bind (this, grid));
gridNode.addEventListener ('click',
this._onGridClicked.bind (this, grid));
var column = new ColumnText ({columnIndex: this.showColumnIndex});
grid.appendColumn (column);

View File

@ -85,7 +85,7 @@ module.exports = new Class
* Shows the popup relative to another element.
*
* @param {Node} parent The relative element
* @param {boolean} fitParent Wether to set the width same to the parent
* @param {Boolean} fitParent Wether to set the width same to the parent
* @param {HTMLEvent} ignoreEvent An optional event object to ignore
*/
,show: function (parent, fitParent, ignoreEvent)
@ -99,7 +99,7 @@ module.exports = new Class
* Opens the popup.
*
* @param {Node} parent The relative element
* @param {boolean} fitParent Wether to set the width same to the parent
* @param {Boolean} fitParent Wether to set the width same to the parent
*/
,open: function (ignoreEvent)
{
@ -139,13 +139,14 @@ module.exports = new Class
setTimeout (this._onOpacityTimeout.bind (this), 10);
this._isOpen = true;
this.emit ('open');
}
/**
* Returns if the popup window shoud be modal based on the modal property
* and if the device is mobile.
*
* @return {boolean} %true if it's modal, %false otherwise
* @return {Boolean} %true if it's modal, %false otherwise
*/
,isModal: function ()
{

23
js/htk/step.js Normal file
View File

@ -0,0 +1,23 @@
module.exports = new Class
({
Extends: Vn.Component
,Tag: 'htk-step'
,Properties:
{
name: {
type: String
,value: null
}
}
,appendChild: function (child)
{
this._node.appendChild (child);
}
,render: function ()
{
var node = this.createRoot ('div');
node.className = 'htk-step';
}
});

View File

@ -524,6 +524,7 @@ td.cell-image .htk-image
.htk-assistant > div
{
display: none;
color: #555;
}
.htk-assistant > div > h2
{
@ -535,10 +536,6 @@ td.cell-image .htk-image
margin: 0;
margin-bottom: 1em;
}
.htk-assistant *
{
color: #555;
}
/* Assistant bar */

View File

@ -80,7 +80,11 @@ module.exports = new Class
{
this._rowLock = true;
var row = this._model.getObject (this._row);
var row;
if (this._model)
row = this._model.getObject (this._row);
this.params = row != null ? row : {};
this._rowLock = false;

View File

@ -1,90 +0,0 @@
var VnObject = require ('./object');
var ModelIface = require ('./model-iface');
var ModelProxy = require ('./model-proxy');
var Mode = ModelProxy.Mode;
/**
* Model that holds an array of Javascript objects with
* the same structure.
*/
module.exports = new Class
({
Extends: VnObject
,Implements: ModelIface
,Tag: 'vn-json-model'
,Properties:
{
numRows:
{
type: Number
},
status:
{
type: Number
},
mode:
{
enumType: Mode
,value: Mode.ON_CHANGE
},
data:
{
type: Array
,set: function (x)
{
this.data = x;
}
,get: function ()
{
return this.data;
}
}
}
,checkColExists: function () {}
,checkRowExists: function () {}
,getColumnIndex: function () {}
,get: function (rowIndex, columnName)
{
return this.data[rowIndex][columnName];
}
,getByIndex: function (rowIndex, column)
{
var columnName = this.columns[column];
return this.data[rowIndex][columnName];
}
,getObject: function (rowIndex)
{
return this.data[rowIndex];
}
,sortByName: function () {}
,sort: function () {}
,search: function () {}
,searchByIndex: function () {}
,set: function () {}
,setByIndex: function () {}
,deleteRow: function () {}
,insertRow: function () {}
,clean: function () {}
,performOperations: function () {}
,indexColumn: function () {}
});

View File

@ -1,8 +1,6 @@
var VnObject = require ('./object');
// TODO: Remove this dependency
var Type = require ('db/connection').Type;
var simpleEquals = require ('./value').simpleEquals;
var Klass = new Class ();
module.exports = Klass;
@ -298,17 +296,12 @@ Klass.implement
this._buildIndex (column);
}
,getHashFunc: function (type)
,getHashValue: function (value)
{
switch (type)
{
case Type.TIMESTAMP:
case Type.DATE_TIME:
case Type.DATE:
return function (value) { return value.toString (); };
default:
return function (value) { return value; };
}
if (value instanceof Date)
return value.getTime();
else
return value;
}
,_buildIndex: function (columnName)
@ -316,30 +309,27 @@ Klass.implement
if (this.columnMap[columnName] === undefined)
return;
var index = {};
var data = this._data;
var hashFunc = getHashFunc (this.columns[columnName].type);
var values = {};
var nulls = [];
for (var i = 0; i < data.length; i++)
index[hashFunc (data[i][columnName])] = i;
{
var value = data[i][columnName];
this._indexes[columnName] = index;
}
if (value == null)
{
nulls.push (data[i]);
continue;
}
/**
* Searchs a value on the model and returns the row index of the first
* ocurrence.
* If an index have been built on that column, it will be used, for more
* information see the indexColumn() method.
*
* @param {String} columnIndex The column index
* @param {Object} value The value to search
* @return {Number} The column index
*/
,searchByIndex: function (columnIndex, value)
{
var columnName = this.columns[columnIndex].name;
return this.search (columnName, value);
index[this.getHashValue (value)] = data[i];
}
this._indexes[columnName] = {
values: values,
index: index
};
}
/**
@ -352,61 +342,39 @@ Klass.implement
*/
,search: function (columnName, value)
{
var columnIndex = this.columnMap[columnName];
if (columnIndex === undefined)
var data = this._data;
if (data == null)
return -1;
if (value)
switch (this.columns[columnIndex].type)
{
case Type.BOOLEAN:
value = !!value;
break;
case Type.INTEGER:
value = parseInt (value);
break;
case Type.DOUBLE:
value = parseFloat (value);
break;
default:
value = value.toString ();
}
// Searchs the value using an internal index.
var index = this._indexes[columnName];
if (index)
{
if (index[value] !== undefined)
return index[value];
if (value == null)
{
if (index.nulls[0] !== undefined)
return index.nulls[0].index;
}
else
{
var row = index.values[this.getHashValue (value)];
if (rowIndex !== undefined)
return row.index;
}
return -1;
}
// Searchs the value using a loop.
var data = this._data;
switch (this.columns[columnIndex].type)
{
case Type.TIMESTAMP:
case Type.DATE_TIME:
case Type.DATE:
{
for (var i = 0; i < data.length; i++)
if (value === data[i][columnName].toString ())
return i;
for (var i = 0; i < data.length; i++)
if (simpleEquals (data[i][columnName], value))
return i;
break;
}
default:
for (var i = 0; i < data.length; i++)
if (value === data[i][columnName])
return i;
}
return -1;
}
});

View File

@ -61,17 +61,15 @@ module.exports = new Class
,getMethod: function (value, binded)
{
if (this.thisArg)
{
var method = this.thisArg[value];
if (method && binded)
method = method.bind (this.thisArg);
}
else
var method = window[value];
if (method && binded)
method = method.bind (this.thisArg);
if (method === undefined)
this.builder._showError ('Function \'%s\' not found', value);
this.builder.showError ('Function \'%s\' not found', value);
return method;
}

View File

@ -23,7 +23,6 @@ Vn = module.exports = {
,Spec : require ('./spec')
,ModelIface : require ('./model-iface')
,ModelProxy : require ('./model-proxy')
,JsonModel : require ('./json-model')
,IteratorIface : require ('./iterator-iface')
,Iterator : require ('./iterator')
,Form : require ('./form')

View File

@ -31,7 +31,7 @@ Hedera.ShelvesReport = new Class
{
// Fetch query data
var row = resultSet.fetchObject ();
var row = resultSet.fetchRow ();
// Calculates the scale
@ -61,9 +61,9 @@ Hedera.ShelvesReport = new Class
var items = this.items = [];
var remainings = this.remainings = [];
var res = resultSet.fetchResult ();
var res = resultSet.fetchArray ();
if (res.data.length == 0)
if (res.length == 0)
{
Htk.Toast.showError (_('No items found, check that all fields are correct'));
return;
@ -71,28 +71,29 @@ Hedera.ShelvesReport = new Class
var boxScale = scale * 10;
while (row = res.fetchObject ())
if (!this.maxAmount || row.etiquetas <= this.maxAmount)
{
items.push ({
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
,boxHeight: row.z * boxScale
,boxWidth: row.x * boxScale
,boxDepth: row.y * boxScale
});
}
else
{
remainings.push ({
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
});
}
res.forEach (function (row) {
if (!this.maxAmount || row.etiquetas <= this.maxAmount)
{
items.push ({
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
,boxHeight: row.z * boxScale
,boxWidth: row.x * boxScale
,boxDepth: row.y * boxScale
});
}
else
{
remainings.push ({
id: row.Id_Article
,name: row.Article
,packing: row.packing
,amount: row.etiquetas
});
}
}, this);
// Intializes the allocator

View File

@ -30,6 +30,9 @@ var baseConfig = {
'/usr/lib/node_modules'
]
},
node: {
__dirname: true
},
plugins: [
new webpack.DefinePlugin ({
_DEV_MODE: devMode,