Update frontend.

This commit is contained in:
James Cole
2021-02-15 20:32:29 +01:00
parent 0ac0dbc774
commit 5e7c57744c
42 changed files with 275 additions and 99 deletions

View File

@@ -55,7 +55,8 @@ const state = () => ({
piggy_bank: [],
internal_reference: [],
external_url: [],
notes: []
notes: [],
location: []
},
defaultTransaction: {
// basic

View File

@@ -22,7 +22,7 @@
<div>
<alert :message="errorMessage" type="danger"/>
<alert :message="successMessage" type="success"/>
<SplitPills :transactions="transactions" />
<SplitPills :transactions="transactions"/>
<div class="tab-content">
<SplitForm
v-for="(transaction, index) in this.transactions"
@@ -30,6 +30,7 @@
:transaction="transaction"
:index="index"
:count="transactions.length"
:custom-fields="customFields"
:submitted-transaction="submittedTransaction"
v-on:uploaded-attachments="uploadedAttachment($event)"
/>
@@ -116,7 +117,7 @@ export default {
created() {
this.storeAllowedOpposingTypes();
this.storeAccountToTransaction();
this.storeCustomDateFields();
this.storeCustomFields();
this.addTransaction();
},
data() {
@@ -125,6 +126,9 @@ export default {
errorMessage: '',
successMessage: '',
// custom fields, useful for components:
customFields: [],
// states for the form (makes sense right)
enableSubmit: true,
createAnother: false,
@@ -155,7 +159,6 @@ export default {
...mapGetters([
'transactionType',
'transactions',
'customDateFields',
'date',
'groupTitle'
])
@@ -203,27 +206,9 @@ export default {
* it should be done via the create.js Vue store because multiple components are interested in the
* user's custom transaction fields.
*/
storeCustomDateFields: function () {
storeCustomFields: function () {
axios.get('./api/v1/preferences/transaction_journal_optional_fields').then(response => {
let fields = response.data.data.attributes.data;
let allDateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
let selectedDateFields = {
interest_date: false,
book_date: false,
process_date: false,
due_date: false,
payment_date: false,
invoice_date: false,
};
for (let key in fields) {
if (fields.hasOwnProperty(key)) {
if (-1 !== allDateFields.indexOf(key)) {
selectedDateFields[key] = fields[key];
}
}
}
// see we already store it in the store, so this would be an easy change.
this.$store.commit('transactions/create/setCustomDateFields', selectedDateFields);
this.customFields = response.data.data.attributes.data;
});
},
/**

View File

@@ -100,6 +100,7 @@
<div class="col-xl-5 col-lg-5 col-md-12 col-sm-12 col-xs-12 offset-xl-2 offset-lg-2">
<TransactionCustomDates
:index="index"
:custom-fields.sync="customFields"
:errors="transaction.errors.custom_dates"
/>
</div>
@@ -164,12 +165,12 @@
</div>
<!-- end card for meta -->
<!-- card for extra -->
<div class="row">
<div class="row" v-if="hasMetaFields">
<div class="col">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ $t('firefly.transaction_journal_meta') }}
{{ $t('firefly.transaction_journal_extra') }}
<span v-if="count > 1">({{ index + 1 }} / {{ count }}) </span>
</h3>
</div>
@@ -182,17 +183,20 @@
:index="index"
v-model="transaction.internal_reference"
:errors="transaction.errors.internal_reference"
:custom-fields.sync="customFields"
/>
<TransactionExternalUrl
:index="index"
v-model="transaction.external_url"
:errors="transaction.errors.external_url"
:custom-fields.sync="customFields"
/>
<TransactionNotes
:index="index"
v-model="transaction.notes"
:errors="transaction.errors.notes"
:custom-fields.sync="customFields"
/>
</div>
<div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12">
@@ -204,9 +208,20 @@
:transaction_journal_id="transaction.transaction_journal_id"
:submitted_transaction="submittedTransaction"
v-model="transaction.attachments"
:custom-fields.sync="customFields"
/>
<TransactionLocation
:index="index"
v-model="transaction.notes"
:errors="transaction.errors.location"
:custom-fields.sync="customFields"
/>
<TransactionLinks :index="index" v-model="transaction.links" />
<TransactionLinks
:index="index"
v-model="transaction.links"
:custom-fields.sync="customFields"
/>
</div>
</div>
@@ -242,6 +257,7 @@ import TransactionLinks from "./TransactionLinks";
import TransactionAttachments from "./TransactionAttachments";
import SplitPills from "./SplitPills";
import {createNamespacedHelpers} from "vuex";
import TransactionLocation from "./TransactionLocation";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
@@ -251,13 +267,35 @@ export default {
'transaction',
'split',
'count',
'customFields', // for custom transaction form fields.
'index',
'submittedTransaction' // need to know if transaction is submitted.
],
computed: {
...mapGetters(['transactionType',])
...mapGetters(['transactionType',]),
hasMetaFields: function () {
let requiredFields = [
'internal_reference',
'notes',
'attachments',
'external_uri',
'location',
'links',
];
for (let field in this.customFields) {
if (this.customFields.hasOwnProperty(field)) {
if (requiredFields.includes(field)) {
if (true === this.customFields[field]) {
return true;
}
}
}
}
return false;
}
},
components: {
TransactionLocation,
SplitPills,
TransactionAttachments,
TransactionNotes,

View File

@@ -19,7 +19,7 @@
-->
<template>
<div class="form-group">
<div class="form-group" v-if="showField">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.attachments') }}
</div>
@@ -38,16 +38,35 @@
<script>
export default {
name: "TransactionAttachments",
props: ['transaction_journal_id'],
props: ['transaction_journal_id', 'customFields'],
data() {
return {
availableFields: this.customFields
}
},
watch: {
customFields: function (value) {
this.availableFields = value;
},
transaction_journal_id: function (value) {
console.log('transaction_journal_id changed to ' + value);
if (!this.showField) {
return;
}
// console.log('transaction_journal_id changed to ' + value);
// do upload!
if (0 !== value) {
this.doUpload();
}
}
},
computed: {
showField: function () {
if ('attachments' in this.availableFields) {
return this.availableFields.attachments;
}
return false;
}
},
methods: {
doUpload: function () {
console.log('Now in doUpload() for ' + this.$refs.att.files.length + ' files.');

View File

@@ -20,11 +20,11 @@
<template>
<div>
<div class="form-group" v-for="(enabled, name) in enabledDates">
<div class="text-xs d-none d-lg-block d-xl-block" v-if="enabled">
<div class="form-group" v-for="(enabled, name) in availableFields">
<div class="text-xs d-none d-lg-block d-xl-block" v-if="enabled && isDateField(name)">
{{ $t('form.' + name) }}
</div>
<div class="input-group" v-if="enabled">
<div class="input-group" v-if="enabled && isDateField(name)">
<input
class="form-control"
type="date"
@@ -44,52 +44,37 @@
<script>
// TODO: error handling
// TODO dont use store?
import {createNamespacedHelpers} from "vuex";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
export default {
name: "TransactionCustomDates",
props: ['index', 'errors'],
props: ['index', 'errors', 'customFields'],
data() {
return {
enabledDates: {},
dateFields: ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'],
availableFields: this.customFields
}
},
created() {
this.getCustomDates();
watch: {
customFields: function(value) {
this.availableFields = value;
}
},
methods: {
...mapGetters(['transactions']),
...mapMutations(['updateField',],
),
isDateField: function (name) {
return this.dateFields.includes(name)
},
getFieldValue(field) {
return this.transactions()[parseInt(this.index)][field] ?? '';
},
setFieldValue(event, field) {
this.updateField({index: this.index, field: field, value: event.target.value});
},
getCustomDates: function () {
axios.get('./api/v1/preferences/transaction_journal_optional_fields').then(response => {
let fields = response.data.data.attributes.data;
let allDateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
let selectedDateFields = {
interest_date: false,
book_date: false,
process_date: false,
due_date: false,
payment_date: false,
invoice_date: false,
};
for (let key in fields) {
if (fields.hasOwnProperty(key)) {
if (-1 !== allDateFields.indexOf(key)) {
selectedDateFields[key] = fields[key];
}
}
}
this.enabledDates = selectedDateFields;
});
},
}
}
</script>

View File

@@ -19,7 +19,7 @@
-->
<template>
<div class="form-group">
<div class="form-group" v-if="showField">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.external_url') }}
</div>
@@ -44,11 +44,20 @@ import {createNamespacedHelpers} from "vuex";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
export default {
props: ['index', 'value', 'errors'],
props: ['index', 'value', 'errors', 'customFields'],
name: "TransactionExternalUrl",
data() {
return {
url: this.value
url: this.value,
availableFields: this.customFields
}
},
computed: {
showField: function () {
if ('external_uri' in this.availableFields) {
return this.availableFields.external_uri;
}
return false;
}
},
methods: {
@@ -59,6 +68,9 @@ export default {
),
},
watch: {
customFields: function (value) {
this.availableFields = value;
},
url: function (value) {
this.updateField({field: 'external_url', index: this.index, value: value});
}

View File

@@ -19,7 +19,7 @@
-->
<template>
<div class="form-group">
<div class="form-group" v-if="showField">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.internal_reference') }}
</div>
@@ -44,11 +44,20 @@ import {createNamespacedHelpers} from "vuex";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
export default {
props: ['index', 'value', 'errors'],
props: ['index', 'value', 'errors', 'customFields'],
name: "TransactionInternalReference",
data() {
return {
reference: this.value
reference: this.value,
availableFields: this.customFields
}
},
computed: {
showField: function () {
if ('internal_reference' in this.availableFields) {
return this.availableFields.internal_reference;
}
return false;
}
},
methods: {
@@ -59,6 +68,9 @@ export default {
),
},
watch: {
customFields: function (value) {
this.availableFields = value;
},
reference: function (value) {
this.updateField({field: 'internal_reference', index: this.index, value: value});
}

View File

@@ -19,7 +19,7 @@
-->
<template>
<div>
<div v-if="showField">
<div class="form-group">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.journal_links') }}
@@ -191,7 +191,7 @@ const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers
const lodashClonedeep = require('lodash.clonedeep');
// TODO error handling
export default {
props: ['index', 'value', 'errors'],
props: ['index', 'value', 'errors', 'customFields'],
name: "TransactionLinks",
data() {
return {
@@ -202,6 +202,7 @@ export default {
query: '',
searching: false,
links: [],
availableFields: this.customFields
}
},
created() {
@@ -209,9 +210,20 @@ export default {
this.links = lodashClonedeep(this.value);
this.getLinkTypes();
},
computed: {
showField: function () {
if ('links' in this.availableFields) {
return this.availableFields.links;
}
return false;
}
},
watch: {
links: function (value) {
this.updateField({index: this.index, field: 'links', value: lodashClonedeep(value)});
},
customFields: function (value) {
this.availableFields = value;
}
},
methods: {

View File

@@ -0,0 +1,59 @@
<!--
- TransactionLocation.vue
- Copyright (c) 2021 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- 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/>.
-->
<template>
<div class="form-group" v-if="showField">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.location') }}
</div>
<div class="input-group">
(TODO)
</div>
</div>
</template>
<script>
export default {
name: "TransactionLocation",
props: ['index', 'value', 'errors', 'customFields'],
data() {
return {
availableFields: this.customFields
}
},
computed: {
showField: function () {
if ('location' in this.availableFields) {
return this.availableFields.location;
}
return false;
}
},
watch: {
customFields: function (value) {
this.availableFields = value;
},
}
}
</script>
<style scoped>
</style>

View File

@@ -20,7 +20,7 @@
<template>
<div class="form-group">
<div class="form-group" v-if="showField">
<div class="text-xs d-none d-lg-block d-xl-block">
{{ $t('firefly.notes') }}
</div>
@@ -41,11 +41,20 @@ import {createNamespacedHelpers} from "vuex";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
export default {
props: ['index', 'value', 'errors'],
props: ['index', 'value', 'errors', 'customFields'],
name: "TransactionNotes",
data() {
return {
notes: this.value
notes: this.value,
availableFields: this.customFields
}
},
computed: {
showField: function () {
if ('notes' in this.availableFields) {
return this.availableFields.notes;
}
return false;
}
},
methods: {
@@ -56,6 +65,9 @@ export default {
),
},
watch: {
customFields: function (value) {
this.availableFields = value;
},
notes: function (value) {
this.updateField({field: 'notes', index: this.index, value: value});
}

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "\u041c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435",
"other_budgets": "\u0412\u0440\u0435\u043c\u0435\u0432\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0430\u043d\u0438 \u0431\u044e\u0434\u0436\u0435\u0442\u0438",
"journal_links": "\u0412\u0440\u044a\u0437\u043a\u0438 \u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f",
"go_to_withdrawals": "\u0412\u0438\u0436\u0442\u0435 \u0442\u0435\u0433\u043b\u0435\u043d\u0438\u044f\u0442\u0430 \u0441\u0438",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Um\u00edst\u011bn\u00ed",
"other_budgets": "Custom timed budgets",
"journal_links": "Transaction links",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Standort",
"other_budgets": "Zeitlich befristete Budgets",
"journal_links": "Buchungsverkn\u00fcpfungen",
"go_to_withdrawals": "Ausgaben anzeigen",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "\u03a4\u03bf\u03c0\u03bf\u03b8\u03b5\u03c3\u03af\u03b1",
"other_budgets": "\u03a0\u03c1\u03bf\u03cb\u03c0\u03bf\u03bb\u03bf\u03b3\u03b9\u03c3\u03bc\u03bf\u03af \u03bc\u03b5 \u03c7\u03c1\u03bf\u03bd\u03b9\u03ba\u03ae \u03c0\u03c1\u03bf\u03c3\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae",
"journal_links": "\u03a3\u03c5\u03bd\u03b4\u03ad\u03c3\u03b5\u03b9\u03c2 \u03c3\u03c5\u03bd\u03b1\u03bb\u03bb\u03b1\u03b3\u03ce\u03bd",
"go_to_withdrawals": "\u03a0\u03b7\u03b3\u03b1\u03af\u03bd\u03b5\u03c4\u03b5 \u03c3\u03c4\u03b9\u03c2 \u03b1\u03bd\u03b1\u03bb\u03ae\u03c8\u03b5\u03b9\u03c2 \u03c3\u03b1\u03c2",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Location",
"other_budgets": "Custom timed budgets",
"journal_links": "Transaction links",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Location",
"other_budgets": "Custom timed budgets",
"journal_links": "Transaction links",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Ubicaci\u00f3n",
"other_budgets": "Presupuestos de tiempo personalizado",
"journal_links": "Enlaces de transacciones",
"go_to_withdrawals": "Ir a tus retiradas",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Sijainti",
"other_budgets": "Custom timed budgets",
"journal_links": "Tapahtuman linkit",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Emplacement",
"other_budgets": "Budgets \u00e0 p\u00e9riode personnalis\u00e9e",
"journal_links": "Liens d'op\u00e9ration",
"go_to_withdrawals": "Acc\u00e9der \u00e0 vos retraits",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Hely",
"other_budgets": "Custom timed budgets",
"journal_links": "Tranzakci\u00f3 \u00f6sszekapcsol\u00e1sok",
"go_to_withdrawals": "Ugr\u00e1s a k\u00f6lts\u00e9gekhez",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Posizione",
"other_budgets": "Budget a periodi personalizzati",
"journal_links": "Collegamenti della transazione",
"go_to_withdrawals": "Vai ai tuoi prelievi",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Sted",
"other_budgets": "Custom timed budgets",
"journal_links": "Transaksjonskoblinger",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Plaats",
"other_budgets": "Aangepaste budgetten",
"journal_links": "Transactiekoppelingen",
"go_to_withdrawals": "Ga naar je uitgaven",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Lokalizacja",
"other_budgets": "Bud\u017cety niestandardowe",
"journal_links": "Powi\u0105zane transakcje",
"go_to_withdrawals": "Przejd\u017a do swoich wydatk\u00f3w",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Localiza\u00e7\u00e3o",
"other_budgets": "Custom timed budgets",
"journal_links": "Transa\u00e7\u00f5es ligadas",
"go_to_withdrawals": "V\u00e1 para seus saques",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Localiza\u00e7\u00e3o",
"other_budgets": "Or\u00e7amentos de tempo personalizado",
"journal_links": "Liga\u00e7\u00f5es de transac\u00e7\u00e3o",
"go_to_withdrawals": "Ir para os seus levantamentos",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Loca\u021bie",
"other_budgets": "Custom timed budgets",
"journal_links": "Link-uri de tranzac\u021bii",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "\u0420\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435",
"other_budgets": "\u0411\u044e\u0434\u0436\u0435\u0442\u044b \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438",
"journal_links": "\u0421\u0432\u044f\u0437\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438",
"go_to_withdrawals": "\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0432\u0430\u0448\u0438\u043c \u0440\u0430\u0441\u0445\u043e\u0434\u0430\u043c",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Poloha",
"other_budgets": "\u0160pecifick\u00e9 \u010dasovan\u00e9 rozpo\u010dty",
"journal_links": "Prepojenia transakcie",
"go_to_withdrawals": "Zobrazi\u0165 v\u00fdbery",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "Plats",
"other_budgets": "Anpassade tidsinst\u00e4llda budgetar",
"journal_links": "Transaktionsl\u00e4nkar",
"go_to_withdrawals": "G\u00e5 till dina uttag",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "V\u1ecb tr\u00ed",
"other_budgets": "Custom timed budgets",
"journal_links": "Li\u00ean k\u1ebft giao d\u1ecbch",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "\u4f4d\u7f6e",
"other_budgets": "Custom timed budgets",
"journal_links": "\u4ea4\u6613\u8fde\u7ed3",
"go_to_withdrawals": "Go to your withdrawals",

View File

@@ -79,6 +79,7 @@
"custom_period": "Custom period",
"reset_to_current": "Reset to current period",
"select_period": "Select a period",
"location": "\u4f4d\u7f6e",
"other_budgets": "Custom timed budgets",
"journal_links": "\u4ea4\u6613\u9023\u7d50",
"go_to_withdrawals": "Go to your withdrawals",