More auto-complete migration.

This commit is contained in:
James Cole
2020-07-19 17:24:29 +02:00
parent fd6f1fbbf0
commit 8a4999406b
16 changed files with 248 additions and 229 deletions

View File

@@ -27,17 +27,17 @@
{{ $t('firefly.budget') }}
</div>
<div class="col-sm-12">
<select
name="budget[]"
ref="budget"
v-model="selected"
<select
name="budget[]"
ref="budget"
v-model="selected"
@input="handleInput"
v-on:change="signalChange"
v-on:change="signalChange"
:title="$t('firefly.budget')"
class="form-control"
v-if="this.budgets.length > 0">
<option v-for="cBudget in this.budgets"
:label="cBudget.name"
<option v-for="cBudget in this.budgets"
:label="cBudget.name"
:value="cBudget.id">{{cBudget.name}}
</option>
</select>
@@ -53,9 +53,9 @@
export default {
name: "Budget",
props: {
transactionType: String,
transactionType: String,
value: {
type: [String, Number],
type: [String, Number],
default: 0
},
error: Array,
@@ -82,7 +82,7 @@
return this.error.length > 0;
},
loadBudgets: function () {
let URI = document.getElementsByTagName('base')[0].href + "json/budgets";
let URI = document.getElementsByTagName('base')[0].href + 'api/v1/autocomplete/budgets';
axios.get(URI, {}).then((res) => {
this.budgets = [
{
@@ -103,4 +103,4 @@
<style scoped>
</style>
</style>

View File

@@ -85,7 +85,7 @@
},
mounted() {
this.target = this.$refs.input;
this.categoryAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/categories?search=";
this.categoryAutoCompleteURI = document.getElementsByTagName('base')[0].href + "api/v1/autocomplete/categories?query=";
},
methods: {
hasError: function () {
@@ -133,4 +133,4 @@
<style scoped>
</style>
</style>

View File

@@ -307,21 +307,7 @@
},
deleteTransaction(index, event) {
event.preventDefault();
for (const key in this.transactions) {
if (
this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// TODO empty iff?
}
}
this.transactions.splice(index, 1);
for (const key in this.transactions) {
if (
this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// TODO empty iff?
}
}
},
clearDestination(index) {
// console.log('clearDestination(' + index + ')');
@@ -380,6 +366,12 @@
}
},
ucFirst(string) {
if (typeof string === 'string') {
return string.charAt(0).toUpperCase() + string.slice(1);
}
return null;
},
processIncomingGroupRow(transaction) {
// console.log(transaction);
this.setTransactionType(transaction.type);
@@ -390,6 +382,11 @@
newTags.push({text: transaction.tags[key], tiClasses: []});
}
}
console.log('source allowed types for a ' + transaction.type);
//console.log(window.expectedSourceTypes.source[transaction.type]);
console.log(window.expectedSourceTypes.source[this.ucFirst(transaction.type)]);
console.log('destination allowed types for a ' + transaction.type);
console.log(window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]);
this.transactions.push({
transaction_journal_id: transaction.transaction_journal_id,
@@ -445,7 +442,7 @@
currency_name: transaction.currency_name,
currency_code: transaction.currency_code,
currency_decimal_places: transaction.currency_decimal_places,
allowed_types: [transaction.source_type]
allowed_types: window.expectedSourceTypes.source[this.ucFirst(transaction.type)]
},
destination_account: {
id: transaction.destination_id,
@@ -455,10 +452,22 @@
currency_name: transaction.currency_name,
currency_code: transaction.currency_code,
currency_decimal_places: transaction.currency_decimal_places,
allowed_types: [transaction.destination_type]
allowed_types: window.expectedSourceTypes.destination[this.ucFirst(transaction.type)]
}
});
},
limitSourceType: function (type) {
// let i;
// for (i = 0; i < this.transactions.length; i++) {
// this.transactions[i].source_account.allowed_types = [type];
// }
},
limitDestinationType: function (type) {
// let i;
// for (i = 0; i < this.transactions.length; i++) {
// this.transactions[i].destination_account.allowed_types = [type];
// }
},
convertData: function () {
let data = {
'transactions': [],