Files
firefly-iii/public/v2/js/accounts/index.js

2 lines
14 KiB
JavaScript
Raw Normal View History

(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{333:function(t,e,a){t.exports=a(458)},458:function(t,e,a){"use strict";a.r(e);var n=a(8),i=a.n(n),s=a(14),r=a(267);function o(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 c(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?o(Object(a),!0).forEach((function(e){l(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function l(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}var d={name:"Index",props:{accountTypes:String},data:function(){return{accounts:[],allAccounts:[],type:"all",downloaded:!1,loading:!1,ready:!1,fields:[],currentPage:1,perPage:5,total:0,sortBy:"order",sortDesc:!1,sortableOptions:{disabled:!1,chosenClass:"is-selected",onEnd:null},sortable:null}},watch:{storeReady:function(){this.getAccountList()},start:function(){this.getAccountList()},end:function(){this.getAccountList()},orderMode:function(t){this.updateFieldList(),this.reorderAccountList(t),this.makeTableSortable(t)},activeFilter:function(t){this.filterAccountList()}},computed:c(c(c(c({},Object(s.d)("root",["listPageSize"])),Object(s.d)("accounts/index",["orderMode","activeFilter"])),Object(s.d)("dashboard/index",["start","end"])),{},{indexReady:function(){return null!==this.start&&null!==this.end&&null!==this.listPageSize&&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.updateFieldList(),this.ready=!0},methods:{saveAccountSort:function(t){var e=this,a=parseInt(t.oldIndex),n=parseInt(t.newIndex),i=parseInt(t.item.attributes.getNamedItem("data-pk").value);for(var s in this.accounts)if(this.accounts.hasOwnProperty(s)&&/^0$|^[1-9]\d*$/.test(s)&&s<=4294967294){var r=this.accounts[s];if(r.id===i){var o=parseInt(r.order)+(n-a);this.accounts[s].order=o;var c="./api/v1/accounts/"+r.id;axios.put(c,{order:o}).then((function(t){e.getAccountList()}))}}},reorderAccountList:function(t){t&&(this.sortBy="order",this.sortDesc=!1)},makeTableSortable:function(t){this.sortableOptions.disabled=!t,this.sortableOptions.onEnd=this.saveAccountSort,null===this.sortable&&(this.sortable=r.a.create(this.$refs.table.$el.querySelector("tbody"),this.sortableOptions)),this.sortable.option("disabled",this.sortableOptions.disabled)},updateFieldList:function(){this.fields=[],this.fields=[{key:"title",label:this.$t("list.name"),sortable:!this.orderMode}],"asset"===this.type&&this.fields.push({key:"role",label:this.$t("list.role"),sortable:!this.orderMode}),this.fields.push({key:"number",label:this.$t("list.iban"),sortable:!this.orderMode}),this.fields.push({key:"current_balance",label:this.$t("list.currentBalance"),sortable:!this.orderMode}),this.fields.push({key:"menu",label:" ",sortable:!1})},getAccountList:function(){var t;(console.log("getAccountList()"),!this.indexReady||this.loading||this.downloaded)||(console.log("Index ready, not loading and not already downloaded. Reset."),this.loading=!0,this.perPage=null!==(t=this.listPageSize)&&void 0!==t?t:51,this.accounts=[],this.allAccounts=[],this.downloadAccountList(1));this.indexReady&&!this.loading&&this.downloaded&&(console.log("Index ready, not loading and not downloaded."),this.loading=!0,this.filterAccountList())},downloadAccountList:function(t){var e=this;console.log("downloadAccountList("+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
2020-10-17 07:02:18 +02:00
//# sourceMappingURL=index.js.map