mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
2 lines
1.9 KiB
JavaScript
2 lines
1.9 KiB
JavaScript
import{d as c,f as d}from"./format-money-0f129d93.js";import{f as p,i as n}from"./vendor-baac879b.js";import{G as f}from"./get-851d8544.js";let g=function(){return{notifications:{error:{show:!1,text:"",url:""},success:{show:!1,text:"",url:""},wait:{show:!1,text:""}},transactions:[],totalPages:1,perPage:50,page:1,tableColumns:{description:{enabled:!0},source:{enabled:!0},destination:{enabled:!0},amount:{enabled:!0}},formatMoney(t,i){return d(t,i)},format(t){return p(t,n.t("config.date_time_fns"))},init(){this.notifications.wait.show=!0,this.notifications.wait.text=n.t("firefly.wait_loading_data"),this.getTransactions(this.page)},getTransactions(t){const i=window.location.href.split("/"),a=i[i.length-1];new f().list({page:t,type:a}).then(s=>{this.parseTransactions(s.data.data),this.totalPages=s.data.meta.pagination.total_pages,this.perPage=s.data.meta.pagination.per_page,this.page=s.data.meta.pagination.current_page}).catch(s=>{this.notifications.wait.show=!1,this.notifications.error.show=!0,this.notifications.error.text=s.response.data.message})},parseTransactions(t){for(let i in t)if(t.hasOwnProperty(i)){let a=t[i],o=a.attributes.transactions.length>1,s=!0;for(let r in a.attributes.transactions)if(a.attributes.transactions.hasOwnProperty(r)){let e=a.attributes.transactions[r];e.split=o,e.firstSplit=s,e.group_title=a.attributes.group_title,e.id=a.id,e.created_at=a.attributes.created_at,e.updated_at=a.attributes.updated_at,e.user=a.attributes.user,e.user_group=a.attributes.user_group,s=!1,console.log(e),this.transactions.push(e)}}this.notifications.wait.show=!1}}},l={index:g,dates:c};function u(){Object.keys(l).forEach(t=>{console.log(`Loading page component "${t}"`);let i=l[t]();Alpine.data(t,()=>i)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),u()});window.bootstrapped&&(console.log("Loaded through window variable."),u());
|