Files
firefly-iii/public/build/assets/edit-6247ff45.js
2024-01-06 07:42:00 +01:00

2 lines
5.6 KiB
JavaScript

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());