mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 12:50:29 +08:00
Refactor out Setting.getArrayItem()
This commit is contained in:
@@ -73,7 +73,7 @@ class ProviderTable extends React.Component {
|
|||||||
value={text}
|
value={text}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
this.updateField(table, index, 'name', 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);
|
this.updateField(table, index, 'provider', provider);
|
||||||
}} >
|
}} >
|
||||||
{
|
{
|
||||||
|
@@ -448,3 +448,8 @@ export function maskEmail(email) {
|
|||||||
|
|
||||||
return `${username}@${domainTokens.join(".")}`;
|
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 => {
|
<Select virtual={false} style={{width: '100%'}} value={this.props.user.affiliation} onChange={(value => {
|
||||||
const name = 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('affiliation', name);
|
||||||
this.updateUserField('score', id);
|
this.updateUserField('score', id);
|
||||||
})}>
|
})}>
|
||||||
|
Reference in New Issue
Block a user