diff --git a/public/v2/i18n/bg_BG.json b/public/v2/i18n/bg_BG.json index 2fdada8131..2d47da5022 100644 --- a/public/v2/i18n/bg_BG.json +++ b/public/v2/i18n/bg_BG.json @@ -1,7 +1,8 @@ { "config": { "html_language": "bg", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u041f\u043e\u0445\u0430\u0440\u0447\u0435\u043d\u0438", diff --git a/public/v2/i18n/ca_ES.json b/public/v2/i18n/ca_ES.json index 6798bb2aee..7dcddf4e9d 100644 --- a/public/v2/i18n/ca_ES.json +++ b/public/v2/i18n/ca_ES.json @@ -1,7 +1,8 @@ { "config": { "html_language": "ca", - "date_time_fns": "D [de\/d'] MMMM yyyy [a les] HH:mm:ss" + "date_time_fns": "D [de\/d'] MMMM yyyy [a les] HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Gastat", diff --git a/public/v2/i18n/cs_CZ.json b/public/v2/i18n/cs_CZ.json index 9f21ed9577..ad097def54 100644 --- a/public/v2/i18n/cs_CZ.json +++ b/public/v2/i18n/cs_CZ.json @@ -1,7 +1,8 @@ { "config": { "html_language": "cs", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Utraceno", diff --git a/public/v2/i18n/da_DK.json b/public/v2/i18n/da_DK.json index 9fe28e3cf0..27fd84c6b2 100644 --- a/public/v2/i18n/da_DK.json +++ b/public/v2/i18n/da_DK.json @@ -1,7 +1,8 @@ { "config": { "html_language": "da", - "date_time_fns": "MMMM g\u00f8r, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM g\u00f8r, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spent", diff --git a/public/v2/i18n/de_DE.json b/public/v2/i18n/de_DE.json index 41e5cc5635..1a352d6af4 100644 --- a/public/v2/i18n/de_DE.json +++ b/public/v2/i18n/de_DE.json @@ -1,7 +1,8 @@ { "config": { "html_language": "de", - "date_time_fns": "dd. MMM. yyyy um HH:mm:ss" + "date_time_fns": "dd. MMM. yyyy um HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Ausgegeben", diff --git a/public/v2/i18n/el_GR.json b/public/v2/i18n/el_GR.json index 26d479969d..641946b60b 100644 --- a/public/v2/i18n/el_GR.json +++ b/public/v2/i18n/el_GR.json @@ -1,7 +1,8 @@ { "config": { "html_language": "el", - "date_time_fns": "do MMMM yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u0394\u03b1\u03c0\u03b1\u03bd\u03ae\u03b8\u03b7\u03ba\u03b1\u03bd", diff --git a/public/v2/i18n/en.json b/public/v2/i18n/en.json index abc58c0004..7f51e4210c 100644 --- a/public/v2/i18n/en.json +++ b/public/v2/i18n/en.json @@ -1,13 +1,14 @@ { "config": { "html_language": "en", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spent", "left": "Left", "paid": "Paid", - "errors_submission": "There was something wrong with your submission. Please check out the errors below: %{errorMessage}", + "errors_submission_v2": "There was something wrong with your submission. Please check out the errors below: %{errorMessage}", "unpaid": "Unpaid", "default_group_title_name_plain": "ungrouped", "subscriptions_in_group": "Subscriptions in group \"%{title}\"", diff --git a/public/v2/i18n/en_GB.json b/public/v2/i18n/en_GB.json index 35bae66b1f..d3c121ea11 100644 --- a/public/v2/i18n/en_GB.json +++ b/public/v2/i18n/en_GB.json @@ -1,7 +1,8 @@ { "config": { "html_language": "en-gb", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spent", diff --git a/public/v2/i18n/en_US.json b/public/v2/i18n/en_US.json index 6f512a7901..7f51e4210c 100644 --- a/public/v2/i18n/en_US.json +++ b/public/v2/i18n/en_US.json @@ -1,7 +1,8 @@ { "config": { "html_language": "en", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spent", diff --git a/public/v2/i18n/es_ES.json b/public/v2/i18n/es_ES.json index 4b54d85b23..22c3223846 100644 --- a/public/v2/i18n/es_ES.json +++ b/public/v2/i18n/es_ES.json @@ -1,7 +1,8 @@ { "config": { "html_language": "es", - "date_time_fns": "El MMMM hacer, yyyy a las HH:mm:ss" + "date_time_fns": "El MMMM hacer, yyyy a las HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Gastado", diff --git a/public/v2/i18n/fi_FI.json b/public/v2/i18n/fi_FI.json index 8b4d6cd0e6..63bf10229a 100644 --- a/public/v2/i18n/fi_FI.json +++ b/public/v2/i18n/fi_FI.json @@ -1,7 +1,8 @@ { "config": { "html_language": "fi", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "K\u00e4ytetty", diff --git a/public/v2/i18n/fr_FR.json b/public/v2/i18n/fr_FR.json index 19e5faf4d7..107426ba50 100644 --- a/public/v2/i18n/fr_FR.json +++ b/public/v2/i18n/fr_FR.json @@ -1,7 +1,8 @@ { "config": { "html_language": "fr", - "date_time_fns": "do MMMM, yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "D\u00e9pens\u00e9", diff --git a/public/v2/i18n/hu_HU.json b/public/v2/i18n/hu_HU.json index 526c703478..58bdb5c279 100644 --- a/public/v2/i18n/hu_HU.json +++ b/public/v2/i18n/hu_HU.json @@ -1,7 +1,8 @@ { "config": { "html_language": "hu", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Elk\u00f6lt\u00f6tt", diff --git a/public/v2/i18n/id_ID.json b/public/v2/i18n/id_ID.json index 5d6b9f6902..d2c397597d 100644 --- a/public/v2/i18n/id_ID.json +++ b/public/v2/i18n/id_ID.json @@ -1,7 +1,8 @@ { "config": { "html_language": "id", - "date_time_fns": "do MMMM yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Menghabiskan", diff --git a/public/v2/i18n/it_IT.json b/public/v2/i18n/it_IT.json index 1c7582c43a..fa1989f40e 100644 --- a/public/v2/i18n/it_IT.json +++ b/public/v2/i18n/it_IT.json @@ -1,7 +1,8 @@ { "config": { "html_language": "it", - "date_time_fns": "do MMMM yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Speso", diff --git a/public/v2/i18n/ja_JP.json b/public/v2/i18n/ja_JP.json index 5c1c642137..8344e1ef2c 100644 --- a/public/v2/i18n/ja_JP.json +++ b/public/v2/i18n/ja_JP.json @@ -1,7 +1,8 @@ { "config": { "html_language": "ja", - "date_time_fns": "yyyy\u5e74MMMM\u6708do\u65e5 HH:mm:ss" + "date_time_fns": "yyyy\u5e74MMMM\u6708do\u65e5 HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u652f\u51fa", diff --git a/public/v2/i18n/ko_KR.json b/public/v2/i18n/ko_KR.json index dc8c465c43..a464cc667e 100644 --- a/public/v2/i18n/ko_KR.json +++ b/public/v2/i18n/ko_KR.json @@ -1,7 +1,8 @@ { "config": { "html_language": "ko", - "date_time_fns": "YYYY\ub144 M\uc6d4 D\uc77c HH:mm:ss" + "date_time_fns": "YYYY\ub144 M\uc6d4 D\uc77c HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\uc9c0\ucd9c", diff --git a/public/v2/i18n/nb_NO.json b/public/v2/i18n/nb_NO.json index 06269e4359..8b5c611e30 100644 --- a/public/v2/i18n/nb_NO.json +++ b/public/v2/i18n/nb_NO.json @@ -1,7 +1,8 @@ { "config": { "html_language": "nb", - "date_time_fns": "do MMMM, yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Brukt", diff --git a/public/v2/i18n/nl_NL.json b/public/v2/i18n/nl_NL.json index f864394a7b..1d7572f61b 100644 --- a/public/v2/i18n/nl_NL.json +++ b/public/v2/i18n/nl_NL.json @@ -1,7 +1,8 @@ { "config": { "html_language": "nl", - "date_time_fns": "d MMMM yyyy @ HH:mm:ss" + "date_time_fns": "d MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Uitgegeven", diff --git a/public/v2/i18n/nn_NO.json b/public/v2/i18n/nn_NO.json index 86c39af6aa..0c6a2e5f2a 100644 --- a/public/v2/i18n/nn_NO.json +++ b/public/v2/i18n/nn_NO.json @@ -1,7 +1,8 @@ { "config": { "html_language": "nn", - "date_time_fns": "do MMMM, yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Brukt", diff --git a/public/v2/i18n/pl_PL.json b/public/v2/i18n/pl_PL.json index 3e54d25152..0fdf420e5f 100644 --- a/public/v2/i18n/pl_PL.json +++ b/public/v2/i18n/pl_PL.json @@ -1,7 +1,8 @@ { "config": { "html_language": "pl", - "date_time_fns": "do MMMM yyyy @ HH:mm:ss" + "date_time_fns": "do MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Wydano", diff --git a/public/v2/i18n/pt_BR.json b/public/v2/i18n/pt_BR.json index d14ea0cb82..01e0b42978 100644 --- a/public/v2/i18n/pt_BR.json +++ b/public/v2/i18n/pt_BR.json @@ -1,7 +1,8 @@ { "config": { "html_language": "pt-br", - "date_time_fns": "dd 'de' MMMM 'de' yyyy, '\u00e0s' HH:mm:ss" + "date_time_fns": "dd 'de' MMMM 'de' yyyy, '\u00e0s' HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Gasto", diff --git a/public/v2/i18n/pt_PT.json b/public/v2/i18n/pt_PT.json index fc0c629256..570fd6394a 100644 --- a/public/v2/i18n/pt_PT.json +++ b/public/v2/i18n/pt_PT.json @@ -1,7 +1,8 @@ { "config": { "html_language": "pt", - "date_time_fns": "DO [de] MMMM YYYY, @ HH:mm:ss" + "date_time_fns": "DO [de] MMMM YYYY, @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Gasto", diff --git a/public/v2/i18n/ro_RO.json b/public/v2/i18n/ro_RO.json index 0ed025b2d4..5e4331eb12 100644 --- a/public/v2/i18n/ro_RO.json +++ b/public/v2/i18n/ro_RO.json @@ -1,7 +1,8 @@ { "config": { "html_language": "ro", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Cheltuit", diff --git a/public/v2/i18n/ru_RU.json b/public/v2/i18n/ru_RU.json index 627fd9344b..22ac24926a 100644 --- a/public/v2/i18n/ru_RU.json +++ b/public/v2/i18n/ru_RU.json @@ -1,7 +1,8 @@ { "config": { "html_language": "ru", - "date_time_fns": "Do MMMM yyyy, @ HH:mm:ss" + "date_time_fns": "Do MMMM yyyy, @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u0420\u0430\u0441\u0445\u043e\u0434", diff --git a/public/v2/i18n/sk_SK.json b/public/v2/i18n/sk_SK.json index 9e860de53c..39f9530a70 100644 --- a/public/v2/i18n/sk_SK.json +++ b/public/v2/i18n/sk_SK.json @@ -1,7 +1,8 @@ { "config": { "html_language": "sk", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Utraten\u00e9", diff --git a/public/v2/i18n/sl_SI.json b/public/v2/i18n/sl_SI.json index 81e0e3a8b3..2fa660ef31 100644 --- a/public/v2/i18n/sl_SI.json +++ b/public/v2/i18n/sl_SI.json @@ -1,7 +1,8 @@ { "config": { "html_language": "sl", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Porabljeno", diff --git a/public/v2/i18n/sv_SE.json b/public/v2/i18n/sv_SE.json index 0002e40f4b..b2d04495c2 100644 --- a/public/v2/i18n/sv_SE.json +++ b/public/v2/i18n/sv_SE.json @@ -1,7 +1,8 @@ { "config": { "html_language": "sv", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spenderat", diff --git a/public/v2/i18n/tr_TR.json b/public/v2/i18n/tr_TR.json index e247db12f0..4510cce784 100644 --- a/public/v2/i18n/tr_TR.json +++ b/public/v2/i18n/tr_TR.json @@ -1,7 +1,8 @@ { "config": { "html_language": "tr", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Harcanan", diff --git a/public/v2/i18n/uk_UA.json b/public/v2/i18n/uk_UA.json index 8e22e8c3eb..6fa8f9ec5c 100644 --- a/public/v2/i18n/uk_UA.json +++ b/public/v2/i18n/uk_UA.json @@ -1,7 +1,8 @@ { "config": { "html_language": "uk", - "date_time_fns": "MMMM do, yyyy @ HH:mm:ss" + "date_time_fns": "MMMM do, yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "Spent", diff --git a/public/v2/i18n/vi_VN.json b/public/v2/i18n/vi_VN.json index c7af363e27..f43809d2e1 100644 --- a/public/v2/i18n/vi_VN.json +++ b/public/v2/i18n/vi_VN.json @@ -1,7 +1,8 @@ { "config": { "html_language": "vi", - "date_time_fns": "d MMMM yyyy @ HH:mm:ss" + "date_time_fns": "d MMMM yyyy @ HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u0110\u00e3 chi", diff --git a/public/v2/i18n/zh_CN.json b/public/v2/i18n/zh_CN.json index 3b2ea3e13b..bd36519138 100644 --- a/public/v2/i18n/zh_CN.json +++ b/public/v2/i18n/zh_CN.json @@ -1,7 +1,8 @@ { "config": { "html_language": "zh-cn", - "date_time_fns": "YYYY\u5e74M\u6708D\u65e5 HH:mm:ss" + "date_time_fns": "YYYY\u5e74M\u6708D\u65e5 HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u652f\u51fa", diff --git a/public/v2/i18n/zh_TW.json b/public/v2/i18n/zh_TW.json index 4cd2c8a37d..baeba45075 100644 --- a/public/v2/i18n/zh_TW.json +++ b/public/v2/i18n/zh_TW.json @@ -1,7 +1,8 @@ { "config": { "html_language": "zh-tw", - "date_time_fns": "YYYY\u5e74 M\u6708 D\u65e5 dddd \u65bc HH:mm:ss" + "date_time_fns": "YYYY\u5e74 M\u6708 D\u65e5 dddd \u65bc HH:mm:ss", + "date_time_fns_short": "MMMM do, yyyy @ HH:mm" }, "firefly": { "spent": "\u652f\u51fa", diff --git a/resources/assets/v2/css/grid-ff3-theme.css b/resources/assets/v2/css/grid-ff3-theme.css index a9c4a413f7..db6a734e58 100644 --- a/resources/assets/v2/css/grid-ff3-theme.css +++ b/resources/assets/v2/css/grid-ff3-theme.css @@ -22,3 +22,11 @@ .ag-theme-firefly-iii { /* --ag-odd-row-background-color: #f00; */ } +.ag-theme-firefly-iii .ag-root { + border:0; +} +.ag-theme-firefly-iii .ag-root-wrapper +{ + border:0; +} + diff --git a/resources/assets/v2/pages/transactions/index.js b/resources/assets/v2/pages/transactions/index.js index 815b36c918..ca84c19431 100644 --- a/resources/assets/v2/pages/transactions/index.js +++ b/resources/assets/v2/pages/transactions/index.js @@ -32,8 +32,11 @@ import '@ag-grid-community/styles/ag-grid.css'; import '@ag-grid-community/styles/ag-theme-alpine.css'; import '../../css/grid-ff3-theme.css'; +import AmountEditor from "../../support/ag-grid/AmountEditor.js"; + import TransactionDataSource from "../../support/ag-grid/TransactionDataSource.js"; import {InfiniteRowModelModule} from '@ag-grid-community/infinite-row-model'; +import DateTimeEditor from "../../support/ag-grid/DateTimeEditor.js"; const ds = new TransactionDataSource(); ds.setType('withdrawal'); @@ -45,19 +48,25 @@ document.addEventListener('cellEditRequest', () => { let rowImmutableStore = []; let dataTable; -const editableFields = ['description']; +const editableFields = ['description', 'amount', 'date']; const onCellEditRequestMethod = (event) => { + console.log('onCellEditRequestMethod'); const data = event.data; - console.log(event); const field = event.colDef.field; - const newValue = event.newValue; - if(!editableFields.includes(field)) { + let newValue = event.newValue; + if (!editableFields.includes(field)) { console.log('Field ' + field + ' is not editable.'); return; } - console.log('New value for field "'+field+'" in transaction journal #' + data.transaction_journal_id + ' of group #'+data.id+' is "' + newValue + '"'); + // this needs to be better + if('amount' === field) { + newValue = event.newValue.amount; + console.log('New value is now' + newValue); + } + + console.log('New value for field "' + field + '" in transaction journal #' + data.transaction_journal_id + ' of group #' + data.id + ' is "' + newValue + '"'); data[field] = newValue; let rowNode = dataTable.getRowNode(String(event.rowIndex)); rowNode.updateData(data); @@ -78,6 +87,16 @@ const onCellEditRequestMethod = (event) => { }; +document.addEventListener('cellValueChanged', () => { + console.log('I just realized a cell value has changed.'); +}); +document.addEventListener('onCellValueChanged', () => { + console.log('I just realized a cell value has changed.'); +}); + +let doOnCellValueChanged = function(e) { + console.log('I just realized a cell value has changed.'); +}; const gridOptions = { rowModelType: 'infinite', @@ -99,30 +118,124 @@ const gridOptions = { sortable: false, width: 40, cellRenderer: function (params) { - return ''; + if (params.getValue()) { + return ''; + } + return ''; } }, { field: "description", cellDataType: 'text', editable: true, - cellRenderer: function (params) { + // cellRenderer: function (params) { + // if (params.getValue()) { + // return '' + params.getValue() + ''; + // } + // return ''; + // } + + }, + { + field: "amount", + editable: function(params) { + // only when NO foreign amount. + return null === params.data.amount.foreign_amount && null === params.data.amount.foreign_currency_code; + }, + cellEditor: AmountEditor, + cellRenderer(params) { if (params.getValue()) { - return '' + params.getValue() + ''; + let returnString = ''; + let amount= parseFloat(params.getValue().amount); + let obj = params.getValue(); + let stringClass = 'text-danger'; + if (obj.type === 'withdrawal') { + amount = amount * -1; + } + if (obj.type === 'deposit') { + stringClass = 'text-success'; + } + if (obj.type === 'transfer') { + stringClass = 'text-info'; + } + returnString += '' + formatMoney(amount, params.getValue().currency_code) + ''; + + // foreign amount: + if (obj.foreign_amount) { + let foreignAmount= parseFloat(params.getValue().foreign_amount); + if (obj.type === 'withdrawal') { + foreignAmount = foreignAmount * -1; + } + returnString += ' (' + formatMoney(foreignAmount, obj.foreign_currency_code) + ')'; + } + return returnString; } return ''; } }, - {field: "amount"}, { field: "date", + editable: true, cellDataType: 'date', + cellEditor: DateTimeEditor, + cellEditorPopup: true, + cellEditorPopupPosition: 'under', + cellRenderer(params) { + if (params.getValue()) { + return format(params.getValue(), i18next.t('config.date_time_fns_short')); + } + return ''; + } + }, + { + field: "from", + cellDataType: 'text', + cellRenderer: function (params) { + if (params.getValue()) { + let obj = params.getValue(); + return '' + obj.name + ''; + } + return ''; + } + }, + { + field: "to", + cellDataType: 'text', + cellRenderer: function (params) { + if (params.getValue()) { + let obj = params.getValue(); + return '' + obj.name + ''; + } + return ''; + } + }, + { + field: "category", + cellDataType: 'text', + cellRenderer: function (params) { + if (params.getValue()) { + let obj = params.getValue(); + if(null !== obj.id) { + return '' + obj.name + ''; + } + } + return ''; + } + }, + { + field: "budget", + cellDataType: 'text', + cellRenderer: function (params) { + if (params.getValue()) { + let obj = params.getValue(); + if(null !== obj.id) { + return '' + obj.name + ''; + } + } + return ''; + } }, - {field: "from"}, - {field: "to"}, - {field: "category"}, - {field: "budget"}, ] }; diff --git a/resources/assets/v2/support/ag-grid/AmountEditor.js b/resources/assets/v2/support/ag-grid/AmountEditor.js new file mode 100644 index 0000000000..4af7697b26 --- /dev/null +++ b/resources/assets/v2/support/ag-grid/AmountEditor.js @@ -0,0 +1,110 @@ +/* + * AmountEditor.js + * Copyright (c) 2024 james@firefly-iii.org. + * + * This file is part of Firefly III (https://github.com/firefly-iii). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + + + +import Put from "../../api/v2/model/transaction/put.js"; + +export default class AmountEditor { + + init(params) { + + document.addEventListener('cellValueChanged', () => { + console.log('I just realized a cell value has changed.'); + }); + + console.log('AmountEditor.init'); + this.params = params; + this.originalValue = params.value; + this.eGui = document.createElement('div'); + + this.input = document.createElement('input'); + this.input.type = 'number'; + this.input.min = '0'; + this.input.step = 'any'; + this.input.style.overflow = 'hidden'; + this.input.style.textOverflow = 'ellipsis'; + this.input.autofocus = true; + this.input.value = parseFloat(params.value.amount).toFixed(params.value.decimal_places); + + //this.input.onchange = function(e) { this.onChange(e, params);} + // params.onValueChange; + //this.input.onblur = params.onValueChange; + + // this.input.onblur = function () { + // params.stopEditing(); + // }; + + // this.eGui.innerHTML = ``; + } + onChange(e) { + console.log('AmountEditor.onChange'); + this.params.onValueChange(e); + this.params.stopEditing(e); + } + + // focus and select can be done after the gui is attached + afterGuiAttached() { + this.input.focus(); + this.input.select(); + } + + + getGui() { + console.log('AmountEditor.getGui'); + this.eGui.appendChild(this.input); + return this.eGui; + } + + getValue() { + console.log('AmountEditor.getValue'); + this.originalValue.amount = parseFloat(this.input.value); + + // needs a manual submission to Firefly III here. + this.submitAmount(this.originalValue); + + + return this.originalValue; + } + + submitAmount(value) { + console.log('AmountEditor.submitAmount'); + console.log(value); + const newValue = value.amount; + console.log('New value for field "amount" in transaction journal #' + value.transaction_journal_id + ' of group #' + value.id + ' is "' + newValue + '"'); + + // push update to Firefly III over API: + let submission = { + transactions: [ + { + transaction_journal_id: value.transaction_journal_id, + amount: newValue + } + ] + }; + + let putter = new Put(); + putter.put(submission, {id: value.id}); + } + +} diff --git a/resources/assets/v2/support/ag-grid/DateTimeEditor.js b/resources/assets/v2/support/ag-grid/DateTimeEditor.js new file mode 100644 index 0000000000..d802cec07e --- /dev/null +++ b/resources/assets/v2/support/ag-grid/DateTimeEditor.js @@ -0,0 +1,84 @@ +/* + * AmountEditor.js + * Copyright (c) 2024 james@firefly-iii.org. + * + * This file is part of Firefly III (https://github.com/firefly-iii). + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ + + + +import Put from "../../api/v2/model/transaction/put.js"; +import format from "../../util/format.js"; + +export default class DateTimeEditor { + + init(params) { + console.log('DateTimeEditor.init'); + this.params = params; + this.originalValue = params.value; + this.eGui = document.createElement('div'); + + this.input = document.createElement('input'); + this.input.type = 'datetime-local'; + this.input.style.overflow = 'hidden'; + this.input.style.textOverflow = 'ellipsis'; + this.input.value = format(params.value, 'yyyy-MM-dd HH:mm'); + } + onChange(e) { + console.log('DateTimeEditor.onChange'); + this.params.onValueChange(e); + this.params.stopEditing(e); + } + + // focus and select can be done after the gui is attached + afterGuiAttached() { + this.input.focus(); + } + + getGui() { + console.log('DateTimeEditor.getGui'); + this.eGui.appendChild(this.input); + return this.eGui; + } + + getValue() { + console.log('DateTimeEditor.getValue'); + this.originalValue = this.input.value; + + return this.originalValue; + } + + submitAmount(value) { + console.log('AmountEditor.submitAmount'); + console.log(value); + const newValue = value.amount; + console.log('New value for field "amount" in transaction journal #' + value.transaction_journal_id + ' of group #' + value.id + ' is "' + newValue + '"'); + + // push update to Firefly III over API: + let submission = { + transactions: [ + { + transaction_journal_id: value.transaction_journal_id, + amount: newValue + } + ] + }; + + let putter = new Put(); + putter.put(submission, {id: value.id}); + } + +} diff --git a/resources/assets/v2/support/ag-grid/TransactionDataSource.js b/resources/assets/v2/support/ag-grid/TransactionDataSource.js index 182bcf58b9..870098b194 100644 --- a/resources/assets/v2/support/ag-grid/TransactionDataSource.js +++ b/resources/assets/v2/support/ag-grid/TransactionDataSource.js @@ -65,6 +65,7 @@ export default class TransactionDataSource { let entry = {}; // split info + entry.split = isSplit; entry.firstSplit = firstSplit; @@ -78,11 +79,45 @@ export default class TransactionDataSource { // create actual transaction: entry.id = parseInt(current.id); entry.transaction_journal_id = parseInt(transaction.transaction_journal_id); - entry.icon = 'fa fa-solid fa-arrow-left'; - entry.date = new Date(transaction.date); entry.description = transaction.description; + entry.date = new Date(transaction.date); + + // complex fields + entry.from = { + name: transaction.source_name, + id: transaction.source_id, + type: transaction.source_type, + }; + entry.to = { + name: transaction.destination_name, + id: transaction.destination_id, + type: transaction.destination_type, + }; + entry.category = { + name: transaction.category_name, + id: transaction.category_id, + }; + entry.budget = { + name: transaction.budget_name, + id: transaction.budget_id, + }; + + entry.amount = { + id: parseInt(current.id), + transaction_journal_id: parseInt(transaction.transaction_journal_id), + type: transaction.type, + amount: transaction.amount, + currency_code: transaction.currency_code, + decimal_places: transaction.currency_decimal_places, + foreign_amount: transaction.foreign_amount, + foreign_currency_code: transaction.foreign_currency_code, + foreign_decimal_places: transaction.foreign_currency_decimal_places, + }; + + entry.icon = {classes: 'fa fa-solid fa-arrow-left', id: entry.id}; // set firstSplit = false for next run if applicable. + //console.log(transaction); firstSplit = false; transactions.push(entry); } diff --git a/resources/lang/en_US/config.php b/resources/lang/en_US/config.php index a17367b2fb..ca848142ca 100644 --- a/resources/lang/en_US/config.php +++ b/resources/lang/en_US/config.php @@ -46,6 +46,7 @@ return [ // 'date_time' => '%B %e, %Y, @ %T', 'date_time_js' => 'MMMM Do, YYYY, @ HH:mm:ss', 'date_time_fns' => 'MMMM do, yyyy @ HH:mm:ss', + 'date_time_fns_short' => 'MMMM do, yyyy @ HH:mm', // 'specific_day' => '%e %B %Y', 'specific_day_js' => 'D MMMM YYYY', diff --git a/resources/views/v2/transactions/index.blade.php b/resources/views/v2/transactions/index.blade.php index c66e4259aa..7babc68c16 100644 --- a/resources/views/v2/transactions/index.blade.php +++ b/resources/views/v2/transactions/index.blade.php @@ -55,7 +55,7 @@ -