mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 14:15:15 +00:00
37 lines
870 B
JavaScript
37 lines
870 B
JavaScript
import React from 'react';
|
|
|
|
const METHODS_TO_BIND = ['handleClientSettingFieldChange'];
|
|
|
|
export default class SettingsTab extends React.Component {
|
|
constructor() {
|
|
super();
|
|
|
|
METHODS_TO_BIND.forEach((method) => {
|
|
this[method] = this[method].bind(this);
|
|
});
|
|
}
|
|
|
|
getFieldValue(fieldName) {
|
|
if (this.state[fieldName] == null) {
|
|
return this.props.settings[fieldName] || '';
|
|
}
|
|
|
|
return this.state[fieldName];
|
|
}
|
|
|
|
handleClientSettingFieldChange(fieldName, event) {
|
|
let newState = {[fieldName]: event.target.value};
|
|
|
|
this.setState(newState);
|
|
this.props.onClientSettingsChange(newState);
|
|
}
|
|
|
|
handleClientSettingCheckboxChange(fieldName, value) {
|
|
let checkedValue = value ? '1' : '0';
|
|
let newState = {[fieldName]: checkedValue};
|
|
|
|
this.setState(newState);
|
|
this.props.onClientSettingsChange(newState);
|
|
}
|
|
}
|