Expand edit form.

This commit is contained in:
James Cole 2024-01-06 17:24:54 +01:00
parent f615b9c252
commit 4c30a7bc55
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
8 changed files with 52 additions and 30 deletions

View File

@ -106,7 +106,7 @@ class EditController extends Controller
$optionalFields['location'] ??= false;
$optionalFields['location'] = $optionalFields['location'] && true === config('firefly.enable_external_map');
// map info:
// map info voor v2:
$longitude = config('firefly.default_location.longitude');
$latitude = config('firefly.default_location.latitude');
$zoomLevel = config('firefly.default_location.zoom_level');

View File

@ -132,6 +132,7 @@ return [
'has_any_tag' => ['alias' => false, 'needs_context' => false],
'any_notes' => ['alias' => false, 'needs_context' => false],
'has_any_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
'has_notes' => ['alias' => true, 'alias_for' => 'any_notes', 'needs_context' => false],
'any_external_url' => ['alias' => false, 'needs_context' => false],
'has_any_external_url' => ['alias' => true, 'alias_for' => 'any_external_url', 'needs_context' => false],
'has_no_attachments' => ['alias' => false, 'needs_context' => false],

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -101,7 +101,7 @@
"integrity": "sha384-wA/Z8Z+hNOuOA5ZTX8ShykEkdtfxX6dBZFLmmYmanfuUYEeY427OaNi956vrN6cy"
},
"resources/assets/v2/pages/transactions/edit.js": {
"file": "assets/edit-6247ff45.js",
"file": "assets/edit-9f80420b.js",
"imports": [
"_get-c53daca3.js",
"_vendor-4332182f.js",
@ -110,7 +110,7 @@
],
"isEntry": true,
"src": "resources/assets/v2/pages/transactions/edit.js",
"integrity": "sha384-hJTbJsS4rExaV2BGHmiZ/J/nm8RicxSfwzr7TDUe/nwtYOm8gWtmNxrDrsmyzAqS"
"integrity": "sha384-aDpFfamLQtUwfrOIPa3rZYGluWoOFUl+/HT5HVFqxc2Qa78DCqiUGsw20xsnPH71"
},
"resources/assets/v2/sass/app.scss": {
"file": "assets/app-fb7b26ec.css",

View File

@ -57,7 +57,6 @@ let transactions = function () {
// transactions are stored in "entries":
entries: [],
// state of the form is stored in formState:
formStates: {
loadingCurrencies: true,
@ -74,7 +73,8 @@ let transactions = function () {
// form behaviour during transaction
formBehaviour: {
formType: 'create', foreignCurrencyEnabled: true,
formType: 'edit',
foreignCurrencyEnabled: true,
},
// form data (except transactions) is stored in formData
@ -180,9 +180,14 @@ let transactions = function () {
}
return formatMoney(this.groupProperties.totalAmount, this.entries[0].currency_code ?? 'EUR');
},
getTags(index) {
console.log('at get tags ' + index);
console.log(this.entries[index].tags);
return this.entries[index].tags ?? [];
},
getTransactionGroup() {
this.entries = [];
const page = window.location.href.split('/');
const groupId = parseInt(page[page.length - 1]);
const getter = new Get();
@ -192,34 +197,39 @@ let transactions = function () {
this.groupProperties.transactionType = data.attributes.transactions[0].type;
this.groupProperties.title = data.attributes.title ?? data.attributes.transactions[0].description;
this.entries = parseDownloadedSplits(data.attributes.transactions);
//console.log(this.entries);
// remove waiting thing.
this.notifications.wait.show = false;
}).then(() => {
this.groupProperties.totalAmount = 0;
for (let i in this.entries) {
if (this.entries.hasOwnProperty(i)) {
this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);
this.filters.source.push(this.entries[i].source_account.type);
this.filters.destination.push(this.entries[i].source_account.type);
}
}
console.log(this.filters);
setTimeout(() => {
// render tags:
Tags.init('select.ac-tags', {
allowClear: true,
// server: urls.tag,
// liveServer: true,
// clearEnd: true,
selected: [{label:'Bla bla',value:1,selected:true}],
//allowNew: true,
//notFoundMessage: i18n.t('firefly.nothing_found'),
// noCache: true,
// fetchOptions: {
// headers: {
// 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
// }
// }
server: urls.tag,
liveServer: true,
clearEnd: true,
allowNew: true,
notFoundMessage: i18n.t('firefly.nothing_found'),
noCache: true,
fetchOptions: {
headers: {
'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
}
}
});
}, 250);
}, 150);
});
},
init() {
// download translations and get the transaction group.
Promise.all([getVariable('language', 'en_US')]).then((values) => {
@ -282,6 +292,17 @@ let transactions = function () {
this.entries[event.detail.index].zoomLevel = event.detail.zoomLevel;
});
},
changedAmount(e) {
const index = parseInt(e.target.dataset.index);
this.entries[index].amount = parseFloat(e.target.value);
this.groupProperties.totalAmount = 0;
for (let i in this.entries) {
if (this.entries.hasOwnProperty(i)) {
this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);
}
}
}
}
}

View File

@ -66,12 +66,14 @@ export function parseDownloadedSplits(downloads) {
current.destination_account = {
id: download.destination_id,
name: download.destination_name,
type: download.destination_type,
alpine_name: download.destination_name,
};
current.source_account = {
id: download.source_id,
name: download.source_name,
type: download.source_type,
alpine_name: download.source_name,
};
@ -87,10 +89,11 @@ export function parseDownloadedSplits(downloads) {
// longitude: null
// piggy_bank_id: null
// zoomLevel: null
console.log('download:');
console.log(download);
console.log('current:');
console.log(current);
// console.log('download:');
// console.log(download);
// console.log('current:');
// console.log(current);
console.log(current.tags);
returnArray.push(current);
}
}

View File

@ -10,9 +10,6 @@
:name="'tags['+index+'][]'"
multiple>
<option value="">{{ __('firefly.select_tag') }}</option>
<template x-for="tag in transaction.tags" :key="tag">
<option :value="tag" x-text="tag" selected="selected"></option>
</template>
</select>
</div>