mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
2 lines
5.4 KiB
JavaScript
2 lines
5.4 KiB
JavaScript
import{d as g,f as l}from"./format-money-e259f5e4.js";import{G as p}from"./get-3bb14de5.js";import{p as f}from"./parse-downloaded-splits-4afea167.js";import{d as r,e as m,s as w,f as y,g as b,l as v,a as A,b as C,c as S,h as D,i as u,j as c}from"./autocomplete-functions-ac0d2cb1.js";import{m as P,i as a}from"./vendor-fca45885.js";import"./create-empty-split-fb5bda92.js";import"./get-da167d5b.js";const i=D();let L=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 t=function(e,n,s){return e.name_with_balance+'<br><small class="text-muted">'+a.t("firefly.account_type_"+e.type)+"</small>"};r({selector:"input.ac-source",serverUrl:i.account,filters:this.filters.source,onRenderItem:t,onChange:m,onSelectItem:w}),console.log("ok"),console.log(this.entries[0].source_account.alpine_name),r({selector:"input.ac-dest",serverUrl:i.account,filters:this.filters.destination,onRenderItem:t,onChange:y,onSelectItem:b}),r({selector:"input.ac-category",serverUrl:i.category,valueField:"id",labelField:"name",onChange:u,onSelectItem:u}),r({selector:"input.ac-description",serverUrl:i.description,valueField:"id",labelField:"description",onChange:c,onSelectItem:c})},250)},changedDateTime(t){console.warn("changedDateTime, event is not used")},changedDescription(t){console.warn("changedDescription, event is not used")},changedDestinationAccount(t){console.warn("changedDestinationAccount, event is not used")},changedSourceAccount(t){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(t){return console.log("at get tags "+t),console.log(this.entries[t].tags),this.entries[t].tags??[]},getTransactionGroup(){this.entries=[];const t=window.location.href.split("/"),e=parseInt(t[t.length-1]);new p().show(e,{}).then(s=>{const o=s.data.data;this.groupProperties.id=parseInt(o.id),this.groupProperties.transactionType=o.attributes.transactions[0].type,this.groupProperties.title=o.attributes.title??o.attributes.transactions[0].description,this.entries=f(o.attributes.transactions),this.notifications.wait.show=!1}).then(()=>{this.groupProperties.totalAmount=0;for(let s in this.entries)this.entries.hasOwnProperty(s)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[s].amount),this.filters.source.push(this.entries[s].source_account.type),this.filters.destination.push(this.entries[s].source_account.type));console.log(this.filters),setTimeout(()=>{P.init("select.ac-tags",{allowClear:!0,server:i.tag,liveServer:!0,clearEnd:!0,allowNew:!0,notFoundMessage:a.t("firefly.nothing_found"),noCache:!0,fetchOptions:{headers:{"X-CSRF-TOKEN":document.head.querySelector('meta[name="csrf-token"]').content}}})},150)})},init(){this.notifications.wait.show=!0,this.notifications.wait.text=a.t("firefly.wait_loading_transaction"),this.getTransactionGroup(),v().then(t=>{this.formStates.loadingCurrencies=!1,this.formData.defaultCurrency=t.defaultCurrency,this.formData.enabledCurrencies=t.enabledCurrencies,this.formData.nativeCurrencies=t.nativeCurrencies,this.formData.foreignCurrencies=t.foreignCurrencies}),A().then(t=>{this.formData.budgets=t,this.formStates.loadingBudgets=!1}),C().then(t=>{this.formData.piggyBanks=t,this.formStates.loadingPiggyBanks=!1}),S().then(t=>{this.formData.subscriptions=t,this.formStates.loadingSubscriptions=!1}),document.addEventListener("upload-success",t=>{this.processUpload(t),document.querySelectorAll("input[type=file]").value=""}),document.addEventListener("upload-error",t=>{this.processUploadError(t)}),document.addEventListener("location-move",t=>{this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude}),document.addEventListener("location-set",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].latitude=t.detail.latitude,this.entries[t.detail.index].longitude=t.detail.longitude,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel}),document.addEventListener("location-zoom",t=>{this.entries[t.detail.index].hasLocation=!0,this.entries[t.detail.index].zoomLevel=t.detail.zoomLevel})},changedAmount(t){const e=parseInt(t.target.dataset.index);this.entries[e].amount=parseFloat(t.target.value),this.groupProperties.totalAmount=0;for(let n in this.entries)this.entries.hasOwnProperty(n)&&(this.groupProperties.totalAmount=this.groupProperties.totalAmount+parseFloat(this.entries[n].amount))}}},d={transactions:L,dates:g};function h(){Object.keys(d).forEach(t=>{console.log(`Loading page component "${t}"`);let e=d[t]();Alpine.data(t,()=>e)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),h()});window.bootstrapped&&(console.log("Loaded through window variable."),h());
|