0
1
Fork 0

Merge pull request 'master' (!25) from master into test

Reviewed-on: verdnatura/hedera-web#25
This commit is contained in:
Juan Ferrer 2023-02-23 19:22:05 +00:00
commit 4190aad94e
25 changed files with 115 additions and 51 deletions

2
debian/changelog vendored
View File

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

View File

@ -5,21 +5,31 @@ export default new Class({
Template: require('./ui.xml'),
async open() {
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;
await this.loadOrder();
if (this.orderId) {
await Hedera.Form.prototype.open.call(this);
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});
},
activate() {
this.$.items.setInfo('bi', 'myOrderRow', 'hedera');
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) {

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

@ -1 +1,8 @@
Pending: Pendents
PendingOrders: Comandes pendents
NewOrder: Nova comanda
ViewOrder: Veure comanda
RemoveOrder: Eliminar comanda
LoadOrderIntoCart: Carregar comanda a la cistella
AreYouSureDeleteOrder: Segur que vols esborrar la comanda?
OrderLoadedIntoBasket: Comanda carregada a la cistella!

View File

@ -1 +1,8 @@
Pending: Pending
PendingOrders: Pending orders
NewOrder: New order
ViewOrder: View order
RemoveOrder: Delete order
LoadOrderIntoCart: Load order into cart
AreYouSureDeleteOrder: Are you sure you want to delete the order?
OrderLoadedIntoBasket: Order loaded into basket!

View File

@ -5,4 +5,4 @@ ViewOrder: Ver pedido
RemoveOrder: Eliminar pedido
LoadOrderIntoCart: Cargar pedido en la cesta
AreYouSureDeleteOrder: ¿Seguro que quieres borrar el pedido?
OrderLoadedIntoBasket: ¡Pedido cargado en la cesta!
OrderLoadedIntoBasket: ¡Pedido cargado en la cesta!

View File

@ -1 +1,8 @@
Pending: Pendents
Pending: En attente
PendingOrders: Commandes en attente
NewOrder: Nouvelle commande
ViewOrder: Afficher la commande
RemoveOrder: Supprimer la commande
LoadOrderIntoCart: Charger la commande dans le panier
AreYouSureDeleteOrder: Êtes-vous sûr de vouloir supprimer la commande?
OrderLoadedIntoBasket: Commande chargée dans le panier!

View File

@ -1 +1,8 @@
Pending: Pendientes
Pending: Pendentes
PendingOrders: Pedidos pendentes
NewOrder: Novo pedido
ViewOrder: Ver pedido
RemoveOrder: Excluir pedido
LoadOrderIntoCart: Carrega o pedido no carrinho
AreYouSureDeleteOrder: Tem certeza de que deseja excluir o pedido?
OrderLoadedIntoBasket: Pedido carregado na cesta!

View File

@ -13,41 +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'
};
if (err.code == 'orderNotOwnedByUser') {
switch(err.code) {
case 'orderConfirmed':
case 'orderNotOwnedByUser':
this.constructor.unload();
} else {
dst.id = this.orderId;
await this.redirect();
break;
default:
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.2",
"version": "23.6.5",
"description": "Verdnatura web page",
"license": "GPL-3.0",
"repository": {

View File

@ -48,13 +48,13 @@ class JsonService extends RestService {
$json = new JsonException();
if (_ENABLE_DEBUG || $errno & $eUser)
if (_ENABLE_DEBUG || $errno & $eUser) {
$json->message = $message;
else
$json->code = $errno;
} else
$json->message = s('Something went wrong');
if (_ENABLE_DEBUG) {
$json->code = $errno;
$json->file = $file;
$json->line = $line;
}
@ -79,13 +79,13 @@ class JsonService extends RestService {
if (_ENABLE_DEBUG || $e instanceof Lib\UserException) {
$json->exception = get_class($e);
$json->message = $e->getMessage();
$json->code = $e->getCode();
} else {
$json->exception = 'Exception';
$json->message = s('Something went wrong');
}
if (_ENABLE_DEBUG) {
$json->code = $e->getCode();
$json->file = $e->getFile();
$json->line = $e->getLine();
$json->trace = $e->getTrace();