added options to disable auto-opening of promoted attributes and edited notes ribbon tabs, closes #4151

This commit is contained in:
zadam 2023-08-09 22:50:41 +02:00
parent 4240da349d
commit a9cdd93cb4
6 changed files with 49 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import linkService from "../../services/link.js";
import server from "../../services/server.js"; import server from "../../services/server.js";
import froca from "../../services/froca.js"; import froca from "../../services/froca.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js"; import NoteContextAwareWidget from "../note_context_aware_widget.js";
import options from "../../services/options.js";
const TPL = ` const TPL = `
<div class="edited-notes-widget"> <div class="edited-notes-widget">
@ -34,7 +35,9 @@ export default class EditedNotesWidget extends NoteContextAwareWidget {
return { return {
show: this.isEnabled(), show: this.isEnabled(),
// promoted attributes have priority over edited notes // promoted attributes have priority over edited notes
activate: this.note.getPromotedDefinitionAttributes().length === 0, activate:
(this.note.getPromotedDefinitionAttributes().length === 0 || !options.is('promotedAttributesOpenInRibbon'))
&& options.is('editedNotesOpenInRibbon'),
title: 'Edited Notes', title: 'Edited Notes',
icon: 'bx bx-calendar-edit' icon: 'bx bx-calendar-edit'
}; };

View File

@ -4,6 +4,7 @@ import treeService from "../../services/tree.js";
import noteAutocompleteService from "../../services/note_autocomplete.js"; import noteAutocompleteService from "../../services/note_autocomplete.js";
import NoteContextAwareWidget from "../note_context_aware_widget.js"; import NoteContextAwareWidget from "../note_context_aware_widget.js";
import attributeService from "../../services/attributes.js"; import attributeService from "../../services/attributes.js";
import options from "../../services/options.js";
const TPL = ` const TPL = `
<div> <div>
@ -62,7 +63,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
return { return {
show: true, show: true,
activate: true, activate: options.is('promotedAttributesOpenInRibbon'),
title: "Promoted Attributes", title: "Promoted Attributes",
icon: "bx bx-table" icon: "bx bx-table"
}; };

View File

@ -31,6 +31,7 @@ import VacuumDatabaseOptions from "./options/advanced/vacuum_database.js";
import DatabaseAnonymizationOptions from "./options/advanced/database_anonymization.js"; import DatabaseAnonymizationOptions from "./options/advanced/database_anonymization.js";
import BackendLogWidget from "./content/backend_log.js"; import BackendLogWidget from "./content/backend_log.js";
import AttachmentErasureTimeoutOptions from "./options/other/attachment_erasure_timeout.js"; import AttachmentErasureTimeoutOptions from "./options/other/attachment_erasure_timeout.js";
import RibbonOptions from "./options/appearance/ribbon.js";
const TPL = `<div class="note-detail-content-widget note-detail-printable"> const TPL = `<div class="note-detail-content-widget note-detail-printable">
<style> <style>
@ -57,7 +58,8 @@ const CONTENT_WIDGETS = {
FontsOptions, FontsOptions,
ZoomFactorOptions, ZoomFactorOptions,
NativeTitleBarOptions, NativeTitleBarOptions,
MaxContentWidthOptions MaxContentWidthOptions,
RibbonOptions
], ],
_optionsShortcuts: [ KeyboardShortcutsOptions ], _optionsShortcuts: [ KeyboardShortcutsOptions ],
_optionsTextNotes: [ _optionsTextNotes: [

View File

@ -0,0 +1,34 @@
import OptionsWidget from "../options_widget.js";
const TPL = `
<div class="options-section">
<h4>Ribbon widgets</h4>
<label>
<input type="checkbox" class="promoted-attributes-open-in-ribbon">
Promoted Attributes ribbon tab will automatically open if promoted attributes are present on the note
</label>
<label>
<input type="checkbox" class="edited-notes-open-in-ribbon">
Edited Notes ribbon tab will automatically open on day notes
</label>
</div>`;
export default class RibbonOptions extends OptionsWidget {
doRender() {
this.$widget = $(TPL);
this.$promotedAttributesOpenInRibbon = this.$widget.find(".promoted-attributes-open-in-ribbon");
this.$promotedAttributesOpenInRibbon.on('change', () =>
this.updateCheckboxOption('promotedAttributesOpenInRibbon', this.$promotedAttributesOpenInRibbon));
this.$editedNotesOpenInRibbon = this.$widget.find(".edited-notes-open-in-ribbon");
this.$editedNotesOpenInRibbon.on('change', () =>
this.updateCheckboxOption('editedNotesOpenInRibbon', this.$editedNotesOpenInRibbon));
}
async optionsLoaded(options) {
this.setCheckboxState(this.$promotedAttributesOpenInRibbon, options.promotedAttributesOpenInRibbon);
this.setCheckboxState(this.$editedNotesOpenInRibbon, options.editedNotesOpenInRibbon);
}
}

View File

@ -55,7 +55,9 @@ const ALLOWED_OPTIONS = new Set([
'eraseUnusedAttachmentsAfterSeconds', 'eraseUnusedAttachmentsAfterSeconds',
'disableTray', 'disableTray',
'customSearchEngineName', 'customSearchEngineName',
'customSearchEngineUrl' 'customSearchEngineUrl',
'promotedAttributesOpenInRibbon',
'editedNotesOpenInRibbon'
]); ]);
function getOptions() { function getOptions() {

View File

@ -88,7 +88,9 @@ const defaultOptions = [
{ name: 'disableTray', value: 'false', isSynced: false }, { name: 'disableTray', value: 'false', isSynced: false },
{ name: 'eraseUnusedAttachmentsAfterSeconds', value: '2592000', isSynced: true }, { name: 'eraseUnusedAttachmentsAfterSeconds', value: '2592000', isSynced: true },
{ name: 'customSearchEngineName', value: 'DuckDuckGo', isSynced: true }, { name: 'customSearchEngineName', value: 'DuckDuckGo', isSynced: true },
{ name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true } { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: true },
{ name: 'promotedAttributesOpenInRibbon', value: 'true', isSynced: true },
{ name: 'editedNotesOpenInRibbon', value: 'true', isSynced: true }
]; ];
function initStartupOptions() { function initStartupOptions() {