0
1
Fork 0

refs #3971 Webpack imports

This commit is contained in:
Juan Ferrer 2022-11-16 02:44:39 +01:00
parent 5f1f0423cf
commit 0510149fd8
74 changed files with 237 additions and 190 deletions

35
app.js
View File

@ -1,6 +1,7 @@
__webpack_public_path__ = _PUBLIC_PATH; __webpack_public_path__ = _PUBLIC_PATH;
require('hedera/hedera'); require('hedera/hedera');
const locales = require('./import').locales;
const packageJson = require('./package.json'); const packageJson = require('./package.json');
window.onload = function() { window.onload = function() {
@ -22,35 +23,11 @@ function loadLocale(cb) {
var req = require.context('js', true, /locale\/en.yml$/); var req = require.context('js', true, /locale\/en.yml$/);
onLocaleLoad(req); onLocaleLoad(req);
switch (lang) { const fn = locales[lang];
case 'ca': if (fn)
require([], function() { fn(cb);
cb(require.context('js', true, /locale\/ca.yml$/)); else
}); cb();
break;
case 'es':
require([], function() {
cb(require.context('js', true, /locale\/es.yml$/));
});
break;
case 'fr':
require([], function() {
cb(require.context('js', true, /locale\/fr.yml$/));
});
break;
case 'mn':
require([], function() {
cb(require.context('js', true, /locale\/mn.yml$/));
});
break;
case 'pt':
require([], function() {
cb(require.context('js', true, /locale\/pt.yml$/));
});
break;
default:
cb();
}
} }
function onLocaleLoad(req) { function onLocaleLoad(req) {

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (22.44.15) stable; urgency=low hedera-web (22.44.16) stable; urgency=low
* Initial Release. * Initial Release.

View File

@ -1,37 +1,39 @@
import './style.scss';
Hedera.AddressList = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,activate: function() { ,activate() {
this.$.userModel.setInfo('c', 'myClient', 'hedera'); this.$.userModel.setInfo('c', 'myClient', 'hedera');
this.$.addresses.setInfo('a', 'myAddress', 'hedera'); this.$.addresses.setInfo('a', 'myAddress', 'hedera');
} }
,onAddAddressClick: function() { ,onAddAddressClick() {
this.hash.setAll({ this.hash.setAll({
form: 'account/address', form: 'account/address',
address: 0 address: 0
}); });
} }
,onReturnClick: function() { ,onReturnClick() {
window.history.back(); window.history.back();
} }
,onSetDefaultClick: function(event, addressId) { ,onSetDefaultClick(event, addressId) {
if (event.defaultPrevented) return; if (event.defaultPrevented) return;
this.$.defaultAddress.value = addressId; this.$.defaultAddress.value = addressId;
Htk.Toast.showMessage(_('DefaultAddressModified')); Htk.Toast.showMessage(_('DefaultAddressModified'));
} }
,onRemoveAddressClick: function(form) { ,onRemoveAddressClick(form) {
if (confirm(_('AreYouSureDeleteAddress'))) { if (confirm(_('AreYouSureDeleteAddress'))) {
form.set('isActive', false); form.set('isActive', false);
form.refresh(); form.refresh();
} }
} }
,onEditAddressClick: function(id) { ,onEditAddressClick(id) {
this.hash.setAll({ this.hash.setAll({
form: 'account/address', form: 'account/address',
address: id address: id

View File

@ -1,19 +1,19 @@
export default new Class({
Hedera.Address = new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
activate: function() { activate() {
this.$.model.setInfo('a', 'myAddress', 'hedera', ['id'], 'id'); this.$.model.setInfo('a', 'myAddress', 'hedera', ['id'], 'id');
this.$.model.setDefault('clientFk', 'a', this.$.model.setDefault('clientFk', 'a',
new Sql.Function({schema: 'account', name: 'myUser_getId'})); new Sql.Function({schema: 'account', name: 'myUser_getId'}));
}, },
onStatusChange: function() { onStatusChange() {
if (this.$.iter.ready && this.hash.$.address == 0) if (this.$.iter.ready && this.hash.$.address == 0)
this.$.iter.insertRow(); this.$.iter.insertRow();
}, },
onOperationsDone: function() { onOperationsDone() {
Htk.Toast.showMessage(_('AddressChangedSuccessfully')); Htk.Toast.showMessage(_('AddressChangedSuccessfully'));
window.history.back() window.history.back()
} }

View File

@ -1,8 +1,10 @@
import './style.scss';
Hedera.Conf = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml'),
,activate: function() {
activate: function() {
this.$.userModel.setInfo('c', 'myClient', 'hedera'); this.$.userModel.setInfo('c', 'myClient', 'hedera');
this.$.userModel.setInfo('u', 'myUser', 'account'); this.$.userModel.setInfo('u', 'myUser', 'account');

View File

@ -1,5 +0,0 @@
Hedera.AccessLog = new Class({
Extends: Hedera.Form
});

View File

@ -0,0 +1,7 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -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;
}
});

View File

@ -21,7 +21,7 @@ export default new Class({
clearTimeout(this._timeoutId); clearTimeout(this._timeoutId);
} }
,onChangeUserClick: function(userName) { ,onChangeUserClick(userName) {
this.gui.supplantUser(userName, this.gui.supplantUser(userName,
this._onUserSupplant.bind(this)); this._onUserSupplant.bind(this));
} }

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Items = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
activate: function() { activate: function() {
this.$.items.setInfo('i', 'item', 'vn', ['id']); this.$.items.setInfo('i', 'item', 'vn', ['id']);

View File

@ -0,0 +1,7 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -1,5 +0,0 @@
Hedera.Links = new Class({
Extends: Hedera.Form
});

View File

@ -1,4 +1,5 @@
(function() { import './style.scss';
var Status = { var Status = {
NONE : 0 NONE : 0
,WAITING : 1 ,WAITING : 1
@ -6,8 +7,10 @@ var Status = {
,UPLOADED : 3 ,UPLOADED : 3
}; };
Hedera.Photos = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,filesData: [] ,filesData: []
,uploadCount: 0 ,uploadCount: 0
,errors: false ,errors: false
@ -210,4 +213,3 @@ function getFileName(path) {
return path.substr(barIndex, dotIndex); return path.substr(barIndex, dotIndex);
} }
})();

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Queries = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,activate: function() { ,activate: function() {
this.$.resultIndex.value = 0; this.$.resultIndex.value = 0;

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Users = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,rendererFunc: function(scope, form) { ,rendererFunc: function(scope, form) {
var isEnabled = form.$.active var isEnabled = form.$.active

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Visits = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,activate: function() { ,activate: function() {
if (!this.hash.$.to) if (!this.hash.$.to)

View File

@ -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
});
}
});

View File

@ -1,12 +0,0 @@
Hedera.Packages = new Class({
Extends: Hedera.Form
,onShowClick: function(column, agencyId) {
this.hash.setAll({
form: 'agencies/provinces',
agency: agencyId
});
}
});

View File

@ -0,0 +1,7 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -1,5 +0,0 @@
Hedera.Provinces = new Class({
Extends: Hedera.Form
});

View File

@ -1,6 +0,0 @@
Hedera.About = new Class
({
Extends: Hedera.Form
});

7
forms/cms/about/index.js Normal file
View File

@ -0,0 +1,7 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Contact = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,activate: function() { ,activate: function() {
var self = this; var self = this;

View File

@ -1,5 +0,0 @@
Hedera.Home = new Class({
Extends: Hedera.Form
});

6
forms/cms/home/index.js Normal file
View File

@ -0,0 +1,6 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -1,8 +1,10 @@
import './style.scss';
var gmapsIsLoaded = false; var gmapsIsLoaded = false;
Hedera.Location = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,locations: null ,locations: null

7
forms/cms/why/index.js Normal file
View File

@ -0,0 +1,7 @@
import './style.scss';
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
});

View File

@ -1,6 +0,0 @@
Hedera.Why = new Class
({
Extends: Hedera.Form
});

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Basket = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
open() { open() {
this.close(); this.close();

View File

@ -1,6 +1,7 @@
Hedera.Catalog = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,_menuShown: false ,_menuShown: false

View File

@ -152,7 +152,7 @@
on-click="this.onAddItemClick($event, $iter)"> on-click="this.onAddItemClick($event, $iter)">
<htk-image <htk-image
directory="catalog" directory="catalog"
subdir="200x200" subdir="500x500"
form="$iter" form="$iter"
column="image" column="image"
stamp-column="updated" stamp-column="updated"

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Checkout = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
activate: function() { activate: function() {
this.autoStepLocked = true; this.autoStepLocked = true;

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Confirm = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
open: function() { open: function() {
this.close(); this.close();

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Invoices = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
donwloadRenderer: function(column, invoice) { donwloadRenderer: function(column, invoice) {
var invoiceId = invoice.$.id; var invoiceId = invoice.$.id;

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Orders = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
activate: function() { activate: function() {
this.tpv = new Hedera.Tpv({ this.tpv = new Hedera.Tpv({

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.Ticket = new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml'),
onTicketChange: function(ticket) { onTicketChange: function(ticket) {
if (!ticket.value) if (!ticket.value)

View File

@ -1,8 +1,9 @@
const tinymce = require('tinymce/tinymce.min');
import './style.scss';
Vn.include('node_modules/tinymce/tinymce.min'); export default new Class({
Vn.define(function() { Extends: Hedera.Form,
Hedera.New = new Class({ Template: require('./ui.xml')
Extends: Hedera.Form
,editor: null ,editor: null
@ -72,4 +73,3 @@ Hedera.New = new Class({
this.hash.setAll({form: 'news/news'}); this.hash.setAll({form: 'news/news'});
} }
}); });
});

View File

@ -1,6 +1,8 @@
import './style.scss';
Hedera.News = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form,
Template: require('./ui.xml')
,activate: function() { ,activate: function() {
this.$.newsModel.setInfo('n', 'news', 'hedera', ['id'], 'id'); this.$.newsModel.setInfo('n', 'news', 'hedera', ['id'], 'id');

View File

@ -1,5 +1,5 @@
Hedera.ItemsForm = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {

View File

@ -1,5 +1,5 @@
Hedera.Shelves = new Class({ export default new Class({
Extends: Hedera.Form Extends: Hedera.Form
,activate: function() { ,activate: function() {

65
import.js Normal file
View File

@ -0,0 +1,65 @@
export const locales = {
'ca': cb => 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')
};

View File

@ -5,11 +5,10 @@ module.exports = new Class({
,isOpen: false ,isOpen: false
,uiLoaded: false ,uiLoaded: false
,initialize: function(gui, formInfo) { ,initialize: function(gui) {
this.gui = gui; this.gui = gui;
this.conn = gui.conn; this.conn = gui.conn;
this.hash = gui.hash; this.hash = gui.hash;
this.formInfo = formInfo;
} }
,loadUi: function() { ,loadUi: function() {
@ -20,7 +19,7 @@ module.exports = new Class({
const hash = this.hash; const hash = this.hash;
const builder = new Vn.Builder(); 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); const scope = this.builder = builder.load(null, this);
this.$ = scope.$; this.$ = scope.$;

View File

@ -1,7 +1,7 @@
var Module = require('./module'); const Module = require('./module');
var Tpl = require('./gui.xml').default; const Tpl = require('./gui.xml').default;
const formMap = require('../../import').formMap;
require('./gui.scss'); require('./gui.scss');
module.exports = new Class({ module.exports = new Class({
@ -350,17 +350,12 @@ module.exports = new Class({
//++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms //++++++++++++++++++++++++++++++++++++++++++++++++++++++ Forms
,_onFormChange: function() { ,async _onFormChange() {
var formPath = this.formParam.value; var formPath = this.formParam.value;
if (!formPath) if (!formPath)
formPath = Vn.Config.defaultForm; formPath = Vn.Config.defaultForm;
this.openForm(formPath,
this._onFormLoad.bind(this));
}
,openForm: function(formPath, callback) {
this.hideMenu(); this.hideMenu();
this.loaderPush(); this.loaderPush();
@ -374,30 +369,28 @@ module.exports = new Class({
this.choosedOption = newChoosedOption; this.choosedOption = newChoosedOption;
} }
this.activeCss = 'forms/'+ formPath +'/style.css'; let FormKlass;
Vn.includeCss(this.activeCss);
var formInfo = this.forms[formPath];
if (!formInfo) {
formInfo = new Module('forms', formPath);
this.forms[formPath] = formInfo;
}
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(); this.loaderPop();
if (formInfo.error)
return Htk.Toast.showError(_('Error loading form'));
if (!this._shown) if (!this._shown)
return; return;
this.activeForm = new formInfo.klass(this, formInfo); this.activeForm = new FormKlass(this);
this.activeForm.open(); this.activeForm.open();
} }
,async importForm(path) {
const fn = formMap[path];
return fn ? fn() : null;
}
,setForm: function(form) { ,setForm: function(form) {
const holder = this.$.formHolder; const holder = this.$.formHolder;

View File

@ -1,6 +1,5 @@
var Tpl = require('./login.xml');
require('./login.scss'); require('./login.scss');
var Tpl = require('./login.xml').default;
module.exports = new Class({ module.exports = new Class({
Extends: Vn.Component, Extends: Vn.Component,

View File

@ -9,6 +9,10 @@ Mutators.Extends = function() {
this.implement({Properties: {}}); this.implement({Properties: {}});
} }
Mutators.Template = function(template) {
this.extend({Template: template});
};
Mutators.Tag = function(tagName) { Mutators.Tag = function(tagName) {
vnCustomTags[tagName] = this; vnCustomTags[tagName] = this;
this.extend({Tag: tagName}); this.extend({Tag: tagName});

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "22.44.15", "version": "22.44.16",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {

View File

@ -49,6 +49,7 @@ const baseConfig = {
modules: [ modules: [
__dirname +'/js', __dirname +'/js',
__dirname, __dirname,
__dirname +'/forms',
'node_modules', 'node_modules',
'/usr/lib/node_modules' '/usr/lib/node_modules'
] ]