From 668a355afe163c64aff61351ad7995187ff341b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 25 Oct 2023 19:06:29 -0400 Subject: [PATCH 1/2] fix: closes #12126, fix language keys --- src/controllers/admin/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/admin/settings.js b/src/controllers/admin/settings.js index 9ecf08548d..61ccd6a091 100644 --- a/src/controllers/admin/settings.js +++ b/src/controllers/admin/settings.js @@ -49,7 +49,7 @@ settingsController.user = async (req, res) => { const notificationTypes = await notifications.getAllNotificationTypes(); const notificationSettings = notificationTypes.map(type => ({ name: type, - label: `[[notifications:${type}]]`, + label: `[[notifications:${type.replace(/_/g, '-')}]]`, })); res.render('admin/settings/user', { title: '[[admin/menu:settings/user]]', From 1f8007476cb360885fe21834925ca666b646a789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 Oct 2023 11:14:58 -0400 Subject: [PATCH 2/2] feat: closes #12123, allow setting hh:mm for pin expiry use locale for pin expiry and use short form --- install/package.json | 2 +- public/src/client/topic/threadTools.js | 21 ++++++++++----------- public/src/modules/helpers.common.js | 7 +++++-- src/views/modals/set-pin-expiry.tpl | 5 ++++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/install/package.json b/install/package.json index bb3014c057..f6d8338d96 100644 --- a/install/package.json +++ b/install/package.json @@ -102,7 +102,7 @@ "nodebb-plugin-ntfy": "1.7.3", "nodebb-plugin-spam-be-gone": "2.2.0", "nodebb-rewards-essentials": "1.0.0", - "nodebb-theme-harmony": "1.1.90", + "nodebb-theme-harmony": "1.1.91", "nodebb-theme-lavender": "7.1.5", "nodebb-theme-peace": "2.1.23", "nodebb-theme-persona": "13.2.42", diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index 715af804d2..60dfd8b766 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -257,7 +257,6 @@ define('forum/topic/threadTools', [ title: '[[topic:thread-tools.pin]]', message: html, onEscape: true, - size: 'small', buttons: { cancel: { label: '[[modules:bootbox.cancel]]', @@ -267,19 +266,19 @@ define('forum/topic/threadTools', [ label: '[[global:save]]', className: 'btn-primary', callback: function () { - const expiryEl = modal.get(0).querySelector('#expiry'); - let expiry = expiryEl.value; - + const expiryDateEl = modal.get(0).querySelector('#expiry-date'); + const expiryTimeEl = modal.get(0).querySelector('#expiry-time'); + let expiryDate = expiryDateEl.value; + let expiryTime = expiryTimeEl.value; // No expiry set - if (expiry === '') { + if (expiryDate === '' && expiryTime === '') { return onSuccess(); } - - // Expiration date set - expiry = new Date(expiry); - - if (expiry && expiry.getTime() > Date.now()) { - body.expiry = expiry.getTime(); + expiryDate = expiryDate || new Date().toDateString(); + expiryTime = expiryTime || new Date().toTimeString(); + const date = new Date(`${expiryDate} ${expiryTime}`); + if (date.getTime() > Date.now()) { + body.expiry = date.getTime(); onSuccess(); } else { alerts.error('[[error:invalid-date]]'); diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.js index 07ab724963..ab61734efa 100644 --- a/public/src/modules/helpers.common.js +++ b/public/src/modules/helpers.common.js @@ -343,8 +343,11 @@ module.exports = function (utils, Benchpress, relative_path) { return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`; } - function isoTimeToLocaleString(isoTime) { - return new Date(isoTime).toLocaleString().replace(/,/g, ','); + function isoTimeToLocaleString(isoTime, locale = 'en-GB') { + return new Date(isoTime).toLocaleString([locale], { + dateStyle: 'short', + timeStyle: 'short', + }).replace(/,/g, ','); } function shouldHideReplyContainer(post) { diff --git a/src/views/modals/set-pin-expiry.tpl b/src/views/modals/set-pin-expiry.tpl index 523723011e..75fb877cd2 100644 --- a/src/views/modals/set-pin-expiry.tpl +++ b/src/views/modals/set-pin-expiry.tpl @@ -1,5 +1,8 @@
- +
+ + +

[[topic:pin-modal-help]]

\ No newline at end of file