Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expand edit form.
James Cole4c30a7bc5536
diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.phpindex 1945f8ea7d..91dff1c221 100644--- a/app/Http/Controllers/Transaction/EditController.php+++ b/app/Http/Controllers/Transaction/EditController.php@@ -106,7 +106,7 @@ class EditController extends Controller$optionalFields['location'] ??= false;$optionalFields['location'] = $optionalFields['location'] && true === config('firefly.enable_external_map');- // map info:+ // map info voor v2:$longitude = config('firefly.default_location.longitude');$latitude = config('firefly.default_location.latitude');$zoomLevel = config('firefly.default_location.zoom_level');diff --git a/config/search.php b/config/search.phpindex dbbfce291e..021da929f3 100644--- a/config/search.php+++ b/config/search.php@@ -132,6 +132,7 @@ return ['has_any_tag' => ['alias' => false, 'needs_context' => false],'any_notes' => ['alias' => false, 'needs_context' => false],'has_any_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],+ 'has_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],'any_external_url' => ['alias' => false, 'needs_context' => false],'has_any_external_url' => ['alias' => true, 'alias_for' => 'any_external_url', 'needs_context' => false],'has_no_attachments' => ['alias' => false, 'needs_context' => false],diff --git a/public/build/assets/edit-6247ff45.js b/public/build/assets/edit-6247ff45.jsdeleted file mode 100644index 444f0366c1..0000000000--- a/public/build/assets/edit-6247ff45.js+++ /dev/null@@ -1 +0,0 @@-import{d as m,f as l,g as p,l as h}from"./get-c53daca3.js";import{f,l as _,I as y}from"./vendor-4332182f.js";import{G as b}from"./get-c2292133.js";import{e as w,f as r,g as v,s as C,h as S,i as A,l as D,a as x,b as L,c as B,j as k,k as c,m as d}from"./autocomplete-functions-31caaca5.js";function E(e){let o=[];for(let a in e)if(e.hasOwnProperty(a)){let t=e[a],n=w();n.bill_id=t.bill_id,n.budget_id=t.budget_id,n.category_name=t.category_name,n.piggy_bank_id=t.piggy_bank_id,n.book_date=t.book_date,n.due_date=t.due_date,n.interest_date=t.interest_date,n.invoice_date=t.invoice_date,n.payment_date=t.payment_date,n.process_date=t.process_date,n.external_url=t.external_url,n.internal_reference=t.internal_reference,n.notes=t.notes,n.tags=t.tags,n.amount=parseFloat(t.amount).toFixed(t.currency_decimal_places),n.currency_code=t.currency_code,t.foreign_amount!==null&&(n.forein_currency_code=t.foreign_currency_code,n.foreign_amount=parseFloat(t.foreign_amount).toFixed(t.foreign_currency_decimal_places)),n.date=f(new Date(t.date),"yyyy-MM-dd HH:mm"),n.description=t.description,n.destination_account={id:t.destination_id,name:t.destination_name,alpine_name:t.destination_name},n.source_account={id:t.source_id,name:t.source_name,alpine_name:t.source_name},t.latitude!==null&&(n.hasLocation=!0,n.latitude=t.latitude,n.longitude=t.longitude,n.zoomLevel=t.zoom_level),console.log("download:"),console.log(t),console.log("current:"),console.log(n),o.push(n)}return o}let i;const s=k();let P=function(){return{entries:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"create",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},filters:{source:[],destination:[]},addedSplit(){setTimeout(()=>{const e=function(o,a,t){return o.name_with_balance+'<br><small class="text-muted">'+i.t("firefly.account_type_"+o.type)+"</small>"};r({selector:"input.ac-source",serverUrl:s.account,filters:this.filters.source,onRenderItem:e,onChange:v,onSelectItem:C}),console.log("ok"),console.log(this.entries[0].source_account.alpine_name),r({selector:"input.ac-dest",serverUrl:s.account,filters:this.filters.destination,onRenderItem:e,onChange:S,onSelectItem:A}),r({selector:"input.ac-category",serverUrl:s.category,valueField:"id",labelField:"name",onChange:c,onSelectItem:c}),r({selector:"input.ac-description",serverUrl:s.description,valueField:"id",labelField:"description",onChange:d,onSelectItem:d})},250)},changedDateTime(e){console.warn("changedDateTime, event is not used")},changedDescription(e){console.warn("changedDescription, event is not used")},changedDestinationAccount(e){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(e){console.warn("changedSourceAccount, event is not used")},formattedTotalAmount(){return this.entries.length===0?l(this.groupProperties.totalAmount,"EUR"):l(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},getTransactionGroup(){const e=window.location.href.split("/"),o=parseInt(e[e.length-1]);new b().show(o,{}).then(t=>{const n=t.data.data;this.groupProperties.id=parseInt(n.id),this.groupProperties.transactionType=n.attributes.transactions[0].type,this.groupProperties.title=n.attributes.title??n.attributes.transactions[0].description,this.entries=E(n.attributes.transactions),this.notifications.wait.show=!1}).then(()=>{setTimeout(()=>{_.init("select.ac-tags",{allowClear:!0,selected:[{label:"Bla bla",value:1,selected:!0}]})},250)})},init(){Promise.all([p("language","en_US")]).then(e=>{i=new y;const o=e[0].replace("-","_");i.locale=o,h(i,o).then(()=>{this.notifications.wait.show=!0,this.notifications.wait.text=i.t("firefly.wait_loading_transaction"),this.getTransactionGroup()})}),D().then(e=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=e.defaultCurrency,this.formData.enabledCurrencies=e.enabledCurrencies,this.formData.nativeCurrencies=e.nativeCurrencies,this.formData.foreignCurrencies=e.foreignCurrencies}),x().then(e=>{this.formData.budgets=e,this.formStates.loadingBudgets=!1}),L().then(e=>{this.formData.piggyBanks=e,this.formStates.loadingPiggyBanks=!1}),B().then(e=>{this.formData.subscriptions=e,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",e=>{this.processUpload(e),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",e=>{this.processUploadError(e)}),document.addEventListener("location-move",e=>{this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude}),document.addEventListener("location-set",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),document.addEventListener("location-zoom",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel})}}},u={transactions:P,dates:m};function g(){Object.keys(u).forEach(e=>{console.log(`Loading page component "${e}"`);let o=u[e]();Alpine.data(e,()=>o)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),g()});window.bootstrapped&&(console.log("Loaded through window variable."),g());diff --git a/public/build/assets/edit-9f80420b.js b/public/build/assets/edit-9f80420b.jsnew file mode 100644index 0000000000..974f543643--- /dev/null+++ b/public/build/assets/edit-9f80420b.js@@ -0,0 +1 @@+import{d as h,f as l,g as p,l as m}from"./get-c53daca3.js";import{f,l as _,I as y}from"./vendor-4332182f.js";import{G as b}from"./get-c2292133.js";import{e as w,f as r,g as v,s as A,h as S,i as C,l as P,a as D,b as x,c as L,j as k,k as c,m as u}from"./autocomplete-functions-31caaca5.js";function B(e){let o=[];for(let i in e)if(e.hasOwnProperty(i)){let t=e[i],n=w();n.bill_id=t.bill_id,n.budget_id=t.budget_id,n.category_name=t.category_name,n.piggy_bank_id=t.piggy_bank_id,n.book_date=t.book_date,n.due_date=t.due_date,n.interest_date=t.interest_date,n.invoice_date=t.invoice_date,n.payment_date=t.payment_date,n.process_date=t.process_date,n.external_url=t.external_url,n.internal_reference=t.internal_reference,n.notes=t.notes,n.tags=t.tags,n.amount=parseFloat(t.amount).toFixed(t.currency_decimal_places),n.currency_code=t.currency_code,t.foreign_amount!==null&&(n.forein_currency_code=t.foreign_currency_code,n.foreign_amount=parseFloat(t.foreign_amount).toFixed(t.foreign_currency_decimal_places)),n.date=f(new Date(t.date),"yyyy-MM-dd HH:mm"),n.description=t.description,n.destination_account={id:t.destination_id,name:t.destination_name,type:t.destination_type,alpine_name:t.destination_name},n.source_account={id:t.source_id,name:t.source_name,type:t.source_type,alpine_name:t.source_name},t.latitude!==null&&(n.hasLocation=!0,n.latitude=t.latitude,n.longitude=t.longitude,n.zoomLevel=t.zoom_level),console.log(n.tags),o.push(n)}return o}let s;const a=k();let E=function(){return{entries:[],formStates:{loadingCurrencies:!0,loadingBudgets:!0,loadingPiggyBanks:!0,loadingSubscriptions:!0,isSubmitting:!1,returnHereButton:!1,saveAsNewButton:!1,resetButton:!0,rulesButton:!0,webhooksButton:!0},formBehaviour:{formType:"edit",foreignCurrencyEnabled:!0},formData:{defaultCurrency:null,enabledCurrencies:[],nativeCurrencies:[],foreignCurrencies:[],budgets:[],piggyBanks:[],subscriptions:[]},groupProperties:{transactionType:"unknown",title:null,id:null,totalAmount:0},notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},filters:{source:[],destination:[]},addedSplit(){setTimeout(()=>{const e=function(o,i,t){return o.name_with_balance+'<br><small class="text-muted">'+s.t("firefly.account_type_"+o.type)+"</small>"};r({selector:"input.ac-source",serverUrl:a.account,filters:this.filters.source,onRenderItem:e,onChange:v,onSelectItem:A}),console.log("ok"),console.log(this.entries[0].source_account.alpine_name),r({selector:"input.ac-dest",serverUrl:a.account,filters:this.filters.destination,onRenderItem:e,onChange:S,onSelectItem:C}),r({selector:"input.ac-category",serverUrl:a.category,valueField:"id",labelField:"name",onChange:c,onSelectItem:c}),r({selector:"input.ac-description",serverUrl:a.description,valueField:"id",labelField:"description",onChange:u,onSelectItem:u})},250)},changedDateTime(e){console.warn("changedDateTime, event is not used")},changedDescription(e){console.warn("changedDescription, event is not used")},changedDestinationAccount(e){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(e){console.warn("changedSourceAccount, event is not used")},formattedTotalAmount(){return this.entries.length===0?l(this.groupProperties.totalAmount,"EUR"):l(this.groupProperties.totalAmount,this.entries[0].currency_code??"EUR")},getTags(e){return console.log("at get tags "+e),console.log(this.entries[e].tags),this.entries[e].tags??[]},getTransactionGroup(){this.entries=[];const e=window.location.href.split("/"),o=parseInt(e[e.length-1]);new b().show(o,{}).then(t=>{const n=t.data.data;this.groupProperties.id=parseInt(n.id),this.groupProperties.transactionType=n.attributes.transactions[0].type,this.groupProperties.title=n.attributes.title??n.attributes.transactions[0].description,this.entries=B(n.attributes.transactions),this.notifications.wait.show=!1}).then(()=>{this.groupProperties.totalAmount=0;for(let t in this.entries)this.entries.hasOwnProperty(t)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[t].amount),this.filters.source.push(this.entries[t].source_account.type),this.filters.destination.push(this.entries[t].source_account.type));console.log(this.filters),setTimeout(()=>{_.init("select.ac-tags",{allowClear:!0,server:a.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:s.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}})},150)})},init(){Promise.all([p("language","en_US")]).then(e=>{s=new y;const o=e[0].replace("-","_");s.locale=o,m(s,o).then(()=>{this.notifications.wait.show=!0,this.notifications.wait.text=s.t("firefly.wait_loading_transaction"),this.getTransactionGroup()})}),P().then(e=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=e.defaultCurrency,this.formData.enabledCurrencies=e.enabledCurrencies,this.formData.nativeCurrencies=e.nativeCurrencies,this.formData.foreignCurrencies=e.foreignCurrencies}),D().then(e=>{this.formData.budgets=e,this.formStates.loadingBudgets=!1}),x().then(e=>{this.formData.piggyBanks=e,this.formStates.loadingPiggyBanks=!1}),L().then(e=>{this.formData.subscriptions=e,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",e=>{this.processUpload(e),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",e=>{this.processUploadError(e)}),document.addEventListener("location-move",e=>{this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude}),document.addEventListener("location-set",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].latitude=e.detail.latitude,this.entries[e.detail.index].longitude=e.detail.longitude,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel}),document.addEventListener("location-zoom",e=>{this.entries[e.detail.index].hasLocation=!0,this.entries[e.detail.index].zoomLevel=e.detail.zoomLevel})},changedAmount(e){const o=parseInt(e.target.dataset.index);this.entries[o].amount=parseFloat(e.target.value),this.groupProperties.totalAmount=0;for(let i in this.entries)this.entries.hasOwnProperty(i)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[i].amount))}}},d={transactions:E,dates:h};function g(){Object.keys(d).forEach(e=>{console.log(`Loading page component "${e}"`);let o=d[e]();Alpine.data(e,()=>o)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),g()});window.bootstrapped&&(console.log("Loaded through window variable."),g());diff --git a/public/build/manifest.json b/public/build/manifest.jsonindex c04e4d5a26..546faf87ef 100644--- a/public/build/manifest.json+++ b/public/build/manifest.json@@ -101,7 +101,7 @@"integrity": "sha384-wA/Z8Z+hNOuOA5ZTX8ShykEkdtfxX6dBZFLmmYmanfuUYEeY427OaNi956vrN6cy"},"resources/assets/v2/pages/transactions/edit.js": {- "file": "assets/edit-6247ff45.js",+ "file": "assets/edit-9f80420b.js","imports": ["_get-c53daca3.js","_vendor-4332182f.js",@@ -110,7 +110,7 @@],"isEntry": true,"src": "resources/assets/v2/pages/transactions/edit.js",- "integrity": "sha384-hJTbJsS4rExaV2BGHmiZ/J/nm8RicxSfwzr7TDUe/nwtYOm8gWtmNxrDrsmyzAqS"+ "integrity": "sha384-aDpFfamLQtUwfrOIPa3rZYGluWoOFUl+/HT5HVFqxc2Qa78DCqiUGsw20xsnPH71"},"resources/assets/v2/sass/app.scss": {"file": "assets/app-fb7b26ec.css",diff --git a/resources/assets/v2/pages/transactions/edit.js b/resources/assets/v2/pages/transactions/edit.jsindex 7680a12835..5cd83d1e46 100644--- a/resources/assets/v2/pages/transactions/edit.js+++ b/resources/assets/v2/pages/transactions/edit.js@@ -57,7 +57,6 @@ let transactions = function () {// transactions are stored in "entries":entries: [],-// state of the form is stored in formState:formStates: {loadingCurrencies: true,@@ -74,7 +73,8 @@ let transactions = function () {// form behaviour during transactionformBehaviour: {- formType: 'create', foreignCurrencyEnabled: true,+ formType: 'edit',+ foreignCurrencyEnabled: true,},// form data (except transactions) is stored in formData@@ -180,9 +180,14 @@ let transactions = function () {}return formatMoney(this.groupProperties.totalAmount, this.entries[0].currency_code ?? 'EUR');},-+ getTags(index) {+ console.log('at get tags ' + index);+ console.log(this.entries[index].tags);+ return this.entries[index].tags ?? [];+ },getTransactionGroup() {+ this.entries = [];const page = window.location.href.split('/');const groupId = parseInt(page[page.length - 1]);const getter = new Get();@@ -192,34 +197,39 @@ let transactions = function () {this.groupProperties.transactionType = data.attributes.transactions[0].type;this.groupProperties.title = data.attributes.title ?? data.attributes.transactions[0].description;this.entries = parseDownloadedSplits(data.attributes.transactions);- //console.log(this.entries);// remove waiting thing.this.notifications.wait.show = false;}).then(() => {-+ this.groupProperties.totalAmount = 0;+ for (let i in this.entries) {+ if (this.entries.hasOwnProperty(i)) {+ this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);+ this.filters.source.push(this.entries[i].source_account.type);+ this.filters.destination.push(this.entries[i].source_account.type);+ }+ }+ console.log(this.filters);setTimeout(() => {// render tags:Tags.init('select.ac-tags', {allowClear: true,- // server: urls.tag,- // liveServer: true,- // clearEnd: true,- selected: [{label:'Bla bla',value:1,selected:true}],- //allowNew: true,- //notFoundMessage: i18n.t('firefly.nothing_found'),- // noCache: true,- // fetchOptions: {- // headers: {- // 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content- // }- // }+ server: urls.tag,+ liveServer: true,+ clearEnd: true,+ allowNew: true,+ notFoundMessage: i18n.t('firefly.nothing_found'),+ noCache: true,+ fetchOptions: {+ headers: {+ 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content+ }+ }});- }, 250);+ }, 150);});},-init() {// download translations and get the transaction group.Promise.all([getVariable('language', 'en_US')]).then((values) => {@@ -282,6 +292,17 @@ let transactions = function () {this.entries[event.detail.index].zoomLevel = event.detail.zoomLevel;});},++ changedAmount(e) {+ const index = parseInt(e.target.dataset.index);+ this.entries[index].amount = parseFloat(e.target.value);+ this.groupProperties.totalAmount = 0;+ for (let i in this.entries) {+ if (this.entries.hasOwnProperty(i)) {+ this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);+ }+ }+ }}}diff --git a/resources/assets/v2/pages/transactions/shared/parse-downloaded-splits.js b/resources/assets/v2/pages/transactions/shared/parse-downloaded-splits.jsindex 091bb3c7c4..eacee32453 100644--- a/resources/assets/v2/pages/transactions/shared/parse-downloaded-splits.js+++ b/resources/assets/v2/pages/transactions/shared/parse-downloaded-splits.js@@ -66,12 +66,14 @@ export function parseDownloadedSplits(downloads) {current.destination_account = {id: download.destination_id,name: download.destination_name,+ type: download.destination_type,alpine_name: download.destination_name,};current.source_account = {id: download.source_id,name: download.source_name,+ type: download.source_type,alpine_name: download.source_name,};@@ -87,10 +89,11 @@ export function parseDownloadedSplits(downloads) {// longitude: null// piggy_bank_id: null// zoomLevel: null- console.log('download:');- console.log(download);- console.log('current:');- console.log(current);+ // console.log('download:');+ // console.log(download);+ // console.log('current:');+ // console.log(current);+ console.log(current.tags);returnArray.push(current);}}diff --git a/resources/views/v2/partials/form/transaction/tags.blade.php b/resources/views/v2/partials/form/transaction/tags.blade.phpindex 3dfe00f9ff..4f2a55b3bc 100644--- a/resources/views/v2/partials/form/transaction/tags.blade.php+++ b/resources/views/v2/partials/form/transaction/tags.blade.php@@ -10,9 +10,6 @@:name="'tags['+index+'][]'"multiple><option value="">{{ __('firefly.select_tag') }}</option>- <template x-for="tag in transaction.tags" :key="tag">- <option :value="tag" x-text="tag" selected="selected"></option>- </template></select></div>