Expand frontend, first attempt at sorting.

This commit is contained in:
James Cole
2024-02-25 18:09:52 +01:00
parent 243f283bfd
commit 9222c82af0
66 changed files with 1989 additions and 554 deletions

View File

@@ -10,8 +10,8 @@
"split": "Rozd\u011blit",
"single_split": "Rozd\u011blit",
"transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">Transaction #{ID} (\"{title}\")<\/a> has been stored.",
"webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">Webhook #{ID} (\"{title}\")<\/a> has been stored.",
"webhook_updated_link": "<a href=\"webhooks\/show\/{ID}\">Webhook #{ID}<\/a> (\"{title}\") has been updated.",
"webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">Webhook #{ID} (\"{title}\")<\/a> byl ulo\u017een.",
"webhook_updated_link": "<a href=\"webhooks\/show\/{ID}\">Webhook #{ID}<\/a> (\"{title}\") byl aktualizov\u00e1n.",
"transaction_updated_link": "<a href=\"transactions\/show\/{ID}\">Transaction #{ID}<\/a> (\"{title}\") has been updated.",
"transaction_new_stored_link": "<a href=\"transactions\/show\/{ID}\">Transaction #{ID}<\/a> has been stored.",
"transaction_journal_information": "Informace o transakci",
@@ -95,39 +95,39 @@
"multi_account_warning_withdrawal": "Keep in mind that the source account of subsequent splits will be overruled by whatever is defined in the first split of the withdrawal.",
"multi_account_warning_deposit": "Keep in mind that the destination account of subsequent splits will be overruled by whatever is defined in the first split of the deposit.",
"multi_account_warning_transfer": "Keep in mind that the source + destination account of subsequent splits will be overruled by whatever is defined in the first split of the transfer.",
"webhook_trigger_STORE_TRANSACTION": "After transaction creation",
"webhook_trigger_UPDATE_TRANSACTION": "After transaction update",
"webhook_trigger_DESTROY_TRANSACTION": "After transaction delete",
"webhook_response_TRANSACTIONS": "Transaction details",
"webhook_response_ACCOUNTS": "Account details",
"webhook_response_none_NONE": "No details",
"webhook_trigger_STORE_TRANSACTION": "Po vytvo\u0159en\u00ed transakce",
"webhook_trigger_UPDATE_TRANSACTION": "Po aktualizaci transakce",
"webhook_trigger_DESTROY_TRANSACTION": "Po odstran\u011bn\u00ed transakce",
"webhook_response_TRANSACTIONS": "Podrobnosti transakce",
"webhook_response_ACCOUNTS": "Podrobnosti \u00fa\u010dtu",
"webhook_response_none_NONE": "\u017d\u00e1dn\u00e9 detaily",
"webhook_delivery_JSON": "JSON",
"actions": "Akce",
"meta_data": "Metadata",
"webhook_messages": "Webhook message",
"webhook_messages": "Zpr\u00e1va webhooku",
"inactive": "Neaktivn\u00ed",
"no_webhook_messages": "There are no webhook messages",
"inspect": "Inspect",
"create_new_webhook": "Create new webhook",
"no_webhook_messages": "Neexistuj\u00ed \u017e\u00e1dn\u00e9 zpr\u00e1vy webhooku",
"inspect": "Prozkoumat",
"create_new_webhook": "Vytvo\u0159it nov\u00fd webhook",
"webhooks": "Webhooky",
"webhook_trigger_form_help": "Indicate on what event the webhook will trigger",
"webhook_response_form_help": "Indicate what the webhook must submit to the URL.",
"webhook_delivery_form_help": "Which format the webhook must deliver data in.",
"webhook_active_form_help": "The webhook must be active or it won't be called.",
"edit_webhook_js": "Edit webhook \"{title}\"",
"webhook_was_triggered": "The webhook was triggered on the indicated transaction. Please wait for results to appear.",
"view_message": "View message",
"view_attempts": "View failed attempts",
"message_content_title": "Webhook message content",
"message_content_help": "This is the content of the message that was sent (or tried) using this webhook.",
"attempt_content_title": "Webhook attempts",
"attempt_content_help": "These are all the unsuccessful attempts of this webhook message to submit to the configured URL. After some time, Firefly III will stop trying.",
"no_attempts": "There are no unsuccessful attempts. That's a good thing!",
"webhook_trigger_form_help": "Ur\u010dit, na kterou ud\u00e1lost se spust\u00ed webhook",
"webhook_response_form_help": "Ur\u010dit, co mus\u00ed webhook odeslat do URL.",
"webhook_delivery_form_help": "V jak\u00e9m form\u00e1tu mus\u00ed webhook pos\u00edlat data.",
"webhook_active_form_help": "Webhook mus\u00ed b\u00fdt aktivn\u00ed, nebo nebude zavol\u00e1n.",
"edit_webhook_js": "Upravit webhook \"{title}\"",
"webhook_was_triggered": "Webhook byl spu\u0161t\u011bn na ur\u010den\u00e9 transakci. Pros\u00edm po\u010dkejte, ne\u017e se objev\u00ed v\u00fdsledky.",
"view_message": "Zobrazit zpr\u00e1vu",
"view_attempts": "Zobrazit ne\u00fasp\u011b\u0161n\u00e9 pokusy",
"message_content_title": "Obsah zpr\u00e1vy webhooku",
"message_content_help": "Toto je obsah zpr\u00e1vy, kter\u00e1 byla odesl\u00e1na (nebo vyzkou\u0161ena) pomoc\u00ed tohoto webhooku.",
"attempt_content_title": "Pokusy webhooku",
"attempt_content_help": "To v\u0161e jsou ne\u00fasp\u011b\u0161n\u00e9 pokusy t\u00e9to zpravy webhooku o odesl\u00e1n\u00ed na nakonfigurovanou URL. Po n\u011bjak\u00e9 dob\u011b, Firefly III p\u0159estane zkou\u0161et odes\u00edlat zpr\u00e1vu.",
"no_attempts": "Nebyly nalezeny \u017e\u00e1dn\u00e9 ne\u00fasp\u011b\u0161n\u00e9 pokusy. To je dobr\u00e1 v\u011bc!",
"webhook_attempt_at": "Attempt at {moment}",
"logs": "Logs",
"response": "Response",
"visit_webhook_url": "Visit webhook URL",
"reset_webhook_secret": "Reset webhook secret"
"logs": "Logy",
"response": "Odpov\u011b\u010f",
"visit_webhook_url": "Nav\u0161t\u00edvit URL webhooku",
"reset_webhook_secret": "Restartovat tajn\u00fd kl\u00ed\u010d webhooku"
},
"form": {
"url": "URL",
@@ -142,7 +142,7 @@
"invoice_date": "Datum vystaven\u00ed",
"internal_reference": "Intern\u00ed reference",
"webhook_response": "Response",
"webhook_trigger": "Trigger",
"webhook_trigger": "Spou\u0161t\u011b\u010d",
"webhook_delivery": "Delivery"
},
"list": {

View File

@@ -6,7 +6,7 @@
"flash_success": "Sucesso!",
"close": "Fechar",
"split_transaction_title": "Descri\u00e7\u00e3o da transa\u00e7\u00e3o dividida",
"errors_submission": "There was something wrong with your submission. Please check out the errors below.",
"errors_submission": "Algo correu mal com o envio dos dados. Por favor verifique e corrija os erros abaixo.",
"split": "Dividir",
"single_split": "Divis\u00e3o",
"transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">A transa\u00e7\u00e3o #{ID} (\"{title}\")<\/a> foi guardada.",
@@ -31,7 +31,7 @@
"submit": "Guardar",
"amount": "Montante",
"date": "Data",
"is_reconciled_fields_dropped": "Because this transaction is reconciled, you will not be able to update the accounts, nor the amount(s).",
"is_reconciled_fields_dropped": "Como esta transa\u00e7\u00e3o est\u00e1 reconciliada, n\u00e3o pode atualizar as contas, nem os montantes.",
"tags": "Etiquetas",
"no_budget": "(sem or\u00e7amento)",
"no_bill": "(sem encargo)",

View File

@@ -31,8 +31,8 @@ export default class Get {
list(params) {
return api.get('/api/v2/transactions', {params: params});
}
listByCount(params) {
return api.get('/api/v2/transactions-inf', {params: params});
infiniteList(params) {
return api.get('/api/v2/infinite/transactions', {params: params});
}
show(id, params){
return api.get('/api/v2/transactions/' + id, {params: params});

View File

@@ -175,6 +175,11 @@ let transactions = function () {
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
return;
}
if ('unknown' === sourceType && ['Asset account', 'Debt', 'Loan', 'Mortgage'].includes(destType)) {
this.groupProperties.transactionType = 'deposit';
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');
return;
}
if (['Debt', 'Loan', 'Mortgage'].includes(sourceType) && 'Asset account' === destType) {
this.groupProperties.transactionType = 'deposit';
console.log('Transaction type is detected to be "' + this.groupProperties.transactionType + '".');

View File

@@ -23,7 +23,6 @@ import dates from "../shared/dates.js";
import i18next from "i18next";
import {format} from "date-fns";
import formatMoney from "../../util/format-money.js";
import Get from "../../api/v2/model/transaction/get.js";
import Put from "../../api/v2/model/transaction/put.js";
import {createGrid, ModuleRegistry} from "@ag-grid-community/core";
@@ -39,7 +38,11 @@ import {InfiniteRowModelModule} from '@ag-grid-community/infinite-row-model';
import DateTimeEditor from "../../support/ag-grid/DateTimeEditor.js";
const ds = new TransactionDataSource();
ds.setType('withdrawal');
// set type from URL
const urlParts = window.location.href.split('/');
const type = urlParts[urlParts.length - 1];
ds.setType(type);
document.addEventListener('cellEditRequest', () => {
console.log('Loaded through event listener.');
@@ -61,7 +64,7 @@ const onCellEditRequestMethod = (event) => {
}
// this needs to be better
if('amount' === field) {
if ('amount' === field) {
newValue = event.newValue.amount;
console.log('New value is now' + newValue);
}
@@ -94,7 +97,7 @@ document.addEventListener('onCellValueChanged', () => {
console.log('I just realized a cell value has changed.');
});
let doOnCellValueChanged = function(e) {
let doOnCellValueChanged = function (e) {
console.log('I just realized a cell value has changed.');
};
@@ -138,7 +141,7 @@ const gridOptions = {
},
{
field: "amount",
editable: function(params) {
editable: function (params) {
// only when NO foreign amount.
return null === params.data.amount.foreign_amount && null === params.data.amount.foreign_currency_code;
},
@@ -146,7 +149,7 @@ const gridOptions = {
cellRenderer(params) {
if (params.getValue()) {
let returnString = '';
let amount= parseFloat(params.getValue().amount);
let amount = parseFloat(params.getValue().amount);
let obj = params.getValue();
let stringClass = 'text-danger';
if (obj.type === 'withdrawal') {
@@ -162,7 +165,7 @@ const gridOptions = {
// foreign amount:
if (obj.foreign_amount) {
let foreignAmount= parseFloat(params.getValue().foreign_amount);
let foreignAmount = parseFloat(params.getValue().foreign_amount);
if (obj.type === 'withdrawal') {
foreignAmount = foreignAmount * -1;
}
@@ -194,7 +197,7 @@ const gridOptions = {
cellRenderer: function (params) {
if (params.getValue()) {
let obj = params.getValue();
return '<a href="./accounts/show/'+obj.id+'">' + obj.name + '</a>';
return '<a href="./accounts/show/' + obj.id + '">' + obj.name + '</a>';
}
return '';
}
@@ -205,7 +208,7 @@ const gridOptions = {
cellRenderer: function (params) {
if (params.getValue()) {
let obj = params.getValue();
return '<a href="./accounts/show/'+obj.id+'">' + obj.name + '</a>';
return '<a href="./accounts/show/' + obj.id + '">' + obj.name + '</a>';
}
return '';
}
@@ -216,7 +219,7 @@ const gridOptions = {
cellRenderer: function (params) {
if (params.getValue()) {
let obj = params.getValue();
if(null !== obj.id) {
if (null !== obj.id) {
return '<a href="./categories/show/' + obj.id + '">' + obj.name + '</a>';
}
}
@@ -229,7 +232,7 @@ const gridOptions = {
cellRenderer: function (params) {
if (params.getValue()) {
let obj = params.getValue();
if(null !== obj.id) {
if (null !== obj.id) {
return '<a href="./budgets/show/' + obj.id + '">' + obj.name + '</a>';
}
}
@@ -294,25 +297,25 @@ let index = function () {
},
getTransactions(page) {
const urlParts = window.location.href.split('/');
const type = urlParts[urlParts.length - 1];
let getter = new Get();
getter.list({page: page, type: type}).then(response => {
this.parseTransactions(response.data.data)
// set meta data
this.totalPages = response.data.meta.pagination.total_pages;
this.perPage = response.data.meta.pagination.per_page;
this.page = response.data.meta.pagination.current_page;
}).catch(error => {
// todo this is auto generated
this.notifications.wait.show = false;
this.notifications.error.show = true;
this.notifications.error.text = error.response.data.message;
});
},
// getTransactions(page) {
// const urlParts = window.location.href.split('/');
// const type = urlParts[urlParts.length - 1];
// let getter = new Get();
//
// getter.list({page: page, type: type}).then(response => {
// this.parseTransactions(response.data.data)
//
// // set meta data
// this.totalPages = response.data.meta.pagination.total_pages;
// this.perPage = response.data.meta.pagination.per_page;
// this.page = response.data.meta.pagination.current_page;
// }).catch(error => {
// // to do this is auto generated
// this.notifications.wait.show = false;
// this.notifications.error.show = true;
// this.notifications.error.text = error.response.data.message;
// });
// },
parseTransactions(data) {
// no parse, just save
for (let i in data) {

View File

@@ -24,6 +24,7 @@ export default class TransactionDataSource {
constructor() {
this.type = 'all';
this.rowCount = null;
this.sortModel = null;
}
@@ -32,9 +33,19 @@ export default class TransactionDataSource {
}
getRows(params) {
console.log('The sort model used is: ', params.sortModel);
let sorting = [];
for(let i in params.sortModel) {
if(params.sortModel.hasOwnProperty(i)) {
let sort = params.sortModel[i];
sorting.push({column: sort.colId, direction: sort.sort});
}
}
let getter = new Get();
getter.listByCount({start_row: params.startRow, end_row: params.endRow, type: this.type}).then(response => {
getter.infiniteList({start_row: params.startRow, end_row: params.endRow, type: this.type, sorting: sorting}).then(response => {
this.parseTransactions(response.data.data, params.successCallback);
// set meta data