Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix another AC
James Colec16c4ab4ecbd
diff --git a/public/v1/js/ff/object-groups/create-edit.js b/public/v1/js/ff/object-groups/create-edit.jsindex 9a381b086a..5ec90a5491 100644--- a/public/v1/js/ff/object-groups/create-edit.js+++ b/public/v1/js/ff/object-groups/create-edit.js@@ -48,8 +48,6 @@ $(document).ready(function () {result.push(data[i].name);}}- console.log(data);- console.log(result);// Process data if neededreturn result;});diff --git a/public/v1/js/ff/rules/create-edit.js b/public/v1/js/ff/rules/create-edit.jsindex 7400d2c4f7..88d275eb44 100644--- a/public/v1/js/ff/rules/create-edit.js+++ b/public/v1/js/ff/rules/create-edit.js@@ -448,8 +448,6 @@ function createAutoComplete(input, URL) {result.push(data[i].name);}}- console.log(data);- console.log(result);// Process data if neededreturn result;});diff --git a/public/v1/js/ff/transactions/convert.js b/public/v1/js/ff/transactions/convert.jsdeleted file mode 100644index e399e389ff..0000000000--- a/public/v1/js/ff/transactions/convert.js+++ /dev/null@@ -1,62 +0,0 @@-/*- * convert.js- * Copyright (c) 2019 [email protected]- *- * 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/>.- */--$(document).ready(function () {- "use strict";- setAutocompletes();--});--/**- * Set the auto-complete JSON things.- */-function setAutocompletes() {- //initRevenueACField('source_account_revenue');- //initExpenseACField('destination_account_expense');-- makeRevenueAC();-}--function makeRevenueAC() {- var sourceNames = new Bloodhound({- datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),- queryTokenizer: Bloodhound.tokenizers.whitespace,- prefetch: {- url: 'api/v1/autocomplete/accounts?types=Revenue account&uid=' + uid,- filter: function (list) {- return $.map(list, function (object) {- return {name: object.name};- });- }- },- remote: {- url: 'api/v1/autocomplete/accounts?types=Revenue account&query=%QUERY&uid=' + uid,- wildcard: '%QUERY',- filter: function (list) {- return $.map(list, function (object) {- return {name: object.name};- });- }- }- });- sourceNames.initialize();- $('.input-revenue').typeahead({hint: true, highlight: true,}, {source: sourceNames, displayKey: 'name', autoSelect: false});-}-diff --git a/public/v1/js/ff/transactions/show.js b/public/v1/js/ff/transactions/show.jsindex ad4ce3c1e1..a074ad8ff5 100644--- a/public/v1/js/ff/transactions/show.js+++ b/public/v1/js/ff/transactions/show.js@@ -47,38 +47,101 @@ function getLinkModal(e) {function makeAutoComplete() {- // input link-journal- var source = new Bloodhound({- datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),- queryTokenizer: Bloodhound.tokenizers.whitespace,- prefetch: {- url: acURL + '?uid=' + uid,- filter: function (list) {- return $.map(list, function (item) {- return item;- });- }+ var inputItem = document.getElementsByClassName('link-journal')[0];++ inputItem.addEventListener('autocomplete', (event) => {+ selectedJournal(event);+ console.log('Selected value:', event);+ });++ new BootstrapSimpleAutocomplete(inputItem, {+ renderItem: function (option, query, index) {+ const item = document.createElement('a');+ item.className = 'dropdown-item';+ item.innerText = option.name;+ item.setAttribute('role', 'option');+ item.setAttribute('aria-selected', 'false');+ item.id = `autocomplete-item-${this.id}-${index}`;++ item.addEventListener('click', () => this.selectOption(option));+ return item;+ // return option.name;+ // const item = document.createElement('a');+ // item.className = 'dropdown-item';+ // item.setAttribute('role', 'option');+ // item.setAttribute('aria-selected', 'false');+ // item.id = `autocomplete-item-${this.id}-${index}`;+ //+ // // Example: Highlight the query in the option text+ // // const regex = new RegExp(`(${query})`, 'gi');+ // // item.innerHTML = option.replace(regex, '<strong>$1</strong>');+ //+ // // item.addEventListener('click', () => this.selectOption(option));+ // return item;},- remote: {- url: acURL + '?query=%QUERY&uid=' + uid,- wildcard: '%QUERY',- filter: function (list) {- return $.map(list, function (item) {- return item;+ fetchFunction: function (query) {+ // Custom data fetching logic+ return fetch(acURL + '?query=' + encodeURIComponent(query),+ {+ method: 'GET',+ credentials: 'include',+ headers: {+ 'Content-Type': 'application/json',+ 'Accept': 'application/json',+ 'X-CSRF-TOKEN': token+ },+ }+ )+ .then((response) => response.json())+ .then((data) => {+ return data;+ var result = [];+ for(var i in data) {+ if(data.hasOwnProperty(i)) {+ result.push(data[i].name);+ }+ }+ // Process data if needed+ return result;});- }- }+ },});- source.initialize();- $('.link-journal').typeahead({hint: true, highlight: true,}, {source: source, displayKey: 'name', autoSelect: false})- .on('typeahead:select', selectedJournal);+ //+ //+ //+ // // input link-journal+ // var source = new Bloodhound({+ // datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),+ // queryTokenizer: Bloodhound.tokenizers.whitespace,+ // prefetch: {+ // url: acURL + '?uid=' + uid,+ // filter: function (list) {+ // return $.map(list, function (item) {+ // return item;+ // });+ // }+ // },+ // remote: {+ // url: acURL + '?query=%QUERY&uid=' + uid,+ // wildcard: '%QUERY',+ // filter: function (list) {+ // return $.map(list, function (item) {+ // return item;+ // });+ // }+ // }+ // });+ // source.initialize();+ // $('.link-journal').typeahead({hint: true, highlight: true,}, {source: source, displayKey: 'name', autoSelect: false})+ // .on('typeahead:select', selectedJournal);}-function selectedJournal(event, journal) {+function selectedJournal(event) {+ console.log(event);$('#journal-selector').hide();$('#journal-selection').show();- $('#selected-journal').html('<a href="' + groupURL.replace('%GROUP%', journal.transaction_group_id) + '">' + journal.description + '</a>').show();- $('input[name="opposing"]').val(journal.id);+ $('#selected-journal').html('<a href="' + groupURL.replace('%GROUP%', event.detail.value.transaction_group_id) + '">' + event.detail.value.description + '</a>').show();+ $('input[name="opposing"]').val(event.detail.value.id);}function cloneTransaction(e) {diff --git a/resources/views/transactions/convert.blade.php b/resources/views/transactions/convert.blade.phpindex 92c19f470a..384e0ddbb2 100644--- a/resources/views/transactions/convert.blade.php+++ b/resources/views/transactions/convert.blade.php@@ -292,8 +292,4 @@@endsection@section('scripts')@vite(['js/pages/generic.js'])- <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ $FF_BUILD_TIME }}"- nonce="{{ $JS_NONCE }}"></script>- <script type="text/javascript" src="v1/js/ff/transactions/convert.js?v={{ $FF_BUILD_TIME }}"- nonce="{{ $JS_NONCE }}"></script>@endsectiondiff --git a/resources/views/transactions/show.blade.php b/resources/views/transactions/show.blade.phpindex 2717165ccb..784ebd9a41 100644--- a/resources/views/transactions/show.blade.php+++ b/resources/views/transactions/show.blade.php@@ -585,7 +585,8 @@return false}</script>- <script type="text/javascript" src="v1/js/lib/typeahead/typeahead.bundle.min.js?v={{ $FF_BUILD_TIME }}"+ {{-- new auto complete --}}+ <script type="text/javascript" src="v1/js/lib/bootstrap-simple-autocomplete.js?v={{ $FF_BUILD_TIME }}"nonce="{{ $JS_NONCE }}"></script><script type="text/javascript" src="v1/js/ff/transactions/show.js?v={{ $FF_BUILD_TIME }}"nonce="{{ $JS_NONCE }}"></script>