diff --git a/forms/account/address-list/address-list.js b/forms/account/address-list/address-list.js index 527cc6da..1be4719e 100644 --- a/forms/account/address-list/address-list.js +++ b/forms/account/address-list/address-list.js @@ -3,39 +3,37 @@ Hedera.AddressList = new Class ({ Extends: Hedera.Form - ,activate: function () - { - this.$('user-model').setInfo ('c', 'myClient', 'hedera'); - this.$('addresses').setInfo ('a', 'myAddress', 'hedera'); + ,activate: function() { + this.$('user-model').setInfo('c', 'myClient', 'hedera'); + this.$('addresses').setInfo('a', 'myAddress', 'hedera'); } - ,onAddAddressClick: function () - { - this.hash.set ({ + ,onAddAddressClick: function() { + this.hash.set({ form: 'account/address', address: 0 }); } - ,onReturnClick: function () - { + ,onReturnClick: function() { window.history.back(); } + + ,onSetDefaultClick: function() { + Htk.Toast.showMessage(_('DefaultAddressModified')); + } - ,onRemoveAddressClick: function (button, form) - { - if (confirm (_('AreYouSureDeleteAddress'))) - { - form.set ('isActive', false); - form.refresh (); + ,onRemoveAddressClick: function(button, form) { + if (confirm(_('AreYouSureDeleteAddress'))) { + form.set('isActive', false); + form.refresh(); } } - ,onEditAddressClick: function (button, form) - { - this.hash.set ({ + ,onEditAddressClick: function(button, form) { + this.hash.set({ form: 'account/address', - address: form.get ('id') + address: form.get('id') }); } }); diff --git a/forms/account/address-list/locale/ca.yml b/forms/account/address-list/locale/ca.yml index cf541723..cf957550 100644 --- a/forms/account/address-list/locale/ca.yml +++ b/forms/account/address-list/locale/ca.yml @@ -5,3 +5,4 @@ SetAsDefault: Establir com per defecte RemoveAddress: Esborrar direcció EditAddress: Modificar direcció AreYouSureDeleteAddress: Estàs segur de que vols eliminar la direcció? +DefaultAddressModified: Adreça per defecte modificada diff --git a/forms/account/address-list/locale/en.yml b/forms/account/address-list/locale/en.yml index df5b564f..75bdb2ac 100644 --- a/forms/account/address-list/locale/en.yml +++ b/forms/account/address-list/locale/en.yml @@ -5,3 +5,4 @@ SetAsDefault: Set as default RemoveAddress: Remove address EditAddress: Edit address AreYouSureDeleteAddress: Are you sure you want to delete the address? +DefaultAddressModified: Default address modified diff --git a/forms/account/address-list/locale/es.yml b/forms/account/address-list/locale/es.yml index 66c4576d..50a29c77 100644 --- a/forms/account/address-list/locale/es.yml +++ b/forms/account/address-list/locale/es.yml @@ -5,3 +5,4 @@ SetAsDefault: Establecer como predeterminada RemoveAddress: Borrar dirección EditAddress: Modificar dirección AreYouSureDeleteAddress: ¿Estás seguro de que quieres borrar la dirección? +DefaultAddressModified: Dirección por defecto modificada diff --git a/forms/account/address-list/locale/fr.yml b/forms/account/address-list/locale/fr.yml index 9126d4fb..8530ec22 100644 --- a/forms/account/address-list/locale/fr.yml +++ b/forms/account/address-list/locale/fr.yml @@ -5,3 +5,4 @@ SetAsDefault: Définir par défaut RemoveAddress: Supprimer l'adresse EditAddress: Changement d'adresse AreYouSureDeleteAddress: Souhaitez-vous vraiment supprier l'adresse? +DefaultAddressModified: Adresse par défaut modifiée diff --git a/forms/account/address-list/locale/pt.yml b/forms/account/address-list/locale/pt.yml index 4f5fd79a..7657ab26 100644 --- a/forms/account/address-list/locale/pt.yml +++ b/forms/account/address-list/locale/pt.yml @@ -5,3 +5,4 @@ SetAsDefault: Selecionar como pre-determinado RemoveAddress: Eliminar Morada EditAddress: Modificar Morada AreYouSureDeleteAddress: Tens certeza que queres eliminar esta morada? +DefaultAddressModified: Endereço padrão modificado diff --git a/forms/account/address-list/style.css b/forms/account/address-list/style.css index 8bd9a259..661afa20 100644 --- a/forms/account/address-list/style.css +++ b/forms/account/address-list/style.css @@ -1,48 +1,15 @@ -.address-list -{ +.address-list { padding: 1em; } -.address-list .box -{ +.address-list .box { max-width: 30em; } -.address-list .form -{ +.address-list .form { margin: 0 auto; max-width: 25em; padding: 2em; } -.address -{ - padding: 1em; - border-bottom: 1px solid #DDD; -} -.address p -{ - margin: 0.2em 0; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; -} -.address p.important -{ - font-size: 1.2em; -} -.address .actions -{ - float: right; -} -.address .actions > .htk-button -{ - margin: 0; -} -.address .actions > * -{ - display: inline-block; - vertical-align: middle; -} -.address .actions > input -{ - margin: .6em; +.address-list .htk-list .side { + padding-right: 16px; } diff --git a/forms/account/address-list/ui.xml b/forms/account/address-list/ui.xml index f43d945a..e113593b 100644 --- a/forms/account/address-list/ui.xml +++ b/forms/account/address-list/ui.xml @@ -33,15 +33,28 @@ id="default-address" column="defaultAddressFk" form="user-form"/> - + -
-
+
+
+
+
+

+ {{iter.nickname}} +

+

+ {{iter.street}} +

+

+ {{iter.postalCode}}, {{iter.city}} +

+
+
-

- -

-

- -

-

- , - -

diff --git a/forms/cms/home/style.css b/forms/cms/home/style.css index 5f35e4f3..cabc2689 100644 --- a/forms/cms/home/style.css +++ b/forms/cms/home/style.css @@ -43,9 +43,13 @@ } .new-text { margin: 1.5em 0; + font-family: 'Open Sans'; + line-height: 1.3em; } .new-text a { - color: blue; + color: #6a1; +} +.new-text a:hover { text-decoration: underline; } .new-text li { diff --git a/forms/cms/home/ui.xml b/forms/cms/home/ui.xml index d4bc7d88..2ec3e7c2 100644 --- a/forms/cms/home/ui.xml +++ b/forms/cms/home/ui.xml @@ -11,7 +11,7 @@
- + SELECT title, text, image, id FROM news @@ -25,14 +25,14 @@
-

+

{{iter.title}}

- +
diff --git a/forms/ecomerce/basket/basket.js b/forms/ecomerce/basket/basket.js index 2f1239ac..a4366e6a 100644 --- a/forms/ecomerce/basket/basket.js +++ b/forms/ecomerce/basket/basket.js @@ -3,56 +3,43 @@ Hedera.Basket = new Class ({ Extends: Hedera.Form - ,open: function () - { - this.close (); + ,open: function() { + this.close(); this.isOpen = true; - Hedera.BasketChecker.check (this.conn, - this.onBasketCheck.bind (this)); + Hedera.BasketChecker.check(this.conn, + this.onBasketCheck.bind(this)); } - ,onBasketCheck: function (isOk) - { + ,onBasketCheck: function(isOk) { if (isOk) - this.loadUi (); + this.loadUi(); } - ,activate: function () - { - this.$('items').setInfo ('bi', 'myBasketItem', 'hedera'); + ,activate: function() { + this.$('items').setInfo('bi', 'myBasketItem', 'hedera'); } - ,onConfigureClick: function () - { - Htk.Toast.showWarning (_('RememberReconfiguringImpact')); - this.hash.set ({form: 'ecomerce/checkout'}); + ,onConfigureClick: function() { + Htk.Toast.showWarning(_('RememberReconfiguringImpact')); + this.hash.set({form: 'ecomerce/checkout'}); } - ,onCatalogClick: function () - { - this.hash.set ({form: 'ecomerce/catalog'}); + ,onCatalogClick: function() { + this.hash.set({form: 'ecomerce/catalog'}); } - ,onCheckoutClick: function () - { - this.hash.set ({form: 'ecomerce/confirm'}); + ,onCheckoutClick: function() { + this.hash.set({form: 'ecomerce/confirm'}); } - ,repeaterFunc: function (res, form) - { - res.$('subtotal').value = this.subtotal (form); + ,onDeleteClick: function(button, form) { + if (confirm(_('ReallyDelete'))) + form.deleteRow(); } - ,onDeleteClick: function (button, form) - { - if (confirm (_('ReallyDelete'))) - form.deleteRow (); - } - - ,subtotal: function (form) - { - return form.get ('amount') * form.get ('price'); + ,subtotal: function(form) { + return form.get('amount') * form.get('price'); } }); diff --git a/forms/ecomerce/basket/style.css b/forms/ecomerce/basket/style.css index 2b0d1889..09abc932 100644 --- a/forms/ecomerce/basket/style.css +++ b/forms/ecomerce/basket/style.css @@ -1,28 +1,24 @@ -.basket -{ +.basket { padding: 1em; } -.basket .box -{ +.basket .box { max-width: 30em; margin: 0 auto; - padding: 0 2em; + padding: 30px; } -.basket .form > p -{ +.basket .form > p { margin: 0; font-size: 1.4em; color: white; text-align: right; } -.basket .head -{ - padding: 1.8em 0; +.basket .head { + padding-bottom: 30px; margin: 0; border-bottom: 1px solid #DDD; } -.basket .head p -{ +.basket .head p { + font-weight: bold; margin: 0; padding: 0; font-size: 1.4em; @@ -31,61 +27,48 @@ /* Lines */ -.basket .lines -{ - padding: .8em 0; +.basket .line { + display: flex; + gap: 20px; + margin: 24px 0; + height: 65px; } -.basket .line -{ - padding: 1em 0; +.basket .line:last-child { + margin-bottom: 0; } -.basket .line > .delete -{ - margin: -0.5em; - margin-top: 1em; - margin-right: .5em; - float: left; +.basket .line > .delete { + align-self: center; } -.basket .line > .photo -{ - margin-right: 1em; - float: left; +.basket .line > .photo { + flex: none; border-radius: 50%; - height: 4.25em; - width: 4.25em; + width: 65px; } -.basket .line > .info -{ - margin-left: 7.5em; +.basket .line > .info { + flex: 1; } -.basket .line > .info > h2 -{ +.basket .line > .info > h2 { font-size: 1em; font-weight: normal; padding: 0; padding-bottom: .1em; } -.basket .line > .info > p -{ +.basket .line > .info > p { margin: 0; } -.basket .line > .info > .tags -{ +.basket .line > .info > .tags { color: #777; } -.basket .line .subtotal -{ +.basket .line .subtotal { float: right; } /* Fields */ -.basket td.available-exceeded input -{ +.basket td.available-exceeded input { background-color: #FCC; } -.basket .icon > img -{ +.basket .icon > img { border-radius: 50%; } diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml index 62b7b39b..a9de28ac 100644 --- a/forms/ecomerce/basket/ui.xml +++ b/forms/ecomerce/basket/ui.xml @@ -27,7 +27,7 @@

- + SELECT bi.id, bi.amount, bi.price, i.longName item, i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7, @@ -60,19 +60,15 @@

- - - + {{iter.value5}} {{iter.value6}} {{iter.value7}}

- x - + {{iter.amount}} x {{Vn.Value.format(iter.price, '%.2d€')}} - + {{Vn.Value.format(iter.price * iter.amount, '%.2d€')}}

-
diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/catalog.js index d34903e9..048706c5 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/catalog.js @@ -103,11 +103,6 @@ Hedera.Catalog = new Class({ 'form': this.hash.get('form'), 'realm': form.get('id') }); - - var img = builder.$('image'); - img.src = 'image/family/black/'+ form.get('code') +'.svg'; - img.title = form.get('name'); - img.alt = img.title; } ,onRealmChange: function(param, newValue) { diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 35a38fe8..dfb992f3 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -121,7 +121,7 @@
+ title="{{_('AddToBasket')}}">

- + {{item.item}}

- + {{item.subName}}

- - + + - - + + - - + +
{{item.tag5}}{{item.value5}}
{{item.tag6}}{{item.value6}}
{{item.tag7}}{{item.value7}}
- + {{Vn.Value.format(item.grouping, 'x%.0d')}} - + {{item.available}} - + {{Vn.Value.format(item.price, 'x%.0d')}}
@@ -185,7 +185,7 @@
- + {{form.name}} 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 7f928f4d..01e75703 100644 --- a/forms/ecomerce/checkout/style.css +++ b/forms/ecomerce/checkout/style.css @@ -16,7 +16,7 @@ .answers button, .answers p, .radio > div { - font-size: 1.4em; + font-size: 1.2em; } .answers .htk-select { max-width: 10em; @@ -54,13 +54,9 @@ padding: 0.5em; } .thin-calendar { - width: inherit; max-width: 24em; margin: 0 auto; - box-shadow: .05em .05em .2em rgba(0, 0, 0, .2); -} -.thin-calendar tr > th { - color: white; + box-shadow: none; } .htk-assistant .thin { float: right; diff --git a/forms/ecomerce/checkout/ui.xml b/forms/ecomerce/checkout/ui.xml index 47100763..69eecd9a 100644 --- a/forms/ecomerce/checkout/ui.xml +++ b/forms/ecomerce/checkout/ui.xml @@ -174,7 +174,7 @@ -

ConfirmToAccessCatalog

+

ConfirmData

Arrival @@ -192,7 +192,7 @@ -

ConfirmToAccessCatalog

+

ConfirmData

Pickup diff --git a/forms/ecomerce/orders/style.css b/forms/ecomerce/orders/style.css index 01d9ef4f..3dd75dbb 100644 --- a/forms/ecomerce/orders/style.css +++ b/forms/ecomerce/orders/style.css @@ -1,72 +1,44 @@ -.orders -{ +.orders { padding: 1em; } -.orders .box -{ +.orders .box { max-width: 25em; } /* Balance */ -.balance -{ +.balance { margin-right: .5em; } -.balance > * -{ +.balance > * { vertical-align: middle; } -.balance > .amount -{ +.balance > .amount { color: white; padding: 0.3em; } -.balance > .info -{ +.balance > .info { display: inline; cursor: pointer; height: 1.2em; cursor: pointer; } -.balance > .negative -{ +.balance > .negative { background-color: #EF5350; border-radius: 0.1em; box-shadow: 0 0 0.4em #666; } -.balance-popup -{ +.balance-popup { width: 25em; } -.balance-grid -{ +.balance-grid { width: 100%; margin: auto; } /* List */ -.orders .item -{ - display: block; - padding: 1em; - border-bottom: 1px solid #DDD; -} -.orders .item:hover -{ - background-color: rgba(1, 1, 1, 0.05); -} -.orders .item > p -{ - margin: .1em 0; -} -.orders .item > p.important -{ - font-size: 1.2em; -} -.orders .item > p.total -{ +.orders .htk-list .total { float: right; } diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index 8cf4a6bc..9f52ef70 100644 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -39,30 +39,25 @@

- + CALL myTicket_list (NULL, NULL); - -

- -

-

- -

-

- # -

-

- -

-

- -

-
+ +
+

+ {{Vn.Value.format(iter.total, '%.2d€')}} +

+

+ {{Vn.Value.format(iter.landed, '%D')}} +

+

#{{iter.id}}

+

{{iter.nickname}}

+

{{iter.agency}}

+
diff --git a/forms/ecomerce/ticket/locale/ca.yml b/forms/ecomerce/ticket/locale/ca.yml index c0141846..680bc6d6 100644 --- a/forms/ecomerce/ticket/locale/ca.yml +++ b/forms/ecomerce/ticket/locale/ca.yml @@ -1,4 +1,6 @@ OrderDetail: Detall de l'encarrec +ShippingInformation: Dades d'enviament +DeliveryAddress: Adreça de lliurament Print delivery note: Imprimir albarà Agency: Agència Warehouse: Magatzem diff --git a/forms/ecomerce/ticket/locale/en.yml b/forms/ecomerce/ticket/locale/en.yml index 01412c9e..ae229f20 100644 --- a/forms/ecomerce/ticket/locale/en.yml +++ b/forms/ecomerce/ticket/locale/en.yml @@ -1,4 +1,6 @@ OrderDetail: Order detail +ShippingInformation: Shipping information +DeliveryAddress: Delivery address Print delivery note: Print delivery note Agency: Agency Warehouse: Store diff --git a/forms/ecomerce/ticket/locale/es.yml b/forms/ecomerce/ticket/locale/es.yml index 627786d3..f798dc7e 100644 --- a/forms/ecomerce/ticket/locale/es.yml +++ b/forms/ecomerce/ticket/locale/es.yml @@ -1,4 +1,6 @@ OrderDetail: Detalle del pedido +ShippingInformation: Datos de envío +DeliveryAddress: Dirección de entrega Print delivery note: Imprimir albarán Agency: Agencia Warehouse: Almacén diff --git a/forms/ecomerce/ticket/locale/fr.yml b/forms/ecomerce/ticket/locale/fr.yml index 6345329e..74cc068a 100644 --- a/forms/ecomerce/ticket/locale/fr.yml +++ b/forms/ecomerce/ticket/locale/fr.yml @@ -1,4 +1,6 @@ OrderDetail: Détails de la commande +ShippingInformation: Informations sur la livraison +DeliveryAddress: Addresse de livraison Print delivery note: Imprimer bulletin de livraison Agency: Agence Warehouse: Entrepôt diff --git a/forms/ecomerce/ticket/locale/pt.yml b/forms/ecomerce/ticket/locale/pt.yml index 2399b4fb..64bca977 100644 --- a/forms/ecomerce/ticket/locale/pt.yml +++ b/forms/ecomerce/ticket/locale/pt.yml @@ -1,4 +1,6 @@ OrderDetail: Detalhes da encomenda +ShippingInformation: Dados de envio +DeliveryAddress: Endereço de entrega Print delivery note: Imprimir nota de entrega Agency: Agência Warehouse: Armazém diff --git a/forms/ecomerce/ticket/style.css b/forms/ecomerce/ticket/style.css index 9fecbb6f..695c24e5 100644 --- a/forms/ecomerce/ticket/style.css +++ b/forms/ecomerce/ticket/style.css @@ -1,9 +1,7 @@ -.ticket -{ +.ticket { padding: 1em; } -.ticket .box -{ +.ticket .box { max-width: 30em; margin: 0 auto; padding: 2em; @@ -12,36 +10,29 @@ /* Header */ -.ticket .head -{ +.ticket .head { padding: 0; padding-bottom: .2em; border-bottom: 1px solid #DDD; margin-bottom: 1em; } -.ticket .address, -.ticket .total -{ - margin-top: .8em; +.ticket .head > div > div { + margin: 15px 0; } -.ticket .head > div -{ - padding-bottom: .8em; +.ticket .head > div > div:first-child { + margin: 0; } -.ticket .head p -{ - margin: .2em; +.ticket .head p { + margin: .2em 0; } -.ticket .head p.important -{ - font-size: 1.4em; +.ticket .head p.important { + font-size: 1.2rem; + font-weight: bold; } -.ticket .total -{ +.ticket .total { text-align: right; } -.ticket .packages -{ +.ticket .packages { margin-top: 1em; padding-top: 1em; border-top: 1px solid #DDD; @@ -50,47 +41,42 @@ /* Lines */ -.ticket .line -{ - padding: .5em 0; +.ticket .line { + display: flex; + gap: 20px; + margin: 24px 0; + height: 65px; } -.ticket .line > .photo -{ - margin-right: 1em; - float: left; +.ticket .line:last-child { + margin-bottom: 0; +} +.ticket .line > .photo { + flex: none; border-radius: 50%; - height: 4.25em; - width: 4.25em; + width: 65px; } -.ticket .line > .info -{ - margin-left: 5.25em; +.ticket .line > .info { + flex: 1; } -.ticket .line > .info > h2 -{ +.ticket .line > .info > h2 { font-size: 1em; font-weight: normal; padding: 0; padding-bottom: .1em; } -.ticket .line > .info > p -{ +.ticket .line > .info > p { margin: 0; } -.ticket .line > .info > .tags -{ +.ticket .line > .info > .tags { color: #777; } -.ticket .line > .info .discount -{ +.ticket .line > .info .discount { color: green; } -.ticket .line > .info > .amount -{ +.ticket .line > .info > .amount { float: left; } -.ticket .line > .info > .subtotal -{ +.ticket .line > .info > .subtotal { float: right; } diff --git a/forms/ecomerce/ticket/ui.xml b/forms/ecomerce/ticket/ui.xml index c14ff6fa..9f986f6c 100644 --- a/forms/ecomerce/ticket/ui.xml +++ b/forms/ecomerce/ticket/ui.xml @@ -29,6 +29,9 @@

#

+
+
+

ShippingInformation

Preparation

@@ -40,6 +43,7 @@

+

DeliveryAddress

@@ -101,7 +105,6 @@

-
diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml index 0cde1a0a..9e8f7109 100644 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -43,15 +43,10 @@ editable="true" conn="conn"/>

- -

-

- -

-

- Priority - + {{iter.title}}

+

{{iter.nickname}}

+

{{iter.priority}}

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/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/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/form.js b/js/hedera/form.js index 7040315c..b28fa327 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -6,8 +6,7 @@ module.exports = new Class ,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 +18,98 @@ 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 (); + var builder = new Vn.Builder(); builder.signalData = this; - builder.add ('conn', this.conn); - builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml'); + builder.add('conn', this.conn); + builder.loadXml('forms/'+ this.formInfo.path +'/ui.xml'); - var res = this.builder = builder.load (); + var res = this.builder = builder.load(); this.node = res.$('form'); - res.link (); + res.link(this); - var models = res.getByTagName ('db-model'); + var models = res.getByTagName('db-model'); for (var i = 0; i < models.length; i++) models[i].conn = this.conn; - var queries = res.getByTagName ('db-query'); + var queries = res.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(res.$('title')); + this.gui.setActions(res.$('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.scss b/js/hedera/gui.scss index 1240081a..7542f73d 100644 --- a/js/hedera/gui.scss +++ b/js/hedera/gui.scss @@ -64,25 +64,28 @@ padding: 0; margin: 0; height: 100%; - } - .action-bar > div { - padding: 0; - margin: 0; - height: 100%; - display: flex; - align-items: center; - padding: 0 1em; - gap: .5em; - } - .action-bar > div > * { - float: right; - } - .action-bar button { - margin: 0; - padding: .6em; - } - .action-bar button:hover { - background-color: rgba(2550, 255, 255, .2); + + & > 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 */ @@ -277,9 +280,14 @@ /* Mobile */ @media (max-width: 960px) { - .action-bar span.label, - .htk-button > .text { - display: none; + .action-bar { + span.label, + .htk-button > .text { + display: none; + } + .htk-button { + padding: 10px; + } } & > .navbar { padding-left: 2.8em; diff --git a/js/hedera/opensans.ttf b/js/hedera/opensans.ttf new file mode 100644 index 00000000..e21ff5f1 Binary files /dev/null and b/js/hedera/opensans.ttf differ diff --git a/js/hedera/style.scss b/js/hedera/style.scss index e91c6804..779de98c 100644 --- a/js/hedera/style.scss +++ b/js/hedera/style.scss @@ -1,8 +1,14 @@ +@import "../htk/style/classes"; + @font-face { font-family: 'Poppins'; src: url('poppins.ttf') format('truetype'); } +@font-face { + font-family: 'Open Sans'; + src: url('opensans.ttf') format('truetype'); +} /* Global */ @@ -243,12 +249,6 @@ img.editable { cursor: pointer; } -/* Button */ - -.htk-button img { - height: 1.5em; -} - /* Float */ .clear { @@ -258,11 +258,8 @@ img.editable { /* Box */ .box { - background-color: white; + @extend %box; margin: 0 auto; - border-radius: .6em; - box-shadow: .05em .05em .2em rgba(0, 0, 0, .1); - overflow: hidden; } .box .header { padding: 0.6em 0.8em; diff --git a/js/htk/field/bar-button.js b/js/htk/field/bar-button.js index cdb0c1a4..b923f17a 100644 --- a/js/htk/field/bar-button.js +++ b/js/htk/field/bar-button.js @@ -1,8 +1,7 @@ var Button = require('./button'); -module.exports = new Class -({ +module.exports = new Class({ Extends: Button ,Tag: 'htk-bar-button' diff --git a/js/htk/field/button.js b/js/htk/field/button.js index a812f43a..cd01a41d 100644 --- a/js/htk/field/button.js +++ b/js/htk/field/button.js @@ -7,13 +7,13 @@ module.exports = new Class({ image: { type: String ,set: function(x) { - this.span.innerText = x; + this.iconNode.name = x; } }, icon: { type: String ,set: function(x) { - this.span.innerText = x; + this.iconNode.name = x; } }, tip: { @@ -21,7 +21,7 @@ module.exports = new Class({ ,set: function(x) { if (x) { this.node.title = _(x); - this.span.title = _(x); + this.iconNode.title = _(x); } this.renderContent(); @@ -49,9 +49,8 @@ module.exports = new Class({ node.className = 'htk-button'; node.addEventListener('click', this.onClick.bind(this)); - this.span = this.createElement('span'); - this.span.className = 'material-symbols-rounded icon'; - node.appendChild(this.span); + this.iconNode = new Htk.Icon(); + node.appendChild(this.iconNode.node); } ,renderContent: function() { diff --git a/js/htk/field/calendar.js b/js/htk/field/calendar.js index 0a1eb085..f1e54421 100644 --- a/js/htk/field/calendar.js +++ b/js/htk/field/calendar.js @@ -43,12 +43,17 @@ module.exports = new Class({ thead.appendChild(tr); var th = this.createElement('th'); - th.appendChild(this.createTextNode('<')); - th.className = 'button'; - th.addEventListener('click', this.prevMonthClicked.bind(this)); + th.className = 'previous'; tr.appendChild(th); + var previousButton = new Htk.Button({ + icon: 'arrow_back_ios' + }).node; + previousButton.addEventListener('click', this.prevMonthClicked.bind(this)); + th.appendChild(previousButton); + var th = this.createElement('th'); + th.className = 'month-year'; th.colSpan = 5; tr.appendChild(th); @@ -62,12 +67,17 @@ module.exports = new Class({ th.appendChild(yearNode); var th = this.createElement('th'); - th.appendChild(this.createTextNode('>')); - th.className = 'button'; - th.addEventListener('click', this.nextMonthClicked.bind(this)); + th.className = 'next'; tr.appendChild(th); + + var nextButton = new Htk.Button({ + icon: 'arrow_forward_ios' + }).node; + nextButton.addEventListener('click', this.nextMonthClicked.bind(this)); + th.appendChild(nextButton); var tr = this.createElement('tr'); + tr.className = 'weekdays'; thead.appendChild(tr); for (var i = 1; i <= len; i++) { diff --git a/js/htk/field/html.js b/js/htk/field/html.js index 166cab44..641d9a46 100644 --- a/js/htk/field/html.js +++ b/js/htk/field/html.js @@ -4,13 +4,11 @@ module.exports = new Class Extends: Htk.Field ,Tag: 'htk-html' - ,render: function () - { - this.createRoot ('div'); + ,render: function() { + this.createRoot('div'); } - ,putValue: function (value) - { + ,putValue: function(value) { this.node.innerHTML = value; } }); diff --git a/js/htk/htk.js b/js/htk/htk.js index 5fe8cc2f..a193ab6f 100644 --- a/js/htk/htk.js +++ b/js/htk/htk.js @@ -1,6 +1,7 @@ require('db/db'); -require('./style.scss'); +require('./style/classes.scss'); +require('./style/main.scss'); Htk = module.exports = { NodeBuilder : require('./node-builder') diff --git a/js/htk/icon.js b/js/htk/icon.js index 0988fda3..75ed807f 100644 --- a/js/htk/icon.js +++ b/js/htk/icon.js @@ -42,7 +42,7 @@ module.exports = new Class({ ,render: function() { const node = this.createRoot('span'); - node.className = 'material-symbols-rounded icon'; + node.className = 'htk-icon material-symbols-rounded'; } ,_setIcon: function() { diff --git a/js/htk/repeater.js b/js/htk/repeater.js index ef15b692..183e01c2 100644 --- a/js/htk/repeater.js +++ b/js/htk/repeater.js @@ -96,7 +96,7 @@ module.exports = new Class({ var builder = this._builder = new Vn.Builder(); builder.setParent(builderResult); - builder.loadXmlFromNode(node.firstElementChild); + builder.loadXmlFromNode(node.firstElementChild, null, [this._formId]); this._onModelChange(); } @@ -121,7 +121,7 @@ module.exports = new Class({ this._builder.add(this._formId, set); var res = this._builder.load(); - res.link(); + res.link(null, [set.getObject()]); this._childsData.push({ builder: res, diff --git a/js/htk/style/classes.scss b/js/htk/style/classes.scss new file mode 100644 index 00000000..c3f913f3 --- /dev/null +++ b/js/htk/style/classes.scss @@ -0,0 +1,20 @@ + +@import "variables"; + +%box { + border-radius: .6em; + box-shadow: .05em .05em .2em rgba(0, 0, 0, .1); + overflow: hidden; + border: none; + background-color: white; +} +%clickable { + cursor: pointer; + transition: background-color 250ms ease-out; + + &:hover, + &:focus { + background-color: $color-hover-cd; + outline: none; + } +} diff --git a/js/htk/style.scss b/js/htk/style/main.scss similarity index 78% rename from js/htk/style.scss rename to js/htk/style/main.scss index 1bb9d983..cd31d7c0 100644 --- a/js/htk/style.scss +++ b/js/htk/style/main.scss @@ -1,4 +1,7 @@ +@import "variables"; +@import "classes"; + /* Grid */ .htk-grid { @@ -156,8 +159,64 @@ td.cell-image .htk-image { .htk-select-menu td { max-width: 11em; overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + text-overflow: ellipsis; + white-space: nowrap; +} + +/* Icon */ + +.htk-icon {} + +/* List */ + +.htk-list { + .item { + @extend %clickable; + padding: 20px; + border-bottom: 1px solid #DDD; + display: flex; + align-items: center; + + &:hover { + background-color: rgba(1, 1, 1, 0.05); + } + & > .side { + flex: none; + } + & > .content { + flex: 1; + + & > .important { + font-weight: bold; + font-size: 1rem; + margin-bottom: .5em; + } + & > p { + margin: .1em 0; + } + } + & > .actions { + flex: none; + display: none; + + & > .htk-button { + margin: 0; + } + & > * { + display: inline-block; + vertical-align: middle; + } + & > input { + margin: .6em; + } + } + } + .item:hover > .actions { + display: block; + } + .item:last-child { + border-bottom: none; + } } /* Button */ @@ -165,12 +224,12 @@ td.cell-image .htk-image { .htk-button { display: flex; align-items: center; - border-radius: 2em; + border-radius: 22px; font-weight: bold; - gap: .5em; - padding: 0 .5em; + gap: 8px; + padding: 0 10px; - & > span.icon { + & > .htk-icon { display: block; } } @@ -178,73 +237,91 @@ td.cell-image .htk-image { /* Calendar */ .htk-calendar { + @extend %box; width: 20em; - background-color: white; - border: none; - border-radius: .5em; -} -.htk-calendar table { - border-collapse: collapse; -} -.htk-calendar thead tr, -.htk-calendar tfoot tr { - background-color: #888; - color: white; - font-weight: normal; - vertical-align: middle; - text-align: center; - height: 3em; -} -.htk-calendar thead span { - color: white; -} -.htk-calendar thead tr { - border-bottom: none; -} -.htk-calendar tfoot tr { - border-top: none; -} -.htk-calendar th.button { - display: table-cell; -} -.htk-calendar th.button:hover { - cursor: pointer; - background-color: rgba(1, 1, 1, 0.2); -} -.htk-calendar col { - width: 14.2%; -} -.htk-calendar tr { - height: 2em; -} -.htk-calendar tbody td { - text-align: right; -} -.htk-calendar tbody td > div { - height: 2em; - width: 2em; - line-height: 2em; - text-align: center; - border-radius: 2em; - padding: 0.3em; - margin: 0 auto; - color: #555; -} -.htk-calendar div.disabled { - color: #999; -} -.htk-calendar div.today { - font-weight: bold; - color: black; -} -.htk-calendar div.selected { - color: white; - background-color: #8cc63f; -} -.htk-calendar div.enabled:hover { - cursor: pointer; - background-color: rgba(140, 198, 63, 0.8); - color: white; + + table { + border-collapse: collapse; + } + thead tr, + tfoot tr { + font-weight: normal; + vertical-align: middle; + text-align: center; + height: 3em; + } + thead > tr { + &.weekdays > th { + font-weight: normal; + color: #999; + text-transform: lowercase; + } + & > th { + &.previous, &.next { + font-size: .8rem; + + button { + border-radius: 50%; + padding: 10px; + display: block; + margin: 0 auto; + + & > .htk-icon { + font-size: 1rem; + } + } + } + &.month-year { + font-size: 1.2rem; + text-transform: lowercase; + } + } + } + tfoot tr { + border-top: none; + } + th.button { + display: table-cell; + } + th.button:hover { + cursor: pointer; + background-color: rgba(1, 1, 1, 0.2); + } + col { + width: 14.2%; + } + tr { + height: 2em; + } + tbody td { + text-align: right; + } + tbody td > div { + height: 2em; + width: 2em; + line-height: 2em; + text-align: center; + border-radius: 2em; + padding: 0.3em; + margin: 0 auto; + color: #555; + } + div.disabled { + color: #bbb; + } + div.today { + font-weight: bold; + color: black; + } + div.selected { + color: white; + background-color: #8cc63f; + } + div.enabled:hover { + cursor: pointer; + background-color: rgba(140, 198, 63, 0.8); + color: white; + } } /* Image */ @@ -439,7 +516,7 @@ td.cell-image .htk-image { & > h2 { text-align: center; font-weight: normal; - font-size: 1.5em; + font-size: 1.5rem; margin: 0; padding: 0; margin-bottom: 1em; diff --git a/js/htk/style/variables.scss b/js/htk/style/variables.scss new file mode 100644 index 00000000..aa5a68f3 --- /dev/null +++ b/js/htk/style/variables.scss @@ -0,0 +1,2 @@ + +$color-hover-cd: rgba(255, 255, 255, .1); \ No newline at end of file diff --git a/js/vn/builder.js b/js/vn/builder.js index fd741cce..ff38cce1 100644 --- a/js/vn/builder.js +++ b/js/vn/builder.js @@ -1,35 +1,30 @@ -var Object = require ('./object'); +var Object = require('./object'); /** * Creates a object from a XML specification. - **/ -module.exports = new Class -({ + */ +module.exports = new Class({ Extends: Object ,_addedMap: {} ,_contexts: null - ,add: function (id, object) - { + ,add: function(id, object) { this._addedMap[id] = object; } - ,setParent: function (parentResult) - { + ,setParent: function(parentResult) { this._parentResult = parentResult; if (parentResult && !this.signalData) this.signalData = parentResult.builder.signalData; } - ,getMain: function (result) - { + ,getMain: function(result) { return result.objects[this._mainContext]; } - ,getById: function (result, objectId) - { + ,getById: function(result, objectId) { var index = this._contextMap[objectId]; if (index !== undefined) @@ -41,18 +36,16 @@ module.exports = new Class return object; if (this._parentResult) - return this._parentResult.getById (objectId); + return this._parentResult.getById(objectId); return null; } - ,getByTagName: function (result, tagName) - { + ,getByTagName: function(result, tagName) { var tags = this._tags[tagName]; - if (tags) - { - var arr = new Array (tags.length); + if (tags) { + var arr = new Array(tags.length); for (var i = 0; i < tags.length; i++) arr[i] = result.objects[tags[i]]; @@ -69,32 +62,28 @@ module.exports = new Class * @path String The XML path * @dstDocument Document The document used to create the nodes * @return %true on success, %false othersise - **/ - ,loadXml: function (path, dstDocument) - { + */ + ,loadXml: function(path, dstDocument) { this._path = path; - return this.loadFromXmlDoc (Vn.getXml (path), dstDocument); + return this.loadFromXmlDoc(Vn.getXml(path), dstDocument); } - ,loadFromString: function (xmlString, dstDocument) - { - var parser = new DOMParser (); - var xmlDoc = parser.parseFromString (xmlString, 'text/xml'); - return this.loadFromXmlDoc (xmlDoc, dstDocument); + ,loadFromString: function(xmlString, dstDocument) { + var parser = new DOMParser(); + var xmlDoc = parser.parseFromString(xmlString, 'text/xml'); + return this.loadFromXmlDoc(xmlDoc, dstDocument); } - ,loadFromXmlDoc: function (xmlDoc, dstDocument) - { + ,loadFromXmlDoc: function(xmlDoc, dstDocument, scope) { if (!xmlDoc) return false; - this._compileInit (dstDocument); + this._compileInit(dstDocument, scope); var docElement = xmlDoc.documentElement; - if (docElement.tagName !== 'vn') - { - this._showError ('Malformed XML'); + if (docElement.tagName !== 'vn') { + this._showError('Malformed XML'); this._contexts = null; return false; } @@ -103,9 +92,9 @@ module.exports = new Class if (childs) for (var i = 0; i < childs.length; i++) - this._compileNode (childs[i]); + this._compileNode(childs[i]); - this._compileEnd (); + this._compileEnd(); return true; } @@ -115,75 +104,130 @@ module.exports = new Class * @path Node The DOM node * @dstDocument Document The document used to create the nodes * @return %true on success, %false othersise - **/ - ,loadXmlFromNode: function (node, dstDocument) - { - this._compileInit (dstDocument); - this._mainContext = this._compileNode (node).id; - this._compileEnd (); + */ + ,loadXmlFromNode: function(node, dstDocument, scope) { + this._compileInit(dstDocument, scope); + this._mainContext = this._compileNode(node).id; + this._compileEnd(); return true; } - ,load: function () - { + ,load: function() { if (this._contexts === null) return null; var contexts = this._contexts; var len = contexts.length; - var objects = new Array (len); + var objects = new Array(len); - for (var i = 0; i < len; i++) - { + for (var i = 0; i < len; i++) { var context = contexts[i]; if (context.tagName) - objects[i] = this.elementInstantiate (context); + objects[i] = this.elementInstantiate(context); else if (context.klass) - objects[i] = this.objectInstantiate (context); + objects[i] = this.objectInstantiate(context); else - objects[i] = this.textInstantiate (context); + objects[i] = this.textInstantiate(context); } - return new BuilderResult (this, objects); + return new BuilderResult(this, objects); } - ,link: function (result) - { + ,link: function(result, self, scope) { var objects = result.objects; - for (var i = this._links.length - 1; i >= 0; i--) - { + for (var i = this._links.length - 1; i >= 0; i--) { var l = this._links[i]; var addedObject = this._addedMap[l.objectId]; - if (addedObject) - { + if (addedObject) { if (l.prop) objects[l.context.id][l.prop] = addedObject; else - objects[l.context.id].appendChild (addedObject); - } - else - this._showError ('Referenced unexistent object with id \'%s\'', + objects[l.context.id].appendChild(addedObject); + } else + this._showError('Referenced unexistent object with id \'%s\'', l.objectId); } + this.linkExpr(result, self, scope); + var contexts = this._contexts; - for (var i = 0; i < contexts.length; i++) - { + for (var i = 0; i < contexts.length; i++) { var context = contexts[i]; var object = objects[i]; if (context.tagName) - this.elementLink (context, object, objects, result); + this.elementLink(context, object, objects, result); else if (context.klass) - this.objectLink (context, object, objects, result); + this.objectLink(context, object, objects, result); } } + + ,fnExpr(expr) { + return new Function(this._scopeArgs, + '"use strict"; return ' + expr + ';' + ); + } - ,_compileInit: function (dstDocument) - { + ,matchExpr(value) { + const match = /^{{(.*)}}$/.exec(value); + if (!match) return null; + return this.fnExpr(match[1]); + } + + ,linkExpr(result, self, scope) { + const contexts = this._contexts; + const objects = result.objects; + let args = [_] + + if (scope) args = args.concat(scope); + + for (let i = 0; i < contexts.length; i++) { + const context = contexts[i]; + const object = objects[i]; + + if (context.exprs) { + const values = []; + for (expr of context.exprs) { + let value = undefined; + try { + value = expr.apply(self, args); + } catch (e) { + console.warn('Expression error:', e.message); + continue; + } + values.push(value); + } + + let k = 0; + const text = context.text.replace(/{{\d+}}/g, function() { + return values[k++]; + }); + object.textContent = text; + } else { + const dynProps = context.dynProps; + + for (const prop in dynProps) { + let value = undefined; + try { + value = dynProps[prop].apply(self, args); + } catch (e) { + console.warn('Expression error:', e.message); + continue; + } + + if (context.tagName) + object.setAttribute(prop, value); + else + object[prop] = value; + } + } + } + } + + ,_compileInit: function(dstDocument, scope) { this._path = null; this._tags = {}; this._contexts = []; @@ -191,61 +235,58 @@ module.exports = new Class this._links = []; this._mainContext = null; this._doc = dstDocument ? dstDocument : document; + + this._scope = ['_']; + if (scope) + this._scope = this._scope.concat(scope); + this._scopeArgs = this._scope.join(','); } - ,_compileEnd: function () - { - for (var i = this._links.length - 1; i >= 0; i--) - { + ,_compileEnd: function() { + for (var i = this._links.length - 1; i >= 0; i--) { var l = this._links[i]; var contextId = this._contextMap[l.objectId]; - if (contextId != undefined) - { + if (contextId != undefined) { if (l.prop) l.context.objectProps[l.prop] = contextId; else - l.context.childs.push (contextId); + l.context.childs.push(contextId); - this._links.splice (i, 1); - } - else - { + this._links.splice(i, 1); + } else { var object = this._addedMap[l.objectId]; if (!object && this._parentResult) - object = this._parentResult.getById (l.objectId); + object = this._parentResult.getById(l.objectId); - if (object) - { + if (object) { l.context.props[l.prop] = object; - this._links.splice (i, 1); + this._links.splice(i, 1); } } } } - ,_compileNode: function (node) - { + ,_compileNode: function(node) { var context = null; var tagName = null; if (node.nodeType === Node.ELEMENT_NODE) - tagName = node.tagName.toLowerCase (); + tagName = node.tagName.toLowerCase(); else if (node.nodeType !== Node.TEXT_NODE - || /^[\n\r\t]*$/.test (node.textContent)) + || /^[\n\r\t]*$/.test(node.textContent)) return null; var context = - this.textCompile (node, tagName) - || this.objectCompile (node, tagName) - || this.elementCompile (node, tagName); + this.textCompile(node, tagName) + || this.objectCompile(node, tagName) + || this.elementCompile(node, tagName); context.id = this._contexts.length; - if (tagName) - { - var nodeId = node.getAttribute ('id'); + if (tagName) { + var nodeId = node.getAttribute('id'); if (nodeId) this._contextMap[nodeId] = context.id; @@ -255,44 +296,53 @@ module.exports = new Class if (!tags) this._tags[tagName] = tags = []; - tags.push (context.id); + tags.push(context.id); } - this._contexts.push (context); + this._contexts.push(context); return context; } /** * Creates a text node context. - **/ - ,textCompile: function (node, tagName) - { - if (!tagName) - var text = node.textContent; - else if (tagName === 't') - var text = _(node.firstChild.textContent); + */ + ,textCompile: function(node, tagName) { + if (!tagName) { + let text = node.textContent; + + if (/{{.*}}/.test(text)) { + let i = 0; + const self = this; + const exprs = []; + text = text.replace(/{{((?:(?!}}).)*)}}/g, function(match, capture) { + exprs.push(self.fnExpr(capture)); + return `{{${i++}}}`; + }); + + return {text, exprs}; + } else + return {text}; + } else if (tagName === 't') + return {text: _(node.firstChild.textContent)}; else return null; - - return {text: text}; } - ,textInstantiate: function (context) - { - return this._doc.createTextNode (context.text); + ,textInstantiate: function(context) { + return this._doc.createTextNode(context.exprs ? '' : context.text); } /** * Creates a object context. - **/ - ,objectCompile: function (node, tagName) - { + */ + ,objectCompile: function(node, tagName) { var klass = vnCustomTags[tagName]; if (!klass) return null; var props = {}; + var dynProps = {}; var objectProps = {}; var childs = []; var events = {}; @@ -300,6 +350,7 @@ module.exports = new Class var context = { klass: klass, props: props, + dynProps: dynProps, objectProps: objectProps, childs: childs, events: events, @@ -308,21 +359,17 @@ module.exports = new Class var a = node.attributes; - for (var i = 0; i < a.length; i++) - { + for (var i = 0; i < a.length; i++) { var attribute = a[i].nodeName; var value = a[i].nodeValue; - if (this._isEvent (attribute)) - { - var handler = this._getMethod (value) + if (this._isEvent(attribute)) { + var handler = this._getMethod(value) if (handler) - events[attribute.substr (3)] = handler; - } - else if (!/^(id|property)$/.test (attribute)) - { - this.propCompile (context, klass, props, + events[attribute.substr(3)] = handler; + } else if (!/^(id|property)$/.test(attribute)) { + this.propCompile(context, klass, props, dynProps, node, attribute, value); } } @@ -330,97 +377,89 @@ module.exports = new Class var childNodes = node.childNodes; if (childNodes) - for (var i = 0; i < childNodes.length; i++) - { + for (var i = 0; i < childNodes.length; i++) { var child = childNodes[i]; var isElement = child.nodeType === Node.ELEMENT_NODE; - var childTagName = isElement ? child.tagName.toLowerCase () : null; + var childTagName = isElement ? child.tagName.toLowerCase() : null; var childContext; - if (childTagName === 'pointer') - { - this._addLink (context, null, child.getAttribute ('object')); - } - else if (childTagName === 'custom') - { + if (childTagName === 'pointer') { + this._addLink(context, null, child.getAttribute('object')); + } else if (childTagName === 'custom') { context.custom = child; - } - else if (childContext = this._compileNode (child)) - { - var prop = isElement ? child.getAttribute ('property') : null; + } else if (childContext = this._compileNode(child)) { + var prop = isElement ? child.getAttribute('property') : null; - if (prop) - { - prop = prop.replace (/-./g, this._replaceFunc); + if (prop) { + prop = prop.replace(/-./g, this._replaceFunc); objectProps[prop] = childContext.id; - } - else - childs.push (childContext.id); + } else + childs.push(childContext.id); } } return context; } - ,propCompile: function (context, klass, props, node, attribute, value) - { + ,propCompile: function(context, klass, props, dynProps, node, attribute, value) { var isLink = false; var newValue = null; - var propName = attribute.replace (/-./g, this._replaceFunc); + var propName = attribute.replace(/-./g, this._replaceFunc); var propInfo = klass.Properties[propName]; - if (!propInfo) - { - this._showError ('Attribute \'%s\' not valid for tag \'%s\'', + if (!propInfo) { + this._showError('Attribute \'%s\' not valid for tag \'%s\'', attribute, node.tagName); return; } - if (!value) - { - this._showError ('Attribute \'%s\' empty on tag \'%s\'', + if (!value) { + this._showError('Attribute \'%s\' empty on tag \'%s\'', attribute, node.tagName); return; } - switch (propInfo.type) - { + const expr = this.matchExpr(value); + + if (expr) { + dynProps[propName] = expr; + } else { + switch (propInfo.type) { case Boolean: - newValue = (/^(true|1)$/i).test (value); + newValue = (/^(true|1)$/i).test(value); break; case Number: - newValue = 0 + new Number (value); + newValue = 0 + new Number(value); break; case String: - newValue = this._translateValue (value); + newValue = this._translateValue(value); break; case Function: - var method = this._getMethod (value); - newValue = method ? method.bind (this.signalData) : null; + var method = this._getMethod(value); + newValue = method ? method.bind(this.signalData) : null; break; default: if (propInfo.enumType) newValue = propInfo.enumType[value]; else if (propInfo.type instanceof Function) isLink = true; + } + + if (isLink) + this._addLink(context, propName, value); + else if (newValue !== null && newValue !== undefined) + props[propName] = newValue; + else + this._showError('Attribute \'%s\' invalid for tag \'%s\'', + attribute, node.tagName); } - - if (isLink) - this._addLink (context, propName, value); - else if (newValue !== null && newValue !== undefined) - props[propName] = newValue; - else - this._showError ('Attribute \'%s\' invalid for tag \'%s\'', - attribute, node.tagName); } - ,objectInstantiate: function (context) - { - return new context.klass (); + ,objectInstantiate: function(context) { + return new context.klass(); } - ,objectLink: function (context, object, objects, res) - { - object.setProperties (context.props); + ,objectLink: function(context, object, objects, res) { + object.setProperties(context.props); var objectProps = context.objectProps; for (var prop in objectProps) @@ -428,42 +467,42 @@ module.exports = new Class var childs = context.childs; for (var i = 0; i < childs.length; i++) - object.appendChild (objects[childs[i]]); + object.appendChild(objects[childs[i]]); var events = context.events; for (var event in events) - object.on (event, events[event], this.signalData); + object.on(event, events[event], this.signalData); if (context.custom) - object.loadXml (res, context.custom); + object.loadXml(res, context.custom); } /** * Creates a HTML node context. - **/ - ,elementCompile: function (node, tagName) - { + */ + ,elementCompile: function(node, tagName) { var attributes = {}; + var dynProps = {}; var childs = []; var events = {}; var handler; var a = node.attributes; - for (var i = 0; i < a.length; i++) - { + for (var i = 0; i < a.length; i++) { var attribute = a[i].nodeName; var value = a[i].nodeValue; - - if (this._isEvent (attribute)) - { - var handler = this._getMethod (value); + const expr = this.matchExpr(value); + + if (expr) { + dynProps[attribute] = expr; + } else if (this._isEvent(attribute)) { + var handler = this._getMethod(value); if (handler) - events[attribute.substr (3)] = handler; - } - else if (attribute !== 'id') - attributes[attribute] = this._translateValue (value); + events[attribute.substr(3)] = handler; + } else if (attribute !== 'id') + attributes[attribute] = this._translateValue(value); } var childContext; @@ -471,145 +510,129 @@ module.exports = new Class if (childNodes) for (var i = 0; i < childNodes.length; i++) - if (childContext = this._compileNode (childNodes[i])) - childs.push (childContext.id); + if (childContext = this._compileNode(childNodes[i])) + childs.push(childContext.id); return { - tagName: tagName, - attributes: attributes, - childs: childs, - events: events + tagName, + attributes, + dynProps, + childs, + events }; } - ,elementInstantiate: function (context) - { - return this._doc.createElement (context.tagName); + ,elementInstantiate: function(context) { + return this._doc.createElement(context.tagName); } - ,elementLink: function (context, object, objects) - { + ,elementLink: function(context, object, objects) { var attributes = context.attributes; for (var attribute in attributes) - object.setAttribute (attribute, attributes[attribute]); + object.setAttribute(attribute, attributes[attribute]); var childs = context.childs; - for (var i = 0; i < childs.length; i++) - { + for (var i = 0; i < childs.length; i++) { var child = objects[childs[i]]; if (child instanceof Htk.Widget) child = child.node; if (child instanceof Node) - object.appendChild (child); + object.appendChild(child); } var events = context.events; for (var event in events) - object.addEventListener (event, - events[event].bind (this.signalData)); + object.addEventListener(event, + events[event].bind(this.signalData)); } - ,_showError: function (error) - { + ,_showError: function(error) { var path = this._path ? this._path : 'Node'; var logArgs = ['Vn.Builder: %s: '+ error, path]; for (var i = 1; i < arguments.length; i++) - logArgs.push (arguments[i]); + logArgs.push(arguments[i]); - console.warn.apply (null, logArgs); + console.warn.apply(null, logArgs); } - ,_addLink: function (context, prop, objectId) - { - this._links.push ({ + ,_addLink: function(context, prop, objectId) { + this._links.push({ context: context ,prop: prop ,objectId: objectId }); } - ,_translateValue: function (value) - { - var chr = value.charAt (0); + ,_translateValue: function(value) { + var chr = value.charAt(0); if (chr === '_') - return _(value.substr (1)); - else if (chr === '\\' && value.charAt (1) === '_') - return value.substr (1); + return _(value.substr(1)); + else if (chr === '\\' && value.charAt(1) === '_') + return value.substr(1); return value; } - ,_getMethod: function (value) - { + ,_getMethod: function(value) { if (this.signalData) var method = this.signalData[value]; else var method = window[value]; if (method === undefined) - this._showError ('Function \'%s\' not found', value); + this._showError('Function \'%s\' not found', value); return method; } - ,_isEvent: function (attribute) - { - return /^on-\w+/.test (attribute); + ,_isEvent: function(attribute) { + return /^on-\w+/.test(attribute); } - ,_replaceFunc: function (token) - { - return token.charAt(1).toUpperCase (); + ,_replaceFunc: function(token) { + return token.charAt(1).toUpperCase(); } }); -var BuilderResult = new Class -({ +var BuilderResult = new Class({ Extends: Object - ,initialize: function (builder, objects) - { + ,initialize: function(builder, objects) { this.builder = builder; this.objects = objects; } - ,getMain: function () - { - return this.builder.getMain (this); + ,getMain: function() { + return this.builder.getMain(this); } - ,$: function (objectId) - { - return this.builder.getById (this, objectId); + ,$: function(objectId) { + return this.builder.getById(this, objectId); } - ,getById: function (objectId) - { - return this.builder.getById (this, objectId); + ,getById: function(objectId) { + return this.builder.getById(this, objectId); } - ,getByTagName: function (tagName) - { - return this.builder.getByTagName (this, tagName); + ,getByTagName: function(tagName) { + return this.builder.getByTagName(this, tagName); } - ,link: function () - { - this.builder.link (this); + ,link: function(self, scope) { + this.builder.link(this, self, scope); } - ,_destroy: function () - { + ,_destroy: function() { var objects = this.objects; for (var i = 0; i < objects.length; i++) if (objects[i] instanceof Object) - objects[i].unref (); + objects[i].unref(); - this.parent (); + this.parent(); } }); diff --git a/js/vn/date.js b/js/vn/date.js index 96b5a8e0..256c2edb 100644 --- a/js/vn/date.js +++ b/js/vn/date.js @@ -49,7 +49,7 @@ module.exports = ,'Feb' ,'Mar' ,'Apr' - ,'May' + ,'AbrMay' ,'Jun' ,'Jul' ,'Ago' diff --git a/js/vn/locale/ca.yml b/js/vn/locale/ca.yml index cba6b455..8af6588c 100644 --- a/js/vn/locale/ca.yml +++ b/js/vn/locale/ca.yml @@ -27,6 +27,7 @@ December: Decembre Jan: Gen Feb: Febr Mar: Març +AbrMay: Mai Apr: Abr Jun: Juny Jul: Jul diff --git a/js/vn/locale/en.yml b/js/vn/locale/en.yml index ea9ffe58..4ca5bcfa 100644 --- a/js/vn/locale/en.yml +++ b/js/vn/locale/en.yml @@ -28,6 +28,7 @@ Jan: Jan Feb: Feb Mar: Mar Apr: Apr +AbrMay: May Jun: Jun Jul: Jul Ago: Ago diff --git a/js/vn/locale/es.yml b/js/vn/locale/es.yml index 254dffc9..d9663c12 100644 --- a/js/vn/locale/es.yml +++ b/js/vn/locale/es.yml @@ -16,7 +16,7 @@ January: Enero February: Febrero March: Marzo April: Abril -May: May +May: Mayo June: Junio July: Julio August: Agosto @@ -28,6 +28,7 @@ Jan: Ene Feb: Feb Mar: Mar Apr: Abr +AbrMay: May Jun: Jun Jul: Jul Ago: Ago diff --git a/js/vn/locale/fr.yml b/js/vn/locale/fr.yml index bf6b5ba6..a2789597 100644 --- a/js/vn/locale/fr.yml +++ b/js/vn/locale/fr.yml @@ -28,6 +28,7 @@ Jan: Jan Feb: Fév Mar: Mars Apr: Avr +AbrMay: Mai Jun: Juin Jul: Juil Ago: Août diff --git a/js/vn/locale/mn.yml b/js/vn/locale/mn.yml index 9719aec5..97eb4d32 100644 --- a/js/vn/locale/mn.yml +++ b/js/vn/locale/mn.yml @@ -28,6 +28,7 @@ Jan: оны Feb: хоё Mar: Гур Apr: Дөр +AbrMay: May Jun: Jun Jul: Jul Ago: Най diff --git a/js/vn/locale/pt.yml b/js/vn/locale/pt.yml index 05ca2b73..db6c2892 100644 --- a/js/vn/locale/pt.yml +++ b/js/vn/locale/pt.yml @@ -28,6 +28,7 @@ Jan: Jan Feb: Fev Mar: Mar Apr: Abr +AbrMay: Mai Jun: Jun Jul: Jul Ago: Ago