Merge pull request #2866 from jryans/member-info-power

Include the current power level in the selector
This commit is contained in:
J. Ryan Stinnett 2019-04-04 11:38:42 +01:00 committed by GitHub
commit cf69692d9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,8 +73,12 @@ module.exports = React.createClass({
_initStateFromProps: function(newProps) { _initStateFromProps: function(newProps) {
// This needs to be done now because levelRoleMap has translated strings // This needs to be done now because levelRoleMap has translated strings
const levelRoleMap = Roles.levelRoleMap(newProps.usersDefault); const levelRoleMap = Roles.levelRoleMap(newProps.usersDefault);
const options = Object.keys(levelRoleMap).filter((l) => { const options = Object.keys(levelRoleMap).filter(level => {
return l === undefined || l <= newProps.maxValue; return (
level === undefined ||
level <= newProps.maxValue ||
level == newProps.value
);
}); });
const isCustom = levelRoleMap[newProps.value] === undefined; const isCustom = levelRoleMap[newProps.value] === undefined;
@ -130,7 +134,7 @@ module.exports = React.createClass({
<Field id={`powerSelector_custom_${this.props.powerLevelKey}`} type="number" <Field id={`powerSelector_custom_${this.props.powerLevelKey}`} type="number"
label={this.props.label || _t("Power level")} max={this.props.maxValue} label={this.props.label || _t("Power level")} max={this.props.maxValue}
onBlur={this.onCustomBlur} onKeyPress={this.onCustomKeyPress} onChange={this.onCustomChange} onBlur={this.onCustomBlur} onKeyPress={this.onCustomKeyPress} onChange={this.onCustomChange}
value={this.state.customValue} disabled={this.props.disabled} /> value={String(this.state.customValue)} disabled={this.props.disabled} />
); );
} else { } else {
// Each level must have a definition in this.state.levelRoleMap // Each level must have a definition in this.state.levelRoleMap
@ -148,7 +152,7 @@ module.exports = React.createClass({
picker = ( picker = (
<Field id={`powerSelector_notCustom_${this.props.powerLevelKey}`} element="select" <Field id={`powerSelector_notCustom_${this.props.powerLevelKey}`} element="select"
label={this.props.label || _t("Power level")} onChange={this.onSelectChange} label={this.props.label || _t("Power level")} onChange={this.onSelectChange}
value={this.state.selectValue} disabled={this.props.disabled}> value={String(this.state.selectValue)} disabled={this.props.disabled}>
{options} {options}
</Field> </Field>
); );