mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-24 08:20:31 +08:00
Refactor out Setting.getArrayItem()
This commit is contained in:
parent
3923574d57
commit
1bfddc5d53
@ -73,7 +73,7 @@ class ProviderTable extends React.Component {
|
||||
value={text}
|
||||
onChange={value => {
|
||||
this.updateField(table, index, 'name', value);
|
||||
const provider = this.props.providers.filter(provider => provider.name === value)[0];
|
||||
const provider = Setting.getArrayItem(this.props.providers, "name", value);
|
||||
this.updateField(table, index, 'provider', provider);
|
||||
}} >
|
||||
{
|
||||
|
@ -448,3 +448,8 @@ export function maskEmail(email) {
|
||||
|
||||
return `${username}@${domainTokens.join(".")}`;
|
||||
}
|
||||
|
||||
export function getArrayItem(array, key, value) {
|
||||
const res = array.filter(item => item[key] === value)[0];
|
||||
return res;
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ class AffiliationSelect extends React.Component {
|
||||
) : (
|
||||
<Select virtual={false} style={{width: '100%'}} value={this.props.user.affiliation} onChange={(value => {
|
||||
const name = value;
|
||||
const id = this.state.affiliationOptions.filter(affiliationOption => affiliationOption.name === name)[0].id;
|
||||
const affiliationOption = Setting.getArrayItem(this.state.affiliationOptions, "name", name);
|
||||
const id = affiliationOption.id;
|
||||
this.updateUserField('affiliation', name);
|
||||
this.updateUserField('score', id);
|
||||
})}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user