Fix some v2 issues.

This commit is contained in:
James Cole 2021-10-30 17:06:40 +02:00
parent 1401282aa0
commit 51b5b3a846
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5
8 changed files with 776 additions and 729 deletions

View File

@ -30,7 +30,6 @@
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-success" role="progressbar"> aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-success" role="progressbar">
<span v-if="budgetLimit.pctGreen > 35"> <span v-if="budgetLimit.pctGreen > 35">
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }} {{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
<!-- -->
</span> </span>
@ -45,7 +44,7 @@
<div :aria-valuenow="budgetLimit.pctRed" :style="'width: '+ budgetLimit.pctRed + '%;'" <div :aria-valuenow="budgetLimit.pctRed" :style="'width: '+ budgetLimit.pctRed + '%;'"
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-danger" role="progressbar"> aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-danger" role="progressbar">
<span v-if="budgetLimit.pctOrange <= 50 && budgetLimit.pctRed > 35" class="text-muted"> <span v-if="budgetLimit.pctOrange <= 50 && budgetLimit.pctRed > 35" class="text-white">
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }} {{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
</span> </span>
</div> </div>

View File

@ -24,6 +24,7 @@
<td style="width:25%;"> <td style="width:25%;">
<a :href="'./budgets/show/' + budget.id">{{ budget.name }}</a> <a :href="'./budgets/show/' + budget.id">{{ budget.name }}</a>
</td> </td>
<td>&nbsp;</td>
<td class="align-middle text-right"> <td class="align-middle text-right">
<span class="text-danger"> <span class="text-danger">
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budget.currency_code}).format(parseFloat(budget.spent)) }} {{ Intl.NumberFormat(locale, {style: 'currency', currency: budget.currency_code}).format(parseFloat(budget.spent)) }}

View File

@ -214,8 +214,8 @@ export default {
let pctGreen = 0; let pctGreen = 0;
let pctOrange = 0; let pctOrange = 0;
let pctRed = 0; let pctRed = 0;
//console.log('Collected "' + period + '" budget limit #' + currentId + ' (part of budget #' + budgetId + ')'); console.log('Collected "' + period + '" budget limit #' + currentId + ' (part of budget #' + budgetId + ')');
//console.log('Spent ' + spentFloat + ' of ' + amount); console.log('Spent ' + spentFloatPos + ' of ' + amount);
// remove budget info from rawBudgets if it's there: // remove budget info from rawBudgets if it's there:
this.filterBudgets(budgetId, currencyId); this.filterBudgets(budgetId, currencyId);
@ -230,6 +230,12 @@ export default {
pctOrange = (spentFloatPos / amount) * 100; pctOrange = (spentFloatPos / amount) * 100;
pctRed = 100 - pctOrange; pctRed = 100 - pctOrange;
} }
// spent exactly on budget
if (0.0 !== spentFloatPos && spentFloatPos === amount) {
pctOrange = 0;
pctRed = 100;
}
let obj = { let obj = {
id: currentId, id: currentId,
amount: current.attributes.amount, amount: current.attributes.amount,

View File

@ -31,6 +31,7 @@
:count="transactions.length" :count="transactions.length"
:custom-fields="customFields" :custom-fields="customFields"
:date="date" :date="date"
ref="splitForms"
:destination-allowed-types="destinationAllowedTypes" :destination-allowed-types="destinationAllowedTypes"
:index="index" :index="index"
:source-allowed-types="sourceAllowedTypes" :source-allowed-types="sourceAllowedTypes"
@ -433,6 +434,12 @@ export default {
this.updateField({index: payload.index, field: payload.direction + '_account_currency_symbol', value: payload.currency_symbol}); this.updateField({index: payload.index, field: payload.direction + '_account_currency_symbol', value: payload.currency_symbol});
//this.calculateTransactionType(payload.index); //this.calculateTransactionType(payload.index);
if('source' === payload.direction && true === payload.user_selected) {
this.$refs.splitForms[payload.index].$refs.destinationAccount.giveFocus();
}
if('destination' === payload.direction && true === payload.user_selected) {
this.$refs.splitForms[payload.index].$refs.amount.giveFocus();
}
}, },
storeField: function (payload) { storeField: function (payload) {
this.updateField(payload); this.updateField(payload);

View File

@ -58,6 +58,8 @@
:source-allowed-types="sourceAllowedTypes" :source-allowed-types="sourceAllowedTypes"
:transaction-type="transactionType" :transaction-type="transactionType"
direction="source" direction="source"
ref="sourceAccount"
v-on:selected-account="triggerNextAccount($event)"
/> />
</div> </div>
<!-- switcharoo! --> <!-- switcharoo! -->
@ -79,6 +81,7 @@
:destination-allowed-types="destinationAllowedTypes" :destination-allowed-types="destinationAllowedTypes"
:errors="transaction.errors.destination" :errors="transaction.errors.destination"
:index="index" :index="index"
ref="destinationAccount"
:transaction-type="transactionType" :transaction-type="transactionType"
:source-allowed-types="sourceAllowedTypes" :source-allowed-types="sourceAllowedTypes"
direction="destination" direction="destination"
@ -93,6 +96,7 @@
<!-- AMOUNT --> <!-- AMOUNT -->
<TransactionAmount <TransactionAmount
v-on="$listeners" v-on="$listeners"
ref="amount"
:amount="transaction.amount" :amount="transaction.amount"
:destination-currency-symbol="this.transaction.destination_account_currency_symbol" :destination-currency-symbol="this.transaction.destination_account_currency_symbol"
:errors="transaction.errors.amount" :errors="transaction.errors.amount"
@ -379,6 +383,13 @@ export default {
// console.log('Will remove transaction ' + this.index); // console.log('Will remove transaction ' + this.index);
this.$emit('remove-transaction', {index: this.index}); this.$emit('remove-transaction', {index: this.index});
}, },
triggerNextAccount: function(e) {
//alert(e);
if('source' === e) {
console.log('Jump to destination!');
this.$refs.destinationAccount.giveFocus();
}
}
}, },
computed: { computed: {
splitDate: function () { splitDate: function () {

View File

@ -37,6 +37,7 @@
:placeholder="$t('firefly.' + direction + '_account')" :placeholder="$t('firefly.' + direction + '_account')"
:serializer="item => item.name_with_balance" :serializer="item => item.name_with_balance"
:showOnFocus=true :showOnFocus=true
ref="inputThing"
aria-autocomplete="none" aria-autocomplete="none"
autocomplete="off" autocomplete="off"
@hit="userSelectedAccount" @hit="userSelectedAccount"
@ -119,6 +120,12 @@ export default {
getACURL: function (types, query) { getACURL: function (types, query) {
return './api/v1/autocomplete/accounts?types=' + types.join(',') + '&query=' + query; return './api/v1/autocomplete/accounts?types=' + types.join(',') + '&query=' + query;
}, },
giveFocus: function() {
console.log('I want focus! now OK: ' + this.direction + ' l: ' + this.accounts.length);
//console.log(this.$refs.inputThing.$refs.input.value);
this.$refs.inputThing.$refs.input.focus();
console.log(this.$refs.inputThing.isFocused);
},
userSelectedAccount: function (event) { userSelectedAccount: function (event) {
// console.log('userSelectedAccount!'); // console.log('userSelectedAccount!');
// console.log('To prevent invalid propogation, set selectedAccountTrigger = true'); // console.log('To prevent invalid propogation, set selectedAccountTrigger = true');
@ -205,10 +212,14 @@ export default {
currency_id: value.currency_id, currency_id: value.currency_id,
currency_code: value.currency_code, currency_code: value.currency_code,
currency_symbol: value.currency_symbol, currency_symbol: value.currency_symbol,
user_selected: true,
} }
// jump to next field somehow.
); );
//console.log('watch::selectedAccount() will now set accountName because selectedAccountTrigger = true'); //console.log('watch::selectedAccount() will now set accountName because selectedAccountTrigger = true');
this.accountName = value.name; this.accountName = value.name;
} }
if (false === this.selectedAccountTrigger) { if (false === this.selectedAccountTrigger) {
//console.log('watch::selectedAccount() will NOT set accountName because selectedAccountTrigger = false'); //console.log('watch::selectedAccount() will NOT set accountName because selectedAccountTrigger = false');
@ -238,6 +249,7 @@ export default {
currency_id: null, currency_id: null,
currency_code: null, currency_code: null,
currency_symbol: null, currency_symbol: null,
user_selected: false
} }
); );
// this.account = {name: value, type: null, id: null, currency_id: null, currency_code: null, currency_symbol: null}; // this.account = {name: value, type: null, id: null, currency_id: null, currency_code: null, currency_symbol: null};

View File

@ -33,6 +33,7 @@
autocomplete="off" autocomplete="off"
name="amount[]" name="amount[]"
type="number" type="number"
ref="input"
step="any" step="any"
> >
</div> </div>
@ -71,7 +72,10 @@ export default {
methods: { methods: {
formatNumber(str) { formatNumber(str) {
return parseFloat(str).toFixed(this.fractionDigits); return parseFloat(str).toFixed(this.fractionDigits);
} },
giveFocus: function() {
this.$refs.input.focus();
},
}, },
data() { data() {
return { return {

File diff suppressed because it is too large Load Diff