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:
Martin Brennan 2021-02-24 13:25:26 +10:00 committed by GitHub
parent 845987ce23
commit f2126acf5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -135,7 +135,7 @@ export default buildCategoryPanel("settings", {
@action
onAutoCloseDurationChange(minutes) {
let hours = minutes / 60;
let hours = minutes ? minutes / 60 : null;
this.set("category.auto_close_hours", hours);
},
});

View File

@ -1,5 +1,5 @@
import discourseComputed, { on } from "discourse-common/utils/decorators";
import { isBlank } from "@ember/utils";
import Component from "@ember/component";
import I18n from "I18n";
import { action } from "@ember/object";
@ -114,6 +114,9 @@ export default Component.extend({
@discourseComputed("selectedInterval", "duration")
calculatedMinutes(interval, duration) {
if (isBlank(duration)) {
return null;
}
duration = parseFloat(duration);
let mins = 0;