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