import Page from './Page'; import FieldSet from '../../common/components/FieldSet'; import Button from '../../common/components/Button'; import Alert from '../../common/components/Alert'; import Select from '../../common/components/Select'; import LoadingIndicator from '../../common/components/LoadingIndicator'; import saveSettings from '../utils/saveSettings'; export default class MailPage extends Page { init() { super.init(); this.loading = true; this.saving = false; this.driverFields = {}; this.fields = ['mail_driver', 'mail_from']; this.values = {}; const settings = app.data.settings; this.fields.forEach(key => this.values[key] = m.prop(settings[key])); app.request({ method: 'GET', url: app.forum.attribute('apiUrl') + '/mail-drivers' }).then(response => { this.driverFields = response['data'].reduce( (hash, driver) => ({...hash, [driver['id']]: driver['attributes']['fields']}), {} ); Object.keys(this.driverFields).flatMap(key => this.driverFields[key]).forEach( key => { this.fields.push(key); this.values[key] = m.prop(settings[key]); } ); this.loading = false; m.redraw(); }); } view() { if (this.loading) { return (