mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 12:04:00 +00:00
2 lines
11 KiB
JavaScript
Executable File
Vendored
2 lines
11 KiB
JavaScript
Executable File
Vendored
(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_number,n.current_balance=a.attributes.current_balance,n.currency_code=a.attributes.currency_code,n.balance_diff="loading",null!==a.attributes.iban&&(n.iban=a.attributes.iban.match(/.{1,4}/g).join(" ")),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),p=Object(u.a)(d,(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",{ref:"table",attrs:{id:"my-table",striped:"",hover:"","primary-key":"id",items:t.accounts,fields:t.fields,"per-page":t.perPage,"sort-icon-left":"","current-page":t.currentPage,busy:t.loading,"sort-by":t.sortBy,"sort-desc":t.sortDesc},on:{"update:busy":function(e){t.loading=e},"update:sortBy":function(e){t.sortBy=e},"update:sort-by":function(e){t.sortBy=e},"update:sortDesc":function(e){t.sortDesc=e},"update:sort-desc":function(e){t.sortDesc=e}},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 ")]):t._e()]}},{key:"cell(menu)",fn:function(e){return[a("div",{staticClass:"btn-group btn-group-sm"},[a("div",{staticClass:"dropdown"},[a("button",{staticClass:"btn btn-light btn-sm dropdown-toggle",attrs:{type:"button",id:"dropdownMenuButton"+e.item.id,"data-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false"}},[t._v("\n "+t._s(t.$t("firefly.actions"))+"\n ")]),t._v(" "),a("div",{staticClass:"dropdown-menu",attrs:{"aria-labelledby":"dropdownMenuButton"+e.item.id}},[a("a",{staticClass:"dropdown-item",attrs:{href:"./accounts/edit/"+e.item.id}},[a("i",{staticClass:"fa fas fa-pencil-alt"}),t._v(" "+t._s(t.$t("firefly.edit")))]),t._v(" "),a("a",{staticClass:"dropdown-item",attrs:{href:"./accounts/delete/"+e.item.id}},[a("i",{staticClass:"fa far fa-trash"}),t._v(" "+t._s(t.$t("firefly.delete")))]),t._v(" "),"asset"===t.type?a("a",{staticClass:"dropdown-item",attrs:{href:"./accounts/reconcile/"+e.item.id}},[a("i",{staticClass:"fas fa-check"}),t._v("\n "+t._s(t.$t("firefly.reconcile_this_account")))]):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,"1b1a9e64",null).exports,f=a(30),b=a(465),h=a(466),m=a(67),_={name:"IndexOptions",data:function(){return{type:"invalid"}},computed:{orderMode:{get:function(){return this.$store.getters["accounts/index/orderMode"]},set:function(t){this.$store.commit("accounts/index/setOrderMode",t)}}},created:function(){var t=window.location.pathname.split("/");this.type=t[t.length-1]}},y=Object(u.a)(_,(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",["asset"===t.type?a("p",[a("input",{directives:[{name:"model",rawName:"v-model",value:t.orderMode,expression:"orderMode"}],attrs:{type:"checkbox",name:"order_mode",id:"order_mode"},domProps:{checked:Array.isArray(t.orderMode)?t._i(t.orderMode,null)>-1:t.orderMode},on:{change:function(e){var a=t.orderMode,n=e.target,r=!!n.checked;if(Array.isArray(a)){var s=t._i(a,null);n.checked?s<0&&(t.orderMode=a.concat([null])):s>-1&&(t.orderMode=a.slice(0,s).concat(a.slice(s+1)))}else t.orderMode=r}}}),t._v(" "),a("label",{attrs:{for:"order_mode"}},[t._v("Enable order mode")])]):t._e()])}),[],!1,null,"37b8d409",null).exports;a(41);var v=a(43),g={};r.a.component("b-table",b.a),r.a.component("b-pagination",h.a),new r.a({i18n:v,store:f.a,el:"#accounts",render:function(t){return t(p,{props:g})},beforeCreate:function(){this.$store.commit("initialiseStore"),this.$store.dispatch("updateCurrencyPreference"),this.$store.dispatch("root/initialiseStore"),this.$store.dispatch("dashboard/index/initialiseStore")}}),new r.a({i18n:v,store:f.a,el:"#calendar",render:function(t){return t(m.a,{props:g})}}),new r.a({i18n:v,store:f.a,el:"#indexOptions",render:function(t){return t(y,{props:g})}})}},[[333,0,1]]]);
|
|
//# sourceMappingURL=index.js.map
|