0
1
Fork 0
This commit is contained in:
Juan Ferrer 2022-11-29 19:13:32 +01:00
parent ebb6055be5
commit 9309bd156c
11 changed files with 92 additions and 107 deletions

2
debian/changelog vendored
View File

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

View File

@ -16,7 +16,7 @@ export default new Class({
this.locations = resultSet.fetchData(); this.locations = resultSet.fetchData();
if (!gmapsIsLoaded) { if (!gmapsIsLoaded) {
gmapsLoadedCallback = this.gmapsLoaded.bind(this); window.gmapsLoadedCallback = () => this.gmapsLoaded();
Vn.includeJs('https://maps.google.com/maps/api/js' Vn.includeJs('https://maps.google.com/maps/api/js'
+'?sensor=false&callback=gmapsLoadedCallback' +'?sensor=false&callback=gmapsLoadedCallback'
+'&key=AIzaSyBbunFsAFEkjtw-c7BUHNgkThSlKEKFxiE', +'&key=AIzaSyBbunFsAFEkjtw-c7BUHNgkThSlKEKFxiE',
@ -29,7 +29,6 @@ export default new Class({
,gmapsLoaded() { ,gmapsLoaded() {
this.gui.loaderPop(); this.gui.loaderPop();
gmapsIsLoaded = true; gmapsIsLoaded = true;
this.allLoaded();
if (!this.locations || !gmapsIsLoaded) if (!this.locations || !gmapsIsLoaded)
return; return;

View File

@ -176,38 +176,37 @@ export default new Class({
}, },
onAgenciesReady(model) { onAgenciesReady(model) {
if (!model.ready) return; this.selectAgency(model, 'NoAgeciesAvailableForDate');
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'));
}, },
onWarehousesReady(model) { onWarehousesReady(model) {
if (model.ready && model.numRows == 0) this.selectAgency(model, 'NoWarehousesAvailableForDate');
Htk.Toast.showError(_('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) { calendarRestrict(date) {

View File

@ -38,11 +38,11 @@ const contentCss = require('tinymce/skins/content/default/content.css');
export default new Class({ export default new Class({
Extends: Hedera.Form, 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.mode = Db.Model.Mode.ON_DEMAND;
this.$.model.setDefault('userFk', 'news', this.$.model.setDefault('userFk', 'news',
new Sql.Function({schema: 'account', name: 'myUser_getId'})); new Sql.Function({schema: 'account', name: 'myUser_getId'}));
@ -65,7 +65,7 @@ export default new Class({
+'|fontselect fontsizeselect' +'|fontselect fontsizeselect'
+'|forecolor backcolor ' +'|forecolor backcolor '
,image_advtab: true ,image_advtab: true
,init_instance_callback: this._onEditorInit.bind(this) ,init_instance_callback: editor => this._onEditorInit(editor)
,skin: false ,skin: false
,content_css: false ,content_css: false
,content_style: contentUiCss.toString() + '\n' + contentCss.toString() ,content_style: contentUiCss.toString() + '\n' + contentCss.toString()
@ -83,32 +83,25 @@ export default new Class({
}, },
setEditorText() { setEditorText() {
if (!this.editor) if (!this.editor) return;
return;
const row = this.$.iter.$; const row = this.$.iter.$;
this.editor.setContent(row ? row.text : ''); this.editor.setContent(row ? row.text : '');
}, },
onStatusChange() { onReady() {
if (!this.hash.$.new) if (this.hash.$.new)
this.setEditorText();
else
this.$.iter.insertRow(); this.$.iter.insertRow();
}, },
onOperationsDone() { async onAcceptClick() {
this.$.iter.set('text', this.editor.getContent());
await this.$.iter.performOperations();
Htk.Toast.showMessage(_('NewChangedSuccessfully')); Htk.Toast.showMessage(_('NewChangedSuccessfully'));
this.onReturnClick(); this.onReturnClick();
}, },
onReady() {
this.setEditorText();
},
onAcceptClick() {
this.$.iter.set('text', this.editor.getContent());
this.$.iter.performOperations();
},
onReturnClick() { onReturnClick() {
this.hash.setAll({form: 'news/news'}); this.hash.setAll({form: 'news/news'});
} }

View File

@ -1,14 +1,12 @@
<vn> <vn>
<vn-group> <vn-group>
<db-form id="iter" <db-form id="iter"
on-status-changed="this.onStatusChange()"
on-ready="this.onReady()"> on-ready="this.onReady()">
<db-model <db-model
id="model" id="model"
property="model" property="model"
updatable="true" updatable="true"
lot="hash" lot="hash">
on-operations-done="this.onOperationsDone()">
SELECT id, title, text, tag, priority, image SELECT id, title, text, tag, priority, image
FROM news WHERE id = #new FROM news WHERE id = #new
</db-model> </db-model>

View File

@ -2,30 +2,29 @@ import './style.scss';
export default new Class({ export default new Class({
Extends: Hedera.Form, Extends: Hedera.Form,
Template: require('./ui.xml') Template: require('./ui.xml'),
,activate() { activate() {
this.$.newsModel.setInfo('n', 'news', 'hedera', ['id'], 'id'); this.$.newsModel.setInfo('n', 'news', 'hedera', ['id'], 'id');
} },
,editNew(newId) { onAddClick() {
this.hash.setAll({
form: 'news/new',
new: null
});
},
onEditClick(newId) {
this.hash.setAll({ this.hash.setAll({
form: 'news/new', form: 'news/new',
new: newId new: newId
}); });
} },
,onEditClick(newId) { async onDeleteClick(form) {
this.editNew(newId);
}
,onDeleteClick(form) {
if (confirm(_('ReallyDelete'))) if (confirm(_('ReallyDelete')))
form.deleteRow(); await form.deleteRow();
}
,onAddClick() {
this.editNew(0);
} }
}); });

View File

@ -65,20 +65,12 @@ module.exports = new Class({
// Retrieving configuration parameters // Retrieving configuration parameters
var res = resultSet.fetchResult(); Vn.Config.defaultForm = resultSet.fetchValue();
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.imageUrl = resultSet.fetchValue(); Vn.Config.imageUrl = resultSet.fetchValue();
// Retrieving configuration parameters // Retrieving configuration parameters
var isTesting = !resultSet.fetchValue(); const isTesting = !resultSet.fetchValue();
if (isTesting) { if (isTesting) {
this.$.devInfo.style.display = 'block'; this.$.devInfo.style.display = 'block';
@ -87,15 +79,17 @@ module.exports = new Class({
// Retrieving configuration parameters // Retrieving configuration parameters
var res = resultSet.fetchObject(); const res = resultSet.fetchObject();
if (res && res.testDomain) { if (res && res.testDomain) {
let linkText, linkField;
if (location.host != res.productionDomain) { if (location.host != res.productionDomain) {
var linkText = 'Old website'; linkText = 'Old website';
var linkField = 'productionDomain'; linkField = 'productionDomain';
} else { } else {
var linkText = 'Test the new website'; linkText = 'Test the new website';
var linkField = 'testDomain'; linkField = 'testDomain';
} }
Vn.Node.setText(this.$.testLink, _(linkText)); Vn.Node.setText(this.$.testLink, _(linkText));
@ -354,11 +348,12 @@ module.exports = new Class({
formPath = Vn.Config.defaultForm; formPath = Vn.Config.defaultForm;
this.hideMenu(); this.hideMenu();
this.loaderPush();
await this.closeForm(); await this.closeForm();
this.requestedForm = formPath; this.requestedForm = formPath;
var newChoosedOption = this.menuOptions[formPath]; if (!formPath) return;
this.loaderPush();
const newChoosedOption = this.menuOptions[formPath];
if (newChoosedOption) { if (newChoosedOption) {
Vn.Node.addClass(newChoosedOption, 'selected'); Vn.Node.addClass(newChoosedOption, 'selected');

View File

@ -61,7 +61,7 @@ $login-margin-between: 55px;
.vn-login > .column { .vn-login > .column {
max-width: 250px; max-width: 250px;
overflow: visible; overflow: hidden;
& > .header { & > .header {
margin-top: $login-margin-top; margin-top: $login-margin-top;

View File

@ -37,7 +37,7 @@ module.exports =
/** /**
* @returns {Promise} * @returns {Promise}
*/ */
loadLang(path, lang) { async loadLang(path, lang) {
let langLoad = this.loads[lang]; let langLoad = this.loads[lang];
if (!langLoad) if (!langLoad)
langLoad = this.loads[lang] = {}; langLoad = this.loads[lang] = {};
@ -50,19 +50,20 @@ module.exports =
const request = new XMLHttpRequest(); const request = new XMLHttpRequest();
request.open('get', langFile, true); request.open('get', langFile, true);
return new Promise( const promise = new Promise((resolve, reject) => {
(resolve, reject) => {
request.onreadystatechange = request.onreadystatechange =
() => this.onRequestReady(request, resolve, reject); () => this.onRequestReady(request, resolve, reject);
request.send();
})
.then(translations => {
this.add(translations, lang);
})
.catch(err => {
langLoad[path] = false;
console.warn(err);
}); });
request.send();
try {
const translations = await promise;
this.add(translations, lang);
} catch(err) {
langLoad[path] = false;
//console.warn(err);
}
}, },
onRequestReady(request, resolve, reject) { onRequestReady(request, resolve, reject) {

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "22.48.1", "version": "22.48.2",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {
@ -41,7 +41,8 @@
}, },
"scripts": { "scripts": {
"front": "webpack serve --open", "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", "build": "rm -rf build/ ; webpack",
"clean": "rm -rf build/" "clean": "rm -rf build/"
} }

View File

@ -43,16 +43,16 @@ function getWebpackAssets() {
&& property_exists($asset, 'js')) && property_exists($asset, 'js'))
$jsFiles[] = $serverPath . $asset->js; $jsFiles[] = $serverPath . $asset->js;
function addAssets(&$jsFiles, $assets) { function addAssets($serverPath, &$jsFiles, $assets) {
foreach ($assets->js as $asset) foreach ($assets->js as $asset)
if (preg_match('/^chunk\./', basename($asset)) === 0) if (preg_match('/^chunk\./', basename($asset)) === 0)
$jsFiles[] = $serverPath.$asset; $jsFiles[] = $serverPath.$asset;
} }
if (isset($wpAssets->_empty_)) if (isset($wpAssets->_empty_))
addAssets($jsFiles, $wpAssets->_empty_); addAssets($serverPath, $jsFiles, $wpAssets->_empty_);
if (isset($wpAssets->{''})) if (isset($wpAssets->{''}))
addAssets($jsFiles, $wpAssets->{''}); addAssets($serverPath, $jsFiles, $wpAssets->{''});
$jsFiles[] = $serverPath . $wpAssets->main->js; $jsFiles[] = $serverPath . $wpAssets->main->js;