mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FIX: Allow entering blank values in relative-time-picker (#12193)
In certain cases such as the category auto-close hours setting, it makes sense to blank out the relative time picker duration so `null` is sent to the server to clear the value. Meta example: https://meta.discourse.org/t/how-do-i-disable-topic-auto-close/180487
This commit is contained in:
@ -135,7 +135,7 @@ export default buildCategoryPanel("settings", {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
onAutoCloseDurationChange(minutes) {
|
onAutoCloseDurationChange(minutes) {
|
||||||
let hours = minutes / 60;
|
let hours = minutes ? minutes / 60 : null;
|
||||||
this.set("category.auto_close_hours", hours);
|
this.set("category.auto_close_hours", hours);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
||||||
|
import { isBlank } from "@ember/utils";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
@ -114,6 +114,9 @@ export default Component.extend({
|
|||||||
|
|
||||||
@discourseComputed("selectedInterval", "duration")
|
@discourseComputed("selectedInterval", "duration")
|
||||||
calculatedMinutes(interval, duration) {
|
calculatedMinutes(interval, duration) {
|
||||||
|
if (isBlank(duration)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
duration = parseFloat(duration);
|
duration = parseFloat(duration);
|
||||||
|
|
||||||
let mins = 0;
|
let mins = 0;
|
||||||
|
Reference in New Issue
Block a user