mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: closes #12123, allow setting hh:mm for pin expiry
use locale for pin expiry and use short form
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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]]');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user