mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-22 06:13:50 +08:00
fix: add country/region selectbox in prompt page (#1022)
This commit is contained in:
@ -208,10 +208,18 @@ export function isProviderPrompted(providerItem) {
|
|||||||
return isProviderVisible(providerItem) && providerItem.prompted;
|
return isProviderVisible(providerItem) && providerItem.prompted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isSignupItemPrompted(signupItem) {
|
||||||
|
return signupItem.visible && signupItem.prompted;
|
||||||
|
}
|
||||||
|
|
||||||
export function getAllPromptedProviderItems(application) {
|
export function getAllPromptedProviderItems(application) {
|
||||||
return application.providers.filter(providerItem => isProviderPrompted(providerItem));
|
return application.providers.filter(providerItem => isProviderPrompted(providerItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getAllPromptedSignupItems(application) {
|
||||||
|
return application.signupItems.filter(signupItem => isSignupItemPrompted(signupItem));
|
||||||
|
}
|
||||||
|
|
||||||
export function getSignupItem(application, itemName) {
|
export function getSignupItem(application, itemName) {
|
||||||
const signupItems = application.signupItems?.filter(signupItem => signupItem.name === itemName);
|
const signupItems = application.signupItems?.filter(signupItem => signupItem.name === itemName);
|
||||||
if (signupItems.length === 0) {
|
if (signupItems.length === 0) {
|
||||||
@ -283,6 +291,11 @@ export function hasPromptPage(application) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const signupItems = getAllPromptedSignupItems(application);
|
||||||
|
if (signupItems.length !== 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return isAffiliationPrompted(application);
|
return isAffiliationPrompted(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ class SignupTable extends React.Component {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record.visible) {
|
if (record.visible && record.name !== "Country/Region") {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import * as Setting from "../Setting";
|
|||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import AffiliationSelect from "../common/AffiliationSelect";
|
import AffiliationSelect from "../common/AffiliationSelect";
|
||||||
import OAuthWidget from "../common/OAuthWidget";
|
import OAuthWidget from "../common/OAuthWidget";
|
||||||
|
import SelectRegionBox from "../SelectRegionBox";
|
||||||
|
|
||||||
class PromptPage extends React.Component {
|
class PromptPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -90,6 +91,16 @@ class PromptPage extends React.Component {
|
|||||||
this.submitUserEdit(false);
|
this.submitUserEdit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateUserFieldWithoutSubmit(key, value) {
|
||||||
|
value = this.parseUserField(key, value);
|
||||||
|
|
||||||
|
const user = this.state.user;
|
||||||
|
user[key] = value;
|
||||||
|
this.setState({
|
||||||
|
user: user,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
renderAffiliation(application) {
|
renderAffiliation(application) {
|
||||||
if (!Setting.isAffiliationPrompted(application)) {
|
if (!Setting.isAffiliationPrompted(application)) {
|
||||||
return null;
|
return null;
|
||||||
@ -120,6 +131,31 @@ class PromptPage extends React.Component {
|
|||||||
application?.providers.filter(providerItem => Setting.isProviderPrompted(providerItem)).map((providerItem, index) => <OAuthWidget key={providerItem.name} labelSpan={6} user={this.state.user} application={application} providerItem={providerItem} account={this.props.account} onUnlinked={() => {return this.unlinked();}} />)
|
application?.providers.filter(providerItem => Setting.isProviderPrompted(providerItem)).map((providerItem, index) => <OAuthWidget key={providerItem.name} labelSpan={6} user={this.state.user} application={application} providerItem={providerItem} account={this.props.account} onUnlinked={() => {return this.unlinked();}} />)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
(application === null || this.state.user === null) ? null : (
|
||||||
|
application?.signupItems.filter(signupItem => Setting.isSignupItemPrompted(signupItem)).map((signupItem, index) => {
|
||||||
|
if (signupItem.name !== "Country/Region") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Row key={signupItem.name} style={{marginTop: "20px", justifyContent: "space-between"}} >
|
||||||
|
<Col style={{marginTop: "5px"}} >
|
||||||
|
<span style={{marginLeft: "5px"}}>
|
||||||
|
{
|
||||||
|
i18next.t("user:Country/Region")
|
||||||
|
}:
|
||||||
|
</span>
|
||||||
|
</Col>
|
||||||
|
<Col >
|
||||||
|
<SelectRegionBox defaultValue={this.state.user.region} onChange={(value) => {
|
||||||
|
this.updateUserFieldWithoutSubmit("region", value);
|
||||||
|
}} />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -151,7 +187,7 @@ class PromptPage extends React.Component {
|
|||||||
if (redirectUrl === "") {
|
if (redirectUrl === "") {
|
||||||
redirectUrl = res.data2;
|
redirectUrl = res.data2;
|
||||||
}
|
}
|
||||||
if (redirectUrl !== "") {
|
if (redirectUrl !== "" && redirectUrl !== null) {
|
||||||
Setting.goToLink(redirectUrl);
|
Setting.goToLink(redirectUrl);
|
||||||
} else {
|
} else {
|
||||||
Setting.goToLogin(this, this.getApplicationObj());
|
Setting.goToLogin(this, this.getApplicationObj());
|
||||||
|
Reference in New Issue
Block a user