Fancy looking accout selection table
This commit is contained in:
parent
ba349d96cf
commit
d635ae0cbf
|
@ -1,5 +1,4 @@
|
||||||
import React from 'jsx-dom'; // necessary for react to work
|
import React from 'jsx-dom'; // necessary for react to work
|
||||||
import { Actions, GetAccountsReply } from '../background/messages';
|
|
||||||
import { Event, ClientEvents } from './events';
|
import { Event, ClientEvents } from './events';
|
||||||
import * as background from './background';
|
import * as background from './background';
|
||||||
import { Account } from '../landsbankinn/models';
|
import { Account } from '../landsbankinn/models';
|
||||||
|
@ -9,32 +8,90 @@ interface AccountListProps {
|
||||||
accounts: Array<Account>;
|
accounts: Array<Account>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatAccountNumber = (accountNumber: string) => accountNumber.substring(0, 4) + '-' + accountNumber.substring(4, 6) + '-' + accountNumber.substring(6, 12);
|
||||||
|
|
||||||
function AccountList(props: AccountListProps) {
|
function AccountList(props: AccountListProps) {
|
||||||
|
const boxStyle = { display: 'inline-block', width: "100%", cursor: 'pointer' };
|
||||||
|
|
||||||
const selectAllHandler = () => {
|
const selectAllHandler = () => {
|
||||||
|
$(`#check-all`).prop('checked', !$('#check-all').prop('checked'));
|
||||||
const checked = $('#check-all').prop('checked');
|
const checked = $('#check-all').prop('checked');
|
||||||
$('#account-export-list input[type="checkbox"]').prop('checked', checked);
|
$('#account-export-list input[type="checkbox"]').prop('checked', checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectAccountHandler = (accountNumber: string) => () =>
|
||||||
|
$(`#export-${accountNumber}`)
|
||||||
|
.prop('checked', !$(`#export-${accountNumber}`).prop('checked'));
|
||||||
|
|
||||||
const accountList = props.accounts.map(acct =>
|
const accountList = props.accounts.map(acct =>
|
||||||
<li>
|
<tr>
|
||||||
<input id="export-{acct.acountNumber}" type="checkbox" />
|
<td>
|
||||||
|
<input id={`export-${acct.accountNumber}`} type="checkbox" />
|
||||||
<label htmlFor="export-{acct.acountNumber}">
|
</td>
|
||||||
{acct.accountNumber} - {acct.name}
|
<td onClick={selectAccountHandler(acct.accountNumber)}>
|
||||||
</label>
|
<span style={boxStyle}>
|
||||||
</li>
|
{formatAccountNumber(acct.accountNumber)}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td onClick={selectAccountHandler(acct.accountNumber)}>
|
||||||
|
<span style={boxStyle}>
|
||||||
|
{acct.name}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr >
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="account-export-list">
|
<div id="account-export-list">
|
||||||
<ul>
|
<table>
|
||||||
<li>
|
<thead>
|
||||||
<input id="check-all" type="checkbox" onClick={selectAllHandler} />
|
<tr>
|
||||||
|
<th scope="colgroup">Select</th>
|
||||||
<label htmlFor="check-all">Select All</label>
|
<th scope="colgroup">Account Number</th>
|
||||||
</li>
|
<th scope="colgroup">Account Name</th>
|
||||||
{accountList}
|
</tr>
|
||||||
</ul>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input id="check-all" type="checkbox" onClick={selectAllHandler} />
|
||||||
|
</td>
|
||||||
|
<td onClick={selectAllHandler}>
|
||||||
|
<span style={boxStyle}>Select All</span>
|
||||||
|
</td>
|
||||||
|
<td onClick={selectAllHandler}>
|
||||||
|
<span style={boxStyle}>
|
||||||
|
N/A (Selects all accounts below)
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{accountList}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div >
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExportDiv(props: AccountListProps) {
|
||||||
|
return (
|
||||||
|
<div id="account-export" class="content-box fill shadow ui-form" >
|
||||||
|
<h2>Download Transaction Statements</h2>
|
||||||
|
<p>
|
||||||
|
Here, you can export statements from one or more of your accounts
|
||||||
|
over a specified date range.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<label htmlFor="export-date-from">Date From</label>
|
||||||
|
<input id="export-date-from" type="date" />
|
||||||
|
|
||||||
|
<label htmlFor="export-date-to">Date From</label>
|
||||||
|
<input id="export-date-to" type="date" />
|
||||||
|
|
||||||
|
<div class="row-column">
|
||||||
|
<div class="column-span2 column-span2--base">
|
||||||
|
<AccountList accounts={props.accounts} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,18 +101,7 @@ window.addEventListener('DOMContentLoaded', async () => {
|
||||||
const response = await background.getAccounts();
|
const response = await background.getAccounts();
|
||||||
|
|
||||||
if (response.error == null) {
|
if (response.error == null) {
|
||||||
const exportDiv = (
|
const exportDiv = <ExportDiv accounts={response.accounts} />;
|
||||||
<div id="account-export" class="content-box fill shadow ui-form">
|
|
||||||
<h2>Download Transaction Statements</h2>
|
|
||||||
<p>
|
|
||||||
Here, you can export statements from one or more of your accounts
|
|
||||||
over a specified date range.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<AccountList accounts={response.accounts} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
const contentDiv = document.querySelector(
|
const contentDiv = document.querySelector(
|
||||||
'div[class="table-data content-box fill shadow"]'
|
'div[class="table-data content-box fill shadow"]'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue