Add Account Title to the views list.html so we can see which account we're working on

This commit is contained in:
Simon Redfern 2015-07-20 04:20:54 +02:00
parent 950bd732fc
commit cb6d6090f3
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package code.snippet
import code.util.Helper._
import net.liftweb.http.js.JE.{Call, Str}
import net.liftweb.http.js.JsCmd
import net.liftweb.util.Helpers._
@ -10,7 +11,7 @@ import net.liftweb.http.{S, SHtml}
import net.liftweb.json.JsonAST.JValue
import net.liftweb.json._
import net.liftweb.http.js.JsCmds.{SetHtml, Alert, RedirectTo}
import net.liftweb.common.{Loggable, Box}
import net.liftweb.common.{Full, Loggable, Box}
import code.lib.ObpAPI
import net.liftweb.http.SHtml.{text,ajaxSubmit, ajaxButton}
import ObpAPI.{addView, deleteView, updateAccountLabel, getAccount}
@ -35,6 +36,21 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable {
val bank = viewsDataJson.bankId
val account = 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 getTableContent(xhtml: NodeSeq) :NodeSeq = {
//add ajax callback to save view
@ -217,6 +233,8 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable {
if (result.isDefined) {
val msg = "Label " + newLabel + " has been set"
Call("socialFinanceNotifications.notify", msg).cmd
// So we can see the new account title which may use the updated label
RedirectTo("")
} else {
val msg = "Sorry, Label" + newLabel + " could not be set ("+ result +")"
Call("socialFinanceNotifications.notifyError", msg).cmd

View File

@ -38,6 +38,9 @@ See views.js for the javascript which manipulates the DOM for editing
-->
<div class="lift:surround?with=default;at=content">
<div class="lift:ViewsOverview.setAccountTitle" id="account_details">
<span id="accountShortDescription" class="account_title">Account Title</span>
</div>
<div class="views">
<div class="action-bar">
<button id="view-add">Add new view</button>