diff --git a/src/main/scala/code/snippet/Management.scala b/src/main/scala/code/snippet/Management.scala index 3b1ade43..1a1f0601 100644 --- a/src/main/scala/code/snippet/Management.scala +++ b/src/main/scala/code/snippet/Management.scala @@ -33,6 +33,7 @@ Berlin 13359, Germany package code.snippet +import code.util.Helper._ import net.liftweb.json.JsonAST._ import net.liftweb.util.Helpers._ import scala.xml.NodeSeq @@ -58,6 +59,9 @@ class Management(params : (OtherAccountsJson, ManagementURLParams)) { val options = CustomTableSorter.options(headers, sortList) + + def setAccountTitle = ".account_title *" #> getAccountTitle(urlParams.bankId, urlParams.accountId) + def tableSorter(xhtml: NodeSeq) : NodeSeq = { CustomTableSorter("#other_acc_management", options) } diff --git a/src/main/scala/code/snippet/ViewsOverview.scala b/src/main/scala/code/snippet/ViewsOverview.scala index 0a8fcc73..8b0c9460 100644 --- a/src/main/scala/code/snippet/ViewsOverview.scala +++ b/src/main/scala/code/snippet/ViewsOverview.scala @@ -33,23 +33,10 @@ For maintaining permissions on the views (entitlements on the account) */ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable { val views = viewsDataJson.views - val bank = viewsDataJson.bankId - val account = viewsDataJson.accountId + val bankId = viewsDataJson.bankId + val accountId = viewsDataJson.accountId - - // Get the Account Title - // TODO put this into code.util.Helper - def getAccountTitleFromAccount : String = { - val accountJsonBox = getAccount(bank, account, "owner") - - val accountTitle = accountJsonBox match { - case Full(accountJson) => getAccountTitle(accountJson) - case _ => "Unknown Account" - } - accountTitle - } - - def setAccountTitle = ".account_title *" #> getAccountTitleFromAccount + def setAccountTitle = ".account_title *" #> getAccountTitle(bankId, accountId) def getTableContent(xhtml: NodeSeq) :NodeSeq = { @@ -200,7 +187,7 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable { Call("socialFinanceNotifications.notifyError", msg).cmd } else { // This only adds the view (does not grant the current user access) - val result = addView(bank, account, newViewName) + val result = addView(bankId, accountId, newViewName) if (result.isDefined) { val msg = "View " + newViewName + " has been created. Please use the Access tab to grant yourself or others access." @@ -229,7 +216,7 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable { def process(): JsCmd = { logger.debug(s"ViewsOverview.setupEditLabel.process: edit label $newLabel") - val result = updateAccountLabel(bank, account, newLabel) + val result = updateAccountLabel(bankId, accountId, newLabel) if (result.isDefined) { val msg = "Label " + newLabel + " has been set" Call("socialFinanceNotifications.notify", msg).cmd @@ -241,7 +228,7 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable { } } - val label = getAccount(bank, account, "owner").get.label.getOrElse("Label") + val label = getAccount(bankId, accountId, "owner").get.label.getOrElse("Label") ( // Bind newViewName field to variable (e.g. http://chimera.labs.oreilly.com/books/1234000000030/ch03.html) "@new_label" #> text(newLabel, s => newLabel = s) & diff --git a/src/main/scala/code/util/Helper.scala b/src/main/scala/code/util/Helper.scala index 99b5c750..fc88bee5 100644 --- a/src/main/scala/code/util/Helper.scala +++ b/src/main/scala/code/util/Helper.scala @@ -1,18 +1,31 @@ package code.util +import code.lib.ObpAPI._ import code.lib.ObpJson.AccountJson +import net.liftweb.common.Full object Helper { + // From bankId / accountId + def getAccountTitle (bankId: String, accountId: String) : String = { + val accountJsonBox = getAccount(bankId, accountId, "owner") + + val accountTitle = accountJsonBox match { + case Full(accountJson) => getAccountTitle(accountJson) + case _ => "Unknown Account" + } + accountTitle + } + + /* Returns a string which can be used for the title of the account */ def getAccountTitle(accountJson: AccountJson ) : String = { - - // TODO rewrite in more idiomatic style + // Rewrite in more idiomatic style? var title = accountJson.label.getOrElse("") if (title.isEmpty) { if (hasManagementAccess(accountJson)) diff --git a/src/main/webapp/banks/star/accounts/star/management.html b/src/main/webapp/banks/star/accounts/star/management.html index efd42d5d..374a7ef5 100644 --- a/src/main/webapp/banks/star/accounts/star/management.html +++ b/src/main/webapp/banks/star/accounts/star/management.html @@ -30,6 +30,10 @@ Berlin 13359, Germany -->