Offer the bank only to a kroner transfer
This commit is contained in:
1 parent
bd5c59fd07
commit
b13ea897d7
1 file changed
+31
-2
+31
-2
@@ -386,14 +386,43 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var marketList = [];
|
||||||
|
|
||||||
function fillMarkets(markets) {
|
function fillMarkets(markets) {
|
||||||
markets.forEach(function (market) {
|
marketList = markets;
|
||||||
|
fillMarketSelects();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The bank is offered only where docs/spec.md section 3.11 allows it: a transfer
|
||||||
|
whose amount is in kroner, as the account it is drawn from or the one it goes
|
||||||
|
to. Everywhere else it is not a choice. */
|
||||||
|
function bankAllowed() {
|
||||||
|
return type() === "transfer_out"
|
||||||
|
&& Skuld.fieldValue("leg_out_currency") === "nok";
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillMarketSelects() {
|
||||||
|
var allowBank = bankAllowed();
|
||||||
["market_id", "to_market"].forEach(function (name) {
|
["market_id", "to_market"].forEach(function (name) {
|
||||||
|
var select = document.querySelector('[name="' + name + '"]');
|
||||||
|
var keep = select.value;
|
||||||
|
select.textContent = "";
|
||||||
|
if (name === "to_market") {
|
||||||
|
var empty = document.createElement("option");
|
||||||
|
empty.value = "";
|
||||||
|
empty.textContent = "Vel konto";
|
||||||
|
select.appendChild(empty);
|
||||||
|
}
|
||||||
|
marketList.forEach(function (market) {
|
||||||
|
if (market.bank && !allowBank) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
option.value = String(market.id);
|
option.value = String(market.id);
|
||||||
option.textContent = market.name;
|
option.textContent = market.name;
|
||||||
document.querySelector('[name="' + name + '"]').appendChild(option);
|
select.appendChild(option);
|
||||||
});
|
});
|
||||||
|
select.value = keep;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user