2020-06-06 00:03:37 +02:00
|
|
|
"use strict";
|
2016-04-11 22:38:59 +02:00
|
|
|
|
2020-06-06 00:03:37 +02:00
|
|
|
const settings = require("../models/settings.js");
|
|
|
|
const topNavigation = require("../models/top_navigation.js");
|
|
|
|
const SettingsView = require("../views/settings_view.js");
|
2016-04-11 22:38:59 +02:00
|
|
|
|
|
|
|
class SettingsController {
|
|
|
|
constructor() {
|
2020-06-06 00:03:37 +02:00
|
|
|
topNavigation.activate("settings");
|
|
|
|
topNavigation.setTitle("Browsing settings");
|
2016-06-14 10:31:48 +02:00
|
|
|
this._view = new SettingsView({
|
|
|
|
settings: settings.get(),
|
|
|
|
});
|
2020-06-06 00:03:37 +02:00
|
|
|
this._view.addEventListener("submit", (e) => this._evtSubmit(e));
|
2016-04-11 22:38:59 +02:00
|
|
|
}
|
|
|
|
|
2016-08-22 20:45:58 +02:00
|
|
|
_evtSubmit(e) {
|
2016-06-14 10:31:48 +02:00
|
|
|
this._view.clearMessages();
|
2016-08-05 20:09:11 +02:00
|
|
|
settings.save(e.detail);
|
2020-06-06 00:03:37 +02:00
|
|
|
this._view.showSuccess("Settings saved.");
|
2016-04-11 22:38:59 +02:00
|
|
|
}
|
2020-06-04 20:09:35 +02:00
|
|
|
}
|
2016-04-11 22:38:59 +02:00
|
|
|
|
2020-06-06 00:03:37 +02:00
|
|
|
module.exports = (router) => {
|
|
|
|
router.enter(["settings"], (ctx, next) => {
|
2016-06-14 10:31:48 +02:00
|
|
|
ctx.controller = new SettingsController();
|
|
|
|
});
|
|
|
|
};
|