From a5854290e96110f9133b5eef8020c0427fab115c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 23 Mar 2017 17:20:51 +0100 Subject: [PATCH] Backup --- .eslintrc.yml | 3 +- forms/account/address-list/ui.xml | 2 +- forms/account/address/ui.xml | 2 +- forms/account/conf/ui.xml | 2 +- forms/admin/access-log/ui.xml | 2 +- forms/admin/connections/ui.xml | 2 +- forms/admin/items/ui.xml | 2 +- forms/admin/links/ui.xml | 2 +- forms/admin/photos/ui.xml | 2 +- forms/admin/queries/ui.xml | 2 +- forms/admin/shelves/ui.xml | 2 +- forms/admin/users/ui.xml | 2 +- forms/admin/visits/ui.xml | 2 +- forms/agencies/packages/ui.xml | 2 +- forms/agencies/provinces/ui.xml | 2 +- forms/cms/about/ui.xml | 2 +- forms/cms/contact/ui.xml | 2 +- forms/cms/home/ui.xml | 2 +- forms/cms/location/ui.xml | 2 +- forms/cms/training/ui.xml | 2 +- forms/cms/why/ui.xml | 2 +- forms/ecomerce/basket/ui.xml | 2 +- forms/ecomerce/catalog/ui.xml | 2 +- forms/ecomerce/checkout/ui.xml | 2 +- forms/ecomerce/confirm/ui.xml | 2 +- forms/ecomerce/invoices/ui.xml | 2 +- forms/ecomerce/orders/locale/ca.json | 1 + forms/ecomerce/orders/locale/en.json | 1 + forms/ecomerce/orders/locale/es.json | 1 + forms/ecomerce/orders/locale/fr.json | 1 + forms/ecomerce/orders/locale/mn.json | 1 + forms/ecomerce/orders/locale/pt.json | 1 + forms/ecomerce/orders/orders.js | 4 + forms/ecomerce/orders/style.css | 5 + forms/ecomerce/orders/ui.xml | 17 +++- forms/ecomerce/ticket/ticket.js | 5 +- forms/ecomerce/ticket/ui.xml | 2 +- forms/news/new/ui.xml | 2 +- forms/news/news/ui.xml | 2 +- forms/preview/locale/ca.json | 5 + forms/preview/locale/en.json | 5 + forms/preview/locale/es.json | 5 + forms/preview/locale/fr.json | 5 + forms/preview/locale/mn.json | 5 + forms/preview/locale/pt.json | 5 + forms/preview/preview.js | 43 +++++++++ forms/preview/style.css | 0 forms/preview/ui.xml | 12 +++ image/icon/light/print_backup.svg | 136 --------------------------- js/hedera/form.js | 24 +---- js/hedera/gui.js | 44 ++------- js/hedera/module.js | 29 +++++- js/hedera/report.js | 69 +++----------- js/htk/component.js | 7 ++ js/sql/value.js | 6 +- js/vn/builder.js | 6 +- js/vn/enum.js | 4 + js/vn/hash-param.js | 57 +++++++---- js/vn/hash.js | 2 +- js/vn/type.js | 4 + js/vn/value.js | 2 +- js/vn/vn.js | 3 +- 62 files changed, 265 insertions(+), 309 deletions(-) create mode 100755 forms/preview/locale/ca.json create mode 100755 forms/preview/locale/en.json create mode 100755 forms/preview/locale/es.json create mode 100755 forms/preview/locale/fr.json create mode 100755 forms/preview/locale/mn.json create mode 100644 forms/preview/locale/pt.json create mode 100644 forms/preview/preview.js create mode 100644 forms/preview/style.css create mode 100755 forms/preview/ui.xml delete mode 100644 image/icon/light/print_backup.svg create mode 100644 js/vn/enum.js create mode 100644 js/vn/type.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 899e7a33..cf2ca1e9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -2,4 +2,5 @@ extends: eslint:recommended rules: no-undef: 0 no-redeclare: 0 - no-mixed-spaces-and-tabs: 0 \ No newline at end of file + no-mixed-spaces-and-tabs: 0 + no-console: 0 \ No newline at end of file diff --git a/forms/account/address-list/ui.xml b/forms/account/address-list/ui.xml index 69fd8f50..460768ce 100755 --- a/forms/account/address-list/ui.xml +++ b/forms/account/address-list/ui.xml @@ -28,7 +28,7 @@ tip="_AddAddress" on-click="onAddAddressClick"/> -
+
-
+
diff --git a/forms/account/conf/ui.xml b/forms/account/conf/ui.xml index 639c61a9..6cba81cb 100755 --- a/forms/account/conf/ui.xml +++ b/forms/account/conf/ui.xml @@ -43,7 +43,7 @@ tip="_Change password" on-click="onPassChangeClick"/>
-
+
diff --git a/forms/admin/access-log/ui.xml b/forms/admin/access-log/ui.xml index 73bfb7ae..a4e2e446 100755 --- a/forms/admin/access-log/ui.xml +++ b/forms/admin/access-log/ui.xml @@ -19,7 +19,7 @@

AccessLog

-
+

diff --git a/forms/admin/connections/ui.xml b/forms/admin/connections/ui.xml index ece7ef8b..bf14e9e4 100755 --- a/forms/admin/connections/ui.xml +++ b/forms/admin/connections/ui.xml @@ -17,7 +17,7 @@ connections

-
+
diff --git a/forms/admin/items/ui.xml b/forms/admin/items/ui.xml index 4110bec0..36d90a56 100755 --- a/forms/admin/items/ui.xml +++ b/forms/admin/items/ui.xml @@ -8,7 +8,7 @@ tip="_Preview" on-click="onPreviewClick"/>
-
+
diff --git a/forms/admin/links/ui.xml b/forms/admin/links/ui.xml index f6936f23..08a9b7a3 100755 --- a/forms/admin/links/ui.xml +++ b/forms/admin/links/ui.xml @@ -2,7 +2,7 @@

ControlPanel

-
+
diff --git a/forms/admin/photos/ui.xml b/forms/admin/photos/ui.xml index 42c04f54..98ff7ea4 100755 --- a/forms/admin/photos/ui.xml +++ b/forms/admin/photos/ui.xml @@ -2,7 +2,7 @@

Photos

-
+
diff --git a/forms/admin/queries/ui.xml b/forms/admin/queries/ui.xml index 4c62a742..00a49464 100755 --- a/forms/admin/queries/ui.xml +++ b/forms/admin/queries/ui.xml @@ -12,7 +12,7 @@ tip="_Clean" on-click="_onCleanClick"/>
-
+
diff --git a/forms/admin/shelves/ui.xml b/forms/admin/shelves/ui.xml index df4160e2..c793fbb4 100755 --- a/forms/admin/shelves/ui.xml +++ b/forms/admin/shelves/ui.xml @@ -19,7 +19,7 @@ tip="_Preview" on-click="onPreviewClick"/>
-
+
diff --git a/forms/admin/users/ui.xml b/forms/admin/users/ui.xml index bc7893b8..d458ca42 100755 --- a/forms/admin/users/ui.xml +++ b/forms/admin/users/ui.xml @@ -10,7 +10,7 @@
-
+
diff --git a/forms/admin/visits/ui.xml b/forms/admin/visits/ui.xml index 5f94ebee..e2738f4d 100755 --- a/forms/admin/visits/ui.xml +++ b/forms/admin/visits/ui.xml @@ -12,7 +12,7 @@ tip="_Connections" on-click="onSessionsClick"/>
-
+
diff --git a/forms/agencies/packages/ui.xml b/forms/agencies/packages/ui.xml index ac2c8ae3..7cfb991d 100755 --- a/forms/agencies/packages/ui.xml +++ b/forms/agencies/packages/ui.xml @@ -2,7 +2,7 @@

ListByAgency

-
+
diff --git a/forms/agencies/provinces/ui.xml b/forms/agencies/provinces/ui.xml index 5e255840..a70ccc53 100755 --- a/forms/agencies/provinces/ui.xml +++ b/forms/agencies/provinces/ui.xml @@ -6,7 +6,7 @@

ByProvince

-
+
diff --git a/forms/cms/about/ui.xml b/forms/cms/about/ui.xml index 626ac82a..723835fe 100755 --- a/forms/cms/about/ui.xml +++ b/forms/cms/about/ui.xml @@ -2,7 +2,7 @@

About

-
+

diff --git a/forms/cms/contact/ui.xml b/forms/cms/contact/ui.xml index 3cc0c14a..874094f6 100755 --- a/forms/cms/contact/ui.xml +++ b/forms/cms/contact/ui.xml @@ -2,7 +2,7 @@

IWantCustomer

-
+
diff --git a/forms/cms/home/ui.xml b/forms/cms/home/ui.xml index cf86d5e3..3f06bb6e 100755 --- a/forms/cms/home/ui.xml +++ b/forms/cms/home/ui.xml @@ -9,7 +9,7 @@ tip="_Start order" on-click="onStartOrderClick"/>
-
+
diff --git a/forms/cms/location/ui.xml b/forms/cms/location/ui.xml index c9d830fb..bcfcff01 100755 --- a/forms/cms/location/ui.xml +++ b/forms/cms/location/ui.xml @@ -2,5 +2,5 @@

Location

-
+
diff --git a/forms/cms/training/ui.xml b/forms/cms/training/ui.xml index 2d1ab7be..62716607 100755 --- a/forms/cms/training/ui.xml +++ b/forms/cms/training/ui.xml @@ -2,7 +2,7 @@

Training

-
+
diff --git a/forms/cms/why/ui.xml b/forms/cms/why/ui.xml index a7e612cd..59146976 100755 --- a/forms/cms/why/ui.xml +++ b/forms/cms/why/ui.xml @@ -2,7 +2,7 @@

AboutCompany

-
+
    diff --git a/forms/ecomerce/basket/ui.xml b/forms/ecomerce/basket/ui.xml index 5579b182..17fbadf1 100755 --- a/forms/ecomerce/basket/ui.xml +++ b/forms/ecomerce/basket/ui.xml @@ -16,7 +16,7 @@ tip="_ConfigureOrder" on-click="onConfigureClick"/>
-
+

diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 527c6533..5f0215ff 100755 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -139,7 +139,7 @@

-
+
-
+
Order summary -
+
diff --git a/forms/ecomerce/invoices/ui.xml b/forms/ecomerce/invoices/ui.xml index 089331a7..ded8ee4a 100755 --- a/forms/ecomerce/invoices/ui.xml +++ b/forms/ecomerce/invoices/ui.xml @@ -2,7 +2,7 @@

Invoices

-
+
diff --git a/forms/ecomerce/orders/locale/ca.json b/forms/ecomerce/orders/locale/ca.json index d17fe4fd..30bdcaa2 100755 --- a/forms/ecomerce/orders/locale/ca.json +++ b/forms/ecomerce/orders/locale/ca.json @@ -10,6 +10,7 @@ ,"LastOrders": "Últimes comandes" + ,"Show orders from": "Mostra comandes desde" ,"Balance:": "Saldo:" ,"PaymentInfo": "La quantitat mostrada és el teu saldo pendent (negatiu) o favorable a dia d'avui, no té en compte comandes del futur. Perquè la teva comanda sigui enviat, aquesta quantitat ha de ser igual o més gran que 0. Si vols fer un lliurament a compte, prem el botó de pagament, esborra la quantitat suggerida e introdueix la quantitat que vulguis." ,"MakePayment": "Realitzar pagament" diff --git a/forms/ecomerce/orders/locale/en.json b/forms/ecomerce/orders/locale/en.json index 49ea44b6..29c9e19c 100755 --- a/forms/ecomerce/orders/locale/en.json +++ b/forms/ecomerce/orders/locale/en.json @@ -10,6 +10,7 @@ ,"LastOrders": "Last orders" + ,"Show orders from": "Show orders from" ,"Balance:": "Balance:" ,"PaymentInfo": "The amount shown is your slope (negative) or favorable balance today, it disregards future orders. For get your order shipped, this amount must be equal to or greater than 0. If you want to make a down payment, click the payment button, delete the suggested amount and enter the amount you want." ,"MakePayment": "Make payment" diff --git a/forms/ecomerce/orders/locale/es.json b/forms/ecomerce/orders/locale/es.json index edf69c75..9f1010c5 100755 --- a/forms/ecomerce/orders/locale/es.json +++ b/forms/ecomerce/orders/locale/es.json @@ -10,6 +10,7 @@ ,"LastOrders": "Últimos pedidos" + ,"Show orders from": "Mostrar pedidos desde" ,"Balance:": "Saldo:" ,"PaymentInfo": "La cantidad mostrada es tu saldo pendiente (negativa) o favorable a día de hoy, no tiene en cuenta pedidos del futuro. Para que tu pedido sea enviado, esta cantidad debe ser igual o mayor que 0. Si quieres realizar una entrega a cuenta, pulsa el botón de pago, borra la cantidad sugerida e introduce la cantidad que desees." ,"MakePayment": "Realizar pago" diff --git a/forms/ecomerce/orders/locale/fr.json b/forms/ecomerce/orders/locale/fr.json index dcb046d3..7640cf58 100755 --- a/forms/ecomerce/orders/locale/fr.json +++ b/forms/ecomerce/orders/locale/fr.json @@ -10,6 +10,7 @@ ,"LastOrders": "Les dernières commandes" + ,"Show orders from": "Afficher les commandes de" ,"Balance:": "Balance:" ,"PaymentInfo": "Le montant indiqué est votre pente (négative) ou balance favorable aujourd'hui, ne tient pas compte pour les commandes futures. Obtenir votre commande est expédiée, ce montant doit être égal ou supérieur à 0. Si vous voulez faire un versement, le montant suggéré effacé et entrez le montant que vous souhaitez." ,"MakePayment": "Effectuer un paiement" diff --git a/forms/ecomerce/orders/locale/mn.json b/forms/ecomerce/orders/locale/mn.json index 3e194aff..dfd1d44d 100755 --- a/forms/ecomerce/orders/locale/mn.json +++ b/forms/ecomerce/orders/locale/mn.json @@ -10,6 +10,7 @@ ,"LastOrders": "Last orders" + ,"Show orders from": "-Аас харуулах захиалга" ,"Balance:": "Balance:" ,"PaymentInfo": "Үзүүлсэн хэмжээ цаашид захиалга эзэлж биш, таны налуу (сөрөг), эсвэл тааламжтай тэнцвэр нь өнөөдөр юм. Хэрэв та дүн арилгаж гэж хэлж байсан нь доош нь төлбөр хийж, өөрийн хүссэн хэмжээгээр орж хүсэж байгаа бол таны захиалга ирдэг бол авах, энэ хэмжээ тэнцүү буюу 0-ээс их байх ёстой." ,"MakePayment": "Make payment" diff --git a/forms/ecomerce/orders/locale/pt.json b/forms/ecomerce/orders/locale/pt.json index 65daa841..d0d338f6 100644 --- a/forms/ecomerce/orders/locale/pt.json +++ b/forms/ecomerce/orders/locale/pt.json @@ -10,6 +10,7 @@ ,"LastOrders": "Últimos pedidos" + ,"Show orders from": "Mostrar ordens de" ,"Balance:": "Saldo:" ,"PaymentInfo": "A quantidade mostrada é seu saldo pendente (negativo) ou favorável a dia de hoje, não se vincula a pedidos futuros. Para que seu pedido seja enviado, esta quantidade deve ser igual ou superior a 0. Se queres realizar um depósito à conta, clique no botão de pagamento, apague a quantidade sugerida e introduza a quantidade que deseje." ,"MakePayment": "Realizar pagamento" diff --git a/forms/ecomerce/orders/orders.js b/forms/ecomerce/orders/orders.js index c412f925..b06e3d56 100644 --- a/forms/ecomerce/orders/orders.js +++ b/forms/ecomerce/orders/orders.js @@ -7,6 +7,10 @@ Hedera.Orders = new Class { this.tpv = new Hedera.Tpv ({conn: this.conn}); this.tpv.check (this._onTpvCheck.bind (this)); + + var from = new Date (); + from.setDate (from.getDate () - 25); + this.$('from').value = from; } ,_onTpvCheck: function (tpv, tpvOrder, tpvStatus) diff --git a/forms/ecomerce/orders/style.css b/forms/ecomerce/orders/style.css index 34a9d463..47cbc93c 100644 --- a/forms/ecomerce/orders/style.css +++ b/forms/ecomerce/orders/style.css @@ -1,4 +1,9 @@ +.orders .card +{ + max-width: 28em; +} + /* Balance */ .balance diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index 5e9265ad..dfd967fe 100755 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -1,5 +1,7 @@ + + @@ -37,13 +39,24 @@ alt="Info"/>
-
+
+
+
+ + +
+
-
+
diff --git a/forms/news/new/ui.xml b/forms/news/new/ui.xml index 435940c5..625b842f 100755 --- a/forms/news/new/ui.xml +++ b/forms/news/new/ui.xml @@ -34,7 +34,7 @@ tip="_Return" on-click="onReturnClick"/>
-
+
diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml index 2f2d637d..2466c3f6 100755 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -8,7 +8,7 @@ tip="_AddNew" on-click="onAddClick"/>
-
+
diff --git a/forms/preview/locale/ca.json b/forms/preview/locale/ca.json new file mode 100755 index 00000000..d8389468 --- /dev/null +++ b/forms/preview/locale/ca.json @@ -0,0 +1,5 @@ +{ + "Report": "Informe" + ,"Preview": "Visualització prèvia" + ,"Print": "Imprimir" +} diff --git a/forms/preview/locale/en.json b/forms/preview/locale/en.json new file mode 100755 index 00000000..2c26d18c --- /dev/null +++ b/forms/preview/locale/en.json @@ -0,0 +1,5 @@ +{ + "Report": "Report" + ,"Preview": "Preview" + ,"Print": "Print" +} diff --git a/forms/preview/locale/es.json b/forms/preview/locale/es.json new file mode 100755 index 00000000..2289b4db --- /dev/null +++ b/forms/preview/locale/es.json @@ -0,0 +1,5 @@ +{ + "Report": "Informe" + ,"Preview": "Vista preliminar" + ,"Print": "Imprimir" +} diff --git a/forms/preview/locale/fr.json b/forms/preview/locale/fr.json new file mode 100755 index 00000000..d69401d5 --- /dev/null +++ b/forms/preview/locale/fr.json @@ -0,0 +1,5 @@ +{ + "Report": "Rapport" + ,"Preview": "Avant-première" + ,"Print": "Imprimer" +} diff --git a/forms/preview/locale/mn.json b/forms/preview/locale/mn.json new file mode 100755 index 00000000..44a01367 --- /dev/null +++ b/forms/preview/locale/mn.json @@ -0,0 +1,5 @@ +{ + "Report": "тайлан" + ,"Preview": "Урьдчилан харах" + ,"Print": "хэвлэх" +} diff --git a/forms/preview/locale/pt.json b/forms/preview/locale/pt.json new file mode 100644 index 00000000..8a8b19f9 --- /dev/null +++ b/forms/preview/locale/pt.json @@ -0,0 +1,5 @@ +{ + "Report": "Relatório" + ,"Preview": "Vsualização" + ,"Print": "Impressão" +} diff --git a/forms/preview/preview.js b/forms/preview/preview.js new file mode 100644 index 00000000..16c877db --- /dev/null +++ b/forms/preview/preview.js @@ -0,0 +1,43 @@ + +Hedera.Preview = new Class +({ + Extends: Hedera.Form + + ,activate: function () + { + var reportName = Vn.Hash.get ('report'); + + if (!reportName) + { + Htk.Toast.showError (_('Report name not set')); + return; + } + + this.gui.loaderPush (); + + var module = new Hedera.Module ('reports', reportName); + module.load (this._onReportLoad.bind (this)); + } + + ,_onReportLoad: function (module) + { + this.gui.loaderPop (); + + if (module.error) + { + Htk.Toast.showError (_('Error loading report')); + return; + } + + var batch = new Sql.Batch (); + batch.addValues (Vn.Hash._hashMap); + + var report = new module.klass (module, this.gui); + report.open (batch, this.node); + } + + ,onPrintClick: function () + { + this.doc.defaultView.print (); + } +}); diff --git a/forms/preview/style.css b/forms/preview/style.css new file mode 100644 index 00000000..e69de29b diff --git a/forms/preview/ui.xml b/forms/preview/ui.xml new file mode 100755 index 00000000..54dfa8fe --- /dev/null +++ b/forms/preview/ui.xml @@ -0,0 +1,12 @@ + +

+ Preview +

+
+ +
+
+ diff --git a/image/icon/light/print_backup.svg b/image/icon/light/print_backup.svg deleted file mode 100644 index b14a8256..00000000 --- a/image/icon/light/print_backup.svg +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - image/svg+xml - - Gnome Symbolic Icon Theme - - - - - - - Gnome Symbolic Icon Theme - - - - - - - - - - - - - - - - diff --git a/js/hedera/form.js b/js/hedera/form.js index b1864abf..48d2eaad 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -1,7 +1,7 @@ module.exports = new Class ({ - Extends: Vn.Object + Extends: Htk.Component ,isOpen: false ,uiLoaded: false @@ -13,20 +13,6 @@ module.exports = new Class this.hash = gui.hash; this.formInfo = formInfo; } - - /** - * Gets an object from the builder associated to this form. - * - * @param {string} objectId The object identifier - * @return {Object} The object, or %null if not found - */ - ,$: function (objectId) - { - if (this.builder) - return this.builder.getById (objectId); - - return null; - } ,loadUi: function () { @@ -37,10 +23,8 @@ module.exports = new Class builder.signalData = this; builder.add ('conn', this.conn); builder.loadXml ('forms/'+ this.formInfo.path +'/ui.xml'); - - var res = this.builder = builder.load (); - this.node = res.$('form'); - res.link (); + + var res = this.builderResultInit (builder); var models = res.getByTagName ('db-model'); @@ -51,7 +35,7 @@ module.exports = new Class for (var i = 0; i < queries.length; i++) queries[i].conn = this.conn; - + if (this.node) { this.gui.setForm (this.node); diff --git a/js/hedera/gui.js b/js/hedera/gui.js index d24e0b9c..8dc7c9e3 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -24,7 +24,6 @@ module.exports = new Class ,forms: {} ,activeForm: null - ,activeCss: null ,requestedForm: null ,menuShown: false ,menuOptions: {} @@ -398,9 +397,6 @@ module.exports = new Class this.choosedOption = newChoosedOption; } - this.activeCss = 'forms/'+ formPath +'/style.css'; - Vn.includeCss (this.activeCss); - var formInfo = this.forms[formPath]; if (!formInfo) @@ -409,7 +405,7 @@ module.exports = new Class this.forms[formPath] = formInfo; } - formInfo.addCallback (callback); + formInfo.load (callback); } ,_onFormLoad: function (formInfo) @@ -459,50 +455,30 @@ module.exports = new Class { if (this.activeForm) { + this.activeForm.formInfo.unload (); this.activeForm.close (); this.activeForm.unref (); this.activeForm = null; } - if (this.activeCss) - { - Vn.excludeCss (this.activeCss); - this.activeCss = null; - } - if (this.choosedOption) { Vn.Node.removeClass (this.choosedOption, 'selected'); this.choosedOption = null; } } - - //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Reports - - ,openReport: function (reportName, batch) - { - this.loaderPush (); - var module = new Module ('reports', reportName); - module.addCallback (this._onReportLoad.bind (this, batch)); - } - - ,_onReportLoad: function (batch, module) + ,openReport: function (reportName, params) { - this.loaderPop (); - - if (module.error) - { - Htk.Toast.showError (_('Error loading report')); - return; - } - - var report = new module.klass (module, this); - report.open (batch); + var hashParams = { + form: 'preview', + report: reportName + }; + Vn.Hash.set (Object.assign (hashParams, params)); } - + //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Supplant - + ,supplantUser: function (user, callback) { this._conn.supplantUser (user, diff --git a/js/hedera/module.js b/js/hedera/module.js index 2810921b..d6dc9882 100644 --- a/js/hedera/module.js +++ b/js/hedera/module.js @@ -29,13 +29,31 @@ module.exports = new Class this.path = path; this.moduleName = moduleName; } - - ,addCallback: function (callback) + + ,getCssPath: function () { - if (!this.ready) - this.callbacks.push (callback); - else + return this.basePath +'/'+ this.path +'/style.css'; + } + + ,includeCss: function () + { + Vn.includeCss (this.getCssPath ()); + } + + ,unload: function () + { + Vn.excludeCss (this.getCssPath ()); + } + + ,load: function (callback) + { + if (this.ready) + { + this.includeCss (); callback (this); + } + else + this.callbacks.push (callback); } ,onLocaleReady: function (success) @@ -78,6 +96,7 @@ module.exports = new Class var callbacks = this.callbacks; this.callbacks = null; + this.includeCss (); for (var i = 0; i < callbacks.length; i++) callbacks[i] (this); diff --git a/js/hedera/report.js b/js/hedera/report.js index b7fe0165..cade3ee9 100644 --- a/js/hedera/report.js +++ b/js/hedera/report.js @@ -1,7 +1,7 @@ module.exports = new Class ({ - Extends: Vn.Object + Extends: Htk.Component ,initialize: function (moduleInfo, gui) { @@ -11,23 +11,10 @@ module.exports = new Class this.parent (null); } - /** - * Gets an object from the builder associated to this report. - * - * @param {string} objectId The object identifier - * @return {Object} The object, or %null if not found - */ - ,$: function (objectId) - { - if (this.builderResult) - return this.builderResult.getById (objectId); - - return null; - } - - ,open: function (batch) + ,open: function (batch, body) { this.batch = batch; + this.body = body; this.createWindow (); } @@ -36,53 +23,25 @@ module.exports = new Class this.window.print (); } - ,includeCss: function (path) - { - var basePath = location.protocol +'//'+ location.host; - basePath += location.port ? ':'+ location.port : ''; - basePath += location.pathname.substring (0, - location.pathname.lastIndexOf ('/')); - - var link = this.doc.createElement ('link'); - link.rel = 'stylesheet'; - link.type = 'text/css'; - link.href = basePath +'/'+ path + Vn.getVersion (); - - var head = this.doc.getElementsByTagName ('head')[0]; - head.appendChild (link); - } - ,createWindow: function () { - var reportWindow = window.open ( - 'js/hedera/report.html', '_blank', - 'height=650, width=950, resizable=yes, fullscreen=no,'+ - 'titlebar=no, menubar=no, toolbar=no, location=no, scrollbars=yes' - ); - - if (!reportWindow) - { - Htk.Toast.showError ( - _('Please unlock popups and try again')); - return false; - } - + var iframe = this.iframe = this.createElement ('iframe'); + iframe.src = 'js/hedera/report.html'; + iframe.style.display = 'none'; + document.body.appendChild (iframe); + + var reportWindow = iframe.contentWindow; + reportWindow.addEventListener ('load', this._onWindowLoad.bind (this)); this.window = reportWindow; + return true; } ,_onWindowLoad: function () { this.doc = this.window.document - - this.includeCss ('reports/'+ this.info.path +'/style.css'); - - var printButton = this.doc.getElementById ('print'); - printButton.addEventListener ('click', this.print.bind (this)); - Vn.Node.setText (printButton, _('Print')); - this.onWindowCreate (); } @@ -94,9 +53,7 @@ module.exports = new Class builder.add ('conn', this.conn); builder.loadXml ('reports/'+ this.info.path +'/ui.xml'); - var res = this.builderResult = builder.load (); - res.link (); - - this.doc.body.appendChild (res.$('report')); + var res = this.builderResultInit (builder); + this.body.appendChild (res.$('report')); } }); diff --git a/js/htk/component.js b/js/htk/component.js index 9f6465fb..4b37b4ed 100644 --- a/js/htk/component.js +++ b/js/htk/component.js @@ -28,8 +28,15 @@ module.exports = new Class var res = this.builder = builder.load (); this._node = res.$('main'); res.link (); + return res; } + /** + * Gets an object from the builder associated to this component. + * + * @param {string} objectId The object identifier + * @return {Object} The object, or %null if not found + */ ,$: function (id) { if (this.builder) diff --git a/js/sql/value.js b/js/sql/value.js index cee4f5dc..c0a73d5b 100644 --- a/js/sql/value.js +++ b/js/sql/value.js @@ -90,7 +90,7 @@ module.exports = new Class return token; } - ,render: function (batch) + ,render: function () { var v = this._value; @@ -105,8 +105,8 @@ module.exports = new Class case 'object': if (v instanceof Date) return Vn.Date.strftime (v, '\'%Y-%m-%d\''); - default: - return 'NULL'; } + + return 'NULL'; } }); diff --git a/js/vn/builder.js b/js/vn/builder.js index 31277225..5cf0fb46 100644 --- a/js/vn/builder.js +++ b/js/vn/builder.js @@ -1,5 +1,6 @@ var Object = require ('./object'); +var Type = require ('./type'); /** * Creates a object from a XML specification. @@ -400,6 +401,9 @@ module.exports = new Class var method = this._getMethod (value); newValue = method ? method.bind (this.signalData) : null; break; + case Type: + newValue = window[value]; + break; default: if (propInfo.enumType) newValue = propInfo.enumType[value]; @@ -521,7 +525,7 @@ module.exports = new Class for (var i = 1; i < arguments.length; i++) logArgs.push (arguments[i]); - console.warn.apply (null, logArgs); + console.warn.apply (console, logArgs); } ,_addLink: function (context, prop, objectId) diff --git a/js/vn/enum.js b/js/vn/enum.js new file mode 100644 index 00000000..0f1712c1 --- /dev/null +++ b/js/vn/enum.js @@ -0,0 +1,4 @@ +/** + * Base type for ennumerations. + */ +module.exports = function () {}; diff --git a/js/vn/hash-param.js b/js/vn/hash-param.js index 7af54c9b..1a02ccb9 100644 --- a/js/vn/hash-param.js +++ b/js/vn/hash-param.js @@ -2,6 +2,8 @@ var Object = require ('./object'); var Param = require ('./param'); var Hash = require ('./hash'); +var Type = require ('./type'); +var VnDate = require ('./date'); module.exports = new Class ({ @@ -50,7 +52,7 @@ module.exports = new Class }, type: { - type: Object + type: Type ,set: function (x) { this._type = x; @@ -77,26 +79,47 @@ module.exports = new Class this._onHashChange (); } + ,parseHashValue: function (v, type) + { + if (v === '') + return null; + + if (type && v !== undefined && v !== null) + switch (type) + { + case Boolean: + return (/^(true|1)$/i).test (v); + case Number: + return 0 + new Number (v); + case Date: + return new Date(v); + } + + return v; + } + + ,renderHashValue: function (v) + { + switch (typeof v) + { + case 'number': + return v; + case 'boolean': + return (v) ? 'true' : 'false'; + case 'object': + if (v instanceof Date) + return VnDate.strftime (v, '%Y-%m-%d'); + } + + return v; + } + ,_onHashChange: function () { if (this._hashLock || !this._key || !this._listener) return; - var newValue = Hash.get (this._key); - - if (newValue === '') - newValue = null; - - if (this._type && newValue !== undefined && newValue !== null) - switch (this._type) - { - case Boolean: - newValue = (/^(true|1)$/i).test (newValue); - break; - case Number: - newValue = 0 + new Number (newValue); - break; - } + var newValue = this.parseHashValue (Hash.get (this._key), this._type); this._hashLock = true; this._setValue (newValue, true); @@ -115,7 +138,7 @@ module.exports = new Class this._hashLock = true; var map = {}; - map[this._key] = newValue; + map[this._key] = this.renderHashValue(newValue); Hash.add (map); this._hashLock = false; diff --git a/js/vn/hash.js b/js/vn/hash.js index 2ead138e..72e9cf46 100644 --- a/js/vn/hash.js +++ b/js/vn/hash.js @@ -126,7 +126,7 @@ module.exports = var kvPair = kvPairs[i].split ('=', 2); if (kvPair[0]) - newMap[kvPair[0]] = kvPair[1]; + newMap[kvPair[0]] = decodeURIComponent(kvPair[1]); } this._hashMap = newMap; diff --git a/js/vn/type.js b/js/vn/type.js new file mode 100644 index 00000000..9515ada6 --- /dev/null +++ b/js/vn/type.js @@ -0,0 +1,4 @@ +/** + * Type that references another type. + */ +module.exports = function () {}; \ No newline at end of file diff --git a/js/vn/value.js b/js/vn/value.js index 50dcb287..a4c30c90 100644 --- a/js/vn/value.js +++ b/js/vn/value.js @@ -10,7 +10,7 @@ module.exports = { if (a === b) return true; - if (typeof a === typeof b && a instanceof Date) + if (a instanceof Date && b instanceof Date) return a.getTime () === b.getTime (); return false; diff --git a/js/vn/vn.js b/js/vn/vn.js index 74860294..3da01551 100644 --- a/js/vn/vn.js +++ b/js/vn/vn.js @@ -3,7 +3,8 @@ require ('mootools'); Vn = module.exports = { Locale : require ('./locale') - ,Enum : function () {} + ,Enum : require ('./enum') + ,Type : require ('./type') ,Object : require ('./object') ,Browser : require ('./browser') ,Cookie : require ('./cookie')