Refactored Javascript considerably
This commit is contained in:
@@ -693,6 +693,10 @@
|
||||
<data name="BalanceTransactions_Info" xml:space="preserve">
|
||||
<value>Some auto-imported financial transactions can't be automatically matched to the ongoing accounting. This is where you manually match such transactions to "balance" them (if a transaction only has one part completed, like the money sent to the organization with no record of what the money is for, the transaction is said to be "unbalanced").</value>
|
||||
</data>
|
||||
<data name="BalanceTransactions_ModalHeader" xml:space="preserve">
|
||||
<value>Balancing/Matching Transaction #<span id="spanModalTransactionId">67890</span></value>
|
||||
<comment>The span text is replaced runtime.</comment>
|
||||
</data>
|
||||
<data name="BalanceTransactions_PageTitle" xml:space="preserve">
|
||||
<value>Balance & Match Transactions</value>
|
||||
</data>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Formatting.aspx.cs" Inherits="Swarmops.Frontend.Automation.Formatting" %>
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Services;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace Swarmops.Frontend.Automation
|
||||
{
|
||||
public partial class Formatting : DataV5Base
|
||||
{
|
||||
protected void Page_Load (object sender, EventArgs e)
|
||||
{
|
||||
// This page exists only for its web methods, which are called by Ajax.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a culturally-formatted integer with thousands separators.
|
||||
/// </summary>
|
||||
/// <param name="input">The integer to format.</param>
|
||||
/// <returns>The formatted integer for display.</returns>
|
||||
[WebMethod]
|
||||
public static string FormatInteger (int input)
|
||||
{
|
||||
GetAuthenticationDataAndCulture();
|
||||
return input.ToString ("N0");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,67 @@
|
||||
e.preventDefault(); // prevent the default action (scroll / move caret)
|
||||
});
|
||||
});
|
||||
|
||||
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain: enables keyboard navigation
|
||||
|
||||
(function () {
|
||||
$.extend($.fn.combotree.methods, {
|
||||
nav: function (jq, dir) {
|
||||
return jq.each(function () {
|
||||
var opts = $(this).combotree('options');
|
||||
var t = $(this).combotree('tree');
|
||||
var nodes = t.tree('getChildren');
|
||||
if (!nodes.length) { return }
|
||||
var node = t.tree('getSelected');
|
||||
if (!node) {
|
||||
t.tree('select', dir > 0 ? nodes[0].target : nodes[nodes.length - 1].target);
|
||||
} else {
|
||||
var index = 0;
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].target == node.target) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dir > 0) {
|
||||
while (index < nodes.length - 1) {
|
||||
index++;
|
||||
if ($(nodes[index].target).is(':visible')) { break }
|
||||
}
|
||||
} else {
|
||||
while (index > 0) {
|
||||
index--;
|
||||
if ($(nodes[index].target).is(':visible')) { break }
|
||||
}
|
||||
}
|
||||
t.tree('select', nodes[index].target);
|
||||
}
|
||||
if (opts.selectOnNavigation) {
|
||||
var node = t.tree('getSelected');
|
||||
$(node.target).trigger('click');
|
||||
$(this).combotree('showPanel');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$.extend($.fn.combotree.defaults.keyHandler, {
|
||||
up: function () {
|
||||
$(this).combotree('nav', -1);
|
||||
},
|
||||
down: function () {
|
||||
$(this).combotree('nav', 1);
|
||||
},
|
||||
enter: function () {
|
||||
var t = $(this).combotree('tree');
|
||||
var node = t.tree('getSelected');
|
||||
if (node) {
|
||||
$(node.target).trigger('click');
|
||||
}
|
||||
$(this).combotree('hidePanel');
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
</script>
|
||||
|
||||
<span id="<%=this.ClientID %>_SpanGeographies"><select class="easyui-combotree" name="DropGeographies" id="<%=this.ClientID %>_DropGeographies" animate="true" style="width:300px"></select></span>
|
||||
@@ -13,10 +13,15 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('#<%=this.ClientID%>').showModalDialog = <%=this.ClientID%>_open;
|
||||
});
|
||||
|
||||
function <%=this.ClientID%>_open() {
|
||||
$('#<%=this.ClientID%>_divModalCover').fadeIn();
|
||||
}
|
||||
|
||||
function <%=this.ClientID%>_close() {
|
||||
$('#<%=this.ClientID %>_divModalCover').fadeOut(100); // fast - 1/4 of normal time
|
||||
$('#<%=this.ClientID %>_divModalCover').fadeOut(100); // fast - 1/4 of normal time
|
||||
|
||||
<%
|
||||
if (!string.IsNullOrEmpty (this.OnClientClose))
|
||||
@@ -26,6 +31,8 @@
|
||||
%>
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div id="<%=this.ClientID %>_divModalCover" class="modalCover">
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain
|
||||
// below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain: enables keyboard navigation
|
||||
|
||||
(function () {
|
||||
$.extend($.fn.combotree.methods, {
|
||||
|
||||
@@ -28,8 +28,9 @@ namespace Swarmops.Frontend.Controls.v5.UI
|
||||
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/Style/jquery.switchButton.css\" />\r\n");
|
||||
break;
|
||||
case "jsonparameters":
|
||||
scriptRef.Append (
|
||||
"<script language=\"javascript\" type=\"text/javascript\" src=\"/Scripts/jquery.json.min.js\"></script>");
|
||||
// Do nothing - this is now included stock, unconditionally
|
||||
/*scriptRef.Append (
|
||||
"<script language=\"javascript\" type=\"text/javascript\" src=\"/Scripts/jquery.json.min.js\"></script>");*/
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/jquery.qtip.js" ></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/hoverIntent.min.js" ></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/superfish.js" ></script>
|
||||
<script language="javascript" type="text/javascript" src="/Scripts/jquery.json.min.js" ></script>
|
||||
|
||||
<!-- Swarmops common JS functions -->
|
||||
<script language="javascript" type="text/javascript" src="/Swarmops-v5.js" ></script>
|
||||
|
||||
<!-- fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
|
||||
@@ -41,7 +45,7 @@
|
||||
|
||||
<!-- additional scripts etc from individual pages -->
|
||||
<Swarmops5:IncludedScripts ID="IncludedScripts" runat="server" />
|
||||
|
||||
|
||||
<asp:ContentPlaceHolder id="PlaceHolderHead" runat="server" />
|
||||
<asp:Literal ID="LiteralCrowdinScript" runat="server" Text="" />
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@
|
||||
|
||||
window.scrollTo(0, 0);
|
||||
$('body').css('overflow-y', 'hidden');
|
||||
$('#<%=this.DialogAccount.ClientID %>_divModalCover').fadeIn();
|
||||
<%=this.DialogAccount.ClientID %>_open();
|
||||
|
||||
setTimeout(function() {
|
||||
$('#divModalBox').animate({ "height": ($('#DivModalFields').outerHeight() + $('#HeaderModal').outerHeight()) + 40 + "px" }, 50);
|
||||
@@ -443,7 +443,7 @@
|
||||
}
|
||||
|
||||
function modalShow() {
|
||||
$('#<%=this.DialogAccount.ClientID %>_divModalCover').fadeIn();
|
||||
<%=this.DialogAccount.ClientID %>_open();
|
||||
}
|
||||
|
||||
function onOwnerChange(personId) {
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
$('#gridTransactions').datagrid({
|
||||
onLoadSuccess: function() {
|
||||
|
||||
$('img.LocalIconFix').click(function() {
|
||||
$('img.LocalIconFix').click(function(e) {
|
||||
transactionId = $(this).attr("txId");
|
||||
onFixTransaction(transactionId);
|
||||
e.stopPropagation(); // prevents checking of row
|
||||
});
|
||||
|
||||
}
|
||||
@@ -24,8 +25,17 @@
|
||||
|
||||
function onFixTransaction(newTransactionId) {
|
||||
transactionId = newTransactionId;
|
||||
SwarmopsJS.formatInteger(transactionId, function(result) { $('span#spanModalTransactionId').text(result); });
|
||||
<%= this.DialogTx.ClientID %>_open();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.LocalIconFix {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
@@ -53,32 +63,12 @@
|
||||
|
||||
<Swarmops5:ModalDialog runat="server" ID="DialogTx">
|
||||
<DialogCode>
|
||||
<div class="divIconCloseModal"><img id="IconCloseEdit" src="/Images/Icons/iconshock-cross-16px.png" /></div><h2><asp:Literal ID="LiteralEditHeader" runat="server"/></h2>
|
||||
<table id="gridTransaction" class="easyui-datagrid" style="width: 910px"
|
||||
data-options="rownumbers:false,singleSelect:false,nowrap:false,fitColumns:true,fit:true,showFooter:false,loading:false,selectOnCheck:true,checkOnSelect:true,url:'Json-InspectLedgerTxData.aspx'"
|
||||
idField="id">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-options="field:'accountName',width:270"><asp:Label ID="LabelGridHeaderAccountName2" runat="server" Text="XYZ Description" /></th>
|
||||
<th data-options="field:'deltaPos',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaPositive2" runat="server" Text="XYZ Debit" /></th>
|
||||
<th data-options="field:'deltaNeg',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaNegative2" runat="server" Text="XYZ Credit" /></th>
|
||||
<th data-options="field:'dateTime',width:90"><asp:Label ID="LabelGridHeaderDateTimeEntered" runat="server" Text="XYZ DateTime" /></th>
|
||||
<th data-options="field:'initials',width:50"><asp:Label ID="LabelGridHeaderInitials" runat="server" Text="ID#"/></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
<div id="divEditTransaction">
|
||||
<h2><asp:Label ID="LabelAddTransactionRowsHeader" runat="server" /></h2>
|
||||
<span class="content"><h2 style="border-bottom: none"><asp:Label ID="LabelAddRowAccount" runat="server" /><Swarmops5:ComboBudgets ID="BudgetAddRow" ListType="All" runat="server" />, <asp:Label ID="LabelAddRowAmount" runat="server" /> <Swarmops5:CurrencyTextBox ID="TextInsertAmount" runat="server" /> <span class="elementFloatFar"><input id="ButtonAddTransactionRow" type="button" value=' <asp:Literal ID="LiteralAddRowButton" runat="server" /> '/></span></h2></span>
|
||||
|
||||
</div>
|
||||
<div id="divTransactionTracking">
|
||||
<h2><asp:Label ID="LabelTrackedTransactionHeader" runat="server" /></h2>
|
||||
<div id="divTransactionTrackingDetails"></div>
|
||||
</div>
|
||||
|
||||
|
||||
<h2><asp:Literal runat="server" ID="LiteralModalHeader" Text="Matching/Balancing transaction #foobar XYZ" /></h2>
|
||||
<p><asp:Literal ID="LabelDoYouWishTo" runat="server" Text="The balance is off by SEK +6,141.14. is Do you wish to... XYZ" /></p>
|
||||
<p><asp:RadioButton runat="server" ID="RadioBalance" GroupName="TxOptions" Text="Balance the transaction manually? XYZ" /></p>
|
||||
<p><asp:RadioButton runat="server" ID="RadioPayout" GroupName="TxOptions" Text="Match this balance to an open payout? XYZ" /></p>
|
||||
<p><asp:RadioButton runat="server" ID="RadioExistingPayment" GroupName="TxOptions" Text="Match this balance to a recorded payment? XYZ" /></p>
|
||||
<p><asp:RadioButton runat="server" ID="RadioExpectedPayment" GroupName="TxOptions" Text="Match this balance to an expected, unrecorded payment? XYZ" /></p>
|
||||
</DialogCode>
|
||||
</Swarmops5:ModalDialog>
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
this.LabelGridHeaderDelta.Text = Resources.Pages.Ledgers.BalanceTransactions_GridHeader_Amount;
|
||||
this.LabelGridHeaderId.Text = Resources.Pages.Ledgers.BalanceTransactions_GridHeader_TransactionId;
|
||||
this.LabelGridHeaderDescription.Text = Resources.Pages.Ledgers.BalanceTransactions_GridHeader_Description;
|
||||
|
||||
this.LiteralModalHeader.Text = Resources.Pages.Ledgers.BalanceTransactions_ModalHeader;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@
|
||||
window.scrollTo(0, 0);
|
||||
$('body').css('overflow-y', 'hidden');
|
||||
$('#<%=this.DialogEditTx.ClientID%>_divModalCover').fadeIn();
|
||||
$('span#spanModalTransactionId').text(transactionId);
|
||||
SwarmopsJS.formatInteger(transactionId, function(result) { $('span#spanModalTransactionId').text(result); });
|
||||
|
||||
$('#gridTransaction').datagrid({ url: 'Json-InspectLedgerTxData.aspx?TxId=' + transactionId });
|
||||
|
||||
@@ -304,9 +304,9 @@
|
||||
idField="id">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-options="field:'id',width:50,align:'right'"><asp:Label ID="LabelGridHeaderId" runat="server" Text="ID#"/></th>
|
||||
<th data-options="field:'id',width:70,align:'right'"><asp:Label ID="LabelGridHeaderId" runat="server" Text="ID#"/></th>
|
||||
<th data-options="field:'datetime',width:90,sortable:true"><asp:Label ID="LabelGridHeaderDateTime" runat="server" Text="XYZ DateTime" /></th>
|
||||
<th data-options="field:'description',width:270"><asp:Label ID="LabelGridHeaderDescription" runat="server" Text="XYZ Description" /></th>
|
||||
<th data-options="field:'description',width:250"><asp:Label ID="LabelGridHeaderDescription" runat="server" Text="XYZ Description" /></th>
|
||||
<th data-options="field:'deltaPos',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaPositive" runat="server" Text="XYZ Debit" /></th>
|
||||
<th data-options="field:'deltaNeg',width:70,align:'right'"><asp:Label ID="LabelGridHeaderDeltaNegative" runat="server" Text="XYZ Credit" /></th>
|
||||
<th data-options="field:'balance',width:80,align:'right'"><asp:Label ID="LabelGridHeaderBalance" runat="server" Text="XYZ Balance" /></th>
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Swarmops.Frontend.Pages.v5.Ledgers
|
||||
}
|
||||
|
||||
result.Append ("{" + String.Format (
|
||||
"\"id\":\"{0}\",\"datetime\":\"{1:MMM-dd HH:mm}\",\"description\":\"{2}\"," +
|
||||
"\"id\":\"{0:N0}\",\"datetime\":\"{1:MMM-dd HH:mm}\",\"description\":\"{2}\"," +
|
||||
"\"deltaPos\":\"{3}\",\"deltaNeg\":\"{4}\",\"balance\":\"{5:N0}\",\"action\":\"{6}\"",
|
||||
row.FinancialTransactionId,
|
||||
row.TransactionDateTime,
|
||||
|
||||
@@ -819,6 +819,18 @@ select.comboperson+span>input:focus
|
||||
}
|
||||
|
||||
|
||||
input[type="radio"] {
|
||||
vertical-align: text-bottom;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-left: 10px;
|
||||
font-size: 120%;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
|
||||
/* IN-PAGE HEADERS */
|
||||
|
||||
h1, h2, h3
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
var SwarmopsJS = (function() {
|
||||
var publicSymbols = {},
|
||||
initFunctions = [];
|
||||
|
||||
publicSymbols.formatInteger = formatInteger;
|
||||
function formatInteger (number, callbackSuccess, callbackError)
|
||||
{
|
||||
if (callbackSuccess === undefined) {
|
||||
alert("FormatInteger() called without callbackSuccess parameter. This is not allowed.");
|
||||
return ("[Undefined]");
|
||||
}
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.input = number;
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
url: '/Automation/Formatting.aspx/FormatInteger',
|
||||
dataType: 'json',
|
||||
data: $.toJSON(jsonData),
|
||||
|
||||
success: function(data) {
|
||||
callbackSuccess(data.d);
|
||||
},
|
||||
|
||||
error: function(){
|
||||
if (callbackError !== undefined) {
|
||||
callbackError();
|
||||
} else {
|
||||
alertify.error("AJAX error calling SwarmopsJS.FormatInteger. Are the server and network still available?"); // TODO: Loc - how?
|
||||
callbackSuccess("[Undefined]");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Below copied from http://stackoverflow.com/questions/4578424/javascript-extend-a-function, assumed to be in public domain
|
||||
|
||||
publicSymbols.init = init;
|
||||
function init() {
|
||||
var funcs = initFunctions;
|
||||
|
||||
initFunctions = undefined;
|
||||
|
||||
for (index = 0; index < funcs.length; ++index) {
|
||||
try { funcs[index](); } catch (e) { }
|
||||
}
|
||||
}
|
||||
|
||||
publicSymbols.addInitFunction = addInitFunction;
|
||||
|
||||
function addInitFunction(f) {
|
||||
if (initFunctions) {
|
||||
// Init hasn't run yet, rememeber it
|
||||
initFunctions.push(f);
|
||||
} else {
|
||||
// `init` has already run, call it almost immediately
|
||||
// but *asynchronously* (so the caller never sees the
|
||||
// call synchronously)
|
||||
setTimeout(f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return publicSymbols;
|
||||
})();
|
||||
Reference in New Issue
Block a user