2019-05-29 21:56:39 +02:00
|
|
|
|
2019-05-04 20:58:11 +02:00
|
|
|
<!--
|
|
|
|
- Budget.vue
|
|
|
|
- Copyright (c) 2019 thegrumpydictator@gmail.com
|
|
|
|
-
|
2019-10-02 06:43:38 +02:00
|
|
|
- This file is part of Firefly III (https://github.com/firefly-iii).
|
2019-05-04 20:58:11 +02:00
|
|
|
-
|
2019-10-02 06:43:38 +02:00
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
2019-05-04 20:58:11 +02:00
|
|
|
-
|
2019-10-02 06:43:38 +02:00
|
|
|
- This program is distributed in the hope that it will be useful,
|
2019-05-04 20:58:11 +02:00
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:43:38 +02:00
|
|
|
- GNU Affero General Public License for more details.
|
2019-05-04 20:58:11 +02:00
|
|
|
-
|
2019-10-02 06:43:38 +02:00
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-05-04 20:58:11 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
2019-05-24 05:29:04 +02:00
|
|
|
<div class="form-group"
|
|
|
|
v-bind:class="{ 'has-error': hasError()}"
|
2019-08-18 09:07:08 +02:00
|
|
|
v-if="typeof this.transactionType === 'undefined' || this.transactionType === 'withdrawal' || this.transactionType === 'Withdrawal' || this.transactionType === '' || null === this.transactionType">
|
2019-05-04 20:58:11 +02:00
|
|
|
<div class="col-sm-12">
|
2019-08-23 06:10:03 +02:00
|
|
|
<select name="budget[]" ref="budget" v-model="value" @input="handleInput" class="form-control"
|
2019-05-24 05:29:04 +02:00
|
|
|
v-if="this.budgets.length > 0">
|
2019-08-23 06:10:03 +02:00
|
|
|
<option v-for="cBudget in this.budgets" :label="cBudget.name" :value="cBudget.id"
|
|
|
|
|
|
|
|
>{{cBudget.name}}</option>
|
2019-05-04 20:58:11 +02:00
|
|
|
</select>
|
2019-05-24 05:29:04 +02:00
|
|
|
<ul class="list-unstyled" v-for="error in this.error">
|
|
|
|
<li class="text-danger">{{ error }}</li>
|
|
|
|
</ul>
|
2019-05-04 20:58:11 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "Budget",
|
2019-05-24 05:29:04 +02:00
|
|
|
props: ['transactionType', 'value', 'error'],
|
2019-05-04 20:58:11 +02:00
|
|
|
mounted() {
|
|
|
|
this.loadBudgets();
|
2019-09-06 16:29:52 +02:00
|
|
|
// console.log('budget value');
|
|
|
|
// console.log(this.value);
|
2019-05-04 20:58:11 +02:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
budgets: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-05-11 05:32:09 +02:00
|
|
|
handleInput(e) {
|
|
|
|
this.$emit('input', this.$refs.budget.value);
|
|
|
|
},
|
2019-05-24 05:29:04 +02:00
|
|
|
hasError: function () {
|
|
|
|
return this.error.length > 0;
|
|
|
|
},
|
2019-05-04 20:58:11 +02:00
|
|
|
loadBudgets: function () {
|
|
|
|
let URI = document.getElementsByTagName('base')[0].href + "json/budgets";
|
|
|
|
axios.get(URI, {}).then((res) => {
|
|
|
|
this.budgets = [
|
|
|
|
{
|
|
|
|
name: '(no budget)',
|
|
|
|
id: 0,
|
|
|
|
}
|
|
|
|
];
|
|
|
|
for (const key in res.data) {
|
|
|
|
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
|
|
|
this.budgets.push(res.data[key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|