mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-05 20:51:33 +08:00
feat(time_selector): use time_selector in attachment_erasure_timeout
This commit is contained in:
parent
e0e530b219
commit
f672054441
@ -2,33 +2,37 @@ import OptionsWidget from "../options_widget.js";
|
||||
import server from "../../../../services/server.js";
|
||||
import toastService from "../../../../services/toast.js";
|
||||
import { t } from "../../../../services/i18n.js";
|
||||
import type { OptionMap } from "../../../../../../services/options_interface.js";
|
||||
import TimeSelector from "../time_selector.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="options-section">
|
||||
<h4>${t("attachment_erasure_timeout.attachment_erasure_timeout")}</h4>
|
||||
|
||||
<p>${t("attachment_erasure_timeout.attachment_auto_deletion_description")}</p>
|
||||
`;
|
||||
|
||||
<div class="form-group">
|
||||
<label>${t("attachment_erasure_timeout.erase_attachments_after_x_seconds")}</label>
|
||||
<input class="erase-unused-attachments-after-time-in-seconds form-control options-number-input" type="number" min="0">
|
||||
</div>
|
||||
|
||||
const TPL2 = `
|
||||
<p>${t("attachment_erasure_timeout.manual_erasing_description")}</p>
|
||||
|
||||
<button class="erase-unused-attachments-now-button btn btn-secondary">${t("attachment_erasure_timeout.erase_unused_attachments_now")}</button>
|
||||
</div>`;
|
||||
|
||||
export default class AttachmentErasureTimeoutOptions extends OptionsWidget {
|
||||
export default class AttachmentErasureTimeoutOptions extends TimeSelector {
|
||||
|
||||
private $eraseUnusedAttachmentsAfterTimeInSeconds!: JQuery<HTMLElement>;
|
||||
private $eraseUnusedAttachmentsNowButton!: JQuery<HTMLElement>;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
widgetId: "erase-unused-attachments-after",
|
||||
widgetLabelId: "attachment_erasure_timeout.erase_attachments_after_x_seconds",
|
||||
optionValueId: "eraseUnusedAttachmentsAfterSeconds",
|
||||
optionTimeScaleId: "eraseUnusedAttachmentsAfterTimeScale"
|
||||
})
|
||||
super.doRender()
|
||||
}
|
||||
|
||||
doRender() {
|
||||
this.$widget = $(TPL);
|
||||
this.$eraseUnusedAttachmentsAfterTimeInSeconds = this.$widget.find(".erase-unused-attachments-after-time-in-seconds");
|
||||
this.$eraseUnusedAttachmentsAfterTimeInSeconds.on("change", () => this.updateOption("eraseUnusedAttachmentsAfterSeconds", this.$eraseUnusedAttachmentsAfterTimeInSeconds.val()));
|
||||
this.$widget = $(TPL).append(this.$widget).append(TPL2);
|
||||
|
||||
this.$eraseUnusedAttachmentsNowButton = this.$widget.find(".erase-unused-attachments-now-button");
|
||||
this.$eraseUnusedAttachmentsNowButton.on("click", () => {
|
||||
@ -38,7 +42,4 @@ export default class AttachmentErasureTimeoutOptions extends OptionsWidget {
|
||||
});
|
||||
}
|
||||
|
||||
async optionsLoaded(options: OptionMap) {
|
||||
this.$eraseUnusedAttachmentsAfterTimeInSeconds.val(options.eraseUnusedAttachmentsAfterSeconds);
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ const ALLOWED_OPTIONS = new Set([
|
||||
"checkForUpdates",
|
||||
"disableTray",
|
||||
"eraseUnusedAttachmentsAfterSeconds",
|
||||
"eraseUnusedAttachmentsAfterTimeScale",
|
||||
"disableTray",
|
||||
"customSearchEngineName",
|
||||
"customSearchEngineUrl",
|
||||
|
@ -122,7 +122,8 @@ const defaultOptions: DefaultOption[] = [
|
||||
{ name: "highlightsList", value: '["bold","italic","underline","color","bgColor"]', isSynced: true },
|
||||
{ name: "checkForUpdates", value: "true", isSynced: true },
|
||||
{ name: "disableTray", value: "false", isSynced: false },
|
||||
{ name: "eraseUnusedAttachmentsAfterSeconds", value: "2592000", isSynced: true },
|
||||
{ name: "eraseUnusedAttachmentsAfterSeconds", value: "2592000", isSynced: true }, // default 30 days
|
||||
{ name: "eraseUnusedAttachmentsAfterTimeScale", value: "86400", isSynced: true }, // default 86400 seconds = Day
|
||||
{ name: "customSearchEngineName", value: "DuckDuckGo", isSynced: true },
|
||||
{ name: "customSearchEngineUrl", value: "https://duckduckgo.com/?q={keyword}", isSynced: true },
|
||||
{ name: "promotedAttributesOpenInRibbon", value: "true", isSynced: true },
|
||||
|
@ -67,6 +67,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
|
||||
maxContentWidth: number;
|
||||
minTocHeadings: number;
|
||||
eraseUnusedAttachmentsAfterSeconds: number;
|
||||
eraseUnusedAttachmentsAfterTimeScale: number;
|
||||
firstDayOfWeek: number;
|
||||
|
||||
initialized: boolean;
|
||||
|
Loading…
x
Reference in New Issue
Block a user