mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
allow editing account labels
This commit is contained in:
parent
6018a55025
commit
be942e06ba
@ -162,7 +162,7 @@ class Boot extends Loggable{
|
||||
for {
|
||||
//TODO: Pagination: This is not totally trivial, since the transaction list groups by date and 2 pages may have some transactions on the same date
|
||||
transactionsJson <- ObpAPI.transactions(bank, account, viewName, Some(10000), Some(0), None, None, None)
|
||||
accountJson <- ObpAPI.account(bank, account, viewName) //TODO: Execute this request and the one above in parallel
|
||||
accountJson <- ObpAPI.getAccount(bank, account, viewName) //TODO: Execute this request and the one above in parallel
|
||||
} yield {
|
||||
(transactionsJson, accountJson, transactionsURLParams)
|
||||
}
|
||||
@ -264,7 +264,7 @@ class Boot extends Loggable{
|
||||
logOrReturnResult {
|
||||
for {
|
||||
viewsJson <- ObpAPI.getViews(bank, account)
|
||||
accountJson <- ObpAPI.account(bank, account, "owner" /*TODO: This shouldn't be hardcoded*/) //TODO: Execute this request and the one above in parallel
|
||||
accountJson <- ObpAPI.getAccount(bank, account, "owner" /*TODO: This shouldn't be hardcoded*/) //TODO: Execute this request and the one above in parallel
|
||||
} yield {
|
||||
(viewsJson, accountJson, PermissionsUrlParams(bank, account))
|
||||
}
|
||||
@ -314,7 +314,7 @@ class Boot extends Loggable{
|
||||
for {
|
||||
permissionsJson <- ObpAPI.getPermissions(bank, account)
|
||||
accountViewsJson <- ObpAPI.getViews(bank, account)
|
||||
accountJson <- ObpAPI.account(bank, account, "owner" /*TODO: This shouldn't be hardcoded*/) //TODO: Execute this request and the one above in parallel
|
||||
accountJson <- ObpAPI.getAccount(bank, account, "owner" /*TODO: This shouldn't be hardcoded*/) //TODO: Execute this request and the one above in parallel
|
||||
} yield (permissionsJson, accountJson, accountViewsJson, PermissionsUrlParams(bank, account))
|
||||
}
|
||||
} else Empty
|
||||
|
||||
@ -83,7 +83,7 @@ object ObpAPI extends Loggable {
|
||||
ObpGet("/v1.2.1/accounts/private").flatMap(_.extractOpt[BarebonesAccountsJson])
|
||||
}
|
||||
|
||||
def account(bankId: String, accountId: String, viewId: String) : Box[AccountJson] = {
|
||||
def getAccount(bankId: String, accountId: String, viewId: String) : Box[AccountJson] = {
|
||||
ObpGet("/v1.2/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId) + "/" + urlEncode(viewId) + "/account").flatMap(x => x.extractOpt[AccountJson])
|
||||
}
|
||||
|
||||
@ -94,7 +94,15 @@ object ObpAPI extends Loggable {
|
||||
val deleteAccountUrl = "/internal/v1.0/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId)
|
||||
ObpInternalDelete(deleteAccountUrl)
|
||||
}
|
||||
|
||||
|
||||
def updateAccountLabel(bankId: String, accountId : String, label: String) = {
|
||||
val json =
|
||||
("id" -> accountId) ~
|
||||
("label" -> label) ~
|
||||
("bank_id" -> bankId)
|
||||
ObpPost("/v1.2.1/banks/" + urlEncode(bankId) + "/accounts/" + urlEncode(accountId), json)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The json for the comment if it was successfully added
|
||||
*/
|
||||
|
||||
@ -55,7 +55,7 @@ class Nav {
|
||||
val bankId = url( url.indexOf("banks")+1 )
|
||||
val accountId = url( url.indexOf("accounts")+1 )
|
||||
|
||||
ObpAPI.account(bankId, accountId, viewId)
|
||||
ObpAPI.getAccount(bankId, accountId, viewId)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@ -417,10 +417,12 @@ Used in transactions list
|
||||
availableViews.exists(view => view.id == Some("owner"))
|
||||
}
|
||||
var label = accountJson.label.getOrElse("")
|
||||
if (label.isEmpty && hasManagementAccess)
|
||||
label = accountJson.number.getOrElse("")
|
||||
else
|
||||
label = accountJson.id.getOrElse("")
|
||||
if (label.isEmpty) {
|
||||
if (hasManagementAccess)
|
||||
label = accountJson.number.getOrElse("")
|
||||
else
|
||||
label = accountJson.id.getOrElse("")
|
||||
}
|
||||
|
||||
"#accountShortDiscription *" #> label
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import net.liftweb.http.js.JsCmds.{SetHtml, Alert, RedirectTo}
|
||||
import net.liftweb.common.{Loggable, Box}
|
||||
import code.lib.ObpAPI
|
||||
import net.liftweb.http.SHtml.{text,ajaxSubmit, ajaxButton}
|
||||
import ObpAPI.{addView, deleteView}
|
||||
import ObpAPI.{addView, deleteView, updateAccountLabel, getAccount}
|
||||
import SHtml._
|
||||
|
||||
case class ViewUpdateData(
|
||||
@ -204,4 +204,30 @@ class ViewsOverview(viewsDataJson: ViewsDataJSON) extends Loggable {
|
||||
"type=submit" #> ajaxSubmit("OK", process)
|
||||
).apply(xhtml)
|
||||
}
|
||||
|
||||
//set up ajax handlers to edit account label
|
||||
def setupEditLabel(xhtml: NodeSeq): NodeSeq = {
|
||||
var newLabel = ""
|
||||
|
||||
def process(): JsCmd = {
|
||||
logger.debug(s"ViewsOverview.setupEditLabel.process: edit label $newLabel")
|
||||
val result = updateAccountLabel(bank, account, newLabel)
|
||||
if (result.isDefined) {
|
||||
val msg = "Label " + newLabel + " has been set"
|
||||
Call("socialFinanceNotifications.notify", msg).cmd
|
||||
} else {
|
||||
val msg = "Sorry, Label" + newLabel + " could not be set ("+ result +")"
|
||||
Call("socialFinanceNotifications.notifyError", msg).cmd
|
||||
}
|
||||
}
|
||||
|
||||
val label = getAccount(bank, account, "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) &
|
||||
// Replace the type=submit with Javascript that makes the ajax call.
|
||||
"type=submit" #> ajaxSubmit("OK", process) &
|
||||
"type=text [value]" #> label
|
||||
).apply(xhtml)
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,8 +36,6 @@ 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">
|
||||
|
||||
@ -48,6 +48,13 @@ See views.js for the javascript which manipulates the DOM for editing
|
||||
</form>
|
||||
</div>
|
||||
<button id="view-edit-advanced-options">Show advanced options</button>
|
||||
<button id="account-edit-label">Change account label</button>
|
||||
<div id="account-edit-label-form" class="lift:ViewsOverview.setupEditLabel">
|
||||
<form class="lift:form.ajax">
|
||||
<input type="text" name="new_label" placeholder="Label">
|
||||
<input type="submit" value="placeholder">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lift:ViewsOverview.getTableContent">
|
||||
<table id="view_table">
|
||||
|
||||
@ -933,7 +933,7 @@ td.main-attributes{
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
#add-view-form {
|
||||
#add-view-form, #account-edit-label-form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,16 @@ $(document).ready(function(){
|
||||
}
|
||||
})
|
||||
|
||||
$('#account-edit-label').click(function(){
|
||||
var el = $('#account-edit-label-form')
|
||||
if (el.is(":visible")) {
|
||||
el.hide()
|
||||
} else {
|
||||
el.css("display", "inline-block")
|
||||
$('#account-edit-label-form form input:first-of-type').focus()
|
||||
}
|
||||
})
|
||||
|
||||
/* clicking on edit: change view to edit mode for selected view */
|
||||
$(".edit").on("click", function(){
|
||||
var viewId = $(this).attr("data-id")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user