mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 09:45:52 +01:00
refactored access to options on frontend
This commit is contained in:
@@ -3,6 +3,7 @@ import utils from "../../services/utils.js";
|
||||
import cssLoader from "../../services/css_loader.js";
|
||||
import zoomService from "../../services/zoom.js";
|
||||
import optionsService from "../../services/options.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
|
||||
const TPL = `
|
||||
<p><strong>Settings on this options tab are saved automatically after each change.</strong></p>
|
||||
@@ -107,7 +108,7 @@ export default class ApperanceOptions {
|
||||
server.put('options/theme/' + newTheme);
|
||||
});
|
||||
|
||||
this.$zoomFactorSelect.on('change', () => { zoomService.setZoomFactorAndSave(this.$zoomFactorSelect.val()); });
|
||||
this.$zoomFactorSelect.on('change', () => { appContext.trigger('setZoomFactorAndSave', {zoomFactor: this.$zoomFactorSelect.val()}); });
|
||||
|
||||
this.$nativeTitleBarSelect.on('change', () => {
|
||||
const nativeTitleBarVisible = this.$nativeTitleBarSelect.val() === 'show' ? 'true' : 'false';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import server from "../../services/server.js";
|
||||
import mimeTypesService from "../../services/mime_types.js";
|
||||
import optionsService from "../../services/options.js";
|
||||
import options from "../../services/options.js";
|
||||
|
||||
const TPL = `
|
||||
<h4>Available MIME types in the dropdown</h4>
|
||||
@@ -14,7 +13,7 @@ export default class CodeNotesOptions {
|
||||
this.$mimeTypes = $("#options-mime-types");
|
||||
}
|
||||
|
||||
async optionsLoaded(options) {
|
||||
async optionsLoaded() {
|
||||
this.$mimeTypes.empty();
|
||||
|
||||
let idCtr = 1;
|
||||
@@ -42,10 +41,8 @@ export default class CodeNotesOptions {
|
||||
this.$mimeTypes.find("input:checked").each(
|
||||
(i, el) => enabledMimeTypes.push($(el).attr("data-mime-type")));
|
||||
|
||||
const opts = { codeNotesMimeTypes: JSON.stringify(enabledMimeTypes) };
|
||||
await options.save('codeNotesMimeTypes', JSON.stringify(enabledMimeTypes));
|
||||
|
||||
await server.put('options', opts);
|
||||
|
||||
await optionsService.reloadOptions();
|
||||
mimeTypesService.loadMimeTypes();
|
||||
}
|
||||
}
|
||||
@@ -101,8 +101,6 @@ export default class ProtectedSessionOptions {
|
||||
const eraseNotesAfterTimeInSeconds = this.$eraseNotesAfterTimeInSeconds.val();
|
||||
|
||||
server.put('options', { 'eraseNotesAfterTimeInSeconds': eraseNotesAfterTimeInSeconds }).then(() => {
|
||||
optionsService.reloadOptions();
|
||||
|
||||
toastService.showMessage("Options change have been saved.");
|
||||
});
|
||||
|
||||
@@ -115,8 +113,6 @@ export default class ProtectedSessionOptions {
|
||||
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
|
||||
|
||||
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
||||
optionsService.reloadOptions();
|
||||
|
||||
toastService.showMessage("Options change have been saved.");
|
||||
});
|
||||
|
||||
|
||||
@@ -104,8 +104,6 @@ export default class SidebarOptions {
|
||||
});
|
||||
|
||||
await server.put('options', opts);
|
||||
|
||||
optionsService.reloadOptions();
|
||||
}
|
||||
|
||||
parseJsonSafely(str) {
|
||||
|
||||
Reference in New Issue
Block a user