diff --git a/debian/changelog b/debian/changelog index 7d7784b2..1392bb32 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (22.48.1) stable; urgency=low +hedera-web (22.48.2) stable; urgency=low * Initial Release. diff --git a/forms/cms/location/index.js b/forms/cms/location/index.js index a0ca3678..8aa1ffa4 100644 --- a/forms/cms/location/index.js +++ b/forms/cms/location/index.js @@ -16,7 +16,7 @@ export default new Class({ this.locations = resultSet.fetchData(); if (!gmapsIsLoaded) { - gmapsLoadedCallback = this.gmapsLoaded.bind(this); + window.gmapsLoadedCallback = () => this.gmapsLoaded(); Vn.includeJs('https://maps.google.com/maps/api/js' +'?sensor=false&callback=gmapsLoadedCallback' +'&key=AIzaSyBbunFsAFEkjtw-c7BUHNgkThSlKEKFxiE', @@ -29,7 +29,6 @@ export default new Class({ ,gmapsLoaded() { this.gui.loaderPop(); gmapsIsLoaded = true; - this.allLoaded(); if (!this.locations || !gmapsIsLoaded) return; diff --git a/forms/ecomerce/checkout/index.js b/forms/ecomerce/checkout/index.js index 8e9668ef..90cda232 100644 --- a/forms/ecomerce/checkout/index.js +++ b/forms/ecomerce/checkout/index.js @@ -176,38 +176,37 @@ export default new Class({ }, onAgenciesReady(model) { - if (!model.ready) return; - - if (model.numRows > 0) { - let agency; - const agencies = []; - - if (this.$.orderForm.$) - agencies.push(this.$.orderForm.$); - - const defaults = this.$.defaults.$; - if (defaults) - agencies.push( - defaults.agencyModeFk, - defaults.defaultAgencyFk - ); - - for (let i = 0; i < agencies.length; i++) { - agency = agencies[i]; - if (model.search('id', agency) !== -1) - break; - } - - this.autoStepLocked = true; - this.$.lot.assign({agency}); - this.autoStepLocked = false; - } else - Htk.Toast.showError(_('NoAgeciesAvailableForDate')); + this.selectAgency(model, 'NoAgeciesAvailableForDate'); }, onWarehousesReady(model) { - if (model.ready && model.numRows == 0) - Htk.Toast.showError(_('NoWarehousesAvailableForDate')); + this.selectAgency(model, 'NoWarehousesAvailableForDate'); + }, + + selectAgency(model, emptyMessage) { + if (!model.ready) return; + let agencyId = null; + + if (model.numRows > 0) { + const agencies = [this.$.lot.$.agency]; + + const defaults = this.$.defaults.$ || {}; + if (defaults.agencyModeFk) + defaults.push(defaults.agencyModeFk); + if (defaults.defaultAgencyFk) + defaults.push(defaults.defaultAgencyFk); + + for (const agency of agencies) + if (model.search('id', agency) !== -1) { + agencyId = agency; + break; + } + } else + Htk.Toast.showError(_(emptyMessage)); + + this.autoStepLocked = true; + this.$.lot.assign({agency: agencyId}); + this.autoStepLocked = false; }, calendarRestrict(date) { diff --git a/forms/news/new/index.js b/forms/news/new/index.js index 9a249db8..1b6e1d4c 100644 --- a/forms/news/new/index.js +++ b/forms/news/new/index.js @@ -38,11 +38,11 @@ const contentCss = require('tinymce/skins/content/default/content.css'); export default new Class({ Extends: Hedera.Form, - Template: require('./ui.xml') + Template: require('./ui.xml'), - ,editor: null + editor: null, - ,activate() { + activate() { this.$.model.mode = Db.Model.Mode.ON_DEMAND; this.$.model.setDefault('userFk', 'news', new Sql.Function({schema: 'account', name: 'myUser_getId'})); @@ -65,7 +65,7 @@ export default new Class({ +'|fontselect fontsizeselect' +'|forecolor backcolor ' ,image_advtab: true - ,init_instance_callback: this._onEditorInit.bind(this) + ,init_instance_callback: editor => this._onEditorInit(editor) ,skin: false ,content_css: false ,content_style: contentUiCss.toString() + '\n' + contentCss.toString() @@ -83,32 +83,25 @@ export default new Class({ }, setEditorText() { - if (!this.editor) - return; - + if (!this.editor) return; const row = this.$.iter.$; this.editor.setContent(row ? row.text : ''); }, - onStatusChange() { - if (!this.hash.$.new) + onReady() { + if (this.hash.$.new) + this.setEditorText(); + else this.$.iter.insertRow(); }, - - onOperationsDone() { + + async onAcceptClick() { + this.$.iter.set('text', this.editor.getContent()); + await this.$.iter.performOperations(); Htk.Toast.showMessage(_('NewChangedSuccessfully')); this.onReturnClick(); }, - onReady() { - this.setEditorText(); - }, - - onAcceptClick() { - this.$.iter.set('text', this.editor.getContent()); - this.$.iter.performOperations(); - }, - onReturnClick() { this.hash.setAll({form: 'news/news'}); } diff --git a/forms/news/new/ui.xml b/forms/news/new/ui.xml index dcfee891..305f9478 100644 --- a/forms/news/new/ui.xml +++ b/forms/news/new/ui.xml @@ -1,14 +1,12 @@ + lot="hash"> SELECT id, title, text, tag, priority, image FROM news WHERE id = #new diff --git a/forms/news/news/index.js b/forms/news/news/index.js index fcc0f392..770472e2 100644 --- a/forms/news/news/index.js +++ b/forms/news/news/index.js @@ -2,30 +2,29 @@ import './style.scss'; export default new Class({ Extends: Hedera.Form, - Template: require('./ui.xml') + Template: require('./ui.xml'), - ,activate() { + activate() { this.$.newsModel.setInfo('n', 'news', 'hedera', ['id'], 'id'); - } + }, + + onAddClick() { + this.hash.setAll({ + form: 'news/new', + new: null + }); + }, - ,editNew(newId) { + onEditClick(newId) { this.hash.setAll({ form: 'news/new', new: newId }); - } + }, - ,onEditClick(newId) { - this.editNew(newId); - } - - ,onDeleteClick(form) { + async onDeleteClick(form) { if (confirm(_('ReallyDelete'))) - form.deleteRow(); - } - - ,onAddClick() { - this.editNew(0); + await form.deleteRow(); } }); diff --git a/js/hedera/gui.js b/js/hedera/gui.js index 20624eec..9b724cf4 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -65,20 +65,12 @@ module.exports = new Class({ // Retrieving configuration parameters - var res = resultSet.fetchResult(); - var columns = res.columns; - - if (res.next()) - for (var i = 0; i < res.columns.length; i++) - Vn.Config[columns[i].name] = res.get(columns[i].name); - - // Retrieving configuration parameters - + Vn.Config.defaultForm = resultSet.fetchValue(); Vn.Config.imageUrl = resultSet.fetchValue(); // Retrieving configuration parameters - var isTesting = !resultSet.fetchValue(); + const isTesting = !resultSet.fetchValue(); if (isTesting) { this.$.devInfo.style.display = 'block'; @@ -87,15 +79,17 @@ module.exports = new Class({ // Retrieving configuration parameters - var res = resultSet.fetchObject(); + const res = resultSet.fetchObject(); if (res && res.testDomain) { + let linkText, linkField; + if (location.host != res.productionDomain) { - var linkText = 'Old website'; - var linkField = 'productionDomain'; + linkText = 'Old website'; + linkField = 'productionDomain'; } else { - var linkText = 'Test the new website'; - var linkField = 'testDomain'; + linkText = 'Test the new website'; + linkField = 'testDomain'; } Vn.Node.setText(this.$.testLink, _(linkText)); @@ -354,11 +348,12 @@ module.exports = new Class({ formPath = Vn.Config.defaultForm; this.hideMenu(); - this.loaderPush(); await this.closeForm(); this.requestedForm = formPath; - var newChoosedOption = this.menuOptions[formPath]; + if (!formPath) return; + this.loaderPush(); + const newChoosedOption = this.menuOptions[formPath]; if (newChoosedOption) { Vn.Node.addClass(newChoosedOption, 'selected'); diff --git a/js/hedera/login.scss b/js/hedera/login.scss index 20c2fee0..6281783a 100644 --- a/js/hedera/login.scss +++ b/js/hedera/login.scss @@ -61,7 +61,7 @@ $login-margin-between: 55px; .vn-login > .column { max-width: 250px; - overflow: visible; + overflow: hidden; & > .header { margin-top: $login-margin-top; diff --git a/js/vn/locale.js b/js/vn/locale.js index b27d591e..61cd3aea 100644 --- a/js/vn/locale.js +++ b/js/vn/locale.js @@ -37,7 +37,7 @@ module.exports = /** * @returns {Promise} */ - loadLang(path, lang) { + async loadLang(path, lang) { let langLoad = this.loads[lang]; if (!langLoad) langLoad = this.loads[lang] = {}; @@ -50,19 +50,20 @@ module.exports = const request = new XMLHttpRequest(); request.open('get', langFile, true); - return new Promise( - (resolve, reject) => { - request.onreadystatechange = - () => this.onRequestReady(request, resolve, reject); - request.send(); - }) - .then(translations => { - this.add(translations, lang); - }) - .catch(err => { - langLoad[path] = false; - console.warn(err); - }); + const promise = new Promise((resolve, reject) => { + request.onreadystatechange = + () => this.onRequestReady(request, resolve, reject); + }); + + request.send(); + + try { + const translations = await promise; + this.add(translations, lang); + } catch(err) { + langLoad[path] = false; + //console.warn(err); + } }, onRequestReady(request, resolve, reject) { diff --git a/package.json b/package.json index 64b4482d..a59d3fa6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "22.48.1", + "version": "22.48.2", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { @@ -41,7 +41,8 @@ }, "scripts": { "front": "webpack serve --open", - "back": "cd ../salix && NODE_ENV=test gulp backOnly", + "back": "cd ../salix && gulp backOnly", + "db": "cd ../vn-database && myvc run", "build": "rm -rf build/ ; webpack", "clean": "rm -rf build/" } diff --git a/web/html.php b/web/html.php index 923f8742..c5a9627b 100644 --- a/web/html.php +++ b/web/html.php @@ -43,16 +43,16 @@ function getWebpackAssets() { && property_exists($asset, 'js')) $jsFiles[] = $serverPath . $asset->js; - function addAssets(&$jsFiles, $assets) { + function addAssets($serverPath, &$jsFiles, $assets) { foreach ($assets->js as $asset) if (preg_match('/^chunk\./', basename($asset)) === 0) $jsFiles[] = $serverPath.$asset; } if (isset($wpAssets->_empty_)) - addAssets($jsFiles, $wpAssets->_empty_); + addAssets($serverPath, $jsFiles, $wpAssets->_empty_); if (isset($wpAssets->{''})) - addAssets($jsFiles, $wpAssets->{''}); + addAssets($serverPath, $jsFiles, $wpAssets->{''}); $jsFiles[] = $serverPath . $wpAssets->main->js;