Skip to content

Firefly III: a personal finances manager

Fix auto complete (#1519) for editing reconciliations.

James Cole93ca07d8127e
diff --git a/public/js/ff/accounts/edit-reconciliation.js b/public/js/ff/accounts/edit-reconciliation.js
index 2ee2c8ae37..c7148cae4a 100644
--- a/public/js/ff/accounts/edit-reconciliation.js
+++ b/public/js/ff/accounts/edit-reconciliation.js
@@ -31,23 +31,46 @@ $(document).ready(function () {
*/
function setAutocompletes() {
- $.getJSON('json/categories').done(function (data) {
- $('input[name="category"]').typeahead({source: data, autoSelect: false});
- });
-
- $.getJSON('json/tags').done(function (data) {
- var opt = {
- typeahead: {
- source: data,
- afterSelect: function () {
- this.$element.val("");
- },
- autoSelect: false,
- }
- };
- $('input[name="tags"]').tagsinput(
- opt
- );
- });
+
+
+ // do categories auto complete:
+ var categories = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ prefetch: {
+ url: 'json/categories',
+ filter: function (list) {
+ return $.map(list, function (name) {
+ return {name: name};
+ });
+ }
+ }
+ });
+ categories.initialize();
+ $('input[name="category"]').typeahead({}, {source: categories, displayKey: 'name', autoSelect: false});
+
+
+ // do tags auto complete:
+ var tagTags = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ prefetch: {
+ url: 'json/tags',
+ filter: function (list) {
+ return $.map(list, function (tagTag) {
+ return {name: tagTag};
+ });
+ }
+ }
+ });
+ tagTags.initialize();
+ $('input[name="tags"]').tagsinput({
+ typeaheadjs: {
+ name: 'tags',
+ displayKey: 'name',
+ valueKey: 'name',
+ source: tagTags.ttAdapter()
+ }
+ });
}
diff --git a/resources/views/accounts/reconcile/edit.twig b/resources/views/accounts/reconcile/edit.twig
index 116fa6f29d..cbc53038c1 100644
--- a/resources/views/accounts/reconcile/edit.twig
+++ b/resources/views/accounts/reconcile/edit.twig
@@ -96,7 +96,7 @@
<script type="text/javascript">
var what = "{{ what }}";
</script>
- <script type="text/javascript" src="js/lib/bootstrap3-typeahead.min.js?v={{ FF_VERSION }}"></script>
+ <script type="text/javascript" src="js/lib/typeahead/typeahead.bundle.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/bootstrap-tagsinput.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/jquery-ui.min.js?v={{ FF_VERSION }}"></script>
<script type="text/javascript" src="js/lib/modernizr-custom.js?v={{ FF_VERSION }}"></script>