-
-
-
- SELECT vu.userFk userId, vu.stamp, u.nickname, s.lastUpdate,
- a.platform, a.browser, a.version, u.name user
- FROM userSession s
- JOIN visitUser vu ON vu.id = s.userVisitFk
- JOIN visitAccess ac ON ac.id = vu.accessFk
- JOIN visitAgent a ON a.id = ac.agentFk
- JOIN visit v ON v.id = a.visitFk
- JOIN account.user u ON u.id = vu.userFk
- ORDER BY lastUpdate DESC
-
-
+
+
-
-
-
+ SELECT vu.userFk userId, vu.stamp, u.nickname, s.lastUpdate,
+ a.platform, a.browser, a.version, u.name user
+ FROM userSession s
+ JOIN visitUser vu ON vu.id = s.userVisitFk
+ JOIN visitAccess ac ON ac.id = vu.accessFk
+ JOIN visitAgent a ON a.id = ac.agentFk
+ JOIN visit v ON v.id = a.visitFk
+ JOIN account.user u ON u.id = vu.userFk
+ ORDER BY lastUpdate DESC
+
+
+
+
+
diff --git a/forms/ecomerce/checkout/locale/ca.yml b/forms/ecomerce/checkout/locale/ca.yml
index 5846dff5..41a84a8f 100644
--- a/forms/ecomerce/checkout/locale/ca.yml
+++ b/forms/ecomerce/checkout/locale/ca.yml
@@ -11,7 +11,7 @@ AddressQuestion: On vols rebre la comanda?
AddressQuestionPickup: A què direcció vols associar la comanda? (Opcional)
AgencyQuestion: Com vols rebre la comanda?
PickupWarehouseQuestion: En quin magatzem vols recollir la comanda?
-ConfirmToAccessCatalog: Confirma les dades per accedir al catàleg
+ConfirmData: Confirma les dades
Arrival: Arribada
Pickup: Recollida
Agency: Agència
diff --git a/forms/ecomerce/checkout/locale/en.yml b/forms/ecomerce/checkout/locale/en.yml
index 45a54a7b..c9c94c90 100644
--- a/forms/ecomerce/checkout/locale/en.yml
+++ b/forms/ecomerce/checkout/locale/en.yml
@@ -11,7 +11,7 @@ AddressQuestion: Where do you want to receive the order?
AddressQuestionPickup: To which address do you want to associate the order? (Optional)
AgencyQuestion: How you want to receive the order?
PickupWarehouseQuestion: What store you want to pickup your order?
-ConfirmToAccessCatalog: Confirm the data to access the catalog
+ConfirmData: Confirm the data
Arrival: Arrival
Pickup: Pickup
Agency: Agency
diff --git a/forms/ecomerce/checkout/locale/es.yml b/forms/ecomerce/checkout/locale/es.yml
index a699f3e0..b2276376 100644
--- a/forms/ecomerce/checkout/locale/es.yml
+++ b/forms/ecomerce/checkout/locale/es.yml
@@ -11,7 +11,7 @@ AddressQuestion: ¿Dónde quieres recibir el pedido?
AddressQuestionPickup: ¿A qué dirección quieres asociar el pedido? (Opcional)
AgencyQuestion: ¿Cómo quieres recibir el pedido?
PickupWarehouseQuestion: ¿En qué almacén quieres recoger el pedido?
-ConfirmToAccessCatalog: Confirma los datos para acceder al catálogo
+ConfirmData: Confirma los datos
Arrival: Llegada
Pickup: Recogida
Agency: Agencia
diff --git a/forms/ecomerce/checkout/locale/fr.yml b/forms/ecomerce/checkout/locale/fr.yml
index 5a04e06a..53166061 100644
--- a/forms/ecomerce/checkout/locale/fr.yml
+++ b/forms/ecomerce/checkout/locale/fr.yml
@@ -11,7 +11,7 @@ AddressQuestion: Adresse livraison?
AddressQuestionPickup: À quelle adresse voulez-vous associer la commande? (Optionnel)
AgencyQuestion: Agence de livraison
PickupWarehouseQuestion: Dans quel magasin vuoulez-vous retirer votre commande?
-ConfirmToAccessCatalog: Confirmez les coordonnées pour accéder au catalogue
+ConfirmData: Confirmez les coordonnées
Arrival: Arrivée
Pickup: Retrait
Agency: Agence
diff --git a/forms/ecomerce/checkout/locale/pt.yml b/forms/ecomerce/checkout/locale/pt.yml
index aa4b59e2..c6f76484 100644
--- a/forms/ecomerce/checkout/locale/pt.yml
+++ b/forms/ecomerce/checkout/locale/pt.yml
@@ -11,7 +11,7 @@ AddressQuestion: Onde queres receber a encomenda?
AddressQuestionPickup: Para qual endereço deseja associar o pedido? (Opcional)
AgencyQuestion: Como queres receber a encomenda?
PickupWarehouseQuestion: Em qual armazém queres levantar a encomenda?
-ConfirmToAccessCatalog: Confirme os dados para entrar no catálogo
+ConfirmData: Confirme os dados
Arrival: Chegada
Pickup: Recolhida
Agency: Agência
diff --git a/forms/ecomerce/checkout/style.css b/forms/ecomerce/checkout/style.css
index d1dc875f..61885aad 100644
--- a/forms/ecomerce/checkout/style.css
+++ b/forms/ecomerce/checkout/style.css
@@ -1,89 +1,54 @@
-.checkout
-{
- padding: 1em;
- max-width: 40em;
- margin: 0 auto;
-}
-.checkout .bar
-{
- margin-bottom: 1em;
-}
-.checkout .form
-{
- max-width: 40em;
- padding: 4em 2em;
+
+.checkout .bar {
+ margin-bottom: 16px;
}
/* Step */
.answers button,
.answers p,
-.radio > div
-{
+.radio > div {
+ font-size: 1.2em;
+}
+.answers .htk-select {
+ max-width: 15em;
+ margin: 0 auto;
font-size: 1.4em;
}
-.answers .htk-select
-{
- max-width: 10em;
- display: block;
- margin: 0 auto;
- font-size: 1.6em;
- height: 1.8em;
-}
-.answers p
-{
+.answers p {
margin: 0.3em 0;
}
-.target
-{
+.target {
max-width: 28em;
margin: 0 auto;
}
-.address
-{
+.address {
border-radius: 0.1em;
padding: 0.6em 1.4em;
}
-.address.selected
-{
+.address.selected {
background-color: rgba(1, 1, 1, .1);
}
-.address:hover
-{
+.address:hover {
cursor: pointer;
background-color: rgba(1, 1, 1, .05);
}
-.address p.consignee
-{
+.address p.consignee {
font-weight: bold;
}
-.radio
-{
+.radio {
max-width: 20em;
margin: 0 auto;
}
-.radio > div
-{
+.radio > div {
padding: 0.5em;
- border-top: 1px solid #AAA;
}
-.radio > div:first-child
-{
- border-top: none;
-}
-.thin-calendar
-{
- width: inherit;
+.thin-calendar {
max-width: 24em;
margin: 0 auto;
- box-shadow: 0 0.1em 0.3em #ccc;
+ box-shadow: none;
}
-.thin-calendar tr > th
-{
- color: white;
-}
-.htk-assistant .thin
-{
+.htk-assistant .thin {
float: right;
}
diff --git a/forms/ecomerce/checkout/ui.xml b/forms/ecomerce/checkout/ui.xml
index 47100763..ec6db8da 100644
--- a/forms/ecomerce/checkout/ui.xml
+++ b/forms/ecomerce/checkout/ui.xml
@@ -68,144 +68,146 @@
on-click="onCancelClick"/>
-
-
-
-
-
-
-
-
DeliveryOrPickupQuestion
-
-
-
-
+
+
+
+
+
+
+
+
+
DeliveryOrPickupQuestion
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SELECT a.id, a.nickname, p.name province, a.city, a.street, a.isActive, c.country
- FROM myAddress a
- LEFT JOIN vn.province p ON p.id = a.provinceFk
- JOIN vn.country c ON c.id = p.countryFk
- WHERE a.isActive
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
AgencyQuestion
-
-
-
-
-
-
PickupWarehouseQuestion
-
-
-
-
-
-
ConfirmToAccessCatalog
-
-
- Arrival
-
-
-
-
-
-
- Agency
-
-
-
-
-
-
-
ConfirmToAccessCatalog
-
-
- Pickup
-
-
-
- Warehouse
-
-
-
-
-
-
+
+
+
+
+
+
+
+ SELECT a.id, a.nickname, p.name province, a.city, a.street, a.isActive, c.country
+ FROM myAddress a
+ LEFT JOIN vn.province p ON p.id = a.provinceFk
+ JOIN vn.country c ON c.id = p.countryFk
+ WHERE a.isActive
+
+
+
-
-
-
-
-
- SELECT id, name FROM vn2008.warehouse
- WHERE reserve ORDER BY name
-
-
-
-
-
-
-
-
-
-
- SELECT id, reino FROM vn2008.reinos
- WHERE display != FALSE ORDER BY reino
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ SELECT id, name FROM vn2008.warehouse
+ WHERE reserve ORDER BY name
+
+
+
+
+
+
+
+
+
+
+ SELECT id, reino FROM vn2008.reinos
+ WHERE display != FALSE ORDER BY reino
+
+
+
+
+
+
+
diff --git a/forms/reports/shelves/shelves.js b/forms/reports/shelves/shelves.js
index 483ebdfb..221f37df 100644
--- a/forms/reports/shelves/shelves.js
+++ b/forms/reports/shelves/shelves.js
@@ -1,16 +1,13 @@
-Hedera.Shelves = new Class
-({
+Hedera.Shelves = new Class({
Extends: Hedera.Form
- ,activate: function ()
- {
- this.$('date').value = new Date ();
+ ,activate: function() {
+ this.$('date').value = new Date();
this.$('useIds').value = false;
}
- ,onConfigChange: function ()
- {
+ ,onConfigChange: function() {
var fields = [
'realm'
,'family'
@@ -24,11 +21,10 @@ Hedera.Shelves = new Class
];
for (var i = 0; i < fields.length; i++)
- this.$(fields[i]).value = this.$('config').get (fields[i]);
+ this.$(fields[i]).value = this.$('config').get(fields[i]);
}
- ,onPreviewClick: function ()
- {
+ ,onPreviewClick: function() {
var fields = [
'family'
,'warehouse'
@@ -42,12 +38,12 @@ Hedera.Shelves = new Class
,'date'
];
- var batch = new Sql.Batch ();
+ var batch = new Sql.Batch();
for (var i = 0; i < fields.length; i++)
- batch.addValue (fields[i], this.$(fields[i]).value);
+ batch.addValue(fields[i], this.$(fields[i]).value);
- this.gui.openReport ('shelves-report', batch);
+ this.gui.openReport('shelves-report', batch);
}
});
diff --git a/forms/reports/shelves/style.css b/forms/reports/shelves/style.css
index 0be2e7cf..e69de29b 100644
--- a/forms/reports/shelves/style.css
+++ b/forms/reports/shelves/style.css
@@ -1,30 +0,0 @@
-
-.shelves
-{
- padding: 1em;
-}
-.shelves .box
-{
- max-width: 30em;
- padding: 2em;
-}
-.shelves .form
-{
- max-width: 25em;
- margin: auto;
-}
-.shelves .form-group
-{
- padding: 0.4em;
-}
-.shelves form label
-{
- display: block;
- margin-bottom: 0.5em;
-}
-.shelves input[type=text],
-.shelves select
-{
- margin: 0;
- width: 100%;
-}
diff --git a/forms/reports/shelves/ui.xml b/forms/reports/shelves/ui.xml
index e1fa2a94..8bb26e4f 100644
--- a/forms/reports/shelves/ui.xml
+++ b/forms/reports/shelves/ui.xml
@@ -16,96 +16,100 @@
+ on-click="this.onPreviewClick()"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ SELECT id, reino FROM vn2008.reinos
+ WHERE display != FALSE ORDER BY reino
+
+
+
+
+
+
+
+
+
+ SELECT tipo_id, Tipo FROM vn2008.Tipos
+ WHERE reino_id = #realm ORDER BY Tipo
+
+
- SELECT id, reino FROM vn2008.reinos
- WHERE display != FALSE ORDER BY reino
+
-
-
-
-
-
-
-
-
- SELECT tipo_id, Tipo FROM vn2008.Tipos
- WHERE reino_id = #realm ORDER BY Tipo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SELECT id, name FROM vn2008.warehouse
- WHERE reserve ORDER BY name
-
-
-
-
-
-
-
-
-
- SELECT id, name FROM shelf
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ SELECT id, name FROM vn2008.warehouse
+ WHERE reserve ORDER BY name
+
+
+
+
+
+
+
+
+
+ SELECT id, name FROM shelf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ Show packing
+
+
+
+
-
-
+ Stack different items
+
+
+
+
+ Use ids instead of names
+
diff --git a/image/family/black/accessory.svg b/image/family/black/accessory.svg
new file mode 100644
index 00000000..f49d134a
--- /dev/null
+++ b/image/family/black/accessory.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/artificial.svg b/image/family/black/artificial.svg
new file mode 100644
index 00000000..83000adc
--- /dev/null
+++ b/image/family/black/artificial.svg
@@ -0,0 +1,59 @@
+
+
+
+
diff --git a/image/family/black/flower.svg b/image/family/black/flower.svg
new file mode 100644
index 00000000..cd941b4d
--- /dev/null
+++ b/image/family/black/flower.svg
@@ -0,0 +1,76 @@
+
+
+
+
diff --git a/image/family/black/fruit.svg b/image/family/black/fruit.svg
new file mode 100644
index 00000000..0c1ad7e0
--- /dev/null
+++ b/image/family/black/fruit.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/greenery.svg b/image/family/black/greenery.svg
new file mode 100644
index 00000000..e99f102a
--- /dev/null
+++ b/image/family/black/greenery.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/handmade.svg b/image/family/black/handmade.svg
new file mode 100644
index 00000000..1ff9644d
--- /dev/null
+++ b/image/family/black/handmade.svg
@@ -0,0 +1,59 @@
+
+
+
+
diff --git a/image/family/black/handmadeArtificial.svg b/image/family/black/handmadeArtificial.svg
new file mode 100644
index 00000000..f4ea2768
--- /dev/null
+++ b/image/family/black/handmadeArtificial.svg
@@ -0,0 +1,59 @@
+
+
+
+
diff --git a/image/family/black/mortuary.svg b/image/family/black/mortuary.svg
new file mode 100644
index 00000000..979e5118
--- /dev/null
+++ b/image/family/black/mortuary.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/pets.svg b/image/family/black/pets.svg
new file mode 100644
index 00000000..437f7648
--- /dev/null
+++ b/image/family/black/pets.svg
@@ -0,0 +1,79 @@
+
+
diff --git a/image/family/black/plant.svg b/image/family/black/plant.svg
new file mode 100644
index 00000000..67e2240a
--- /dev/null
+++ b/image/family/black/plant.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/preserved.svg b/image/family/black/preserved.svg
new file mode 100644
index 00000000..b88d5399
--- /dev/null
+++ b/image/family/black/preserved.svg
@@ -0,0 +1,49 @@
+
+
+
+
diff --git a/image/family/black/treatments.svg b/image/family/black/treatments.svg
new file mode 100644
index 00000000..69dcbf82
--- /dev/null
+++ b/image/family/black/treatments.svg
@@ -0,0 +1,59 @@
+
+
+
+
diff --git a/image/logo-dark.svg b/image/logo-dark.svg
index 6cf594a7..4d53b7b3 100644
--- a/image/logo-dark.svg
+++ b/image/logo-dark.svg
@@ -1,6 +1,4 @@
-
-
\ No newline at end of file
+ inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
+ sodipodi:docname="logo-dark.svg">image/svg+xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/image/logo-margin.svg b/image/logo-margin.svg
new file mode 100644
index 00000000..57e0a756
--- /dev/null
+++ b/image/logo-margin.svg
@@ -0,0 +1,77 @@
+
+
+
diff --git a/image/logo.svg b/image/logo.svg
index bba010e3..23b6df49 100644
--- a/image/logo.svg
+++ b/image/logo.svg
@@ -1,6 +1,4 @@
-
-
\ No newline at end of file
+ style="fill:#97d700;fill-opacity:1" />
+
diff --git a/image/social/mail.svg b/image/social/mail.svg
new file mode 100644
index 00000000..d94d03c3
--- /dev/null
+++ b/image/social/mail.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/image/social/phone.svg b/image/social/phone.svg
new file mode 100644
index 00000000..34fb46ff
--- /dev/null
+++ b/image/social/phone.svg
@@ -0,0 +1,43 @@
+
+
+
diff --git a/index.js b/index.js
new file mode 100644
index 00000000..aa8a23f4
--- /dev/null
+++ b/index.js
@@ -0,0 +1,60 @@
+__webpack_public_path__ = _PUBLIC_PATH;
+
+require('hedera/hedera');
+
+window.onload = function() {
+ loadLocale(main);
+}
+
+function main(req) {
+ if (req)
+ onLocaleLoad(req);
+
+ hederaWeb = new Hedera.App();
+ hederaWeb.run();
+}
+
+function loadLocale(cb) {
+ Vn.Locale.init();
+ var lang = Vn.Locale.language;
+
+ var req = require.context('js', true, /locale\/en.yml$/);
+ onLocaleLoad(req);
+
+ switch (lang) {
+ case 'ca':
+ require([], function() {
+ cb(require.context('js', true, /locale\/ca.yml$/));
+ });
+ break;
+ case 'es':
+ require([], function() {
+ cb(require.context('js', true, /locale\/es.yml$/));
+ });
+ break;
+ case 'fr':
+ require([], function() {
+ cb(require.context('js', true, /locale\/fr.yml$/));
+ });
+ break;
+ case 'mn':
+ require([], function() {
+ cb(require.context('js', true, /locale\/mn.yml$/));
+ });
+ break;
+ case 'pt':
+ require([], function() {
+ cb(require.context('js', true, /locale\/pt.yml$/));
+ });
+ break;
+ default:
+ cb();
+ }
+}
+
+function onLocaleLoad(req) {
+ var keys = req.keys();
+
+ for (var i = 0; i < keys.length; i++)
+ Vn.Locale.add(req(keys[i]));
+}
diff --git a/js/db/calc-sum.js b/js/db/calc-sum.js
index 8755e65e..9314a236 100644
--- a/js/db/calc-sum.js
+++ b/js/db/calc-sum.js
@@ -3,7 +3,7 @@ var Calc = require ('./calc');
/**
* Computes a sum of data in the model.
- **/
+ */
module.exports = new Class
({
Extends: Calc
diff --git a/js/db/calc.js b/js/db/calc.js
index 17e8d91f..17851a6b 100644
--- a/js/db/calc.js
+++ b/js/db/calc.js
@@ -4,7 +4,7 @@ var SimpleIterator = require ('./simple-iterator');
/**
* Interface for handle foreach operations on the model.
- **/
+ */
module.exports = new Class
({
Extends: Vn.Param
@@ -132,23 +132,23 @@ module.exports = new Class
* You don't need to define it if model isn't updatable.
*
* @param {integer} row The row number
- **/
+ */
,before: function (row) {}
/**
* Called after each update or insert row operation.
*
* @param {integer} row The row number
- **/
+ */
,after: function (row) {}
/**
* Called before each model refresh.
- **/
+ */
,init: function () {}
/**
* Called when an operation in the model is complete.
- **/
+ */
,done: function () {}
});
diff --git a/js/db/form.js b/js/db/form.js
index b97b8edb..53affd10 100644
--- a/js/db/form.js
+++ b/js/db/form.js
@@ -11,7 +11,7 @@ module.exports = new Class
{
/**
* The model associated to this form.
- **/
+ */
model:
{
type: Model
@@ -30,7 +30,7 @@ module.exports = new Class
},
/**
* The row where the form positioned, has -1 if the row is unselected.
- **/
+ */
row:
{
type: Number
@@ -51,7 +51,7 @@ module.exports = new Class
},
/**
* The number of rows in the form.
- **/
+ */
numRows:
{
type: Number
@@ -65,7 +65,7 @@ module.exports = new Class
},
/**
* Checks if the form data is ready.
- **/
+ */
ready:
{
type: Boolean
diff --git a/js/db/iterator.js b/js/db/iterator.js
index 346f4d7e..c69d6b48 100644
--- a/js/db/iterator.js
+++ b/js/db/iterator.js
@@ -1,36 +1,30 @@
-var Model = require ('./model');
+var Model = require('./model');
-module.exports = new Class
-({
- Properties:
- {
+module.exports = new Class({
+ Properties: {
/**
* The model associated to this form.
- **/
- model:
- {
+ */
+ model: {
type: Model
},
/**
* The row where the form positioned, has -1 if the row is unselected.
- **/
- row:
- {
+ */
+ row: {
type: Number
},
/**
* The number of rows in the form.
- **/
- numRows:
- {
+ */
+ numRows: {
type: Number
},
/**
* Checks if the form data is ready.
- **/
- ready:
- {
+ */
+ ready: {
type: Boolean
}
}
@@ -38,18 +32,16 @@ module.exports = new Class
,_model: null
,_row: -1
- ,refresh: function ()
- {
+ ,refresh: function() {
if (this._model)
- this._model.refresh ();
+ this._model.refresh();
}
/**
* Emits the 'iter-changed' signal on the form.
- **/
- ,iterChanged: function ()
- {
- this.signalEmit ('iter-changed');
+ */
+ ,iterChanged: function() {
+ this.signalEmit('iter-changed');
}
/**
@@ -57,45 +49,49 @@ module.exports = new Class
*
* @param {String} columnName The column name
* @return {integer} The column index or -1 if column not exists
- **/
- ,getColumnIndex: function (columnName)
- {
+ */
+ ,getColumnIndex: function(columnName) {
if (this._model)
- return this._model.getColumnIndex (columnName);
+ return this._model.getColumnIndex(columnName);
return -1;
}
- ,insertRow: function ()
- {
+ ,insertRow: function() {
if (this._model)
- this.row = this._model.insertRow ();
+ this.row = this._model.insertRow();
}
- ,performOperations: function ()
- {
+ ,performOperations: function() {
if (this._model)
- this._model.performOperations ();
+ this._model.performOperations();
}
/**
* Removes the current row.
- **/
- ,deleteRow: function ()
- {
+ */
+ ,deleteRow: function() {
if (this._row >= 0)
- this._model.deleteRow (this._row);
+ this._model.deleteRow(this._row);
}
-
+
+ /**
+ * Gets the row as object.
+ *
+ * @return {Object} The row
+ */
+ ,getObject: function() {
+ return this._model.getObject(this._row);
+ }
+
/**
* Gets a value from the form.
*
* @param {String} columnName The column name
* @return {Object} The value
- **/
- ,get: function (columnName)
- {
- return this._model.get (this._row, columnName);
+ */
+ ,get: function(columnName) {
+ return this._model.get(this._row, columnName);
}
/**
@@ -103,10 +99,9 @@ module.exports = new Class
*
* @param {String} columnName The column name
* @param {Object} value The new value
- **/
- ,set: function (columnName, value)
- {
- return this._model.set (this._row, columnName, value);
+ */
+ ,set: function(columnName, value) {
+ return this._model.set(this._row, columnName, value);
}
/**
@@ -114,10 +109,9 @@ module.exports = new Class
*
* @param {String} columnName The column index
* @return {Object} The value
- **/
- ,getByIndex: function (column)
- {
- return this._model.getByIndex (this._row, column);
+ */
+ ,getByIndex: function(column) {
+ return this._model.getByIndex(this._row, column);
}
/**
@@ -125,10 +119,9 @@ module.exports = new Class
*
* @param {String} columnName The column index
* @param {Object} value The new value
- **/
- ,setByIndex: function (column, value)
- {
- return this._model.setByIndex (this._row, column, value);
+ */
+ ,setByIndex: function(column, value) {
+ return this._model.setByIndex(this._row, column, value);
}
});
diff --git a/js/db/model.js b/js/db/model.js
index 469140d7..e8b67ef3 100644
--- a/js/db/model.js
+++ b/js/db/model.js
@@ -1,5 +1,5 @@
-var Connection = require ('./connection');
+var Connection = require('./connection');
/**
* Class to handle the Database select results. Also allows
@@ -9,174 +9,152 @@ var Connection = require ('./connection');
* Note that table and column names must be unique in the selection query,
* otherwise updates are not allowed on that table/column. If two tables or
* columns have the same name, an alias should be used to make it updatable.
- **/
-var Model = new Class ();
+ */
+var Model = new Class();
module.exports = Model;
-var Status =
-{
+var Status = {
CLEAN : 1
,LOADING : 2
,READY : 3
,ERROR : 4
};
-var Mode =
-{
+var Mode = {
ON_CHANGE : 1
,ON_DEMAND : 2
};
-var Operation =
-{
+var Operation = {
INSERT : 1 << 1
,UPDATE : 1 << 2
,DELETE : 1 << 3
};
-var SortWay =
-{
+var SortWay = {
ASC : 1
,DESC : 2
};
-Model.extend
-({
+Model.extend({
Status: Status
,Mode: Mode
,Operation: Operation
,SortWay: SortWay
});
-Model.implement
-({
+Model.implement({
Extends: Vn.Object
,Tag: 'db-model'
- ,Properties:
- {
+ ,Properties: {
/**
* The connection used to execute the statement.
- **/
+ */
conn:
{
type: Connection
- ,set: function (x)
- {
+ ,set: function(x) {
this._conn = x;
- this._autoLoad ();
+ this._autoLoad();
}
- ,get: function ()
- {
+ ,get: function() {
return this._conn;
}
},
/**
* The result index.
- **/
+ */
resultIndex:
{
type: Number
- ,set: function (x)
- {
+ ,set: function(x) {
this._resultIndex = x;
}
- ,get: function ()
- {
+ ,get: function() {
return this._resultIndex;
}
},
/**
* The batch used to execute the statement.
- **/
+ */
batch:
{
type: Sql.Batch
- ,set: function (x)
- {
- this.link ({_batch: x}, {'changed': this._autoLoad});
- this._autoLoad ();
+ ,set: function(x) {
+ this.link({_batch: x}, {'changed': this._autoLoad});
+ this._autoLoad();
}
- ,get: function ()
- {
+ ,get: function() {
return this._batch;
}
},
/**
* The model select statement.
- **/
+ */
stmt:
{
type: Sql.Stmt
- ,set: function (x)
- {
+ ,set: function(x) {
this._stmt = x;
- this._autoLoad ();
+ this._autoLoad();
}
- ,get: function ()
- {
+ ,get: function() {
return this._stmt;
}
},
/**
* The model query.
- **/
+ */
query:
{
type: String
- ,set: function (x)
- {
- this.stmt = new Sql.String ({query: x});
+ ,set: function(x) {
+ this.stmt = new Sql.String({query: x});
}
- ,get: function ()
- {
+ ,get: function() {
if (this._stmt)
- return this._stmt.render (null);
+ return this._stmt.render(null);
else
return null;
}
},
/**
* The main table.
- **/
+ */
mainTable:
{
type: String
- ,set: function (x)
- {
+ ,set: function(x) {
this._mainTable = null;
this._requestedMainTable = x;
- this._refreshMainTable ();
+ this._refreshMainTable();
}
- ,get: function ()
- {
+ ,get: function() {
return this._mainTable;
}
},
/**
* Determines if the model is updatable.
- **/
+ */
updatable:
{
type: Boolean
- ,set: function (x)
- {
+ ,set: function(x) {
this._updatable = false;
this._requestedUpdatable = x;
- this._refreshUpdatable ();
+ this._refreshUpdatable();
}
- ,get: function ()
- {
+ ,get: function() {
return this._updatable;
}
},
/**
* The number of rows in the model.
- **/
+ */
numRows:
{
type: Number
- ,get: function ()
- {
+ ,get: function() {
if (this.data)
return this.data.length;
@@ -185,29 +163,27 @@ Model.implement
},
/**
* The current status of the model.
- **/
+ */
status:
{
type: Number
- ,get: function ()
- {
+ ,get: function() {
return this._status;
}
},
/**
* Checks if the model data is ready.
- **/
+ */
ready:
{
type: Boolean
- ,get: function ()
- {
+ ,get: function() {
return this._status == Status.READY;
}
},
/**
* Update mode.
- **/
+ */
mode:
{
enumType: Mode
@@ -215,7 +191,7 @@ Model.implement
},
/**
* Wether to execute the model query automatically.
- **/
+ */
autoLoad:
{
type: Boolean
@@ -248,22 +224,19 @@ Model.implement
,_defaults: []
,_requestedMainTable: null
- ,initialize: function (props)
- {
- this.parent (props);
- this._cleanData ();
- this._setStatus (Status.CLEAN);
+ ,initialize: function(props) {
+ this.parent(props);
+ this._cleanData();
+ this._setStatus(Status.CLEAN);
}
- ,appendChild: function (child)
- {
+ ,appendChild: function(child) {
if (child.nodeType === Node.TEXT_NODE)
this.query = child.textContent;
}
- ,loadXml: function (builder, node)
- {
- this.parent (builder, node);
+ ,loadXml: function(builder, node) {
+ this.parent(builder, node);
var query = node.firstChild.nodeValue;
@@ -271,76 +244,63 @@ Model.implement
this.query = query;
}
- ,_autoLoad: function ()
- {
+ ,_autoLoad: function() {
if (this.autoLoad)
- this.refresh ();
+ this.refresh();
else
- this.clean ();
+ this.clean();
}
/**
* Refresh the model data reexecuting the query on the database.
- **/
- ,refresh: function ()
- {
+ */
+ ,refresh: function() {
var ready = false;
- if (this._stmt && this._conn)
- {
- var ids = this._stmt.findHolders ();
+ if (this._stmt && this._conn) {
+ var ids = this._stmt.findHolders();
- if (ids)
- {
- if (this._batch && this._batch.isReady ())
- {
+ if (ids) {
+ if (this._batch && this._batch.isReady()) {
ready = true;
for (var i = 0; i < ids.length; i++)
- if (!this._batch.get (ids[i]))
- {
+ if (!this._batch.get(ids[i])) {
ready = false;
break;
}
}
- }
- else
+ } else
ready = true;
}
- if (ready)
- {
- this._setStatus (Status.LOADING);
- this._conn.execStmt (this._stmt, this._selectDone.bind (this), this._batch);
- }
- else
- this.clean ();
+ if (ready) {
+ this._setStatus(Status.LOADING);
+ this._conn.execStmt(this._stmt, this._selectDone.bind(this), this._batch);
+ } else
+ this.clean();
}
- ,clean: function ()
- {
- this._cleanData ();
- this._setStatus (Status.CLEAN);
+ ,clean: function() {
+ this._cleanData();
+ this._setStatus(Status.CLEAN);
}
- ,_selectDone: function (resultSet)
- {
+ ,_selectDone: function(resultSet) {
var result;
var dataResult;
- this._cleanData ();
+ this._cleanData();
try {
- for (var i = 0; result = resultSet.fetchResult (); i++)
+ for (var i = 0; result = resultSet.fetchResult(); i++)
if (i == this._resultIndex)
dataResult = result;
if (!dataResult || typeof dataResult !== 'object')
- throw new Error ('The provided statement doesn\'t return a result set');
- }
- catch (e)
- {
- this._setStatus (Status.ERROR);
+ throw new Error('The provided statement doesn\'t return a result set');
+ } catch (e) {
+ this._setStatus(Status.ERROR);
throw e;
}
@@ -348,34 +308,32 @@ Model.implement
this.tables = dataResult.tables;
this.columns = dataResult.columns;
this.columnMap = dataResult.columnMap;
- this._repairColumns ();
- this._refreshRowIndexes (0);
- this._refreshMainTable ();
+ this._repairColumns();
+ this._refreshRowIndexes(0);
+ this._refreshMainTable();
for (column in this._requestedIndexes)
- this._buildIndex (column);
+ this._buildIndex(column);
var sortColumn = -1;
if (this._requestedSortName)
- sortColumn = this.getColumnIndex (this._requestedSortName);
+ sortColumn = this.getColumnIndex(this._requestedSortName);
else if (this._requestedSortIndex !== -1
- && this.checkColExists (this._requestedSortIndex))
+ && this.checkColExists(this._requestedSortIndex))
sortColumn = this._requestedSortIndex;
if (sortColumn !== -1)
- this._realSort (sortColumn, this._sortWay);
+ this._realSort(sortColumn, this._sortWay);
- this._setStatus (Status.READY);
+ this._setStatus(Status.READY);
}
- ,_refreshRowIndexes: function (start)
- {
+ ,_refreshRowIndexes: function(start) {
for (var i = start; i < this.data.length; i++)
this.data[i].index = i;
- if (this._operationsMap)
- {
+ if (this._operationsMap) {
this._operationsMap = {};
for (var i = 0; i < this._operations.length; i++)
@@ -383,28 +341,25 @@ Model.implement
}
}
- ,_cleanData: function ()
- {
+ ,_cleanData: function() {
this.data = null;
this.tables = null;
this.columns = null;
this.columnMap = null;
this._sortColumn = -1;
this._indexes = [];
- this._resetOperations ();
+ this._resetOperations();
}
- ,_refreshUpdatable: function ()
- {
+ ,_refreshUpdatable: function() {
var oldValue = this._updatable;
this._updatable = this._mainTable !== null && this._requestedUpdatable;
if (oldValue != this._updatable)
- this.signalEmit ('updatable-changed');
+ this.signalEmit('updatable-changed');
}
- ,_refreshMainTable: function ()
- {
+ ,_refreshMainTable: function() {
var newMainTable = null;
var tables = this.tables;
@@ -412,14 +367,13 @@ Model.implement
for (var i = 0; i < tables.length; i++)
if (tables[i].pks.length > 0)
if (!this._requestedMainTable
- || tables[i].name === this._requestedMainTable)
- {
+ || tables[i].name === this._requestedMainTable) {
newMainTable = i;
break;
}
this._mainTable = newMainTable;
- this._refreshUpdatable ();
+ this._refreshUpdatable();
}
/**
@@ -428,11 +382,9 @@ Model.implement
* @param {String} field The destination field name
* @param {String} table The destination table name
* @param {Sql.Expr} srcColumn The default value expression
- **/
- ,setDefault: function (field, table, expr)
- {
- this._defaults.push
- ({
+ */
+ ,setDefault: function(field, table, expr) {
+ this._defaults.push({
field: field
,table: table
,expr: expr
@@ -445,11 +397,9 @@ Model.implement
* @param {String} field The destination field name
* @param {String} table The destination table name
* @param {Object} value The default value
- **/
- ,setDefaultFromValue: function (field, table, value)
- {
- this._defaults.push
- ({
+ */
+ ,setDefaultFromValue: function(field, table, value) {
+ this._defaults.push({
field: field
,table: table
,value: value
@@ -463,11 +413,9 @@ Model.implement
* @param {String} field The destination field name
* @param {String} table The destination table name
* @param {String} srcColumn The source column
- **/
- ,setDefaultFromColumn: function (field, table, srcColumn)
- {
- this._defaults.push
- ({
+ */
+ ,setDefaultFromColumn: function(field, table, srcColumn) {
+ this._defaults.push({
field: field
,table: table
,srcColumn: srcColumn
@@ -479,9 +427,8 @@ Model.implement
*
* @param {integer} column The column index
* @return {Boolean} %true if column exists, %false otherwise
- **/
- ,checkColExists: function (column)
- {
+ */
+ ,checkColExists: function(column) {
return this.columns
&& column >= 0
&& column < this.columns.length;
@@ -492,21 +439,19 @@ Model.implement
*
* @param {integer} rowIndex The row index
* @return {Boolean} %true if row exists, %false otherwise
- **/
- ,checkRowExists: function (rowIndex)
- {
+ */
+ ,checkRowExists: function(rowIndex) {
return this.data
&& rowIndex >= 0
&& rowIndex < this.data.length;
}
- ,_checkTableUpdatable: function (tableIndex)
- {
+ ,_checkTableUpdatable: function(tableIndex) {
var tableUpdatable = tableIndex !== null
&& this.tables[tableIndex].pks.length > 0;
if (!tableUpdatable)
- console.warn ("Db.Model: Table %s is not updatable",
+ console.warn("Db.Model: Table %s is not updatable",
this.tables[tableIndex].name);
return tableUpdatable;
@@ -517,9 +462,8 @@ Model.implement
*
* @param {string} columnName The column name
* @return {number} The column index or -1 if column not exists
- **/
- ,getColumnIndex: function (columnName)
- {
+ */
+ ,getColumnIndex: function(columnName) {
var index;
if (this.columnMap
@@ -528,6 +472,23 @@ Model.implement
return -1;
}
+
+ /**
+ * Gets the row as object.
+ *
+ * @param {number} rowIndex The row index
+ * @return {Object} The row
+ */
+ ,getObject: function(rowIndex) {
+ if (!this.checkRowExists(rowIndex))
+ return undefined;
+
+ const row = this.data[rowIndex];
+ const object = {};
+ for(let i = 0; i < row.length; i++)
+ object[this.columns[i].name] = row[i];
+ return object;
+ }
/**
* Gets a value from the model.
@@ -535,13 +496,12 @@ Model.implement
* @param {number} rowIndex The row index
* @param {string} columnName The column name
* @return {mixed} The value
- **/
- ,get: function (rowIndex, columnName)
- {
- var index = this.getColumnIndex (columnName);
+ */
+ ,get: function(rowIndex, columnName) {
+ var index = this.getColumnIndex(columnName);
if (index != -1)
- return this.getByIndex (rowIndex, index);
+ return this.getByIndex(rowIndex, index);
return undefined;
}
@@ -552,15 +512,14 @@ Model.implement
* @param {number} rowIndex The row index
* @param {string} columnName The column name
* @param {mixed} value The new value
- **/
- ,set: function (rowIndex, columnName, value)
- {
- var index = this.getColumnIndex (columnName);
+ */
+ ,set: function(rowIndex, columnName, value) {
+ var index = this.getColumnIndex(columnName);
if (index != -1)
- this.setByIndex (rowIndex, index, value);
+ this.setByIndex(rowIndex, index, value);
else
- console.warn ('Db.Model: Column %s doesn\'t exist', columnName);
+ console.warn('Db.Model: Column %s doesn\'t exist', columnName);
}
/**
@@ -569,10 +528,9 @@ Model.implement
* @param {number} rowIndex The row index
* @param {number} column The column index
* @return {mixed} The value
- **/
- ,getByIndex: function (rowIndex, column)
- {
- if (this.checkRowExists (rowIndex) && this.checkColExists (column))
+ */
+ ,getByIndex: function(rowIndex, column) {
+ if (this.checkRowExists(rowIndex) && this.checkColExists(column))
return this.data[rowIndex][column];
return undefined;
@@ -584,21 +542,20 @@ Model.implement
* @param {number} rowIndex The row index
* @param {number} col The column index
* @param {mixed} value The new value
- **/
- ,setByIndex: function (rowIndex, col, value)
- {
- if (!this.checkRowExists (rowIndex)
- && !this.checkColExists (col))
+ */
+ ,setByIndex: function(rowIndex, col, value) {
+ if (!this.checkRowExists(rowIndex)
+ && !this.checkColExists(col))
return;
var tableIndex = this.columns[col].table;
- if (!this._checkTableUpdatable (tableIndex))
+ if (!this._checkTableUpdatable(tableIndex))
return;
var row = this.data[rowIndex];
- var op = this._createOperation (rowIndex);
+ var op = this._createOperation(rowIndex);
op.type |= Operation.UPDATE;
if (!op.oldValues)
@@ -608,14 +565,12 @@ Model.implement
var tableOp = op.tables[tableIndex];
- if (!tableOp)
- {
+ if (!tableOp) {
tableOp = Operation.UPDATE;
var pks = this.tables[tableIndex].pks;
for (var i = 0; i < pks.length; i++)
- if (!row[pks[i]] && !op.oldValues[pks[i]])
- {
+ if (!row[pks[i]] && !op.oldValues[pks[i]]) {
tableOp = Operation.INSERT;
break;
}
@@ -627,39 +582,35 @@ Model.implement
&& op.oldValues[col] === undefined)
op.oldValues[col] = row[col];
- this.signalEmit ('row-updated-before', rowIndex);
+ this.signalEmit('row-updated-before', rowIndex);
row[col] = value;
- this.signalEmit ('row-updated', rowIndex, [col]);
+ this.signalEmit('row-updated', rowIndex, [col]);
if (this.mode == Mode.ON_CHANGE
&& !(op.type & Operation.INSERT))
- this.performOperations ();
+ this.performOperations();
}
/**
* Deletes a row from the model.
*
* @param {number} rowIndex The row index
- **/
- ,deleteRow: function (rowIndex)
- {
- if (!this.checkRowExists (rowIndex)
- || !this._checkTableUpdatable (this._mainTable))
+ */
+ ,deleteRow: function(rowIndex) {
+ if (!this.checkRowExists(rowIndex)
+ || !this._checkTableUpdatable(this._mainTable))
return;
- var op = this._createOperation (rowIndex);
+ var op = this._createOperation(rowIndex);
op.type |= Operation.DELETE;
- if (!this._requestedMainTable)
- {
- this.signalEmit ('row-deleted-before', rowIndex);
- this.data.splice (rowIndex, 1);
- this.signalEmit ('row-deleted', rowIndex);
- this._refreshRowIndexes (rowIndex);
- }
- else
- {
- this.signalEmit ('row-updated-before', rowIndex);
+ if (!this._requestedMainTable) {
+ this.signalEmit('row-deleted-before', rowIndex);
+ this.data.splice(rowIndex, 1);
+ this.signalEmit('row-deleted', rowIndex);
+ this._refreshRowIndexes(rowIndex);
+ } else {
+ this.signalEmit('row-updated-before', rowIndex);
if (!op.oldValues)
op.oldValues = [];
@@ -667,34 +618,32 @@ Model.implement
var updatedCols = [];
for (var i = 0; i < this.columns.length; i++)
- if (this.columns[i].table == this._mainTable)
- {
+ if (this.columns[i].table == this._mainTable) {
if (op.oldValues[i] === undefined)
op.oldValues[i] = op.row[i];
op.row[i] = null;
- updatedCols.push (i);
+ updatedCols.push(i);
}
- this.signalEmit ('row-updated', rowIndex, updatedCols);
+ this.signalEmit('row-updated', rowIndex, updatedCols);
}
if (this.mode === Mode.ON_CHANGE)
- this.performOperations ();
+ this.performOperations();
}
/**
* Inserts a new row on the model.
*
* @return The index of the inserted row
- **/
- ,insertRow: function ()
- {
- if (!this._checkTableUpdatable (this._mainTable))
+ */
+ ,insertRow: function() {
+ if (!this._checkTableUpdatable(this._mainTable))
return -1;
var cols = this.columns;
- var newRow = new Array (cols.length);
+ var newRow = new Array(cols.length);
for (var i = 0; i < cols.length; i++)
if (cols[i].table === this._mainTable)
@@ -702,164 +651,142 @@ Model.implement
else
newRow[i] = null;
- var rowIndex = this.data.push (newRow) - 1;
+ var rowIndex = this.data.push(newRow) - 1;
newRow.index = rowIndex;
- var op = this._createOperation (rowIndex);
+ var op = this._createOperation(rowIndex);
op.type |= Operation.INSERT;
- this.signalEmit ('row-inserted', rowIndex);
+ this.signalEmit('row-inserted', rowIndex);
return rowIndex;
}
/**
* Performs all model changes on the database.
- **/
- ,performOperations: function ()
- {
+ */
+ ,performOperations: function() {
var ops = this._operations;
- if (ops.length === 0)
- {
- this.signalEmit ('operations-done');
+ if (ops.length === 0) {
+ this.signalEmit('operations-done');
return;
}
- var stmts = new Sql.MultiStmt ();
+ var stmts = new Sql.MultiStmt();
- var query = new Sql.String ({query: 'START TRANSACTION'});
- stmts.addStmt (query);
+ var query = new Sql.String({query: 'START TRANSACTION'});
+ stmts.addStmt(query);
- for (var i = 0; i < ops.length; i++)
- {
+ for (var i = 0; i < ops.length; i++) {
query = null;
var op = ops[i];
- if (op.type & Operation.DELETE)
- {
+ if (op.type & Operation.DELETE) {
if (op.type & Operation.INSERT)
continue;
- var where = this._createWhere (this._mainTable, op, true);
+ var where = this._createWhere(this._mainTable, op, true);
- if (where)
- {
- query = new Sql.Delete ({where: where});
- query.addTarget (this._createTarget (this._mainTable));
+ if (where) {
+ query = new Sql.Delete({where: where});
+ query.addTarget(this._createTarget(this._mainTable));
}
- }
- else if (op.type & (Operation.INSERT | Operation.UPDATE))
- {
- query = new Sql.MultiStmt ();
+ } else if (op.type & (Operation.INSERT | Operation.UPDATE)) {
+ query = new Sql.MultiStmt();
- for (var tableIndex in op.tables)
- {
- var stmt = this._createDmlQuery (op, parseInt (tableIndex));
- query.addStmt (stmt);
+ for (var tableIndex in op.tables) {
+ var stmt = this._createDmlQuery(op, parseInt(tableIndex));
+ query.addStmt(stmt);
}
}
- if (query)
- {
- stmts.addStmt (query);
- }
- else
- {
- console.warn ('Db.Model: %s', _('ErrorSavingChanges'));
+ if (query) {
+ stmts.addStmt(query);
+ } else {
+ console.warn('Db.Model: %s', _('ErrorSavingChanges'));
return;
}
}
- var query = new Sql.String ({query: 'COMMIT'});
- stmts.addStmt (query);
+ var query = new Sql.String({query: 'COMMIT'});
+ stmts.addStmt(query);
- this._conn.execStmt (stmts,
- this._onOperationsDone.bind (this, ops));
+ this._conn.execStmt(stmts,
+ this._onOperationsDone.bind(this, ops));
- this._resetOperations ();
+ this._resetOperations();
}
- ,_createDmlQuery: function (op, tableIndex)
- {
- var where = this._createWhere (tableIndex, op, false);
+ ,_createDmlQuery: function(op, tableIndex) {
+ var where = this._createWhere(tableIndex, op, false);
if (!where)
return null;
- var multiStmt = new Sql.MultiStmt ();
- var target = this._createTarget (tableIndex);
+ var multiStmt = new Sql.MultiStmt();
+ var target = this._createTarget(tableIndex);
- var select = new Sql.Select ({where: where});
- select.addTarget (target);
+ var select = new Sql.Select({where: where});
+ select.addTarget(target);
var row = op.row;
var cols = this.columns;
- if (op.tables[tableIndex] & Operation.INSERT)
- {
- var dmlQuery = new Sql.Insert ();
+ if (op.tables[tableIndex] & Operation.INSERT) {
+ var dmlQuery = new Sql.Insert();
var table = this.tables[tableIndex];
- for (var i = 0; i < this._defaults.length; i++)
- {
+ for (var i = 0; i < this._defaults.length; i++) {
var def = this._defaults[i];
- if (def.table === table.name)
- {
+ if (def.table === table.name) {
if (def.value)
- dmlQuery.addSet (def.field, def.value);
+ dmlQuery.addSet(def.field, def.value);
else if (def.expr)
- dmlQuery.addExpr (def.field, def.expr);
- else if (def.srcColumn)
- {
- var columnIndex = this.getColumnIndex (def.srcColumn);
- dmlQuery.addSet (def.field, row[columnIndex]);
+ dmlQuery.addExpr(def.field, def.expr);
+ else if (def.srcColumn) {
+ var columnIndex = this.getColumnIndex(def.srcColumn);
+ dmlQuery.addSet(def.field, row[columnIndex]);
}
}
}
for (var i = 0; i < cols.length; i++)
- if (cols[i].table === tableIndex)
- {
+ if (cols[i].table === tableIndex) {
if (row[i] !== null)
- dmlQuery.addSet (cols[i].orgname, row[i]);
+ dmlQuery.addSet(cols[i].orgname, row[i]);
- select.addField (cols[i].orgname);
+ select.addField(cols[i].orgname);
}
- }
- else
- {
- var updateWhere = this._createWhere (tableIndex, op, true);
+ } else {
+ var updateWhere = this._createWhere(tableIndex, op, true);
if (!updateWhere)
return null;
- var dmlQuery = new Sql.Update ({where: updateWhere});
+ var dmlQuery = new Sql.Update({where: updateWhere});
for (var i = 0; i < cols.length; i++)
- if (cols[i].table === tableIndex && op.oldValues[i] !== undefined)
- {
+ if (cols[i].table === tableIndex && op.oldValues[i] !== undefined) {
var fieldName = cols[i].orgname;
- dmlQuery.addSet (fieldName, row[i]);
- select.addField (fieldName);
+ dmlQuery.addSet(fieldName, row[i]);
+ select.addField(fieldName);
}
}
- dmlQuery.addTarget (target);
+ dmlQuery.addTarget(target);
- multiStmt.addStmt (dmlQuery);
- multiStmt.addStmt (select);
+ multiStmt.addStmt(dmlQuery);
+ multiStmt.addStmt(select);
return multiStmt;
}
- ,_onOperationsDone: function (ops, resultSet)
- {
- var error = resultSet.getError ();
+ ,_onOperationsDone: function(ops, resultSet) {
+ var error = resultSet.getError();
- if (error)
- {
- this._operations = this._operations.concat (ops);
+ if (error) {
+ this._operations = this._operations.concat(ops);
for (var i = 0; i < ops.length; i++)
this._operationsMap[ops[i].row.index] = ops[i];
@@ -867,11 +794,10 @@ Model.implement
throw error;
}
- resultSet.fetchResult ();
+ resultSet.fetchResult();
var isOperation = false;
- for (var i = 0; i < ops.length; i++)
- {
+ for (var i = 0; i < ops.length; i++) {
var op = ops[i];
var row = op.row;
@@ -879,96 +805,80 @@ Model.implement
&& op.type & Operation.INSERT))
isOperation = true;
- if (op.type & Operation.DELETE)
- {
- resultSet.fetchResult ();
- }
- else if (op.type & (Operation.INSERT | Operation.UPDATE))
- {
- this.signalEmit ('row-updated-before', row.index);
+ if (op.type & Operation.DELETE) {
+ resultSet.fetchResult();
+ } else if (op.type & (Operation.INSERT | Operation.UPDATE)) {
+ this.signalEmit('row-updated-before', row.index);
var updatedCols = [];
var cols = this.columns;
- for (var tableIndex in op.tables)
- {
+ for (var tableIndex in op.tables) {
var j = 0;
- tableIndex = parseInt (tableIndex);
+ tableIndex = parseInt(tableIndex);
- resultSet.fetchResult ();
- var newValues = resultSet.fetchRow ();
+ resultSet.fetchResult();
+ var newValues = resultSet.fetchRow();
- if (op.tables[tableIndex] & Operation.INSERT)
- {
+ if (op.tables[tableIndex] & Operation.INSERT) {
for (var i = 0; i < cols.length; i++)
- if (cols[i].table === tableIndex)
- {
+ if (cols[i].table === tableIndex) {
row[i] = newValues[j++];
- updatedCols.push (i);
+ updatedCols.push(i);
}
- }
- else
- {
+ } else {
for (var i = 0; i < cols.length; i++)
if (cols[i].table === tableIndex
- && op.oldValues[i] !== undefined)
- {
+ && op.oldValues[i] !== undefined) {
row[i] = newValues[j++];
- updatedCols.push (i);
+ updatedCols.push(i);
}
}
}
- this.signalEmit ('row-updated', row.index, updatedCols);
+ this.signalEmit('row-updated', row.index, updatedCols);
}
}
- resultSet.fetchResult ();
+ resultSet.fetchResult();
// if (isOperation)
- this.signalEmit ('operations-done');
+ this.signalEmit('operations-done');
}
/**
* Undoes all unsaved changes made to the model.
- **/
- ,reverseOperations: function ()
- {
- for (var i = 0; i < this._operations.length; i++)
- {
+ */
+ ,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.signalEmit ('row-inserted', row.index);
- }
- else if (op.type & Operation.UPDATE)
- {
- this.signalEmit ('row-updated-before', row.index);
+ && !(op.type & Operation.INSERT)) {
+ this.data.splice(row.index, 0, row);
+ this.signalEmit('row-inserted', row.index);
+ } else if (op.type & Operation.UPDATE) {
+ this.signalEmit('row-updated-before', row.index);
var updatedCols = [];
var cols = this.columns;
for (var i = 0; i < cols.length; i++)
- if (op.oldValues[i] !== undefined)
- {
+ if (op.oldValues[i] !== undefined) {
row[i] = op.oldValues[i];
- updatedCols.push (i);
+ updatedCols.push(i);
}
- this.signalEmit ('row-updated', row.index, updatedCols);
+ this.signalEmit('row-updated', row.index, updatedCols);
}
}
- this._resetOperations ();
- this._refreshRowIndexes (0);
+ this._resetOperations();
+ this._refreshRowIndexes(0);
}
- ,_resetOperations: function ()
- {
+ ,_resetOperations: function() {
this._operations = [];
this._operationsMap = {};
}
@@ -976,8 +886,7 @@ Model.implement
/*
* Function used to sort the model ascending.
*/
- ,sortFunctionAsc: function (column, a, b)
- {
+ ,sortFunctionAsc: function(column, a, b) {
if (a[column] < b[column])
return -1;
else if (a[column] > b[column])
@@ -989,8 +898,7 @@ Model.implement
/*
* Function used to sort the model descending.
*/
- ,sortFunctionDesc: function (column, a, b)
- {
+ ,sortFunctionDesc: function(column, a, b) {
if (a[column] > b[column])
return -1;
else if (a[column] < b[column])
@@ -1004,16 +912,15 @@ Model.implement
*
* @param {integer} column The column name
* @param {SortWay} way The sort way
- **/
- ,sortByName: function (columnName, way)
- {
+ */
+ ,sortByName: function(columnName, way) {
this._requestedSortIndex = -1;
this._requestedSortName = columnName;
- var index = this.getColumnIndex (columnName);
+ var index = this.getColumnIndex(columnName);
if (index != -1)
- this._sort (index, way);
+ this._sort(index, way);
}
/**
@@ -1021,43 +928,38 @@ Model.implement
*
* @param {integer} column The column index
* @param {SortWay} way The sort way
- **/
- ,sort: function (column, way)
- {
+ */
+ ,sort: function(column, way) {
this._requestedSortIndex = column;
this._requestedSortName = null;
- if (!this.checkColExists (column))
+ if (!this.checkColExists(column))
return;
- this._sort (column, way);
+ this._sort(column, way);
}
- ,_sort: function (column, way)
- {
- this._setStatus (Status.LOADING);
- this._realSort (column, way);
- this._setStatus (Status.READY);
+ ,_sort: function(column, way) {
+ this._setStatus(Status.LOADING);
+ this._realSort(column, way);
+ this._setStatus(Status.READY);
}
- ,_realSort: function (column, way)
- {
- if (column !== this._sortColumn)
- {
+ ,_realSort: function(column, way) {
+ if (column !== this._sortColumn) {
if (way === SortWay.DESC)
var sortFunction = this.sortFunctionDesc;
else
var sortFunction = this.sortFunctionAsc;
- this.data.sort (sortFunction.bind (this, column));
- }
- else if (way !== this._sortWay)
- this.data.reverse ();
+ this.data.sort(sortFunction.bind(this, column));
+ } else if (way !== this._sortWay)
+ this.data.reverse();
this._sortColumn = column;
this._sortWay = way;
- this._refreshRowIndexes (0);
+ this._refreshRowIndexes(0);
}
/**
@@ -1068,31 +970,27 @@ Model.implement
* FIXME: Not fully implemented.
*
* @param {String} column The column name
- **/
- ,indexColumn: function (column)
- {
+ */
+ ,indexColumn: function(column) {
this._requestedIndexes[column] = true;
if (this._status === Status.READY)
- this._buildIndex (column);
+ this._buildIndex(column);
}
- ,_buildIndex: function (column)
- {
- var columnIndex = this.getColumnIndex (column);
+ ,_buildIndex: function(column) {
+ var columnIndex = this.getColumnIndex(column);
- if (columnIndex !== -1)
- {
+ if (columnIndex !== -1) {
var index = {};
var data = this.data;
- switch (this.columns[columnIndex].type)
- {
+ switch (this.columns[columnIndex].type) {
case Connection.Type.TIMESTAMP:
case Connection.Type.DATE_TIME:
case Connection.Type.DATE:
for (var i = 0; i < data.length; i++)
- index[data[i][columnIndex].toString ()] = i;
+ index[data[i][columnIndex].toString()] = i;
break;
default:
for (var i = 0; i < data.length; i++)
@@ -1112,11 +1010,10 @@ Model.implement
* @param {String} column The column name
* @param {Object} value The value to search
* @return {integer} The column index
- **/
- ,search: function (column, value)
- {
- var index = this.getColumnIndex (column);
- return this.searchByIndex (index, value);
+ */
+ ,search: function(column, value) {
+ var index = this.getColumnIndex(column);
+ return this.searchByIndex(index, value);
}
/**
@@ -1126,34 +1023,31 @@ Model.implement
* @param {integer} col The column index
* @param {Object} value The value to search
* @return {integer} The column index
- **/
- ,searchByIndex: function (col, value)
- {
- if (!this.checkColExists (col))
+ */
+ ,searchByIndex: function(col, value) {
+ if (!this.checkColExists(col))
return -1;
if (value)
- switch (this.columns[col].type)
- {
+ switch (this.columns[col].type) {
case Connection.Type.BOOLEAN:
value = !!value;
break;
case Connection.Type.INTEGER:
- value = parseInt (value);
+ value = parseInt(value);
break;
case Connection.Type.DOUBLE:
- value = parseFloat (value);
+ value = parseFloat(value);
break;
default:
- value = value.toString ();
+ value = value.toString();
}
// Searchs the value using an internal index.
var index = this._indexes[col];
- if (index)
- {
+ if (index) {
if (index[value] !== undefined)
return index[value];
@@ -1164,14 +1058,13 @@ Model.implement
var data = this.data;
- switch (this.columns[col].type)
- {
+ switch (this.columns[col].type) {
case Connection.Type.TIMESTAMP:
case Connection.Type.DATE_TIME:
case Connection.Type.DATE:
{
for (var i = 0; i < data.length; i++)
- if (value === data[i][col].toString ())
+ if (value === data[i][col].toString())
return i;
break;
@@ -1185,40 +1078,35 @@ Model.implement
return -1;
}
- ,_setStatus: function (status)
- {
+ ,_setStatus: function(status) {
this._status = status;
- this.signalEmit ('status-changed', status);
- this.signalEmit ('status-changed-after', status);
+ this.signalEmit('status-changed', status);
+ this.signalEmit('status-changed-after', status);
}
- ,_createTarget: function (tableIndex)
- {
+ ,_createTarget: function(tableIndex) {
var table = this.tables[tableIndex];
- return new Sql.Table
- ({
+ return new Sql.Table({
name: table.orgname
,schema: table.schema
});
}
- ,_createWhere: function (tableIndex, op, useOldValues)
- {
- var where = new Sql.Operation ({type: Sql.Operation.Type.AND});
+ ,_createWhere: function(tableIndex, op, useOldValues) {
+ var where = new Sql.Operation({type: Sql.Operation.Type.AND});
var pks = this.tables[tableIndex].pks;
if (pks.length === 0)
return null;
- for (var i = 0; i < pks.length; i++)
- {
+ for (var i = 0; i < pks.length; i++) {
var col = pks[i];
var column = this.columns[col];
- var equalOp = new Sql.Operation ({type: Sql.Operation.Type.EQUAL});
- equalOp.exprs.add (new Sql.Field ({name: column.orgname}));
- where.exprs.add (equalOp);
+ var equalOp = new Sql.Operation({type: Sql.Operation.Type.EQUAL});
+ equalOp.exprs.add(new Sql.Field({name: column.orgname}));
+ where.exprs.add(equalOp);
var pkValue = null;
@@ -1229,9 +1117,9 @@ Model.implement
pkValue = op.row[col];
if (pkValue)
- equalOp.exprs.add (new Sql.Value ({value: pkValue}));
+ equalOp.exprs.add(new Sql.Value({value: pkValue}));
else if (column.flags & Connection.Flag.AI && !useOldValues)
- equalOp.exprs.add (new Sql.Function ({name: 'LAST_INSERT_ID'}));
+ equalOp.exprs.add(new Sql.Function({name: 'LAST_INSERT_ID'}));
else
return null;
}
@@ -1239,17 +1127,15 @@ Model.implement
return where;
}
- ,_createOperation: function (rowIndex)
- {
+ ,_createOperation: function(rowIndex) {
var op = this._operationsMap[rowIndex];
- if (!op)
- {
+ if (!op) {
op = {
type: 0,
row: this.data[rowIndex]
};
- this._operations.push (op);
+ this._operations.push(op);
this._operationsMap[rowIndex] = op;
}
@@ -1270,9 +1156,8 @@ Model.implement
* @param {String} schema The original table schema
* @param {Array} pks Array with the names of primary keys
* @param {String} ai The autoincrement column name
- **/
- ,setInfo: function (table, orgname, schema, pks, ai)
- {
+ */
+ ,setInfo: function(table, orgname, schema, pks, ai) {
if (!this.tableInfo)
this.tableInfo = {};
@@ -1284,16 +1169,14 @@ Model.implement
ai: ai
};
- this._repairColumns ();
+ this._repairColumns();
}
- ,_repairColumns: function ()
- {
+ ,_repairColumns: function() {
// Repairs wrong table info
if (this.tableInfo && this.tables)
- for (var i = 0; i < this.tables.length; i++)
- {
+ for (var i = 0; i < this.tables.length; i++) {
var table = this.tables[i];
var tableInfo = this.tableInfo[table.name];
@@ -1303,32 +1186,29 @@ Model.implement
table.orgname = tableInfo.orgname;
table.schema = tableInfo.schema;
- if (tableInfo.pks)
- {
+ if (tableInfo.pks) {
table.pks = [];
- for (var j = 0; j < tableInfo.pks.length; j++)
- {
- var colIndex = this.getColumnIndex (tableInfo.pks[j]);
+ for (var j = 0; j < tableInfo.pks.length; j++) {
+ var colIndex = this.getColumnIndex(tableInfo.pks[j]);
if (colIndex !== -1)
- table.pks.push (colIndex);
+ table.pks.push(colIndex);
else
- console.warn ('Db.Model: Can\'t repair primary key: `%s`.`%s`'
+ console.warn('Db.Model: Can\'t repair primary key: `%s`.`%s`'
,tableInfo.orgname
,tableInfo.pks[j]
);
}
}
- if (tableInfo.ai)
- {
- var colIndex = this.getColumnIndex (tableInfo.ai);
+ if (tableInfo.ai) {
+ var colIndex = this.getColumnIndex(tableInfo.ai);
if (colIndex !== -1)
this.columns[colIndex].flags |= Connection.Flag.AI;
else
- console.warn ('Db.Model: Can\'t repair autoincrement column: `%s`.`%s`'
+ console.warn('Db.Model: Can\'t repair autoincrement column: `%s`.`%s`'
,tableInfo.orgname
,tableInfo.ai
);
diff --git a/js/db/param.js b/js/db/param.js
index 02058053..daa630b7 100644
--- a/js/db/param.js
+++ b/js/db/param.js
@@ -10,7 +10,7 @@ module.exports = new Class
{
/**
* The form field referenced by this param.
- **/
+ */
column:
{
type: String
@@ -26,7 +26,7 @@ module.exports = new Class
},
/**
* The form referenced by this param.
- **/
+ */
form:
{
type: Form
@@ -48,7 +48,7 @@ module.exports = new Class
/**
* Determines whether the link to the form is unidirectional, ie, a
* change in the form updates the parameter but not vice versa.
- **/
+ */
oneWay:
{
type: Boolean
diff --git a/js/db/query.js b/js/db/query.js
index c0e9f64c..eca97c8e 100644
--- a/js/db/query.js
+++ b/js/db/query.js
@@ -9,7 +9,7 @@ module.exports = new Class
{
/**
* The connection used to execute the statement.
- **/
+ */
conn:
{
type: Connection
@@ -25,7 +25,7 @@ module.exports = new Class
},
/**
* The model query.
- **/
+ */
query:
{
type: String
@@ -41,7 +41,7 @@ module.exports = new Class
},
/**
* The model select statement.
- **/
+ */
stmt:
{
type: Sql.Stmt
@@ -57,7 +57,7 @@ module.exports = new Class
},
/**
* The batch used to execute the statement.
- **/
+ */
batch:
{
type: Sql.Batch
@@ -73,7 +73,7 @@ module.exports = new Class
},
/**
* Wether to execute automatically de query que it's ready.
- **/
+ */
autoLoad:
{
type: Boolean,
diff --git a/js/db/result-set.js b/js/db/result-set.js
index 241a219b..daaed703 100644
--- a/js/db/result-set.js
+++ b/js/db/result-set.js
@@ -3,14 +3,14 @@ var Result = require('./result');
/**
* This class stores the database results.
- **/
+ */
module.exports = new Class({
results: null
,error: null
/**
* Initilizes the resultset object.
- **/
+ */
,initialize: function(results, error) {
this.results = results;
this.error = error;
@@ -20,7 +20,7 @@ module.exports = new Class({
* Gets the query error.
*
* @return {Db.Err} the error or null if no errors hapened
- **/
+ */
,getError: function() {
return this.error;
}
@@ -40,7 +40,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
- **/
+ */
,fetchResult: function() {
var result = this.fetch();
@@ -53,12 +53,12 @@ module.exports = new Class({
return null;
}
-
+
/**
* Fetchs the first row from the next resultset.
*
* @return {Array} the row if success, %null otherwise
- **/
+ */
,fetchRow: function() {
var result = this.fetch();
@@ -70,6 +70,11 @@ module.exports = new Class({
return null;
}
+ /**
+ * Fetchs the first row object from the next resultset.
+ *
+ * @return {Array} the row if success, %null otherwise
+ */
,fetchObject: function() {
var result = this.fetch();
@@ -90,7 +95,7 @@ module.exports = new Class({
* Fetchs the first row and column value from the next resultset.
*
* @return {Object} the value if success, %null otherwise
- **/
+ */
,fetchValue: function() {
var row = this.fetchRow();
diff --git a/js/db/result.js b/js/db/result.js
index 90466c93..2fb2eefe 100644
--- a/js/db/result.js
+++ b/js/db/result.js
@@ -1,11 +1,11 @@
/**
* This class stores a database result.
- **/
+ */
module.exports = new Class
({
/**
* Initilizes the result object.
- **/
+ */
initialize: function (result)
{
this.data = result.data;
@@ -29,7 +29,7 @@ module.exports = new Class
*
* @param {String} columnName The column name
* @return {Object} The cell value
- **/
+ */
,get: function (columnName)
{
var columnIndex = this.columnMap[columnName];
@@ -38,7 +38,7 @@ module.exports = new Class
/**
* Resets the result iterator.
- **/
+ */
,reset: function ()
{
this.row = -1;
@@ -46,7 +46,7 @@ module.exports = new Class
/**
* Moves the internal iterator to the next row.
- **/
+ */
,next: function ()
{
this.row++;
diff --git a/js/db/simple-iterator.js b/js/db/simple-iterator.js
index 7aca8a49..b2f8537e 100644
--- a/js/db/simple-iterator.js
+++ b/js/db/simple-iterator.js
@@ -1,54 +1,44 @@
-var Iterator = require ('./iterator');
-var Model = require ('./model');
+var Iterator = require('./iterator');
+var Model = require('./model');
/**
* A light iterator for models.
- **/
-module.exports = new Class
-({
+ */
+module.exports = new Class({
Extends: Vn.Object
,Implements: Iterator
- ,Properties:
- {
+ ,Properties: {
/**
* The model associated to this form.
- **/
- model:
- {
+ */
+ model: {
type: Model
- ,set: function (x)
- {
+ ,set: function(x) {
this._model = x;
}
- ,get: function ()
- {
+ ,get: function() {
return this._model;
}
},
/**
* The row where the form positioned, has -1 if the row is unselected.
- **/
- row:
- {
+ */
+ row: {
type: Number
- ,set: function (x)
- {
+ ,set: function(x) {
this._row = x;
}
- ,get: function ()
- {
+ ,get: function() {
return this._row;
}
},
/**
* The number of rows in the form.
- **/
- numRows:
- {
+ */
+ numRows: {
type: Number
- ,get: function ()
- {
+ ,get: function() {
if (this._model)
return this._model.numRows;
@@ -57,12 +47,10 @@ module.exports = new Class
},
/**
* Checks if the form data is ready.
- **/
- ready:
- {
+ */
+ ready: {
type: Boolean
- ,get: function ()
- {
+ ,get: function() {
if (this._model)
return this._model.ready;
diff --git a/js/hedera/app.js b/js/hedera/app.js
index a27fa926..faded048 100644
--- a/js/hedera/app.js
+++ b/js/hedera/app.js
@@ -62,38 +62,42 @@ module.exports = new Class({
}
,_onConnError: function(conn, error) {
- if (error instanceof Vn.JsonException)
- switch (error.exception) {
- case 'BadLogin':
- Htk.Toast.showError(_('Invalid login'));
- this._logout();
- break;
- case 'Forbidden':
- Htk.Toast.showError(_('You don\'t have enough privileges'));
- break;
- case 'UserDisabled':
- Htk.Toast.showError(_('User disabled'));
- this._logout();
- break;
- case 'SessionExpired':
- Htk.Toast.showError(_('Session expired'));
- this._logout();
- break;
- case 'OutdatedVersion':
- this._newVersion(error);
- break;
- default:
+ if (error instanceof Vn.JsonException) {
+ if (error.message)
Htk.Toast.showError(error.message);
- } else if (error.statusCode)
- switch (error.statusCode) {
+ else
+ switch (error.exception) {
+ case 'BadLogin':
+ Htk.Toast.showError(_('Invalid login'));
+ this._logout();
+ break;
+ case 'Forbidden':
+ Htk.Toast.showError(_('You don\'t have enough privileges'));
+ break;
+ case 'UserDisabled':
+ Htk.Toast.showError(_('User disabled'));
+ this._logout();
+ break;
+ case 'SessionExpired':
+ Htk.Toast.showError(_('Session expired'));
+ this._logout();
+ break;
+ case 'OutdatedVersion':
+ this._newVersion(error);
+ break;
+ default:
+ Htk.Toast.showError(error.message);
+ }
+ } else if (error.statusCode) {
+ switch (error.statusCode) {
case 401:
Htk.Toast.showError(_('Invalid login'));
this._logout();
break;
default:
Htk.Toast.showError(error.message);
- }
- else {
+ }
+ } else {
console.error(error);
this._notifyError(error);
}
diff --git a/js/hedera/form.js b/js/hedera/form.js
index 7040315c..a3723c0d 100644
--- a/js/hedera/form.js
+++ b/js/hedera/form.js
@@ -1,13 +1,11 @@
-module.exports = new Class
-({
+module.exports = new Class({
Extends: Vn.Object
,isOpen: false
,uiLoaded: false
- ,initialize: function (gui, formInfo)
- {
+ ,initialize: function(gui, formInfo) {
this.gui = gui;
this.conn = gui.conn;
this.hash = gui.hash;
@@ -19,107 +17,97 @@ module.exports = new Class
*
* @param {string} objectId The object identifier
* @return {Object} The object, or %null if not found
- **/
- ,$: function (objectId)
- {
+ */
+ ,$: function(objectId) {
if (this.builder)
- return this.builder.getById (objectId);
+ return this.builder.getById(objectId);
return null;
}
- ,loadUi: function ()
- {
+ ,loadUi: function() {
if (!this.isOpen)
return;
- var builder = new Vn.Builder ();
- builder.signalData = this;
- builder.add ('conn', this.conn);
- builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml');
+ var builder = new Vn.Builder();
+ builder.compileFile('forms/'+ this.formInfo.path +'/ui.xml');
- var res = this.builder = builder.load ();
- this.node = res.$('form');
- res.link ();
+ var scope = this.builder = builder.load(null, this);
+ scope.link(null, {conn: this.conn});
- var models = res.getByTagName ('db-model');
+ this.node = scope.$('form');
+
+ var models = scope.getByTagName('db-model');
for (var i = 0; i < models.length; i++)
models[i].conn = this.conn;
- var queries = res.getByTagName ('db-query');
+ var queries = scope.getByTagName('db-query');
for (var i = 0; i < queries.length; i++)
queries[i].conn = this.conn;
- if (this.node)
- {
- this.gui.setForm (this.node);
- this.gui.setTitle (res.$('title'));
- this.gui.setActions (res.$('actions'));
- this.activate ();
+ if (this.node) {
+ this.gui.setForm(this.node);
+ this.gui.setTitle(scope.$('title'));
+ this.gui.setActions(scope.$('actions'));
+ this.activate();
}
this.uiLoaded = true;
}
- ,unloadUi: function ()
- {
+ ,unloadUi: function() {
if (!this.uiLoaded)
return;
- if (this.node)
- {
- this.deactivate ();
- this.gui.setTitle (null);
- this.gui.setActions (null);
- Vn.Node.remove (this.node);
- this.deactivate ();
+ if (this.node) {
+ this.deactivate();
+ this.gui.setTitle(null);
+ this.gui.setActions(null);
+ Vn.Node.remove(this.node);
+ this.deactivate();
this.node = null;
}
- if (this.builder)
- {
- this.builder.unref ();
+ if (this.builder) {
+ this.builder.unref();
this.builder = null;
}
}
/**
* Called when the form is opened.
- **/
- ,open: function ()
- {
- this.close ();
+ */
+ ,open: function() {
+ this.close();
this.isOpen = true;
- this.loadUi ();
+ this.loadUi();
}
/**
* Called when the form is closed.
- **/
- ,close: function ()
- {
+ */
+ ,close: function() {
if (!this.isOpen)
return;
this.isOpen = false;
- this.unloadUi ();
+ this.unloadUi();
}
/**
* Called when the form is activated.
- **/
- ,activate: function () {}
+ */
+ ,activate: function() {}
/**
* Called when the form is deactivated.
- **/
- ,deactivate: function () {}
+ */
+ ,deactivate: function() {}
- ,_destroy: function ()
- {
- this.close ();
- this.parent ();
+ ,_destroy: function() {
+ this.close();
+ this.parent();
}
});
diff --git a/js/hedera/gui.css b/js/hedera/gui.css
deleted file mode 100644
index e747901e..00000000
--- a/js/hedera/gui.css
+++ /dev/null
@@ -1,375 +0,0 @@
-
-.vn-gui
-{
- height: inherit;
-}
-
-/* Font */
-
-.vn-gui .user-info,
-.vn-gui .menu-title,
-.vn-gui .main-menu
-{
- font-size: 1.1em;
-}
-
-/* Navigation bar */
-
-.vn-gui .navbar
-{
- position: fixed;
- background-color: #009688;
- left: 15em;
- top: 0;
- right: 0;
- z-index: 1;
- overflow: hidden;
- box-shadow: 0 0 .2em rgba(1, 1, 1, .3);
- height: 3.9em;
- color: white;
-
- transition-property: left, background-color, transform;
- transition-duration: 200ms;
- transition-timing-function: ease-in-out;
-}
-.vn-gui .menu-button
-{
- position: absolute;
- left: 0;
- display: none;
- border: none;
- background-color: transparent;
- padding: 0 .4em;
- margin: 0;
- height: 100%;
-}
-.vn-gui .menu-button:hover
-{
- background-color: rgba(0, 0, 0, .2);
-}
-.vn-gui .menu-button img
-{
- vertical-align: middle;
- height: 1.8em;
-}
-.vn-gui .title
-{
- float: left;
-}
-.vn-gui .title h1
-{
- font-weight: normal;
- font-size: 1.4em;
- padding: .8em .6em;
- padding-right: .3em;
- margin: 0;
-}
-.vn-gui .navbar > .htk-spinner
-{
- float: left;
- margin: 1.05em .8em;
-}
-
-/* Action bar */
-
-.vn-gui .action-bar
-{
- float: right;
- padding: 0;
- margin: 0;
- height: 100%;
-}
-.vn-gui .action-bar > div
-{
- padding: 0;
- margin: 0;
- height: 100%;
-}
-.vn-gui .action-bar > div > *
-{
- float: right;
-}
-.vn-gui .action-bar button
-{
- margin: 0;
- padding: 1.25em .5em;
-}
-.vn-gui .action-bar button:hover
-{
- background-color: rgba(1, 1, 1, .2);
-}
-.vn-gui .action-bar button > img
-{
- vertical-align: middle;
- height: 1.4em;
-}
-
-/* Background */
-
-.vn-gui > .background
-{
- z-index: 10;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- visibility: hidden;
- background-color: rgba(1, 1, 1, .7);
- opacity: 0;
-}
-.vn-gui > .background.show
-{
- visibility: visible;
- transition: opacity 200ms ease-out;
- opacity: 1;
-}
-
-/* Left panel */
-
-.vn-gui .left-panel
-{
- z-index: 20;
- position: fixed;
- left: 0;
- bottom: 0;
- top: 0;
- background-color: white;
- z-index: 20;
- box-shadow: 0 .2em .2em rgba(1, 1, 1, .4);
- width: 15em;
-}
-.vn-gui .menu-overflow
-{
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 4em;
- overflow: auto;
-}
-.vn-gui .menu-header
-{
- background-color: #333;
- color: white;
- padding: 1em;
-}
-.vn-gui .logo
-{
- display: block;
- width: 12em;
- margin-bottom: .8em;
-}
-.vn-gui .user-info
-{
- width: 100%;
- overflow: hidden;
-}
-.vn-gui .user-info > p
-{
- margin: 0;
- margin-top: .2em;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.vn-gui button.logout
-{
- float: right;
- margin: 0;
- padding: .2em;
- display: block;
-}
-.vn-gui button.logout > img
-{
- height: 1.2em;
- display: block;
-}
-.vn-gui .supplant
-{
- margin-top: .2em;
- display: none;
-}
-
-/* Test link */
-
-.vn-gui .test-link
-{
- display: none;
- margin: .5em;
- background-color: #3f51b5;
- color: white;
- padding: 0 1em;
- line-height: 2em;
- border-radius: .1em;
- text-align: center;
-}
-.vn-gui .test-link:hover
-{
- background-color: #4f61c5;
-}
-.vn-gui .dev-info
-{
- display: none;
- padding: .3em .5em;
- color: white;
- background-color: #3f51b5;
- font-size: .9em;
- margin: .5em;
- border-radius: .1em;
-}
-.vn-gui .dev-info > p
-{
- margin: .2em 0;
-}
-.vn-gui .dev-info > .mode
-{
- color: #BBF;
-}
-
-/* Menu */
-
-.vn-gui .main-menu,
-.vn-gui ul.submenu
-{
- list-style-type: none;
- padding: 0;
- margin: 0;
-}
-.vn-gui .main-menu > li
-{
- display: block;
- padding: 0;
- margin: 0;
- width: 100%;
-}
-.vn-gui .main-menu a
-{
- width: 70%;
- padding: 0 15%;
- display: block;
- line-height: 2.8em;
-}
-.vn-gui .main-menu a:hover,
-.vn-gui .main-menu a.selected
-{
- background-color: rgba(1, 1, 1, .1);
-}
-.vn-gui ul.submenu
-{
- display: none;
-}
-.vn-gui ul.submenu.popup
-{
- display: inline;
- position: fixed;
- border: none;
- border-radius: 1px;
- background-color: white;
- box-shadow: 0 0 .3em rgba(1, 1, 1, .3);
- z-index: 50;
- width: 13em;
- max-height: 30em;
-}
-
-/* Social */
-
-.vn-gui .social
-{
- position: absolute;
- bottom: 0;
- right: 0;
- padding: .8em;
-}
-
-/* Body */
-
-.vn-gui > .body
-{
- margin-left: 15em;
- padding-top: 3.9em;
- height: inherit;
- box-sizing: border-box;
- height: inherit;
-
- transition-property: margin-left, margin-right;
- transition-duration: 200ms;
-}
-.vn-gui .form-holder
-{
- position: relative;
- height: inherit;
-
- opacity: 0;
- transform: translateZ(0) translateX(-2em);
- -webkit-transform: translateZ(0) translateX(-2em);
-
- transition-property: opacity, transform;
- transition-duration: 200ms;
- transition-timing-function: ease-out;
-}
-.vn-gui .form-holder.show
-{
- opacity: 1;
- transform: translateZ(0) translateX(0em);
- -webkit-transform: translateZ(0) translateX(0em);
-}
-
-/* Mobile */
-
-@media (max-width: 960px)
-{
- .vn-gui .action-bar span.label,
- .vn-gui .htk-button > span
- {
- display: none;
- }
- .vn-gui > .navbar
- {
- padding-left: 2.8em;
- left: 0;
- }
- .vn-gui > .body
- {
- margin-left: 0;
- }
- .vn-gui .menu-button
- {
- display: block;
- }
- .vn-gui .left-panel
- {
- top: 0;
- left: -15em;
- box-shadow: 0 0 .2em rgba(1, 1, 1, .3);
-
- transition: transform 200ms ease-out;
- -webkit-transition: transform 200ms ease-out;
- }
- .vn-gui .left-panel.show
- {
- transform: translateZ(0) translateX(15em);
- -webkit-transform: translateZ(0) translateX(15em);
- }
- .vn-gui .form-holder
- {
- left: 0;
- }
- .vn-gui ul.submenu
- {
- display: block;
- background-color: #888;
- color: white;
- box-shadow: inset 0 0 .2em rgba(1, 1, 1, .2);
- overflow: hidden;
-
- max-height: 0;
- transition: max-height 300ms ease-out;
- webkit-transition: max-height 300ms ease-out;
- }
- .vn-gui .main-menu li:hover > ul.submenu
- {
- max-height: 20em;
- }
-}
-
diff --git a/js/hedera/gui.js b/js/hedera/gui.js
index 1409d1f2..5c248edc 100644
--- a/js/hedera/gui.js
+++ b/js/hedera/gui.js
@@ -1,8 +1,8 @@
var Module = require('./module');
-var Tpl = require('./gui.xml');
+var Tpl = require('./gui.xml').default;
-require('./gui.css');
+require('./gui.scss');
module.exports = new Class({
Extends: Htk.Component,
@@ -35,23 +35,16 @@ module.exports = new Class({
this.$('background').onclick = function() {};
- this.$('menu-button').addEventListener('click', function(event) {
- event.stopPropagation();
- this.showMenu();
- }.bind(this));
-
this.$('left-panel').addEventListener('click', function(event) {
event.stopPropagation();
});
this.parent(props);
- this.$('social-bar').conn = this._conn;
-
var sql = 'SELECT id, name, nickname FROM account.myUser;'
+'SELECT defaultForm FROM config;'
+'SELECT url FROM imageConfig;'
- +'SELECT dbproduccion FROM vn2008.tblContadores;'
+ +'SELECT dbproduccion FROM vn.config;'
+'SELECT productionDomain, testDomain FROM config;';
this._conn.execQuery(sql, this.onMainQueryDone.bind(this));
@@ -266,6 +259,11 @@ module.exports = new Class({
}
}
+ ,onMenuClick(event) {
+ event.stopPropagation();
+ this.showMenu();
+ }
+
,showMenu: function() {
this.showBackground();
Vn.Node.addClass(this.$('left-panel'), 'show');
@@ -479,9 +477,8 @@ module.exports = new Class({
this._onUserSupplant.bind(this, callback, user));
}
- ,_onUserSupplant: function(callback, user, supplantOk) {
- if (!supplantOk)
- return;
+ ,_onUserSupplant: function(callback, user, supplantOk, err) {
+ if (err) throw err;
sessionStorage.setItem('supplantUser', user);
this.loadMenu();
@@ -496,11 +493,11 @@ module.exports = new Class({
,_onSupplantName: function(resultSet) {
var userName = resultSet.fetchValue();
Vn.Node.setText(this.$('supplanted'), userName);
- Vn.Node.show(this.$('supplant'));
+ this.$('supplant').classList.toggle('show', true);
}
,onSupplantExitClick: function() {
- Vn.Node.hide(this.$('supplant'));
+ this.$('supplant').classList.toggle('show', false);
this._conn.supplantEnd();
sessionStorage.removeItem('supplantUser',
sessionStorage.getItem('supplantUser'));
diff --git a/js/hedera/gui.scss b/js/hedera/gui.scss
new file mode 100644
index 00000000..fe811fa2
--- /dev/null
+++ b/js/hedera/gui.scss
@@ -0,0 +1,360 @@
+
+@import "../htk/style/classes";
+
+$side-panel-width: 250px;
+$navbar-height: 64px;
+
+.vn-gui {
+ height: inherit;
+
+ /* Font */
+
+ .user-name,
+ .menu-title {
+ font-size: 1.1em;
+ }
+
+ /* Navigation bar */
+
+ .navbar {
+ position: fixed;
+ background-color: #1A1A1A;
+ left: $side-panel-width;
+ top: 0;
+ right: 0;
+ z-index: 1;
+ overflow: hidden;
+ height: $navbar-height;
+ color: white;
+ display: flex;
+ align-items: center;
+
+ transition-property: left, background-color, transform;
+ transition-duration: 200ms;
+ transition-timing-function: ease-in-out;
+
+ & > .menu-button {
+ flex: none;
+ display: none;
+ border: none;
+
+ &:hover {
+ background-color: rgba(255, 255, 255, .1);
+ }
+ & > .htk-icon {
+ display: block;
+ }
+ }
+ & > .title-wraper {
+ flex: auto;
+ display: flex;
+ align-items: center;
+ gap: 15px;
+ overflow: hidden;
+ padding-left: 15px;
+
+ & > .title {
+ overflow: hidden;
+
+ h1 {
+ font-weight: normal;
+ font-size: 1.4em;
+ margin: 0;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ }
+ }
+ }
+ & > .action-bar {
+ flex: none;
+ padding: 0;
+ margin: 0;
+ height: 100%;
+
+ & > div {
+ padding: 0;
+ margin: 0;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ padding: 0 1em;
+ gap: .5em;
+
+ & > * {
+ float: right;
+ }
+ }
+ button {
+ margin: 0;
+ padding: 10px 15px;
+
+ &:hover {
+ background-color: rgba(2550, 255, 255, .2);
+ }
+ }
+ }
+ }
+
+ /* Background */
+
+ & > .background {
+ z-index: 10;
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ visibility: hidden;
+ background-color: rgba(1, 1, 1, .7);
+ opacity: 0;
+
+ &.show {
+ visibility: visible;
+ transition: opacity 200ms ease-out;
+ opacity: 1;
+ }
+ }
+
+ /* Left panel */
+
+ .left-panel {
+ z-index: 20;
+ position: fixed;
+ left: 0;
+ bottom: 0;
+ top: 0;
+ background-color: white;
+ z-index: 20;
+ width: $side-panel-width;
+ }
+ .menu-overflow {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 4em;
+ overflow: auto;
+ }
+ .menu-header {
+ background-color: #1A1A1A;
+ color: white;
+ height: $navbar-height;
+ display: flex;
+ }
+ .logo {
+ display: block;
+ width: 160px;
+ margin-left: 37px;
+ }
+ .user-info {
+ margin: 25px;
+
+ & > div {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ overflow: hidden;
+ font-weight: bold;
+ border: 1px solid #eaeaea;
+
+ & > span {
+ padding: 10px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .logout {
+ display: block;
+ margin: 0;
+ text-align: left;
+ border-radius: 0;
+
+ &:hover {
+ background-color: #1a1a1a;
+ color: white;
+ }
+ & > .htk-icon {
+ display: block;
+ }
+ }
+ &.supplant {
+ display: none;
+ border-top: none;
+
+ &.show {
+ display: flex;
+ }
+ }
+ }
+ }
+
+ /* Test link */
+
+ .test-link {
+ display: none;
+ margin: .5em;
+ background-color: #3f51b5;
+ color: white;
+ padding: 0 1em;
+ line-height: 2em;
+ border-radius: .1em;
+ text-align: center;
+
+ &:hover {
+ background-color: #4f61c5;
+ }
+ }
+ .dev-info {
+ display: none;
+ padding: .3em .5em;
+ color: white;
+ background-color: #3f51b5;
+ font-size: .9em;
+ margin: .5em;
+ border-radius: .1em;
+
+ & > p {
+ margin: .2em 0;
+ }
+ & > .mode {
+ color: #BBF;
+ }
+ }
+
+ /* Menu */
+
+ .main-menu,
+ ul.submenu {
+ list-style-type: none;
+ padding: 0;
+ margin: 0;
+ }
+ .main-menu > li {
+ display: block;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ }
+ .main-menu a {
+ width: 70%;
+ padding: 0 15%;
+ display: block;
+ line-height: 2.8em;
+ }
+ .main-menu a:hover,
+ .main-menu a.selected {
+ background-color: rgba(1, 1, 1, .1);
+ }
+ ul.submenu {
+ display: none;
+ }
+ ul.submenu.popup {
+ display: inline;
+ position: fixed;
+ border: none;
+ border-radius: 1px;
+ background-color: white;
+ box-shadow: 0 0 .3em rgba(1, 1, 1, .3);
+ z-index: 50;
+ width: 13em;
+ max-height: 30em;
+ }
+
+ /* Social */
+
+ .menu-footer {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ left: 0;
+ }
+
+ /* Body */
+
+ & > .body {
+ margin-left: $side-panel-width;
+ padding-top: $navbar-height;
+ height: inherit;
+ box-sizing: border-box;
+ height: inherit;
+
+ transition-property: margin-left, margin-right;
+ transition-duration: 200ms;
+ }
+ .form-holder {
+ position: relative;
+ height: inherit;
+
+ opacity: 0;
+ transform: translateZ(0) translateX(-2em);
+ -webkit-transform: translateZ(0) translateX(-2em);
+
+ transition-property: opacity, transform;
+ transition-duration: 200ms;
+ transition-timing-function: ease-out;
+
+ &.show {
+ opacity: 1;
+ transform: translateZ(0) translateX(0em);
+ -webkit-transform: translateZ(0) translateX(0em);
+ }
+ & > * {
+ padding: $spacing-md;
+ }
+ }
+
+ /* Mobile */
+
+ @media (max-width: 960px) {
+ & > .navbar {
+ padding-left: 16px;
+ left: 0;
+
+ & > .menu-button {
+ display: block;
+ }
+ & > .action-bar {
+ button {
+ padding: 10px;
+ }
+ span.label,
+ button > .text {
+ display: none;
+ }
+ }
+ }
+ & > .body {
+ margin-left: 0;
+ }
+ .left-panel {
+ top: 0;
+ left: -250px;
+ box-shadow: 0 0 .2em rgba(1, 1, 1, .3);
+
+ transition: transform 200ms ease-out;
+ -webkit-transition: transform 200ms ease-out;
+ }
+ .left-panel.show {
+ transform: translateZ(0) translateX(250px);
+ -webkit-transform: translateZ(0) translateX(250px);
+ }
+ .form-holder {
+ left: 0;
+ }
+ ul.submenu {
+ display: block;
+ background-color: #888;
+ color: white;
+ box-shadow: inset 0 0 .2em rgba(1, 1, 1, .2);
+ overflow: hidden;
+
+ max-height: 0;
+ transition: max-height 300ms ease-out;
+ webkit-transition: max-height 300ms ease-out;
+ }
+ .main-menu li:hover > ul.submenu {
+ max-height: 20em;
+ }
+ }
+}
diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml
index 261c6b64..d083ad2c 100644
--- a/js/hedera/gui.xml
+++ b/js/hedera/gui.xml
@@ -1,39 +1,45 @@