mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-16 22:13:50 +08:00
Refactor out Setting.getDeduplicatedArray()
This commit is contained in:
@ -77,7 +77,7 @@ class ProviderTable extends React.Component {
|
|||||||
this.updateField(table, index, 'provider', provider);
|
this.updateField(table, index, 'provider', provider);
|
||||||
}} >
|
}} >
|
||||||
{
|
{
|
||||||
this.props.providers.filter(provider => table.filter(providerItem => providerItem.name === provider.name).length === 0).map((provider, index) => <Option key={index} value={provider.name}>{provider.name}</Option>)
|
Setting.getDeduplicatedArray(this.props.providers, table, "name").map((provider, index) => <Option key={index} value={provider.name}>{provider.name}</Option>)
|
||||||
}
|
}
|
||||||
</Select>
|
</Select>
|
||||||
)
|
)
|
||||||
|
@ -453,3 +453,8 @@ export function getArrayItem(array, key, value) {
|
|||||||
const res = array.filter(item => item[key] === value)[0];
|
const res = array.filter(item => item[key] === value)[0];
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDeduplicatedArray(array, filterArray, key) {
|
||||||
|
const res = array.filter(item => filterArray.filter(filterItem => filterItem[key] === item[key]).length === 0);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
@ -68,6 +68,18 @@ class SignupTable extends React.Component {
|
|||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
|
const items = [
|
||||||
|
{id: 'Username', name: 'Username'},
|
||||||
|
{id: 'ID', name: 'ID'},
|
||||||
|
{id: 'Display name', name: 'Display name'},
|
||||||
|
{id: 'Affiliation', name: 'Affiliation'},
|
||||||
|
{id: 'Email', name: 'Email'},
|
||||||
|
{id: 'Password', name: 'Password'},
|
||||||
|
{id: 'Confirm password', name: 'Confirm password'},
|
||||||
|
{id: 'Phone', name: 'Phone'},
|
||||||
|
{id: 'Agreement', name: 'Agreement'},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select virtual={false} style={{width: '100%'}}
|
<Select virtual={false} style={{width: '100%'}}
|
||||||
value={text}
|
value={text}
|
||||||
@ -75,17 +87,7 @@ class SignupTable extends React.Component {
|
|||||||
this.updateField(table, index, 'name', value);
|
this.updateField(table, index, 'name', value);
|
||||||
}} >
|
}} >
|
||||||
{
|
{
|
||||||
[
|
Setting.getDeduplicatedArray(items, table, "name").map((item, index) => <Option key={index} value={item.name}>{item.name}</Option>)
|
||||||
{id: 'Username', name: 'Username'},
|
|
||||||
{id: 'ID', name: 'ID'},
|
|
||||||
{id: 'Display name', name: 'Display name'},
|
|
||||||
{id: 'Affiliation', name: 'Affiliation'},
|
|
||||||
{id: 'Email', name: 'Email'},
|
|
||||||
{id: 'Password', name: 'Password'},
|
|
||||||
{id: 'Confirm password', name: 'Confirm password'},
|
|
||||||
{id: 'Phone', name: 'Phone'},
|
|
||||||
{id: 'Agreement', name: 'Agreement'},
|
|
||||||
].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
|
|
||||||
}
|
}
|
||||||
</Select>
|
</Select>
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user