Skip to content

Node.js based forum software built for the modern web

feat: closes #12123, allow setting hh:mm for pin expiry

Barış Soner Uşaklı1f8007476cb3
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 @@
<div class="form-group">
<label class="form-label" for="expiry">[[topic:pin-modal-expiry]]</label>
- <input id="expiry" type="date" class="form-control" />
+ <div class="d-flex gap-1">
+ <input id="expiry-date" type="date" class="form-control" />
+ <input id="expiry-time" type="time" class="form-control" />
+ </div>
<p class="form-text">[[topic:pin-modal-help]]</p>
</div>
\ No newline at end of file