diff --git a/obp-api/src/main/scala/code/snippet/BerlinGroupConsent.scala b/obp-api/src/main/scala/code/snippet/BerlinGroupConsent.scala index 59bcbfb57..dab6aa3d8 100644 --- a/obp-api/src/main/scala/code/snippet/BerlinGroupConsent.scala +++ b/obp-api/src/main/scala/code/snippet/BerlinGroupConsent.scala @@ -170,14 +170,14 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510 case Some(accounts) if accounts.isEmpty => // Access is requested updateConsentPayloadValue.set(true) accessAccountsDefinedVar.set(true) - userIbans.toList + List() case Some(accounts) if accounts.flatMap(_.iban).toSet.subsetOf(userIbans) => // Access is requested for specific IBANs accessAccountsDefinedVar.set(true) accounts.flatMap(_.iban) case Some(accounts) => // Logged in user is not an owner of IBAN/IBANs userIsOwnerOfAccountsValue.set(false) accessAccountsDefinedVar.set(true) - accounts.flatMap(_.iban) + accounts.flatMap(_.iban) //even if not the owner, we will also show them in the page. case None => // Access is not requested accessAccountsDefinedVar.set(false) List() @@ -186,7 +186,7 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510 case Some(balances) if balances.isEmpty => // Access is requested updateConsentPayloadValue.set(true) accessBalancesDefinedVar.set(true) - userIbans.toList + List() case Some(balances) if balances.flatMap(_.iban).toSet.subsetOf(userIbans) => // Access is requested for specific IBANs accessBalancesDefinedVar.set(true) balances.flatMap(_.iban) @@ -202,7 +202,7 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510 case Some(transactions) if transactions.isEmpty => // Access is requested updateConsentPayloadValue.set(true) accessTransactionsDefinedVar.set(true) - userIbans.toList + List() case Some(transactions) if transactions.flatMap(_.iban).toSet.subsetOf(userIbans) => // Access is requested for specific IBANs accessTransactionsDefinedVar.set(true) transactions.flatMap(_.iban) @@ -215,42 +215,53 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510 List() } + // all Selected IBANs + val ibansFromGetConsentResponseJson = (canReadAccountsIbans ::: canReadBalancesIbans ::: canReadTransactionsIbans).distinct + /** * Generates toggle switches for IBAN lists. * * @param scope The scope of the IBANs (e.g., "canReadAccountsIbans"). * @param ibans List of IBANs to display. * @param selectedList Set of currently selected IBANs. - * @param sessionVar Session variable to update when toggling. * @return Sequence of NodeSeq representing the toggle switches. */ - def generateCheckboxes(scope: String, ibans: List[String], selectedList: Set[String], sessionVar: SessionVar[Set[String]]): immutable.Seq[NodeSeq] = { - ibans.map { iban => - if (updateConsentPayloadValue.is) { - // Show toggle switch when updateConsentPayloadValue is true -
- + def generateCheckboxes(scope: String, ibans: List[String], selectedList: Set[String], sessionVar: SessionVar[Set[String]], ibansFromGetConsentResponseJson:List[String]): immutable.Seq[NodeSeq] = { + if (ibansFromGetConsentResponseJson.isEmpty) { + ibans.map { iban => + if (updateConsentPayloadValue.is) { + // Show toggle switch when updateConsentPayloadValue is true +
+ + + {iban} + +
+ } else { + // Show only the IBAN text when updateConsentPayloadValue is false {iban} -
- } else { + } + } + } else { + ibansFromGetConsentResponseJson.map { iban => // Show only the IBAN text when updateConsentPayloadValue is false {iban} - } } } + } // Form text and user details val currentUser = AuthUser.currentUser @@ -280,7 +291,7 @@ class BerlinGroupConsent extends MdcLoggable with RestHelper with APIMethods510

Accounts:

- {generateCheckboxes("canReadAccountsIbans", userIbans.toList, selectedAccountsIbansValue.is, selectedAccountsIbansValue)} + {generateCheckboxes("canReadAccountsIbans", userIbans.toList, selectedAccountsIbansValue.is, selectedAccountsIbansValue, ibansFromGetConsentResponseJson)}