From 0510149fd81fbfae3a48684ac85ac89f3d242d84 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 16 Nov 2022 02:44:39 +0100 Subject: [PATCH] refs #3971 Webpack imports --- app.js | 35 ++-------- debian/changelog | 2 +- .../{address-list.js => index.js} | 18 ++--- .../address-list/{style.css => style.scss} | 0 .../account/address/{address.js => index.js} | 10 +-- forms/account/conf/{conf.js => index.js} | 10 +-- forms/account/conf/{style.css => style.scss} | 0 forms/admin/access-log/access-log.js | 5 -- forms/admin/access-log/index.js | 7 ++ .../access-log/{style.css => style.scss} | 0 forms/admin/connections/connections.js | 35 ---------- forms/admin/connections/index.js | 2 +- .../connections/{style.css => style.scss} | 0 forms/admin/items/{items.js => index.js} | 4 +- forms/admin/items/{style.css => style.scss} | 0 forms/admin/links/index.js | 7 ++ forms/admin/links/links.js | 5 -- forms/admin/links/{style.css => style.scss} | 0 forms/admin/photos/{photos.js => index.js} | 10 +-- forms/admin/photos/{style.css => style.scss} | 0 forms/admin/queries/{queries.js => index.js} | 6 +- forms/admin/queries/{style.css => style.scss} | 0 forms/admin/users/{users.js => index.js} | 6 +- forms/admin/users/{style.css => style.scss} | 0 forms/admin/visits/{visits.js => index.js} | 6 +- forms/admin/visits/{style.css => style.scss} | 0 forms/agencies/packages/index.js | 14 ++++ forms/agencies/packages/packages.js | 12 ---- .../packages/style.scss} | 0 forms/agencies/provinces/index.js | 7 ++ forms/agencies/provinces/provinces.js | 5 -- .../style.css => provinces/style.scss} | 0 forms/cms/about/about.js | 6 -- forms/cms/about/index.js | 7 ++ forms/cms/about/{style.css => style.scss} | 0 forms/cms/contact/{contact.js => index.js} | 6 +- forms/cms/contact/{style.css => style.scss} | 0 forms/cms/home/home.js | 5 -- forms/cms/home/index.js | 6 ++ forms/cms/home/{style.css => style.scss} | 0 forms/cms/location/{location.js => index.js} | 6 +- forms/cms/location/{style.css => style.scss} | 0 forms/cms/why/index.js | 7 ++ forms/cms/why/{style.css => style.scss} | 0 forms/cms/why/why.js | 6 -- forms/ecomerce/basket/{basket.js => index.js} | 4 +- .../ecomerce/basket/{style.css => style.scss} | 0 .../ecomerce/catalog/{catalog.js => index.js} | 5 +- .../catalog/{style.css => style.scss} | 0 forms/ecomerce/catalog/ui.xml | 2 +- .../checkout/{checkout.js => index.js} | 4 +- .../checkout/{style.css => style.scss} | 0 .../ecomerce/confirm/{confirm.js => index.js} | 4 +- .../confirm/{style.css => style.scss} | 0 .../invoices/{invoices.js => index.js} | 4 +- forms/ecomerce/invoices/style.css | 0 .../invoices/style.scss} | 0 forms/ecomerce/orders/{orders.js => index.js} | 4 +- .../ecomerce/orders/{style.css => style.scss} | 0 forms/ecomerce/ticket/{ticket.js => index.js} | 4 +- .../ecomerce/ticket/{style.css => style.scss} | 0 forms/news/new/{new.js => index.js} | 10 +-- forms/news/new/{style.css => style.scss} | 0 forms/news/news/{news.js => index.js} | 6 +- forms/news/news/{style.css => style.scss} | 0 forms/reports/items-form/items-form.js | 2 +- forms/reports/shelves/shelves.js | 2 +- import.js | 65 +++++++++++++++++++ js/hedera/form.js | 5 +- js/hedera/gui.js | 41 +++++------- js/hedera/login.js | 3 +- js/vn/mutators.js | 4 ++ package.json | 2 +- webpack.config.js | 1 + 74 files changed, 237 insertions(+), 190 deletions(-) rename forms/account/address-list/{address-list.js => index.js} (66%) rename forms/account/address-list/{style.css => style.scss} (100%) rename forms/account/address/{address.js => index.js} (76%) rename forms/account/conf/{conf.js => index.js} (93%) rename forms/account/conf/{style.css => style.scss} (100%) delete mode 100644 forms/admin/access-log/access-log.js create mode 100644 forms/admin/access-log/index.js rename forms/admin/access-log/{style.css => style.scss} (100%) delete mode 100644 forms/admin/connections/connections.js rename forms/admin/connections/{style.css => style.scss} (100%) rename forms/admin/items/{items.js => index.js} (57%) rename forms/admin/items/{style.css => style.scss} (100%) create mode 100644 forms/admin/links/index.js delete mode 100644 forms/admin/links/links.js rename forms/admin/links/{style.css => style.scss} (100%) rename forms/admin/photos/{photos.js => index.js} (97%) rename forms/admin/photos/{style.css => style.scss} (100%) rename forms/admin/queries/{queries.js => index.js} (94%) rename forms/admin/queries/{style.css => style.scss} (100%) rename forms/admin/users/{users.js => index.js} (80%) rename forms/admin/users/{style.css => style.scss} (100%) rename forms/admin/visits/{visits.js => index.js} (55%) rename forms/admin/visits/{style.css => style.scss} (100%) create mode 100644 forms/agencies/packages/index.js delete mode 100644 forms/agencies/packages/packages.js rename forms/{account/address/style.css => agencies/packages/style.scss} (100%) create mode 100644 forms/agencies/provinces/index.js delete mode 100644 forms/agencies/provinces/provinces.js rename forms/agencies/{packages/style.css => provinces/style.scss} (100%) delete mode 100644 forms/cms/about/about.js create mode 100644 forms/cms/about/index.js rename forms/cms/about/{style.css => style.scss} (100%) rename forms/cms/contact/{contact.js => index.js} (87%) rename forms/cms/contact/{style.css => style.scss} (100%) delete mode 100644 forms/cms/home/home.js create mode 100644 forms/cms/home/index.js rename forms/cms/home/{style.css => style.scss} (100%) rename forms/cms/location/{location.js => index.js} (96%) rename forms/cms/location/{style.css => style.scss} (100%) create mode 100644 forms/cms/why/index.js rename forms/cms/why/{style.css => style.scss} (100%) delete mode 100644 forms/cms/why/why.js rename forms/ecomerce/basket/{basket.js => index.js} (87%) rename forms/ecomerce/basket/{style.css => style.scss} (100%) rename forms/ecomerce/catalog/{catalog.js => index.js} (98%) rename forms/ecomerce/catalog/{style.css => style.scss} (100%) rename forms/ecomerce/checkout/{checkout.js => index.js} (98%) rename forms/ecomerce/checkout/{style.css => style.scss} (100%) rename forms/ecomerce/confirm/{confirm.js => index.js} (97%) rename forms/ecomerce/confirm/{style.css => style.scss} (100%) rename forms/ecomerce/invoices/{invoices.js => index.js} (87%) delete mode 100644 forms/ecomerce/invoices/style.css rename forms/{agencies/provinces/style.css => ecomerce/invoices/style.scss} (100%) rename forms/ecomerce/orders/{orders.js => index.js} (93%) rename forms/ecomerce/orders/{style.css => style.scss} (100%) rename forms/ecomerce/ticket/{ticket.js => index.js} (92%) rename forms/ecomerce/ticket/{style.css => style.scss} (100%) rename forms/news/new/{new.js => index.js} (91%) rename forms/news/new/{style.css => style.scss} (100%) rename forms/news/news/{news.js => index.js} (79%) rename forms/news/news/{style.css => style.scss} (100%) create mode 100644 import.js diff --git a/app.js b/app.js index bd9c9fa9..d5becac6 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,7 @@ __webpack_public_path__ = _PUBLIC_PATH; require('hedera/hedera'); +const locales = require('./import').locales; const packageJson = require('./package.json'); window.onload = function() { @@ -22,35 +23,11 @@ function loadLocale(cb) { var req = require.context('js', true, /locale\/en.yml$/); onLocaleLoad(req); - switch (lang) { - case 'ca': - require([], function() { - cb(require.context('js', true, /locale\/ca.yml$/)); - }); - break; - case 'es': - require([], function() { - cb(require.context('js', true, /locale\/es.yml$/)); - }); - break; - case 'fr': - require([], function() { - cb(require.context('js', true, /locale\/fr.yml$/)); - }); - break; - case 'mn': - require([], function() { - cb(require.context('js', true, /locale\/mn.yml$/)); - }); - break; - case 'pt': - require([], function() { - cb(require.context('js', true, /locale\/pt.yml$/)); - }); - break; - default: - cb(); - } + const fn = locales[lang]; + if (fn) + fn(cb); + else + cb(); } function onLocaleLoad(req) { diff --git a/debian/changelog b/debian/changelog index ffe054f3..cbba0dd0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (22.44.15) stable; urgency=low +hedera-web (22.44.16) stable; urgency=low * Initial Release. diff --git a/forms/account/address-list/address-list.js b/forms/account/address-list/index.js similarity index 66% rename from forms/account/address-list/address-list.js rename to forms/account/address-list/index.js index 4078e792..051cde67 100644 --- a/forms/account/address-list/address-list.js +++ b/forms/account/address-list/index.js @@ -1,37 +1,39 @@ +import './style.scss'; -Hedera.AddressList = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') - ,activate: function() { + ,activate() { this.$.userModel.setInfo('c', 'myClient', 'hedera'); this.$.addresses.setInfo('a', 'myAddress', 'hedera'); } - ,onAddAddressClick: function() { + ,onAddAddressClick() { this.hash.setAll({ form: 'account/address', address: 0 }); } - ,onReturnClick: function() { + ,onReturnClick() { window.history.back(); } - ,onSetDefaultClick: function(event, addressId) { + ,onSetDefaultClick(event, addressId) { if (event.defaultPrevented) return; this.$.defaultAddress.value = addressId; Htk.Toast.showMessage(_('DefaultAddressModified')); } - ,onRemoveAddressClick: function(form) { + ,onRemoveAddressClick(form) { if (confirm(_('AreYouSureDeleteAddress'))) { form.set('isActive', false); form.refresh(); } } - ,onEditAddressClick: function(id) { + ,onEditAddressClick(id) { this.hash.setAll({ form: 'account/address', address: id diff --git a/forms/account/address-list/style.css b/forms/account/address-list/style.scss similarity index 100% rename from forms/account/address-list/style.css rename to forms/account/address-list/style.scss diff --git a/forms/account/address/address.js b/forms/account/address/index.js similarity index 76% rename from forms/account/address/address.js rename to forms/account/address/index.js index 649deaee..374d9bda 100644 --- a/forms/account/address/address.js +++ b/forms/account/address/index.js @@ -1,19 +1,19 @@ - -Hedera.Address = new Class({ +export default new Class({ Extends: Hedera.Form, + Template: require('./ui.xml'), - activate: function() { + activate() { this.$.model.setInfo('a', 'myAddress', 'hedera', ['id'], 'id'); this.$.model.setDefault('clientFk', 'a', new Sql.Function({schema: 'account', name: 'myUser_getId'})); }, - onStatusChange: function() { + onStatusChange() { if (this.$.iter.ready && this.hash.$.address == 0) this.$.iter.insertRow(); }, - onOperationsDone: function() { + onOperationsDone() { Htk.Toast.showMessage(_('AddressChangedSuccessfully')); window.history.back() } diff --git a/forms/account/conf/conf.js b/forms/account/conf/index.js similarity index 93% rename from forms/account/conf/conf.js rename to forms/account/conf/index.js index 437adb61..020a711f 100644 --- a/forms/account/conf/conf.js +++ b/forms/account/conf/index.js @@ -1,8 +1,10 @@ +import './style.scss'; -Hedera.Conf = new Class({ - Extends: Hedera.Form - - ,activate: function() { +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml'), + + activate: function() { this.$.userModel.setInfo('c', 'myClient', 'hedera'); this.$.userModel.setInfo('u', 'myUser', 'account'); diff --git a/forms/account/conf/style.css b/forms/account/conf/style.scss similarity index 100% rename from forms/account/conf/style.css rename to forms/account/conf/style.scss diff --git a/forms/admin/access-log/access-log.js b/forms/admin/access-log/access-log.js deleted file mode 100644 index aa58beda..00000000 --- a/forms/admin/access-log/access-log.js +++ /dev/null @@ -1,5 +0,0 @@ - -Hedera.AccessLog = new Class({ - Extends: Hedera.Form -}); - diff --git a/forms/admin/access-log/index.js b/forms/admin/access-log/index.js new file mode 100644 index 00000000..36552d4f --- /dev/null +++ b/forms/admin/access-log/index.js @@ -0,0 +1,7 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); + diff --git a/forms/admin/access-log/style.css b/forms/admin/access-log/style.scss similarity index 100% rename from forms/admin/access-log/style.css rename to forms/admin/access-log/style.scss diff --git a/forms/admin/connections/connections.js b/forms/admin/connections/connections.js deleted file mode 100644 index ef09f125..00000000 --- a/forms/admin/connections/connections.js +++ /dev/null @@ -1,35 +0,0 @@ - -Hedera.Connections = new Class({ - Extends: Hedera.Form - - ,_timeoutId: null - - ,onModelStatusChange: function() { - if (!this.$.sessions.ready) - return; - - if (this._timeoutId) - clearTimeout(this._timeoutId); - - this._timeoutId = setTimeout( - () => this.$.sessions.refresh(), 60000); - } - - ,deactivate: function() { - clearTimeout(this._timeoutId); - } - - ,onChangeUserClick: function(userName) { - this.gui.supplantUser(userName, - this._onUserSupplant.bind(this)); - } - - ,_onUserSupplant: function() { - this.hash.setAll({form: 'ecomerce/orders'}); - } - - ,sessionsFunc: function() { - return 1; - } -}); - diff --git a/forms/admin/connections/index.js b/forms/admin/connections/index.js index 66e93ab4..4abece1c 100644 --- a/forms/admin/connections/index.js +++ b/forms/admin/connections/index.js @@ -21,7 +21,7 @@ export default new Class({ clearTimeout(this._timeoutId); } - ,onChangeUserClick: function(userName) { + ,onChangeUserClick(userName) { this.gui.supplantUser(userName, this._onUserSupplant.bind(this)); } diff --git a/forms/admin/connections/style.css b/forms/admin/connections/style.scss similarity index 100% rename from forms/admin/connections/style.css rename to forms/admin/connections/style.scss diff --git a/forms/admin/items/items.js b/forms/admin/items/index.js similarity index 57% rename from forms/admin/items/items.js rename to forms/admin/items/index.js index 9c835278..461a6406 100644 --- a/forms/admin/items/items.js +++ b/forms/admin/items/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Items = new Class({ +export default new Class({ Extends: Hedera.Form, + Template: require('./ui.xml'), activate: function() { this.$.items.setInfo('i', 'item', 'vn', ['id']); diff --git a/forms/admin/items/style.css b/forms/admin/items/style.scss similarity index 100% rename from forms/admin/items/style.css rename to forms/admin/items/style.scss diff --git a/forms/admin/links/index.js b/forms/admin/links/index.js new file mode 100644 index 00000000..36552d4f --- /dev/null +++ b/forms/admin/links/index.js @@ -0,0 +1,7 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); + diff --git a/forms/admin/links/links.js b/forms/admin/links/links.js deleted file mode 100644 index 4f761884..00000000 --- a/forms/admin/links/links.js +++ /dev/null @@ -1,5 +0,0 @@ - -Hedera.Links = new Class({ - Extends: Hedera.Form -}); - diff --git a/forms/admin/links/style.css b/forms/admin/links/style.scss similarity index 100% rename from forms/admin/links/style.css rename to forms/admin/links/style.scss diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/index.js similarity index 97% rename from forms/admin/photos/photos.js rename to forms/admin/photos/index.js index f51c8e1a..13dfac20 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/index.js @@ -1,4 +1,5 @@ -(function() { +import './style.scss'; + var Status = { NONE : 0 ,WAITING : 1 @@ -6,8 +7,10 @@ var Status = { ,UPLOADED : 3 }; -Hedera.Photos = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') + ,filesData: [] ,uploadCount: 0 ,errors: false @@ -210,4 +213,3 @@ function getFileName(path) { return path.substr(barIndex, dotIndex); } -})(); diff --git a/forms/admin/photos/style.css b/forms/admin/photos/style.scss similarity index 100% rename from forms/admin/photos/style.css rename to forms/admin/photos/style.scss diff --git a/forms/admin/queries/queries.js b/forms/admin/queries/index.js similarity index 94% rename from forms/admin/queries/queries.js rename to forms/admin/queries/index.js index d27481e8..337a3a90 100644 --- a/forms/admin/queries/queries.js +++ b/forms/admin/queries/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Queries = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,activate: function() { this.$.resultIndex.value = 0; diff --git a/forms/admin/queries/style.css b/forms/admin/queries/style.scss similarity index 100% rename from forms/admin/queries/style.css rename to forms/admin/queries/style.scss diff --git a/forms/admin/users/users.js b/forms/admin/users/index.js similarity index 80% rename from forms/admin/users/users.js rename to forms/admin/users/index.js index 6df40d4d..949d3336 100644 --- a/forms/admin/users/users.js +++ b/forms/admin/users/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Users = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,rendererFunc: function(scope, form) { var isEnabled = form.$.active diff --git a/forms/admin/users/style.css b/forms/admin/users/style.scss similarity index 100% rename from forms/admin/users/style.css rename to forms/admin/users/style.scss diff --git a/forms/admin/visits/visits.js b/forms/admin/visits/index.js similarity index 55% rename from forms/admin/visits/visits.js rename to forms/admin/visits/index.js index 24d54cdb..4d7ad97a 100644 --- a/forms/admin/visits/visits.js +++ b/forms/admin/visits/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Visits = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,activate: function() { if (!this.hash.$.to) diff --git a/forms/admin/visits/style.css b/forms/admin/visits/style.scss similarity index 100% rename from forms/admin/visits/style.css rename to forms/admin/visits/style.scss diff --git a/forms/agencies/packages/index.js b/forms/agencies/packages/index.js new file mode 100644 index 00000000..239f4bc0 --- /dev/null +++ b/forms/agencies/packages/index.js @@ -0,0 +1,14 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml'), + + onShowClick: function(column, agencyId) { + this.hash.setAll({ + form: 'agencies/provinces', + agency: agencyId + }); + } +}); + diff --git a/forms/agencies/packages/packages.js b/forms/agencies/packages/packages.js deleted file mode 100644 index d86d89c6..00000000 --- a/forms/agencies/packages/packages.js +++ /dev/null @@ -1,12 +0,0 @@ - -Hedera.Packages = new Class({ - Extends: Hedera.Form - - ,onShowClick: function(column, agencyId) { - this.hash.setAll({ - form: 'agencies/provinces', - agency: agencyId - }); - } -}); - diff --git a/forms/account/address/style.css b/forms/agencies/packages/style.scss similarity index 100% rename from forms/account/address/style.css rename to forms/agencies/packages/style.scss diff --git a/forms/agencies/provinces/index.js b/forms/agencies/provinces/index.js new file mode 100644 index 00000000..36552d4f --- /dev/null +++ b/forms/agencies/provinces/index.js @@ -0,0 +1,7 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); + diff --git a/forms/agencies/provinces/provinces.js b/forms/agencies/provinces/provinces.js deleted file mode 100644 index b441f598..00000000 --- a/forms/agencies/provinces/provinces.js +++ /dev/null @@ -1,5 +0,0 @@ - -Hedera.Provinces = new Class({ - Extends: Hedera.Form -}); - diff --git a/forms/agencies/packages/style.css b/forms/agencies/provinces/style.scss similarity index 100% rename from forms/agencies/packages/style.css rename to forms/agencies/provinces/style.scss diff --git a/forms/cms/about/about.js b/forms/cms/about/about.js deleted file mode 100644 index 1244f041..00000000 --- a/forms/cms/about/about.js +++ /dev/null @@ -1,6 +0,0 @@ - -Hedera.About = new Class -({ - Extends: Hedera.Form -}); - diff --git a/forms/cms/about/index.js b/forms/cms/about/index.js new file mode 100644 index 00000000..36552d4f --- /dev/null +++ b/forms/cms/about/index.js @@ -0,0 +1,7 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); + diff --git a/forms/cms/about/style.css b/forms/cms/about/style.scss similarity index 100% rename from forms/cms/about/style.css rename to forms/cms/about/style.scss diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/index.js similarity index 87% rename from forms/cms/contact/contact.js rename to forms/cms/contact/index.js index 6bb9d700..c34b7e5d 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Contact = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,activate: function() { var self = this; diff --git a/forms/cms/contact/style.css b/forms/cms/contact/style.scss similarity index 100% rename from forms/cms/contact/style.css rename to forms/cms/contact/style.scss diff --git a/forms/cms/home/home.js b/forms/cms/home/home.js deleted file mode 100644 index e29f8765..00000000 --- a/forms/cms/home/home.js +++ /dev/null @@ -1,5 +0,0 @@ - -Hedera.Home = new Class({ - Extends: Hedera.Form -}); - diff --git a/forms/cms/home/index.js b/forms/cms/home/index.js new file mode 100644 index 00000000..3e49e755 --- /dev/null +++ b/forms/cms/home/index.js @@ -0,0 +1,6 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); diff --git a/forms/cms/home/style.css b/forms/cms/home/style.scss similarity index 100% rename from forms/cms/home/style.css rename to forms/cms/home/style.scss diff --git a/forms/cms/location/location.js b/forms/cms/location/index.js similarity index 96% rename from forms/cms/location/location.js rename to forms/cms/location/index.js index 3a3c26c8..a4bad7c8 100644 --- a/forms/cms/location/location.js +++ b/forms/cms/location/index.js @@ -1,8 +1,10 @@ +import './style.scss'; var gmapsIsLoaded = false; -Hedera.Location = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,locations: null diff --git a/forms/cms/location/style.css b/forms/cms/location/style.scss similarity index 100% rename from forms/cms/location/style.css rename to forms/cms/location/style.scss diff --git a/forms/cms/why/index.js b/forms/cms/why/index.js new file mode 100644 index 00000000..36552d4f --- /dev/null +++ b/forms/cms/why/index.js @@ -0,0 +1,7 @@ +import './style.scss'; + +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') +}); + diff --git a/forms/cms/why/style.css b/forms/cms/why/style.scss similarity index 100% rename from forms/cms/why/style.css rename to forms/cms/why/style.scss diff --git a/forms/cms/why/why.js b/forms/cms/why/why.js deleted file mode 100644 index ab2f919a..00000000 --- a/forms/cms/why/why.js +++ /dev/null @@ -1,6 +0,0 @@ - -Hedera.Why = new Class -({ - Extends: Hedera.Form -}); - diff --git a/forms/ecomerce/basket/basket.js b/forms/ecomerce/basket/index.js similarity index 87% rename from forms/ecomerce/basket/basket.js rename to forms/ecomerce/basket/index.js index 95d636aa..5e09c238 100644 --- a/forms/ecomerce/basket/basket.js +++ b/forms/ecomerce/basket/index.js @@ -1,6 +1,8 @@ +import './style.scss'; -Hedera.Basket = new Class({ +export default new Class({ Extends: Hedera.Form, + Template: require('./ui.xml'), open() { this.close(); diff --git a/forms/ecomerce/basket/style.css b/forms/ecomerce/basket/style.scss similarity index 100% rename from forms/ecomerce/basket/style.css rename to forms/ecomerce/basket/style.scss diff --git a/forms/ecomerce/catalog/catalog.js b/forms/ecomerce/catalog/index.js similarity index 98% rename from forms/ecomerce/catalog/catalog.js rename to forms/ecomerce/catalog/index.js index 0f50ea19..759f33ba 100644 --- a/forms/ecomerce/catalog/catalog.js +++ b/forms/ecomerce/catalog/index.js @@ -1,6 +1,7 @@ -Hedera.Catalog = new Class({ - Extends: Hedera.Form +export default new Class({ + Extends: Hedera.Form, + Template: require('./ui.xml') ,_menuShown: false diff --git a/forms/ecomerce/catalog/style.css b/forms/ecomerce/catalog/style.scss similarity index 100% rename from forms/ecomerce/catalog/style.css rename to forms/ecomerce/catalog/style.scss diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 5a33f867..6ef236c3 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -152,7 +152,7 @@ on-click="this.onAddItemClick($event, $iter)"> require([], () => cb(require.context('js', true, /locale\/ca.yml$/))), + 'es': cb => require([], () => cb(require.context('js', true, /locale\/es.yml$/))), + 'fr': cb => require([], () => cb(require.context('js', true, /locale\/fr.yml$/))), + 'mn': cb => require([], () => cb(require.context('js', true, /locale\/mn.yml$/))), + 'pt': cb => require([], () => cb(require.context('js', true, /locale\/pt.yml$/))) +}; + +export const formMap = { + 'account/address': + () => import('account/address'), + 'account/address-list': + () => import('account/address-list'), + 'account/conf': + () => import('account/conf'), + 'admin/access-log': + () => import('admin/access-log'), + 'admin/connections': + () => import('admin/connections'), + 'admin/items': + () => import('admin/items'), + 'admin/links': + () => import('admin/links'), + 'admin/photos': + () => import('admin/photos'), + 'admin/queries': + () => import('admin/queries'), + 'admin/users': + () => import('admin/users'), + 'admin/visits': + () => import('admin/visits'), + 'agencies/packages': + () => import('agencies/packages'), + 'agencies/provinces': + () => import('agencies/provinces'), + 'cms/about': + () => import('cms/about'), + 'cms/contact': + () => import('cms/contact'), + 'cms/home': + () => import('cms/home'), + 'cms/location': + () => import('cms/location'), + 'cms/why': + () => import('cms/why'), + 'ecomerce/basket': + () => import('ecomerce/basket'), + 'ecomerce/catalog': + () => import('ecomerce/catalog'), + 'ecomerce/checkout': + () => import('ecomerce/checkout'), + 'ecomerce/confirm': + () => import('ecomerce/confirm'), + 'ecomerce/invoices': + () => import('ecomerce/invoices'), + 'ecomerce/orders': + () => import('ecomerce/orders'), + 'ecomerce/ticket': + () => import('ecomerce/ticket'), + 'news/new': + () => import('news/new'), + 'news/news': + () => import('news/news') +}; diff --git a/js/hedera/form.js b/js/hedera/form.js index f07f3b38..3820714c 100644 --- a/js/hedera/form.js +++ b/js/hedera/form.js @@ -5,11 +5,10 @@ module.exports = new Class({ ,isOpen: false ,uiLoaded: false - ,initialize: function(gui, formInfo) { + ,initialize: function(gui) { this.gui = gui; this.conn = gui.conn; this.hash = gui.hash; - this.formInfo = formInfo; } ,loadUi: function() { @@ -20,7 +19,7 @@ module.exports = new Class({ const hash = this.hash; const builder = new Vn.Builder(); - builder.compileFile(`forms/${this.formInfo.path}/ui.xml`); + builder.compileString(this.$constructor.Template.default); const scope = this.builder = builder.load(null, this); this.$ = scope.$; diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 7e13dcfa..d3633b1c 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -1,7 +1,7 @@ -var Module = require('./module'); -var Tpl = require('./gui.xml').default; - +const Module = require('./module'); +const Tpl = require('./gui.xml').default; +const formMap = require('../../import').formMap; require('./gui.scss'); module.exports = new Class({ @@ -350,17 +350,12 @@ module.exports = new Class({ //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms - ,_onFormChange: function() { + ,async _onFormChange() { var formPath = this.formParam.value; if (!formPath) formPath = Vn.Config.defaultForm; - this.openForm(formPath, - this._onFormLoad.bind(this)); - } - - ,openForm: function(formPath, callback) { this.hideMenu(); this.loaderPush(); @@ -374,30 +369,28 @@ module.exports = new Class({ this.choosedOption = newChoosedOption; } - this.activeCss = 'forms/'+ formPath +'/style.css'; - Vn.includeCss(this.activeCss); - - var formInfo = this.forms[formPath]; - - if (!formInfo) { - formInfo = new Module('forms', formPath); - this.forms[formPath] = formInfo; - } + let FormKlass; - formInfo.addCallback(callback); - } + try { + FormKlass = (await this.importForm(formPath)).default; + } catch (err) { + this.loaderPop(); + return Htk.Toast.showError(_('Error loading form')); + } - ,_onFormLoad: function(formInfo) { this.loaderPop(); - if (formInfo.error) - return Htk.Toast.showError(_('Error loading form')); if (!this._shown) return; - this.activeForm = new formInfo.klass(this, formInfo); + this.activeForm = new FormKlass(this); this.activeForm.open(); } + + ,async importForm(path) { + const fn = formMap[path]; + return fn ? fn() : null; + } ,setForm: function(form) { const holder = this.$.formHolder; diff --git a/js/hedera/login.js b/js/hedera/login.js index d3b8450c..1f3bdeb1 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -1,6 +1,5 @@ - +var Tpl = require('./login.xml'); require('./login.scss'); -var Tpl = require('./login.xml').default; module.exports = new Class({ Extends: Vn.Component, diff --git a/js/vn/mutators.js b/js/vn/mutators.js index a30a14ef..0df4f97a 100644 --- a/js/vn/mutators.js +++ b/js/vn/mutators.js @@ -9,6 +9,10 @@ Mutators.Extends = function() { this.implement({Properties: {}}); } +Mutators.Template = function(template) { + this.extend({Template: template}); +}; + Mutators.Tag = function(tagName) { vnCustomTags[tagName] = this; this.extend({Tag: tagName}); diff --git a/package.json b/package.json index 9f5056b1..0358bb7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "22.44.15", + "version": "22.44.16", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/webpack.config.js b/webpack.config.js index 84eba3a8..5767846b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -49,6 +49,7 @@ const baseConfig = { modules: [ __dirname +'/js', __dirname, + __dirname +'/forms', 'node_modules', '/usr/lib/node_modules' ]