diff --git a/web/src/Setting.js b/web/src/Setting.js index 24a57984..3eb86e2a 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -208,10 +208,18 @@ export function isProviderPrompted(providerItem) { return isProviderVisible(providerItem) && providerItem.prompted; } +export function isSignupItemPrompted(signupItem) { + return signupItem.visible && signupItem.prompted; +} + export function getAllPromptedProviderItems(application) { return application.providers.filter(providerItem => isProviderPrompted(providerItem)); } +export function getAllPromptedSignupItems(application) { + return application.signupItems.filter(signupItem => isSignupItemPrompted(signupItem)); +} + export function getSignupItem(application, itemName) { const signupItems = application.signupItems?.filter(signupItem => signupItem.name === itemName); if (signupItems.length === 0) { @@ -283,6 +291,11 @@ export function hasPromptPage(application) { return true; } + const signupItems = getAllPromptedSignupItems(application); + if (signupItems.length !== 0) { + return true; + } + return isAffiliationPrompted(application); } diff --git a/web/src/SignupTable.js b/web/src/SignupTable.js index 170dd5a1..da577b30 100644 --- a/web/src/SignupTable.js +++ b/web/src/SignupTable.js @@ -152,7 +152,7 @@ class SignupTable extends React.Component { return null; } - if (record.visible) { + if (record.visible && record.name !== "Country/Region") { return null; } diff --git a/web/src/auth/PromptPage.js b/web/src/auth/PromptPage.js index cf9d0a90..df28c9c3 100644 --- a/web/src/auth/PromptPage.js +++ b/web/src/auth/PromptPage.js @@ -21,6 +21,7 @@ import * as Setting from "../Setting"; import i18next from "i18next"; import AffiliationSelect from "../common/AffiliationSelect"; import OAuthWidget from "../common/OAuthWidget"; +import SelectRegionBox from "../SelectRegionBox"; class PromptPage extends React.Component { constructor(props) { @@ -90,6 +91,16 @@ class PromptPage extends React.Component { 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) { if (!Setting.isAffiliationPrompted(application)) { return null; @@ -120,6 +131,31 @@ class PromptPage extends React.Component { application?.providers.filter(providerItem => Setting.isProviderPrompted(providerItem)).map((providerItem, index) => {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 ( + + + + { + i18next.t("user:Country/Region") + }: + + + + { + this.updateUserFieldWithoutSubmit("region", value); + }} /> + + + ); + }) + ) + } ); @@ -151,7 +187,7 @@ class PromptPage extends React.Component { if (redirectUrl === "") { redirectUrl = res.data2; } - if (redirectUrl !== "") { + if (redirectUrl !== "" && redirectUrl !== null) { Setting.goToLink(redirectUrl); } else { Setting.goToLogin(this, this.getApplicationObj());