Adding setAccountTitle to counterparties page

This commit is contained in:
Simon Redfern 2015-07-21 00:59:47 +02:00
parent 98a8fb77d3
commit 839d1a73e1
4 changed files with 29 additions and 21 deletions

View File

@ -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)
}

View File

@ -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) &

View File

@ -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))

View File

@ -30,6 +30,10 @@ Berlin 13359, Germany
-->
<div class="lift:surround?with=default;at=content">
<div class="lift:Management.setAccountTitle" id="account_details">
<span id="accountShortDescription" class="account_title">Account Title</span>
</div>
<div class="management">
<table id="other_acc_management" class="management tablesorter">