From 6458d8db5ebf01041f61977c7b4359a07fb2a390 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 16 Jan 2023 08:32:48 +0100 Subject: [PATCH] #4922 Catalog & fixes --- src/i18n/en-US/index.js | 24 +- src/i18n/es-ES/index.js | 24 +- src/js/db/result-set.js | 14 +- src/js/vn/json-connection.js | 2 - src/layouts/MainLayout.vue | 20 +- src/pages/Cms/Home.vue | 6 + src/pages/Ecomerce/Catalog.vue | 668 +++++++++++++++++++++++++++++++++ src/pages/Ecomerce/Orders.vue | 49 +++ src/router/index.js | 12 + src/router/routes.js | 4 + src/stores/app.js | 6 +- src/stores/user.js | 8 +- 12 files changed, 825 insertions(+), 12 deletions(-) create mode 100644 src/pages/Ecomerce/Catalog.vue diff --git a/src/i18n/en-US/index.js b/src/i18n/en-US/index.js index 77206823..9e717125 100644 --- a/src/i18n/en-US/index.js +++ b/src/i18n/en-US/index.js @@ -59,5 +59,27 @@ export default { 'Nov', 'Dec' ] - } + }, + + // menu + home: 'Home', + catalog: 'Catalog', + orders: 'Orders', + order: 'Pending order', + ticket: 'Order', + conditions: 'Conditions', + about: 'About us', + admin: 'Administration', + panel: 'Control panel', + users: 'Users', + connections: 'Connections', + visits: 'Visits', + news: 'News', + newEdit: 'Edit new', + images: 'Images', + items: 'Items', + config: 'Configuration', + user: 'User', + addresses: 'Addresses', + addressEdit: 'Edit address' } diff --git a/src/i18n/es-ES/index.js b/src/i18n/es-ES/index.js index 807b0074..f1cbef7b 100644 --- a/src/i18n/es-ES/index.js +++ b/src/i18n/es-ES/index.js @@ -59,5 +59,27 @@ export default { 'Nov', 'Dic' ] - } + }, + + // Menu + home: 'Inicio', + catalog: 'Catálogo', + orders: 'Pedidos', + order: 'Pedido pendiente', + ticket: 'Pedido', + conditions: 'Condiciones', + about: 'Sobre nosotros', + admin: 'Administración', + panel: 'Panel de control', + users: 'Usuarios', + connections: 'Conexiones', + visits: 'Visitas', + news: 'Noticias', + newEdit: 'Editar noticia', + images: 'Imágenes', + items: 'Artículos', + config: 'Configuración', + user: 'Usuario', + addresses: 'Direcciones', + addressEdit: 'Editar dirección' } diff --git a/src/js/db/result-set.js b/src/js/db/result-set.js index ad9d4a42..4283f4ad 100644 --- a/src/js/db/result-set.js +++ b/src/js/db/result-set.js @@ -43,7 +43,11 @@ export class ResultSet { const result = this.fetch() if (result !== null) { - if (result.data instanceof Array) { return new Result(result) } else { return true } + if (result.data instanceof Array) { + return new Result(result) + } else { + return true + } } return null @@ -73,7 +77,9 @@ export class ResultSet { const result = this.fetch() if (result !== null && - result.data instanceof Array) { return result.data } + result.data instanceof Array) { + return result.data + } return null } @@ -104,7 +110,9 @@ export class ResultSet { result.data.length > 0) { const object = result.data[0] const row = new Array(result.columns.length) - for (let i = 0; i < row.length; i++) { row[i] = object[result.columns[i].name] } + for (let i = 0; i < row.length; i++) { + row[i] = object[result.columns[i].name] + } return row } diff --git a/src/js/vn/json-connection.js b/src/js/vn/json-connection.js index 51cafa41..abd030d8 100644 --- a/src/js/vn/json-connection.js +++ b/src/js/vn/json-connection.js @@ -179,8 +179,6 @@ export class JsonConnection extends VnObject { } if (error) { - if (error.exception === 'SessionExpired') { this.clearToken() } - this.emit('error', error) reject(error) } else { resolve(data) } diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 30ca0dc2..9cdb1c72 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -10,10 +10,24 @@ aria-label="Menu" @click="toggleLeftDrawer"/> - Home + {{$app.title}} +
+ {{$app.subtitle}} +
+ + + * { padding: 16px; } +#actions > div { + display: flex; + align-items: center; +} @include mobile { #actions > div { .q-btn { diff --git a/src/pages/Cms/Home.vue b/src/pages/Cms/Home.vue index 0b775b22..20747c49 100644 --- a/src/pages/Cms/Home.vue +++ b/src/pages/Cms/Home.vue @@ -71,4 +71,10 @@ export default { startOrder: Start order es-ES: startOrder: Empezar pedido + ca-ES: + startOrder: Començar comanda + fr-FR: + startOrder: Lancer commande + pt-PT: + startOrder: Comece uma encomenda diff --git a/src/pages/Ecomerce/Catalog.vue b/src/pages/Ecomerce/Catalog.vue new file mode 100644 index 00000000..e93d35ea --- /dev/null +++ b/src/pages/Ecomerce/Catalog.vue @@ -0,0 +1,668 @@ + + + + + + + + es-ES: + gridView: Vista de rejilla + listView: Vista de lista + shoppingCart: Cesta de la compra + warehouse: Almacén + agency: Agencia + modify: Modificar + category: Categoría + deleteFilter: Quitar filtro + filterBy: Filtrar por + family: Familia + orderBy: Ordernar por + pleaseSetFilter: Elige un filtro en el menú de la derecha + search: Buscar + diff --git a/src/pages/Ecomerce/Orders.vue b/src/pages/Ecomerce/Orders.vue index e7fb2455..b7f3fde1 100644 --- a/src/pages/Ecomerce/Orders.vue +++ b/src/pages/Ecomerce/Orders.vue @@ -144,9 +144,58 @@ export default { noOrdersFound: No orders found makePayment: Make payment shoppingCart: Shopping cart + balance: 'Balance:' + paymentInfo: >- + The amount shown is your slope (negative) or favorable balance today, it + disregards future orders. For get your order shipped, this amount must be + equal to or greater than 0. If you want to make a down payment, click the + payment button, delete the suggested amount and enter the amount you want. es-ES: startOrder: Empezar pedido noOrdersFound: No se encontrado pedidos makePayment: Realizar pago shoppingCart: Cesta de la compra + balance: 'Saldo:' + paymentInfo: >- + La cantidad mostrada es tu saldo pendiente (negativa) o favorable a día de + hoy, no tiene en cuenta pedidos del futuro. Para que tu pedido sea enviado, + esta cantidad debe ser igual o mayor que 0. Si quieres realizar una entrega a + cuenta, pulsa el botón de pago, borra la cantidad sugerida e introduce la + cantidad que desees. + ca-ES: + startOrder: Començar encàrrec + noOrdersFound: No s'han trobat comandes + makePayment: Realitzar pagament + shoppingCart: Cistella de la compra + balance: 'Saldo:' + paymentInfo: >- + La quantitat mostrada és el teu saldo pendent (negatiu) o favorable a dia + d'avui, no té en compte comandes del futur. Perquè la teva comanda sigui + enviat, aquesta quantitat ha de ser igual o més gran que 0. Si vols fer un + lliurament a compte, prem el botó de pagament, esborra la quantitat suggerida + e introdueix la quantitat que vulguis. + fr-FR: + startOrder: Acheter + noOrdersFound: Aucune commande trouvée + makePayment: Effectuer un paiement + shoppingCart: Panier + balance: 'Balance:' + paymentInfo: >- + Le montant indiqué est votre pente (négative) ou balance favorable + aujourd'hui, ne tient pas compte pour les commandes futures. Obtenir votre + commande est expédiée, ce montant doit être égal ou supérieur à 0. Si vous + voulez faire un versement, le montant suggéré effacé et entrez le montant que + vous souhaitez. + pt-PT: + startOrder: Iniciar encomenda + noOrdersFound: Nenhum pedido encontrado + makePayment: Realizar pagamento + shoppingCart: Cesta da compra + balance: 'Saldo:' + paymentInfo: >- + A quantidade mostrada é seu saldo pendente (negativo) ou favorável a dia de + hoje, não se vincula a pedidos futuros. Para que seu pedido seja enviado, esta + quantidade deve ser igual ou superior a 0. Se queres realizar um depósito à + conta, clique no botão de pagamento, apague a quantidade sugerida e introduza + a quantidade que deseje. diff --git a/src/router/index.js b/src/router/index.js index c2e62352..f530d733 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,4 +1,5 @@ import { route } from 'quasar/wrappers' +import { appStore } from 'stores/app' import { createRouter, createMemoryHistory, createWebHistory, createWebHashHistory } from 'vue-router' import routes from './routes' @@ -26,5 +27,16 @@ export default route(function (/* { store, ssrContext } */) { history: createHistory(process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE) }) + Router.afterEach((to, from) => { + if (from.name === to.name) return + const app = appStore() + app.$patch({ + title: window.i18n.t(to.name || 'home'), + subtitle: null, + useRightDrawer: false, + rightDrawerOpen: true + }) + }) + return Router }) diff --git a/src/router/routes.js b/src/router/routes.js index b9874ec2..721a0df2 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -42,6 +42,10 @@ const routes = [ name: 'invoices', path: '/ecomerce/invoices', component: () => import('pages/Ecomerce/Invoices.vue') + }, { + name: 'catalog', + path: '/ecomerce/catalog/:category?/:type?', + component: () => import('pages/Ecomerce/Catalog.vue') } ] }, diff --git a/src/stores/app.js b/src/stores/app.js index 31a7aa14..475032ae 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -3,7 +3,11 @@ import { jApi } from 'boot/axios' export const appStore = defineStore('hedera', { state: () => ({ - imageUrl: '' + title: null, + subtitle: null, + imageUrl: '', + useRightDrawer: false, + rightDrawerOpen: false }), actions: { diff --git a/src/stores/user.js b/src/stores/user.js index 83539520..80552ef5 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -4,8 +4,8 @@ import { api, jApi } from 'boot/axios' export const userStore = defineStore('user', { state: () => { const token = - localStorage.getItem('vnToken') || - sessionStorage.getItem('vnToken') + sessionStorage.getItem('vnToken') || + localStorage.getItem('vnToken') return { token, @@ -38,7 +38,9 @@ export const userStore = defineStore('user', { async logout () { if (this.token != null) { - await api.post('Accounts/logout') + try { + await api.post('Accounts/logout') + } catch (e) {} localStorage.removeItem('vnToken') sessionStorage.removeItem('vnToken') }