mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-27 00:16:52 +00:00
2 lines
7.2 KiB
JavaScript
Executable File
Vendored
2 lines
7.2 KiB
JavaScript
Executable File
Vendored
(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{331:function(t,e,a){t.exports=a(457)},457:function(t,e,a){"use strict";a.r(e);var n=a(10),r=a.n(n),s=a(14);function c(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}function i(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?c(Object(a),!0).forEach((function(e){o(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):c(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function o(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}var l={name:"Index",props:{accountTypes:String},data:function(){return{accounts:[],type:"all",loading:!0,ready:!1,fields:[],currentPage:1,perPage:50,total:0}},watch:{datesReady:function(t){!0===t&&this.getAccountList()}},computed:i(i(i({},Object(s.d)("",["listPageSize"])),Object(s.d)("dashboard/index",["start","end"])),{},{datesReady:function(){return null!==this.start&&null!==this.end&&this.ready},cardTitle:function(){return this.$t("firefly."+this.type+"_accounts")}}),created:function(){var t=window.location.pathname.split("/");this.type=t[t.length-1];var e=new URLSearchParams(window.location.search);this.currentPage=e.get("page")?parseInt(e.get("page")):1,this.fields=[{key:"title",label:this.$t("list.name"),sortable:!0}],"asset"===this.type&&this.fields.push({key:"role",label:this.$t("list.role"),sortable:!0}),this.fields.push({key:"number",label:this.$t("list.iban"),sortable:!1}),this.fields.push({key:"current_balance",label:this.$t("list.currentBalance"),sortable:!0}),this.fields.push({key:"menu",label:" ",sortable:!1}),this.ready=!0},methods:{getAccountList:function(){this.perPage=this.listPageSize,this.accounts=[],this.downloadAccountList(1)},downloadAccountList:function(t){var e=this;console.log("Downloading page "+t),axios.get("./api/v1/accounts?type="+this.type+"&page="+t).then((function(t){var a=parseInt(t.data.meta.pagination.current_page),n=parseInt(t.data.meta.pagination.total_pages);if(e.total=parseInt(t.data.meta.pagination.total),e.parseAccounts(t.data.data),a<n){var r=a+1;e.downloadAccountList(r)}}))},roleTranslate:function(t){return null===t?"":this.$t("firefly.account_role_"+t)},parsePages:function(t){this.total=parseInt(t.pagination.total)},parseAccounts:function(t){for(var e in t)if(t.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294){var a=t[e],n={};n.id=a.id,n.title=a.attributes.name,n.role=this.roleTranslate(a.attributes.account_role),n.iban=a.attributes.iban,n.account_number=a.attributes.account_number,n.current_balance=a.attributes.current_balance,n.currency_code=a.attributes.currency_code,n.balance_diff="loading",this.accounts.push(n),"asset"===this.type&&this.getAccountBalanceDifference(this.accounts.length-1,a)}},getAccountBalanceDifference:function(t,e){var a=this,n=[];n.push(new Promise((function(a){a({account:e,index:t})}))),n.push(axios.get("./api/v1/accounts/"+e.id+"?date="+this.start.toISOString().split("T")[0])),n.push(axios.get("./api/v1/accounts/"+e.id+"?date="+this.end.toISOString().split("T")[0])),Promise.all(n).then((function(t){var e=t[0].index,n=parseFloat(t[1].data.data.attributes.current_balance),r=parseFloat(t[2].data.data.attributes.current_balance);a.accounts[e].balance_diff=r-n}))},loadAccounts:function(t){for(var e in t)if(t.hasOwnProperty(e)&&/^0$|^[1-9]\d*$/.test(e)&&e<=4294967294){var a=t[e];this.accounts.push(a)}}}},u=a(4),d=Object(u.a)(l,(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"row"},[a("div",{staticClass:"col-lg-12 col-md-12 col-sm-12 col-xs-12"},[a("b-pagination",{attrs:{"total-rows":t.total,"per-page":t.perPage,"aria-controls":"my-table"},model:{value:t.currentPage,callback:function(e){t.currentPage=e},expression:"currentPage"}})],1)]),t._v(" "),a("div",{staticClass:"row"},[a("div",{staticClass:"col-lg-12 col-md-12 col-sm-12 col-xs-12"},[a("div",{staticClass:"card"},[a("div",{staticClass:"card-header"}),t._v(" "),a("div",{staticClass:"card-body p-0"},[a("b-table",{attrs:{id:"my-table",striped:"",hover:"","primary-key":"id",items:t.accounts,fields:t.fields,"per-page":t.perPage,"current-page":t.currentPage},scopedSlots:t._u([{key:"cell(title)",fn:function(e){return[a("a",{attrs:{href:"./accounts/show/"+e.item.id,title:e.value}},[t._v(t._s(e.value))])]}},{key:"cell(number)",fn:function(e){return[null!==e.item.iban&&null===e.item.account_number?a("span",[t._v(t._s(e.item.iban))]):t._e(),t._v(" "),null===e.item.iban&&null!==e.item.account_number?a("span",[t._v(t._s(e.item.account_number))]):t._e(),t._v(" "),null!==e.item.iban&&null!==e.item.account_number?a("span",[t._v(t._s(e.item.iban)+" ("+t._s(e.item.account_number)+")")]):t._e()]}},{key:"cell(current_balance)",fn:function(e){return[parseFloat(e.item.current_balance)>0?a("span",{staticClass:"text-success"},[t._v("\n "+t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.current_balance))+"\n ")]):t._e(),t._v(" "),parseFloat(e.item.current_balance)<0?a("span",{staticClass:"text-danger"},[t._v("\n "+t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.current_balance))+"\n ")]):t._e(),t._v(" "),0===parseFloat(e.item.current_balance)?a("span",{staticClass:"text-muted"},[t._v("\n "+t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.current_balance))+"\n ")]):t._e(),t._v(" "),"asset"===t.type&&"loading"===e.item.balance_diff?a("span",[a("i",{staticClass:"fas fa-spinner fa-spin"})]):t._e(),t._v(" "),"asset"===t.type&&"loading"!==e.item.balance_diff?a("span",[t._v("\n ("),parseFloat(e.item.balance_diff)>0?a("span",{staticClass:"text-success"},[t._v(t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.balance_diff)))]):t._e(),0===parseFloat(e.item.balance_diff)?a("span",{staticClass:"text-muted"},[t._v(t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.balance_diff)))]):t._e(),parseFloat(e.item.balance_diff)<0?a("span",{staticClass:"text-danger"},[t._v(t._s(Intl.NumberFormat("en-US",{style:"currency",currency:e.item.currency_code}).format(e.item.balance_diff)))]):t._e(),t._v(")\n\n\n ")]):t._e()]}}])})],1),t._v(" "),a("div",{staticClass:"card-footer"},[a("a",{staticClass:"btn btn-success",attrs:{href:"./accounts/create/"+t.type,title:t.$t("firefly.create_new_"+t.type)}},[t._v(t._s(t.$t("firefly.create_new_"+t.type)))])])])])])])}),[],!1,null,"00cc6a9e",null).exports,p=a(34),f=a(463),b=a(464);a(41);var _=a(43),m={};r.a.component("b-table",f.a),r.a.component("b-pagination",b.a),new r.a({i18n:_,store:p.a,el:"#accounts",render:function(t){return t(d,{props:m})},beforeCreate:function(){this.$store.commit("initialiseStore"),this.$store.dispatch("updateCurrencyPreference"),this.$store.dispatch("updateListPageSizePreference"),this.$store.dispatch("dashboard/index/initialiseStore")}})}},[[331,0,1]]]);
|
|
//# sourceMappingURL=index.js.map
|