mirror of
https://github.com/zoriya/flood.git
synced 2025-12-20 06:05:15 +00:00
Introduce client settings
This commit is contained in:
36
client/source/scripts/components/settings/SettingsTab.js
Normal file
36
client/source/scripts/components/settings/SettingsTab.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user