Fixed longstanding bug with editing multiple account parentages

This commit is contained in:
Rick Falkvinge
2016-05-14 17:25:05 +02:00
parent f260aff0f2
commit 3e0aa97a6b
2 changed files with 24 additions and 12 deletions
+13 -11
View File
@@ -295,13 +295,15 @@
$('#<%=CurrencyInitialBalance.ClientID%>_Input').val('...').css('background-color', '#DDD');
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').attr('placeholder', '...');
accountTree.combotree('setText', '...');
$('span#<%= DropParents.ClientID %>_SpanBudgets span input.textbox-text').css('background-color', '#FFF');
parentAccountName = '';
window.scrollTo(0, 0);
$('body').css('overflow-y', 'hidden');
<%=this.DialogAccount.ClientID %>_open();
$('#<%=DropParents.ClientID %>_DropBudgets').combotree('setText', "...");
setTimeout(function() {
$('#divModalBox').animate({ "height": ($('#DivModalFields').outerHeight() + $('#HeaderModal').outerHeight()) + 40 + "px" }, 50);
}, 50); // set timeout to after checkboxes initialized, if this is the first show of modal
@@ -421,7 +423,7 @@
$('#SpanTextCurrency').text(msg.d.CurrencyCode);
$('#SpanEditBalance').text(msg.d.Balance);
parentAccountName = msg.d.ParentAccountName;
setAccountTreeText(parentAccountName);
setAccountTreeId(msg.d.ParentAccountId);
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').css('background-color', '#FFF');
$('span#<%= DropOwner.ClientID %>_SpanPeople span input.textbox-text').css('background-image', "url('" + msg.d.AccountOwnerAvatarUrl + "')");
@@ -479,17 +481,16 @@
}
function setAccountTreeText (text) {
var accountTree = $('#<%=DropParents.ClientID %>_DropBudgets');
var currentText = accountTree.combotree('getText');
if (currentText.length < 3 && parentAccountName.length > 2) {
accountTree.combotree('setText', parentAccountName);
$('span#<%= DropParents.ClientID %>_SpanBudgets span input.textbox-text').css('background-color', '#FFF');
} else if (!accountTreeLoaded) {
function setAccountTreeId(id) {
if (!accountTreeLoaded) {
setTimeout(function() {
setAccountTreeText(text);
setAccountTreeId(id);
}, 250);
}
} else {
var accountTree = $('#<%=DropParents.ClientID %>_DropBudgets');
accountTree.combotree('setValue', id);
$('span#<%= DropParents.ClientID %>_SpanBudgets span input.textbox-text').css('background-color', '#FFF');
}
}
@@ -531,6 +532,7 @@
// accountTree.combotree('select', 0); // clear any previous selection
accountTreeLoaded = true;
if (parentAccountName != null && parentAccountName.length > 0) {
console.log("Setting textbox to parentAccountName " + parentAccountName);
accountTree.combotree('setText', parentAccountName);
$('span#<%= DropParents.ClientID %>_SpanBudgets span input.textbox-text').css('background-color', '#FFF');
}
+11 -1
View File
@@ -120,8 +120,18 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
JsonAccountData result = new JsonAccountData();
if (account.ParentIdentity == 0)
{
// if this is a root account, put it under the category root node, which has negative the type id
result.ParentAccountId = -(int) account.AccountType;
}
else
{
result.ParentAccountId = account.ParentIdentity;
}
result.AccountName = account.Name;
result.ParentAccountId = account.ParentIdentity;
result.ParentAccountName = account.ParentFinancialAccountId == 0
? Global.ResourceManager.GetString ("Financial_" +
account.AccountType)