From 34cb455df4ea17124aa04cd5570cad27e681cfc0 Mon Sep 17 00:00:00 2001 From: Dipak Savaliya Date: Fri, 16 Jul 2021 13:16:42 +0000 Subject: [PATCH] Ds/issue186 --- app.js | 8 ++++---- locales/it.json | 3 ++- routes/admin.js | 12 ++++++++++++ routes/customer.js | 9 ++++++++- routes/index.js | 12 ++++++++++++ routes/order.js | 7 ++++++- routes/product.js | 4 ++++ routes/reviews.js | 2 ++ routes/user.js | 3 +++ views/layouts/layout.hbs | 4 ++-- views/products.hbs | 6 +++--- views/themes/Cloth/style.css | 3 +++ 12 files changed, 61 insertions(+), 12 deletions(-) diff --git a/app.js b/app.js index 5b3c8206..f3f55666 100644 --- a/app.js +++ b/app.js @@ -330,11 +330,11 @@ handlebars = handlebars.create({ `; }, - eqHidden: (lvalue, rvalue) => { - return lvalue === rvalue ? 'd-none' : 'd-flex'; + eqClass: (lvalue, rvalue, trueval, falseval) => { + return lvalue === rvalue ? trueval : falseval; }, - neqHidden: (lvalue, rvalue) => { - return lvalue !== rvalue ? 'd-none' : 'd-flex'; + neqClass: (lvalue, rvalue, trueval, falseval) => { + return lvalue !== rvalue ? trueval : falseval; } } }); diff --git a/locales/it.json b/locales/it.json index 8545a19e..eaf8b54e 100644 --- a/locales/it.json +++ b/locales/it.json @@ -205,5 +205,6 @@ "Request Date": "Data richiesta", "NFTs purchased": "NFT acquistati", "View": "Visualizza", - "Logout": "Disconnettersi" + "Logout": "Disconnettersi", + "Company": "Company" } \ No newline at end of file diff --git a/routes/admin.js b/routes/admin.js index 09ff0b9f..318fba70 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -123,6 +123,7 @@ router.get('/admin/login', async (req, res) => { req.session.needsSetup = false; res.render('login', { title: 'Login', + language: req.cookies.locale || config.defaultLocale, referringUrl: req.header('Referer'), config: req.app.config, message: clearSessionValue(req.session, 'message'), @@ -230,6 +231,7 @@ router.get('/admin/setup', async (req, res) => { res.render('setup', { title: 'Setup', config: req.app.config, + language: req.cookies.locale || config.defaultLocale, helpers: req.handlebars.helpers, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -379,6 +381,7 @@ router.get('/admin/dashboard', csrfProtection, restrict, async (req, res) => { res.render('dashboard', { title: 'Cart dashboard', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, dashboardData, themes: getThemes(), @@ -396,6 +399,7 @@ router.get('/admin/settings', csrfProtection, restrict, (req, res) => { res.render('settings', { title: 'Cart settings', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, themes: getThemes(), message: clearSessionValue(req.session, 'message'), @@ -423,6 +427,7 @@ router.get('/admin/redemptions', restrict, checkAccess, async (req, res) => { res.render('redemptions', { title: 'Redeem Requests', config: req.app.config, + language: req.cookies.locale || config.defaultLocale, helpers: req.handlebars.helpers, redemptions, message: clearSessionValue(req.session, 'message'), @@ -471,6 +476,7 @@ router.get('/admin/settings/menu', csrfProtection, restrict, async (req, res) => res.render('settings-menu', { title: 'Cart menu', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -491,6 +497,7 @@ router.get('/admin/settings/pages', csrfProtection, restrict, async (req, res) = title: 'Static pages', pages: pages, session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -509,6 +516,7 @@ router.get('/admin/settings/pages/new', csrfProtection, restrict, checkAccess, a res.render('settings-page', { title: 'Static pages', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, button_text: 'Create', message: clearSessionValue(req.session, 'message'), @@ -543,6 +551,7 @@ router.get('/admin/settings/pages/edit/:page', csrfProtection, restrict, checkAc page: page, button_text: 'Update', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -681,6 +690,7 @@ router.get('/admin/settings/discounts', csrfProtection, restrict, checkAccess, a title: 'Discount code', config: req.app.config, session: req.session, + language: req.cookies.locale || config.defaultLocale, discounts, admin: true, message: clearSessionValue(req.session, 'message'), @@ -700,6 +710,7 @@ router.get('/admin/settings/discount/edit/:id', csrfProtection, restrict, checkA res.render('settings-discount-edit', { title: 'Discount code edit', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, discount, message: clearSessionValue(req.session, 'message'), @@ -770,6 +781,7 @@ router.get('/admin/settings/discount/new', csrfProtection, restrict, checkAccess res.render('settings-discount-new', { title: 'Discount code create', session: req.session, + language: req.cookies.locale || config.defaultLocale, admin: true, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), diff --git a/routes/customer.js b/routes/customer.js index 9281c147..012a08c7 100644 --- a/routes/customer.js +++ b/routes/customer.js @@ -31,6 +31,7 @@ router.get('/customer/setup', async (req, res) => { res.render('customer-create', { title: 'Register', config: req.app.config, + language: req.cookies.locale || config.defaultLocale, helpers: req.handlebars.helpers, session: req.session, message: clearSessionValue(req.session, 'message'), @@ -212,7 +213,6 @@ router.post('/customer/save', async (req, res) => { router.get('/customer/account', async (req, res) => { const db = req.app.db; const config = req.app.config; - if(!req.session.customerPresent){ res.redirect('/customer/login'); return; @@ -258,6 +258,7 @@ router.get('/customer/account', async (req, res) => { session: req.session, orders, user, + language: req.cookies.locale || config.defaultLocale, balance: balance ? (balance.balance / Math.pow(10, config.peerplaysAssetPrecision)).toFixed(config.peerplaysAssetPrecision) : 0, transferFees, message: clearSessionValue(req.session, 'message'), @@ -511,6 +512,7 @@ router.get('/admin/customer/view/:id?', restrict, async (req, res) => { return res.render('customer', { title: 'View customer', result: customer, + language: req.cookies.locale || config.defaultLocale, admin: true, session: req.session, message: clearSessionValue(req.session, 'message'), @@ -537,6 +539,7 @@ router.get('/admin/customers', restrict, async (req, res) => { return res.render('customers', { title: 'Customers - List', admin: true, + language: req.cookies.locale || config.defaultLocale, customers: customers, session: req.session, helpers: req.handlebars.helpers, @@ -571,6 +574,7 @@ router.get('/admin/customers/filter/:search', restrict, async (req, res, next) = return res.render('customers', { title: 'Customer results', customers: customers, + language: req.cookies.locale || config.defaultLocale, admin: true, config: req.app.config, session: req.session, @@ -620,6 +624,7 @@ router.get('/customer/login', async (req, res, next) => { title: 'Customer login', config: req.app.config, session: req.session, + language: req.cookies.locale || config.deafultLocale, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), pageUrl: req.originalUrl, @@ -743,6 +748,7 @@ router.get('/customer/forgotten', (req, res) => { title: 'Forgotten', route: 'customer', forgotType: 'customer', + language: req.cookies.locale || config.defaultLocale, config: req.app.config, helpers: req.handlebars.helpers, message: clearSessionValue(req.session, 'message'), @@ -810,6 +816,7 @@ router.get('/customer/reset/:token', async (req, res) => { res.render('reset', { title: 'Reset password', token: req.params.token, + language: req.cookies.locale || config.defaultLocale, route: 'customer', config: req.app.config, message: clearSessionValue(req.session, 'message'), diff --git a/routes/index.js b/routes/index.js index be9c09e2..c69f4331 100644 --- a/routes/index.js +++ b/routes/index.js @@ -163,6 +163,7 @@ router.get('/payment/:orderId', async (req, res, next) => { title: 'Payment complete', config: req.app.config, session: req.session, + language: req.cookies.locale || config.defaultLocale, result: order, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -197,6 +198,7 @@ router.get('/checkout/information', async (req, res, next) => { title: 'Checkout - Information', config: req.app.config, session: req.session, + language: req.cookies.locale || config.defaultLocale, paymentType, cartClose: false, page: 'checkout-information', @@ -242,6 +244,7 @@ router.get('/checkout/shipping', async (req, res, next) => { config: req.app.config, session: req.session, cartClose: false, + language: req.cookies.locale || config.defaultLocale, cartReadOnly: true, page: 'checkout-shipping', countryList, @@ -258,6 +261,7 @@ router.get('/checkout/cart', (req, res) => { res.render(`${config.themeViews}checkout-cart`, { title: 'Checkout - Cart', page: req.query.path, + language: req.cookies.locale || config.defaultLocale, config, session: req.session, message: clearSessionValue(req.session, 'message'), @@ -301,6 +305,7 @@ router.get('/checkout/payment/:ppyAmount', async (req, res) => { config: req.app.config, paymentConfig: getPaymentConfig(), session: req.session, + language: req.cookies.locale || config.defaultLocale, paymentPage: true, paymentType: '', cartClose: true, @@ -328,6 +333,7 @@ router.get('/blockonomics_payment', (req, res, next) => { config: req.app.config, paymentConfig: getPaymentConfig(), session: req.session, + language: req.cookies.locale || config.defaultLocale, paymentPage: true, paymentType, cartClose: true, @@ -604,6 +610,7 @@ router.get('/product/:id/:offerId', async (req, res) => { title: product.productTitle, result: product, relatedProducts, + language: req.cookies.locale || config.defaultLocale, balance, fee, bidFee, @@ -1118,6 +1125,7 @@ router.get('/search/:searchTerm?/:pageNum?', (req, res) => { res.render(`${config.themeViews}index`, { title: 'Results', results: results.data, + language: req.cookies.locale || config.defaultLocale, filtered: true, session: req.session, metaDescription: `${req.app.config.cartTitle} - Search term: ${searchTerm}`, @@ -1175,6 +1183,7 @@ router.get('/category/:cat/:pageNum?', (req, res) => { title: `Category: ${searchTerm}`, results: results.data, filtered: true, + language: req.cookies.locale || config.defaultLocale, session: req.session, searchTerm: searchTerm, metaDescription: `${req.app.config.cartTitle} - Category: ${searchTerm}`, @@ -1260,6 +1269,7 @@ router.get('/page/:pageNum', (req, res, next) => { title: 'Shop', results: results.data, session: req.session, + language: req.cookies.locale || config.defaultLocale, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), metaDescription: `${req.app.config.cartTitle} - Products page: ${req.params.pageNum}`, @@ -1301,6 +1311,7 @@ router.get('/:page?', async (req, res, next) => { res.render(`${config.themeViews}index`, { title: `${config.cartTitle} - Shop`, theme: config.theme, + language: req.cookies.locale || config.defaultLocale, results: results.data, session: req.session, message: clearSessionValue(req.session, 'message'), @@ -1332,6 +1343,7 @@ router.get('/:page?', async (req, res, next) => { title: page.pageName, page: page, searchTerm: req.params.page, + language: req.cookies.locale || config.defaultLocale, session: req.session, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), diff --git a/routes/order.js b/routes/order.js index 11e5e3ee..f719ba94 100644 --- a/routes/order.js +++ b/routes/order.js @@ -8,7 +8,7 @@ const { clearCustomer } = require('../lib/common'); const { - paginateData, + paginateData } = require('../lib/paginate'); const { emptyCart @@ -40,6 +40,7 @@ router.get('/admin/orders/:page?', restrict, async (req, res, next) => { title: 'Cart', orders: orders.data, totalItemCount: orders.totalItems, + language: req.cookies.locale || config.defaultLocale, pageNum, paginateUrl: 'admin/orders', admin: true, @@ -78,6 +79,7 @@ router.get('/admin/orders/bystatus/:orderstatus', restrict, async (req, res, nex orders: orders, admin: true, filteredOrders: true, + language: req.cookies.locale || config.defaultLocale, filteredStatus: req.params.orderstatus, config: req.app.config, session: req.session, @@ -97,6 +99,7 @@ router.get('/admin/order/view/:id', restrict, async (req, res) => { title: 'View order', result: order, config: req.app.config, + language: req.cookies.locale || config.defaultLocale, session: req.session, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), @@ -113,6 +116,7 @@ router.get('/admin/order/create', restrict, async (req, res) => { title: 'Create order', config: req.app.config, session: req.session, + language: req.cookies.locale || config.defaultLocale, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), countryList: getCountryList(), @@ -236,6 +240,7 @@ router.get('/admin/orders/filter/:search', restrict, async (req, res, next) => { title: 'Order results', orders: orders, admin: true, + language: req.cookies.locale || config.defaultLocale, config: req.app.config, session: req.session, searchTerm: searchTerm, diff --git a/routes/product.js b/routes/product.js index 571253c7..f20316d6 100644 --- a/routes/product.js +++ b/routes/product.js @@ -284,6 +284,7 @@ router.get('/customer/products/:page?', async (req, res, next) => { res.render('products', { title: 'My NFTs', + language: req.cookies.locale || config.defaultLocale, results: products.data, purchases, totalItemCount: products.totalItems, @@ -405,6 +406,7 @@ router.get('/customer/products/filter/:search', async (req, res, next) => { res.render('products', { title: 'Results', results: results, + language: req.cookies.locale || config.defaultLocale, resultType: 'filtered', admin: req.session.isAdmin || false, mintFee, @@ -454,6 +456,7 @@ router.get('/customer/product/new', async (req, res) => { res.render('product-new', { title: 'New NFT', session: req.session, + language: req.cookies.locale || config.defaultLocale, productTitle: clearSessionValue(req.session, 'productTitle'), productDescription: clearSessionValue(req.session, 'productDescription'), productPermalink: clearSessionValue(req.session, 'productPermalink'), @@ -770,6 +773,7 @@ router.get('/customer/product/edit/:id', async (req, res) => { title: 'Edit product', result: product, admin: false, + language: req.cookies.locale || config.defaultLocale, session: req.session, updateFee, updateFeeFloat, diff --git a/routes/reviews.js b/routes/reviews.js index 40dcaca3..0a60dc16 100644 --- a/routes/reviews.js +++ b/routes/reviews.js @@ -20,6 +20,7 @@ router.get('/admin/reviews/:page?', restrict, async (req, res, next) => { res.render('reviews', { title: 'Cart - Reviews', results: reviews.data, + language: req.cookies.locale || config.defaultLocale, totalItemCount: reviews.totalItems, pageNum, paginateUrl: 'admin/reviews', @@ -57,6 +58,7 @@ router.get('/admin/reviews/filter/:search', restrict, async (req, res, next) => results: results, resultType: 'filtered', admin: true, + language: req.cookies.locale || config.defaultLocale, config: req.app.config, session: req.session, searchTerm: searchTerm, diff --git a/routes/user.js b/routes/user.js index 8e59ef67..7d7ea3ef 100644 --- a/routes/user.js +++ b/routes/user.js @@ -20,6 +20,7 @@ router.get('/admin/users', restrict, async (req, res) => { title: 'Users', users: users, admin: true, + language: req.cookies.locale || config.defaultLocale, config: req.app.config, isAdmin: req.session.isAdmin, helpers: req.handlebars.helpers, @@ -67,6 +68,7 @@ router.get('/admin/user/edit/:id', restrict, async (req, res) => { user: user, admin: true, session: req.session, + language: req.cookies.locale || config.defaultLocale, message: clearSessionValue(req.session, 'message'), messageType: clearSessionValue(req.session, 'messageType'), pageUrl: req.originalUrl, @@ -80,6 +82,7 @@ router.get('/admin/user/new', restrict, (req, res) => { res.render('user-new', { title: 'User - New', admin: true, + language: req.cookies.locale || config.defaultLocale, session: req.session, helpers: req.handlebars.helpers, message: clearSessionValue(req.session, 'message'), diff --git a/views/layouts/layout.hbs b/views/layouts/layout.hbs index c89a9810..66dd1cde 100644 --- a/views/layouts/layout.hbs +++ b/views/layouts/layout.hbs @@ -206,9 +206,9 @@ - diff --git a/views/products.hbs b/views/products.hbs index e9a68559..469b34fa 100644 --- a/views/products.hbs +++ b/views/products.hbs @@ -115,11 +115,11 @@
-
+
-
+
@@ -201,7 +201,7 @@ {{/if}} {{#unless @root.admin}}
-
+
diff --git a/views/themes/Cloth/style.css b/views/themes/Cloth/style.css index e6f64b8c..a86582cc 100644 --- a/views/themes/Cloth/style.css +++ b/views/themes/Cloth/style.css @@ -13,6 +13,9 @@ /* border: 1px solid #afacac; */ width: 100%; } +.bold{ + font-weight: bold; +} .top-align-space { padding-top: 100px; padding-bottom: 100px;