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

2 lines
11 KiB
JavaScript
Raw Normal View History

2021-03-27 10:19:22 +01:00
(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),r=a.n(n),s=a(14),i=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:[],type:"all",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.sortableOptions.disabled=!t,this.sortableOptions.onEnd=this.saveAccountSort,!0===t&&this.reorderAccountList(),null===this.sortable&&(this.sortable=i.a.create(this.$refs.table.$el.querySelector("tbody"),this.sortableOptions)),this.sortable.option("disabled",this.sortableOptions.disabled)}},computed:c(c(c(c({},Object(s.d)("root",["listPageSize"])),Object(s.d)("accounts/index",["orderMode"])),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),r=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 i=this.accounts[s];if(i.id===r){var o=parseInt(i.order)+(n-a),c="./api/v1/accounts/"+i.id;axios.put(c,{order:o}).then((function(t){e.getAccountList()}))}}},reorderAccountList:function(){this.sortBy="order",this.sortDesc=!1},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;this.indexReady&&!this.loading&&(this.loading=!0,this.perPage=null!==(t=this.listPageSize)&&void 0!==t?t:51,this.accounts=[],this.downloadAccountList(1))},downloadAccountList:function(t){var e=this;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)}else e.loading=!1}))},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=parseInt(a.id),n.order=a.attributes.order,n.title=a.attributes.name,n.role=this.roleTranslate(a.attributes.account_role),n.account_number=a.attributes.account
2020-10-17 07:02:18 +02:00
//# sourceMappingURL=index.js.map