mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
Merge branch 'develop' of https://github.com/OpenBankProject/Social-Finance into develop
This commit is contained in:
commit
98a8fb77d3
@ -68,6 +68,8 @@ class Nav {
|
||||
|
||||
def eraseMenu =
|
||||
"* * " #> ""
|
||||
|
||||
|
||||
def views: net.liftweb.util.CssSel = {
|
||||
val url = S.uri.split("/", 0)
|
||||
if (url.size > 4) {
|
||||
@ -114,7 +116,7 @@ class Nav {
|
||||
if(hasOwnerPermissions) {
|
||||
val editViewsUrl = "/banks/" + url(2) + "/accounts/" + url(4) + "/views/list"
|
||||
".navlink [href]" #> { editViewsUrl } &
|
||||
".navlink *" #> "Views & Permissions" &
|
||||
".navlink *" #> "Views" &
|
||||
".navlink [class+]" #> markIfSelected(editViewsUrl)
|
||||
} else eraseMenu
|
||||
}
|
||||
|
||||
@ -23,6 +23,9 @@ import net.liftweb.http.js.JsCmds.SetHtml
|
||||
import scala.xml.Text
|
||||
import net.liftweb.http.js.jquery.JqJsCmds.Show
|
||||
|
||||
|
||||
import code.util.Helper._
|
||||
|
||||
case class PermissionsUrlParams(bankId : String, accountId: String)
|
||||
case class ClickJson(userId: String, checked: Boolean, viewId : String)
|
||||
|
||||
@ -69,8 +72,8 @@ class PermissionManagement(params : (PermissionsJson, AccountJson, List[ViewJson
|
||||
return JSON.stringify(json);
|
||||
}
|
||||
""").cmd
|
||||
|
||||
def accountInfo = ".account-label *" #> accountJson.label.getOrElse("---")
|
||||
|
||||
def accountInfo = ".account-label *" #> getAccountTitle(accountJson)
|
||||
|
||||
def accountViewHeaders = {
|
||||
val viewNames : List[String] = nonPublicViews.map(_.short_name.getOrElse(""))
|
||||
|
||||
@ -46,6 +46,7 @@ import java.util.Currency
|
||||
import code.lib.ObpJson._
|
||||
import code.lib._
|
||||
import net.liftweb.json.JsonDSL._
|
||||
import code.util.Helper._
|
||||
|
||||
case class TransactionsListURLParams(bankId: String, accountId: String, viewId: String)
|
||||
|
||||
@ -412,19 +413,8 @@ Used in transactions list
|
||||
}
|
||||
|
||||
def accountLabel = {
|
||||
val hasManagementAccess = {
|
||||
val availableViews = accountJson.views_available.toList.flatten
|
||||
availableViews.exists(view => view.id == Some("owner"))
|
||||
}
|
||||
var label = accountJson.label.getOrElse("")
|
||||
if (label.isEmpty) {
|
||||
if (hasManagementAccess)
|
||||
label = accountJson.number.getOrElse("")
|
||||
else
|
||||
label = accountJson.id.getOrElse("")
|
||||
}
|
||||
|
||||
"#accountShortDiscription *" #> label
|
||||
val accountTitle = getAccountTitle(accountJson)
|
||||
"#accountShortDescription *" #> accountTitle
|
||||
}
|
||||
|
||||
/* LocalStorage.getAccount(url(2), url(4)) match {
|
||||
|
||||
@ -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
|
||||
@ -183,13 +199,15 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable {
|
||||
val msg = "Sorry, a View with that name already exists."
|
||||
Call("socialFinanceNotifications.notifyError", msg).cmd
|
||||
} else {
|
||||
// This only adds the view (does not grant the current user access)
|
||||
val result = addView(bank, account, newViewName)
|
||||
|
||||
if (result.isDefined) {
|
||||
val msg = "View " + newViewName + " has been created"
|
||||
val msg = "View " + newViewName + " has been created. Please use the Access tab to grant yourself or others access."
|
||||
Call("socialFinanceNotifications.notify", msg).cmd
|
||||
//reload page for new view to be shown
|
||||
RedirectTo("")
|
||||
// After creation, current user does not have access so, we show message above.
|
||||
// TODO: Redirect to a page where user can give him/her self access - and/or grant access automatically.
|
||||
// For now, don't reload so user can see the message above // reload page for new view to be shown // RedirectTo("")
|
||||
} else {
|
||||
val msg = "View " + newViewName + " could not be created"
|
||||
Call("socialFinanceNotifications.notifyError", msg).cmd
|
||||
@ -215,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
|
||||
|
||||
36
src/main/scala/code/util/Helper.scala
Normal file
36
src/main/scala/code/util/Helper.scala
Normal file
@ -0,0 +1,36 @@
|
||||
package code.util
|
||||
|
||||
import code.lib.ObpJson.AccountJson
|
||||
|
||||
|
||||
object Helper {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Returns a string which can be used for the title of the account
|
||||
*/
|
||||
def getAccountTitle(accountJson: AccountJson ) : String = {
|
||||
|
||||
// TODO rewrite in more idiomatic style
|
||||
var title = accountJson.label.getOrElse("")
|
||||
if (title.isEmpty) {
|
||||
if (hasManagementAccess(accountJson))
|
||||
title = accountJson.number.getOrElse("")
|
||||
else
|
||||
title = accountJson.id.getOrElse("")
|
||||
}
|
||||
title
|
||||
}
|
||||
|
||||
|
||||
def hasManagementAccess (accountJson: AccountJson ) : Boolean = {
|
||||
val availableViews = accountJson.views_available.toList.flatten
|
||||
availableViews.exists(view => view.id == Some("owner"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -30,8 +30,10 @@ Berlin 13359, Germany
|
||||
-->
|
||||
<div class="lift:surround?with=default;at=content">
|
||||
|
||||
<div class="lift:PermissionManagement.accountInfo">Permission management for: <span class="account-label">Account</span></div>
|
||||
<a id="add-permission" href="#" class="lift:PermissionManagement.addPermissionLink">Add Permission</a>
|
||||
<div class="lift:PermissionManagement.accountInfo" id="account_details">
|
||||
<span id="accountShortDescription" class="account-label">Account</span>
|
||||
</div>
|
||||
|
||||
<div class="lift:PermissionManagement.manage">
|
||||
<div class="callback-script"></div>
|
||||
<table>
|
||||
@ -54,4 +56,5 @@ Berlin 13359, Germany
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<a id="add-permission" href="#" class="lift:PermissionManagement.addPermissionLink">Grant access to another user... </a>
|
||||
</div>
|
||||
|
||||
@ -39,7 +39,7 @@ e.g. http://localhost:8080/banks/bnpp-fr2/accounts/1137869186/owner
|
||||
<div class="lift:surround?with=default;at=content">
|
||||
|
||||
<div id="account_details" class="lift:OBPTransactionSnippet.accountDetails">
|
||||
<span id="accountShortDiscription">Account Name</span>
|
||||
<span id="accountShortDescription">Account Name</span>
|
||||
<span id="lastUpdate"></span>
|
||||
</div>
|
||||
<div id="social">
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -110,7 +110,7 @@ input.submit {
|
||||
background: transparent url(../images/header.png) repeat-x 50% 100%;
|
||||
}
|
||||
|
||||
#accountShortDiscription {
|
||||
#accountShortDescription {
|
||||
font-size: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ Berlin 13359, Germany
|
||||
<li class="lift:ConnectBankAccount.connect navitem">
|
||||
<a class="navlink" href="#">Connect your Bank Account</a>
|
||||
</li>
|
||||
<li class="lift:Nav.editViews navitem">
|
||||
<li class="lift:Nav.management navitem">
|
||||
<a class="navlink" href="#">Link name. Has class "selected" if it's the current page.</a>
|
||||
</li>
|
||||
<li class="lift:Nav.management navitem">
|
||||
<li class="lift:Nav.editViews navitem">
|
||||
<a class="navlink" href="#">Link name. Has class "selected" if it's the current page.</a>
|
||||
</li>
|
||||
<li class="lift:Nav.privilegeAdmin navitem">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user