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. * Initial Release.

View File

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

View File

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

View File

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

View File

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

View File

@ -13,44 +13,52 @@ module.exports = class {
); );
resultSet.fetchValue(); resultSet.fetchValue();
} }
async check() { async check(checkoutContinue) {
if (this.orderId) { if (this.orderId) {
return await this.checkRedirect(); return await this.checkRedirect(checkoutContinue);
} else { } else {
this.app.hash.setAll({form: 'ecomerce/checkout'}); this.redirect();
return false; return false;
} }
} }
async checkRedirect() { async checkRedirect(checkoutContinue) {
try { try {
await this.checkOrder(this.orderId); await this.checkOrder(this.orderId);
return true; return true;
} catch(err) { } catch(err) {
if (err.exception == 'Vn.Lib.UserError') { if (err.exception == 'Vn.Lib.UserError') {
const dst = {
form: 'ecomerce/checkout',
continue: 'catalog'
};
switch(err.code) { switch(err.code) {
case 'orderConfirmed': case 'orderConfirmed':
case 'orderNotOwnedByUser': case 'orderNotOwnedByUser':
this.constructor.unload(); this.constructor.unload();
break; await this.redirect();
default: break;
dst.id = this.orderId; default:
Htk.Toast.showError(err.message); this.app.hash.setAll({
form: 'ecomerce/checkout',
id: this.orderId,
continue: checkoutContinue
});
Htk.Toast.showError(err.message);
} }
this.app.hash.setAll(dst);
return false; return false;
} else } else
throw err; 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) { async load(orderId) {
this.loadIntoBasket(orderId); this.loadIntoBasket(orderId);
if (await this.checkRedirect()) if (await this.checkRedirect('catalog'))
this.app.hash.setAll({ this.app.hash.setAll({
form: 'ecomerce/catalog' form: 'ecomerce/catalog'
}); });

View File

@ -63,3 +63,5 @@ Agencies: Agències
Configuration: Configuració Configuration: Configuració
Account: Compte Account: Compte
Addresses: Adreces 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 Configuration: Configuration
Account: Account Account: Account
Addresses: Addresses 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 Configuration: Configuración
Account: Cuenta Account: Cuenta
Addresses: Direcciones 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 Configuration: Configuration
Account: Compte Account: Compte
Addresses: Adresses 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 Configuration: Configuração
Account: Conta Account: Conta
Addresses: Moradas Addresses: Moradas
Load an order: Carregue um pedido pendente no carrinho ou inicie um novo

View File

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

View File

@ -36,7 +36,7 @@ Sep: Set
Oct: Oct Oct: Oct
Nov: Nov Nov: Nov
Dec: Des 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 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' '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 Accept: Acceptar

View File

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

View File

@ -36,7 +36,7 @@ Sep: Sep
Oct: Oct Oct: Oct
Nov: Nov Nov: Nov
Dec: Déc 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é 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' '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 Accept: Accepter

View File

@ -36,6 +36,6 @@ Sep: Есд
Oct: Ара Oct: Ара
Nov: Арв Nov: Арв
Dec: Арв Dec: Арв
'%A, %B %e': '%A, %B %e' '%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Something went wrong 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' '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 Oct: Out
Nov: Nov Nov: Nov
Dec: Dez Dec: Dez
'%A, %B %e': '%A, %B %e' '%A, %B %e %Y': '%A, %B %e %Y'
Something went wrong: Algo deu errado 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' '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 Accept: Aceitar

View File

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