From 4a09fe39a80a79db9632cd9750412301a98d6fd4 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 9 Oct 2023 21:01:11 +0200 Subject: [PATCH] refs #6200 style fixes, mock local date --- debian/changelog | 2 +- forms/admin/visits/index.js | 4 +-- forms/cms/contact/index.js | 2 +- forms/ecomerce/catalog/style.scss | 4 ++- forms/ecomerce/catalog/ui.xml | 4 +-- forms/ecomerce/checkout/index.js | 6 ++-- forms/reports/shelves/index.js | 2 +- js/htk/calendar/index.js | 4 +-- js/htk/image/index.js | 2 +- js/vn/cookie.js | 52 +++++++++++++------------------ js/vn/date.js | 16 ++++++++++ package.json | 2 +- rest/edi/lib/segment.php | 2 +- 13 files changed, 56 insertions(+), 46 deletions(-) diff --git a/debian/changelog b/debian/changelog index 93f3feba..45f25338 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -hedera-web (23.40.2) stable; urgency=low +hedera-web (23.40.3) stable; urgency=low * Initial Release. diff --git a/forms/admin/visits/index.js b/forms/admin/visits/index.js index 78f093d8..02f5fa16 100644 --- a/forms/admin/visits/index.js +++ b/forms/admin/visits/index.js @@ -7,8 +7,8 @@ export default new Class({ ,activate() { if (!this.hash.$.to) this.hash.assign({ - from: new Date(), - to: new Date() + from: Date.vnNew(), + to: Date.vnNew() }); } }); diff --git a/forms/cms/contact/index.js b/forms/cms/contact/index.js index 7bff0faf..9e9d6f68 100644 --- a/forms/cms/contact/index.js +++ b/forms/cms/contact/index.js @@ -14,7 +14,7 @@ export default new Class({ ,refreshCaptcha() { params = { srv: 'rest:misc/captcha', - stamp: new Date().getTime() + stamp: Date.vnNew().getTime() }; this.$.captchaImg.src = '?'+ Vn.Url.makeUri(params); } diff --git a/forms/ecomerce/catalog/style.scss b/forms/ecomerce/catalog/style.scss index 7f0b998d..c218c348 100644 --- a/forms/ecomerce/catalog/style.scss +++ b/forms/ecomerce/catalog/style.scss @@ -193,16 +193,18 @@ margin-bottom: 1px; } & > .min-quantity { - bottom: 30px; + bottom: 32px; right: 0; } } .min-quantity { position: absolute; + display: none; bottom: 30px; right: 0; font-size: .8rem; + color: #c44; & > span { font-size: 16px; diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index 35f0115b..26a80fda 100644 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -469,10 +469,10 @@
- {{card.minQuantity}} production_quantity_limits - + + {{card.minQuantity}}
diff --git a/forms/ecomerce/checkout/index.js b/forms/ecomerce/checkout/index.js index d556c66d..99e07177 100644 --- a/forms/ecomerce/checkout/index.js +++ b/forms/ecomerce/checkout/index.js @@ -8,7 +8,7 @@ export default new Class({ this.autoStepLocked = true; this.$.assistant.stepsIndex = this.agencySteps; - this.today = new Date(); + this.today = Date.vnNew(); this.today.setHours(0, 0, 0, 0); }, @@ -22,8 +22,8 @@ export default new Class({ let date; const row = orderForm.$ || defaultsForm.$ || {}; - if (!date || date.getTime() < (new Date()).getTime()) { - date = new Date(); + if (!date || date.getTime() < (Date.vnNew()).getTime()) { + date = Date.vnNew(); date.setHours(0, 0, 0, 0); let addDays = 0; diff --git a/forms/reports/shelves/index.js b/forms/reports/shelves/index.js index 0cbb379c..1fd0d8d0 100644 --- a/forms/reports/shelves/index.js +++ b/forms/reports/shelves/index.js @@ -6,7 +6,7 @@ export default new Class({ activate() { this.$.lot.assign({ - date: new Date(), + date: Date.vnNew(), useIds: false }); }, diff --git a/js/htk/calendar/index.js b/js/htk/calendar/index.js index 24f757ef..ae265941 100644 --- a/js/htk/calendar/index.js +++ b/js/htk/calendar/index.js @@ -141,7 +141,7 @@ module.exports = new Class({ } ,goToCurrentMonth() { - var date = new Date(); + var date = Date.vnNew(); this.goToMonth(date.getFullYear(), date.getMonth()); } @@ -179,7 +179,7 @@ module.exports = new Class({ // Marks the current day - var today = new Date(); + var today = Date.vnNew(); if (this.year == today.getFullYear() && this.month == today.getMonth()) { diff --git a/js/htk/image/index.js b/js/htk/image/index.js index efe3a752..e73fdc06 100644 --- a/js/htk/image/index.js +++ b/js/htk/image/index.js @@ -192,7 +192,7 @@ module.exports = new Class({ } ,_onFileUpload(cell) { - this._stamp = new Date().getTime(); + this._stamp = Date.vnNew().getTime(); this._refreshSrc(cell); this.popup.hide(); } diff --git a/js/vn/cookie.js b/js/vn/cookie.js index 7ab233e1..8e90dfae 100644 --- a/js/vn/cookie.js +++ b/js/vn/cookie.js @@ -3,69 +3,61 @@ */ module.exports = { - set: function (key, value, days) - { + set: function(key, value, days) { var strCookie = key + '=' + value + ';'; - if (days != undefined) - { - var date = new Date (); - date.setTime (date.getTime () + days * 86400000); - strCookie += 'expires=' + date.toGMTString (); + if (days != undefined) { + var date = Date.vnNew(); + date.setTime(date.getTime() + days * 86400000); + strCookie += 'expires=' + date.toGMTString(); } document.cookie = strCookie; } - ,unset: function (key) - { - this.set (key, '', -1); + ,unset: function(key) { + this.set(key, '', -1); } - ,get: function (key) - { - var cookie = new String (document.cookie); - var start = cookie.indexOf (key + '='); + ,get: function(key) { + var cookie = new String(document.cookie); + var start = cookie.indexOf(key + '='); - if (start != -1) - { + if (start != -1) { var end; start += key.length + 1; - end = cookie.indexOf (';', start); + end = cookie.indexOf(';', start); if (end > 0) - return cookie.substring (start, end); + return cookie.substring(start, end); else - return cookie.substring (start); + return cookie.substring(start); } return null; } - ,getInt: function (key) - { - var value = this.get (key); + ,getInt: function(key) { + var value = this.get(key); if (value != null) - return parseInt (value); + return parseInt(value); return null; } - ,getFloat: function (key) - { - var value = this.get (key); + ,getFloat: function(key) { + var value = this.get(key); if (value != null) - return parseFloat (value); + return parseFloat(value); return null; } - ,check: function (key) - { - return this.get (key) != null; + ,check: function(key) { + return this.get(key) != null; } }; diff --git a/js/vn/date.js b/js/vn/date.js index 470315fb..594a07dc 100644 --- a/js/vn/date.js +++ b/js/vn/date.js @@ -6,6 +6,22 @@ Date.prototype.clone = function() { return new Date(this.getTime()); } +Date.vnUTC = () => { + const env = process.env.NODE_ENV; + if (!env || env === 'development') + return new Date(Date.UTC(2001, 0, 1, 11)); + + return new Date(); +}; + +Date.vnNew = () => { + return new Date(Date.vnUTC()); +}; + +Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); +}; + module.exports = { WDays: [ diff --git a/package.json b/package.json index 06a8834c..1a31fab3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hedera-web", - "version": "23.40.2", + "version": "23.40.3", "description": "Verdnatura web page", "license": "GPL-3.0", "repository": { diff --git a/rest/edi/lib/segment.php b/rest/edi/lib/segment.php index 6e6f52b3..e25bd007 100644 --- a/rest/edi/lib/segment.php +++ b/rest/edi/lib/segment.php @@ -18,7 +18,7 @@ class Segment { switch ($type) { case Type::DATE: - $tmp = new Date(); + $tmp = Date.vnNew(); $tmp->setDate(substr($v, 0, 4), substr($v, 4, 2), substr($v, 6, 2)); return $tmp; case Type::TIME: