mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Fix #1751
This commit is contained in:
@@ -206,17 +206,14 @@ class AutoCompleteController extends Controller
|
|||||||
sort($return);
|
sort($return);
|
||||||
|
|
||||||
if ('' !== $search) {
|
if ('' !== $search) {
|
||||||
$return = array_values(
|
$return = array_filter(
|
||||||
array_unique(
|
|
||||||
array_filter(
|
|
||||||
$return, function (array $array) use ($search) {
|
$return, function (array $array) use ($search) {
|
||||||
$value = $array['name'];
|
$haystack = $array['name'];
|
||||||
|
$result = stripos($haystack, $search);
|
||||||
return !(false === stripos($value, $search));
|
return !(false === $result);
|
||||||
}, ARRAY_FILTER_USE_BOTH
|
}
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
$cache->store($return);
|
$cache->store($return);
|
||||||
|
|
||||||
@@ -311,9 +308,11 @@ class AutoCompleteController extends Controller
|
|||||||
// find everything:
|
// find everything:
|
||||||
/** @var Collection $collection */
|
/** @var Collection $collection */
|
||||||
$collection = $repository->getAccountsByType($types);
|
$collection = $repository->getAccountsByType($types);
|
||||||
$filtered =$collection->filter(function(Account $account) {
|
$filtered = $collection->filter(
|
||||||
|
function (Account $account) {
|
||||||
return $account->active === true;
|
return $account->active === true;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
$return = array_values(array_unique($filtered->pluck('name')->toArray()));
|
$return = array_values(array_unique($filtered->pluck('name')->toArray()));
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
42
public/js/ff/transactions/show.js
vendored
42
public/js/ff/transactions/show.js
vendored
@@ -25,39 +25,35 @@ $(function () {
|
|||||||
var transactions = new Bloodhound({
|
var transactions = new Bloodhound({
|
||||||
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
||||||
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
||||||
|
identify: function (obj) {
|
||||||
|
return obj.id;
|
||||||
|
},
|
||||||
prefetch: {
|
prefetch: {
|
||||||
url: autoCompleteUri,
|
url: autoCompleteUri
|
||||||
filter: function (list) {
|
// filter: function (list) {
|
||||||
return $.map(list, function (name) {
|
// return $.map(list, function (name) {
|
||||||
return {name: name.name};
|
// return {name: name.name};
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
remote: {
|
remote: {
|
||||||
url: autoCompleteUri + '?search=%QUERY',
|
url: autoCompleteUri + '?search=%QUERY',
|
||||||
wildcard: '%QUERY',
|
wildcard: '%QUERY'
|
||||||
filter: function (list) {
|
// filter: function (list) {
|
||||||
return $.map(list, function (name) {
|
// return $.map(list, function (name) {
|
||||||
return {name: name.name};
|
// return {name: name.name};
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
transactions.initialize();
|
transactions.initialize();
|
||||||
var input = $("#link_other");
|
var input = $("#link_other");
|
||||||
input.typeahead({hint: true, highlight: true,}, {source: transactions, displayKey: 'name', autoSelect: false});
|
input.typeahead({hint: true, highlight: true,}, {source: transactions, displayKey: 'name', autoSelect: false});
|
||||||
|
input.bind('typeahead:select', function (ev, suggestion) {
|
||||||
input.change(function () {
|
console.log('Selection: ' + suggestion.name);
|
||||||
var current = input.typeahead("getActive");
|
if (suggestion.name.toLowerCase() === input.val().toLowerCase()) {
|
||||||
if (current) {
|
|
||||||
// Some item from your model is active!
|
|
||||||
if (current.name.toLowerCase() ===
|
|
||||||
input.val().toLowerCase()) {
|
|
||||||
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||||
$('input[name="link_journal_id"]').val(current.id);
|
$('input[name="link_journal_id"]').val(suggestion.id);
|
||||||
} else {
|
|
||||||
$('input[name="link_journal_id"]').val(0);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$('input[name="link_journal_id"]').val(0);
|
$('input[name="link_journal_id"]').val(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user