0
1
Fork 0

refs #5122 Navigation improved, date shows year, fixes

This commit is contained in:
Juan Ferrer 2023-02-23 20:19:56 +01:00
parent dd7185d5dd
commit 9bfd42eaf8
19 changed files with 81 additions and 48 deletions

2
debian/changelog vendored
View File

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

View File

@ -5,23 +5,33 @@ export default new Class({
Template: require('./ui.xml'),
async open() {
await this.loadOrder();
if (this.orderId) {
await Hedera.Form.prototype.open.call(this);
const basket = new Hedera.Basket(this.app);
if (this.$.params.$.id) {
this.orderId = this.$.params.$.id;
} else if (await basket.check()) {
this.orderId = basket.orderId;
}
if (this.orderId)
this.$.lot.assign({id: this.orderId});
}
},
activate() {
this.$.items.setInfo('bi', 'myOrderRow', 'hedera');
},
async onHashChange() {
if (!this.isOpen) return;
await this.loadOrder();
if (this.orderId)
this.$.lot.assign({id: this.orderId});
},
async loadOrder() {
const basket = new Hedera.Basket(this.app);
if (this.hash.$.id) {
this.orderId = this.hash.$.id;
} else if (await basket.check()) {
this.orderId = basket.orderId;
}
},
onOrderReady(form) {
if (form.row < 0)
return;

View File

@ -1,7 +1,4 @@
<vn>
<vn-lot-query id="params">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<div id="title">
<h1>{{_(params.$.id ? 'Order' : 'ShoppingBasket')}}</h1>
</div>
@ -20,6 +17,9 @@
on-click="this.onConfirmClick()"/>
</div>
<vn-group>
<vn-lot-query id="params" on-change="this.onHashChange()">
<vn-spec name="id" type="Number"/>
</vn-lot-query>
<vn-lot id="lot"/>
<db-form v-model="order" on-ready="onOrderReady">
<db-model property="model" lot="lot">
@ -50,7 +50,6 @@
</div>
<div id="address" class="address vn-mt-md">
<h6><t>DeliveryAddress</t></h6>
<p>{{order.nickname}}</p>
<p>{{order.street}}</p>
<p>{{order.postalCode}}, {{order.city}}</p>
</div>

View File

@ -10,7 +10,7 @@ const Catalog = new Class({
const basket = new Hedera.Basket(this.app);
if (!localStorage.getItem('hederaGuest')) {
if (await basket.check())
if (await basket.check('catalog'))
this.orderId = basket.orderId;
} else {
const resultSet = await this.conn.execQuery(

View File

@ -81,21 +81,27 @@ export default new Class({
if (!resultSet.fetchResult())
return;
let redirect;
const basket = new Hedera.Basket(this.app);
if (id) {
Htk.Toast.showMessage(_('OrderUpdated'));
switch(this.hash.$.continue) {
case 'catalog':
this.hash.setAll({form: 'ecomerce/catalog'});
redirect = {form: 'ecomerce/catalog'};
break;
default:
this.hash.setAll({form: 'ecomerce/basket', id});
redirect = {form: 'ecomerce/basket'};
if (id !== basket.orderId)
redirect.id = id;
}
} else {
const basket = new Hedera.Basket(this.app);
basket.loadIntoBasket(resultSet.fetchValue());
this.hash.setAll({form: 'ecomerce/catalog'});
redirect = {form: 'ecomerce/catalog'};
}
this.hash.setAll(redirect);
},
onCancelClick() {

View File

@ -13,44 +13,52 @@ module.exports = class {
);
resultSet.fetchValue();
}
async check() {
async check(checkoutContinue) {
if (this.orderId) {
return await this.checkRedirect();
return await this.checkRedirect(checkoutContinue);
} else {
this.app.hash.setAll({form: 'ecomerce/checkout'});
this.redirect();
return false;
}
}
async checkRedirect() {
async checkRedirect(checkoutContinue) {
try {
await this.checkOrder(this.orderId);
return true;
} catch(err) {
if (err.exception == 'Vn.Lib.UserError') {
const dst = {
form: 'ecomerce/checkout',
continue: 'catalog'
};
switch(err.code) {
case 'orderConfirmed':
case 'orderNotOwnedByUser':
this.constructor.unload();
await this.redirect();
break;
default:
dst.id = this.orderId;
this.app.hash.setAll({
form: 'ecomerce/checkout',
id: this.orderId,
continue: checkoutContinue
});
Htk.Toast.showError(err.message);
}
this.app.hash.setAll(dst);
return false;
} else
throw err;
}
}
async redirect() {
const resultSet = await this.app.conn.execQuery(
'SELECT COUNT(*) > 0 FROM myOrder');
if (resultSet.fetchValue()) {
this.app.hash.setAll({form: 'ecomerce/pending'});
Htk.Toast.showMessage(_('Load an order'));
} else {
this.app.hash.setAll({form: 'ecomerce/checkout'});
}
}
async load(orderId) {
this.loadIntoBasket(orderId);
if (await this.checkRedirect())
if (await this.checkRedirect('catalog'))
this.app.hash.setAll({
form: 'ecomerce/catalog'
});

View File

@ -63,3 +63,5 @@ Agencies: Agències
Configuration: Configuració
Account: Compte
Addresses: Adreces
Load an order: Si us plau carrega una comanda pendent a la cistella o en comença una de nova

View File

@ -59,3 +59,5 @@ Agencies: Agencies
Configuration: Configuration
Account: Account
Addresses: Addresses
Load an order: Please load a pending order to the cart or start a new one

View File

@ -63,3 +63,5 @@ Agencies: Agencias
Configuration: Configuración
Account: Cuenta
Addresses: Direcciones
Load an order: Por favor carga un pedido pendiente en la cesta o empieza uno nuevo

View File

@ -63,3 +63,5 @@ Agencies: Agences
Configuration: Configuration
Account: Compte
Addresses: Adresses
Load an order: Veuillez télécharger une commande en attente dans le panier ou en démarrer une nouvelle

View File

@ -61,3 +61,5 @@ Agencies: Agências
Configuration: Configuração
Account: Conta
Addresses: Moradas
Load an order: Carregue um pedido pendente no carrinho ou inicie um novo

View File

@ -55,7 +55,7 @@ module.exports =
,'Dec'
]
,tokenD: '%A, %B %e'
,tokenD: '%A, %B %e %Y'
,regexp: new RegExp('%[a-zA-Z]', 'g')
@ -101,7 +101,7 @@ module.exports =
// Year with 4 digits
case 'Y': return d.getFullYear();
// Complete date without year
// Complete date
case 'D': return _(this.tokenD).replace(this.regexp, this.regexpFunc.bind(this, d));
}

View File

@ -36,7 +36,7 @@ Sep: Set
Oct: Oct
Nov: Nov
Dec: Des
'%A, %B %e': '%A, %e de %B'
'%A, %B %e %Y': '%A, %e de %B de %Y'
Something went wrong: Alguna cosa ha anat malament
'The server does not respond, please check your Internet connection': 'El servidor no respon, si us plau comprova la teva connexió a Internet'
Accept: Acceptar

View File

@ -36,6 +36,6 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Dic
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Something went wrong
'The server does not respond, please check your Internet connection': 'The server does not respond, please check you Internet connection'

View File

@ -36,7 +36,7 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Dic
'%A, %B %e': '%A, %e de %B'
'%A, %B %e %Y': '%A, %e de %B de %Y'
Something went wrong: Algo salió mal
'The server does not respond, please check your Internet connection': 'El servidor no responde, por favor comprueba tu conexión a Internet'
Accept: Aceptar

View File

@ -36,7 +36,7 @@ Sep: Sep
Oct: Oct
Nov: Nov
Dec: Déc
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Quelque-chose s'est mal passé
'The server does not respond, please check your Internet connection': 'Le serveur ne répond pas, s''il vous plaît vérifier votre connexion Internet'
Accept: Accepter

View File

@ -36,6 +36,6 @@ Sep: Есд
Oct: Ара
Nov: Арв
Dec: Арв
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Something went wrong
'The server does not respond, please check your Internet connection': 'The server does not respond, please check you Internet connection'

View File

@ -36,7 +36,7 @@ Sep: Set
Oct: Out
Nov: Nov
Dec: Dez
'%A, %B %e': '%A, %B %e'
'%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Algo deu errado
'The server does not respond, please check your Internet connection': 'O servidor não responde, por favor, verifique sua conexão com a Internet'
Accept: Aceitar

View File

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