mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Sort topic timer and bookmark time options (#12270)
remove 3 month option for topic timer move relative time input inside the custom date and time shortcut make sure special options are always at the bottom
This commit is contained in:
@@ -78,13 +78,6 @@ export default Component.extend({
|
|||||||
time: startOfDay(now().add(2, "weeks")),
|
time: startOfDay(now().add(2, "weeks")),
|
||||||
timeFormatKey: "dates.long_no_year",
|
timeFormatKey: "dates.long_no_year",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: "far-calendar-plus",
|
|
||||||
id: "three_months",
|
|
||||||
label: "topic.auto_update_input.three_months",
|
|
||||||
time: startOfDay(now().add(3, "months")),
|
|
||||||
timeFormatKey: "dates.long_no_year",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
icon: "far-calendar-plus",
|
icon: "far-calendar-plus",
|
||||||
id: "six_months",
|
id: "six_months",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
TIME_SHORTCUT_TYPES,
|
TIME_SHORTCUT_TYPES,
|
||||||
defaultShortcutOptions,
|
defaultShortcutOptions,
|
||||||
|
specialShortcutOptions,
|
||||||
} from "discourse/lib/time-shortcut";
|
} from "discourse/lib/time-shortcut";
|
||||||
import discourseComputed, {
|
import discourseComputed, {
|
||||||
observes,
|
observes,
|
||||||
@@ -197,16 +198,30 @@ export default Component.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hiddenOptions.length > 0) {
|
customOptions.forEach((opt) => {
|
||||||
options.forEach((opt) => {
|
if (!opt.timeFormatted && opt.time) {
|
||||||
if (hiddenOptions.includes(opt.id)) {
|
opt.timeFormatted = opt.time.format(I18n.t(opt.timeFormatKey));
|
||||||
opt.hidden = true;
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
options = options.concat(customOptions);
|
||||||
|
options.sort((a, b) => {
|
||||||
|
if (a.time < b.time) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.time > b.time) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
let specialOptions = specialShortcutOptions();
|
||||||
|
|
||||||
if (this.lastCustomDate && this.lastCustomTime) {
|
if (this.lastCustomDate && this.lastCustomTime) {
|
||||||
let lastCustom = options.findBy("id", TIME_SHORTCUT_TYPES.LAST_CUSTOM);
|
let lastCustom = specialOptions.findBy(
|
||||||
|
"id",
|
||||||
|
TIME_SHORTCUT_TYPES.LAST_CUSTOM
|
||||||
|
);
|
||||||
lastCustom.time = this.parsedLastCustomDatetime;
|
lastCustom.time = this.parsedLastCustomDatetime;
|
||||||
lastCustom.timeFormatted = this.parsedLastCustomDatetime.format(
|
lastCustom.timeFormatted = this.parsedLastCustomDatetime.format(
|
||||||
I18n.t("dates.long_no_year")
|
I18n.t("dates.long_no_year")
|
||||||
@@ -214,17 +229,15 @@ export default Component.extend({
|
|||||||
lastCustom.hidden = false;
|
lastCustom.hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
customOptions.forEach((opt) => {
|
options = options.concat(specialOptions);
|
||||||
if (!opt.timeFormatted && opt.time) {
|
|
||||||
opt.timeFormatted = opt.time.format(I18n.t(opt.timeFormatKey));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let relativeOptionIndex = options.findIndex(
|
if (hiddenOptions.length > 0) {
|
||||||
(opt) => opt.id === TIME_SHORTCUT_TYPES.RELATIVE
|
options.forEach((opt) => {
|
||||||
);
|
if (hiddenOptions.includes(opt.id)) {
|
||||||
|
opt.hidden = true;
|
||||||
options.splice(relativeOptionIndex, 0, ...customOptions);
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -77,13 +77,18 @@ export function defaultShortcutOptions(timezone) {
|
|||||||
time: nextMonth(timezone),
|
time: nextMonth(timezone),
|
||||||
timeFormatted: nextMonth(timezone).format(I18n.t("dates.long_no_year")),
|
timeFormatted: nextMonth(timezone).format(I18n.t("dates.long_no_year")),
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function specialShortcutOptions() {
|
||||||
|
return [
|
||||||
{
|
{
|
||||||
icon: "far-clock",
|
icon: "undo",
|
||||||
id: TIME_SHORTCUT_TYPES.RELATIVE,
|
id: TIME_SHORTCUT_TYPES.LAST_CUSTOM,
|
||||||
label: "time_shortcut.relative",
|
label: "time_shortcut.last_custom",
|
||||||
time: null,
|
time: null,
|
||||||
timeFormatted: null,
|
timeFormatted: null,
|
||||||
isRelativeTimeShortcut: true,
|
hidden: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: "calendar-alt",
|
icon: "calendar-alt",
|
||||||
@@ -93,14 +98,6 @@ export function defaultShortcutOptions(timezone) {
|
|||||||
timeFormatted: null,
|
timeFormatted: null,
|
||||||
isCustomTimeShortcut: true,
|
isCustomTimeShortcut: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
icon: "undo",
|
|
||||||
id: TIME_SHORTCUT_TYPES.LAST_CUSTOM,
|
|
||||||
label: "time_shortcut.last_custom",
|
|
||||||
time: null,
|
|
||||||
timeFormatted: null,
|
|
||||||
hidden: true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
icon: "ban",
|
icon: "ban",
|
||||||
id: TIME_SHORTCUT_TYPES.NONE,
|
id: TIME_SHORTCUT_TYPES.NONE,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
{{#if option.isCustomTimeShortcut}}
|
{{#if option.isCustomTimeShortcut}}
|
||||||
{{#if customDatetimeSelected}}
|
{{#if customDatetimeSelected}}
|
||||||
<div class="control-group custom-date-time-wrap">
|
<div class="control-group custom-date-time-wrap custom-input-wrap">
|
||||||
<div class="tap-tile-date-input">
|
<div class="tap-tile-date-input">
|
||||||
{{d-icon "calendar-alt"}}
|
{{d-icon "calendar-alt"}}
|
||||||
{{date-picker-future
|
{{date-picker-future
|
||||||
@@ -23,12 +23,8 @@
|
|||||||
{{input placeholder="--:--" id="custom-time" type="time" class="time-input" value=customTime}}
|
{{input placeholder="--:--" id="custom-time" type="time" class="time-input" value=customTime}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
<div class="control-group custom-date-time-wrap custom-relative-wrap">
|
||||||
{{/if}}
|
<label class="control-label">{{i18n "relative_time_picker.relative"}}</label>
|
||||||
|
|
||||||
{{#if option.isRelativeTimeShortcut}}
|
|
||||||
{{#if relativeTimeSelected}}
|
|
||||||
<div class="control-group custom-date-time-wrap">
|
|
||||||
{{relative-time-picker onChange=(action "relativeTimeChanged")}}
|
{{relative-time-picker onChange=(action "relativeTimeChanged")}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -34,4 +34,18 @@
|
|||||||
.date-picker-wrapper {
|
.date-picker-wrapper {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.custom-input-wrap {
|
||||||
|
border-bottom: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.custom-relative-wrap {
|
||||||
|
.relative-time-picker {
|
||||||
|
display: flex;
|
||||||
|
.select-kit.combo-box {
|
||||||
|
width: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -591,6 +591,7 @@ en:
|
|||||||
years:
|
years:
|
||||||
one: "year"
|
one: "year"
|
||||||
other: "years"
|
other: "years"
|
||||||
|
relative: "Relative"
|
||||||
|
|
||||||
time_shortcut:
|
time_shortcut:
|
||||||
later_today: "Later today"
|
later_today: "Later today"
|
||||||
@@ -2460,13 +2461,13 @@ en:
|
|||||||
later_this_week: "Later this week"
|
later_this_week: "Later this week"
|
||||||
this_weekend: "This weekend"
|
this_weekend: "This weekend"
|
||||||
next_week: "Next week"
|
next_week: "Next week"
|
||||||
two_weeks: "Two Weeks"
|
two_weeks: "Two weeks"
|
||||||
next_month: "Next month"
|
next_month: "Next month"
|
||||||
two_months: "Two Months"
|
two_months: "Two months"
|
||||||
three_months: "Three Months"
|
three_months: "Three months"
|
||||||
four_months: "Four Months"
|
four_months: "Four months"
|
||||||
six_months: "Six Months"
|
six_months: "Six months"
|
||||||
one_year: "One Year"
|
one_year: "One year"
|
||||||
forever: "Forever"
|
forever: "Forever"
|
||||||
pick_date_and_time: "Pick date and time"
|
pick_date_and_time: "Pick date and time"
|
||||||
set_based_on_last_post: "Close based on last post"
|
set_based_on_last_post: "Close based on last post"
|
||||||
|
|||||||
Reference in New Issue
Block a user