2017-01-15 19:28:54 +01:00
|
|
|
/*
|
|
|
|
|
* edit.js
|
2020-02-16 13:59:41 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2017-01-15 19:28:54 +01:00
|
|
|
*
|
2019-10-02 06:43:38 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:43:38 +02:00
|
|
|
* 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.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:43:38 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:43:38 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:43:38 +02:00
|
|
|
* 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/>.
|
2017-01-15 19:28:54 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
2019-02-02 07:00:09 +01:00
|
|
|
// description
|
|
|
|
|
if ($('input[name^="description["]').length > 0) {
|
2019-07-20 16:02:50 +02:00
|
|
|
console.log('Description.');
|
2019-02-02 07:00:09 +01:00
|
|
|
var journalNames = new Bloodhound({
|
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
prefetch: {
|
|
|
|
|
url: 'json/transaction-journals/all?uid=' + uid,
|
|
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2019-02-02 07:00:09 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
|
|
|
|
url: 'json/transaction-journals/all?search=%QUERY&uid=' + uid,
|
|
|
|
|
wildcard: '%QUERY',
|
|
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2019-02-02 07:00:09 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
journalNames.initialize();
|
|
|
|
|
$('input[name^="description["]').typeahead({hint: true, highlight: true,}, {source: journalNames, displayKey: 'name', autoSelect: false});
|
|
|
|
|
}
|
2017-01-15 19:28:54 +01:00
|
|
|
// destination account names:
|
2018-06-30 05:21:21 +02:00
|
|
|
if ($('input[name^="destination_name["]').length > 0) {
|
2019-07-20 16:02:50 +02:00
|
|
|
console.log('Destination.');
|
2018-09-23 07:39:04 +02:00
|
|
|
var destNames = new Bloodhound({
|
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
prefetch: {
|
2018-10-28 19:17:33 +01:00
|
|
|
url: 'json/expense-accounts?uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
2018-10-28 19:17:33 +01:00
|
|
|
url: 'json/expense-accounts?search=%QUERY&uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
wildcard: '%QUERY',
|
|
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
destNames.initialize();
|
|
|
|
|
$('input[name^="destination_name["]').typeahead({hint: true, highlight: true,}, {source: destNames, displayKey: 'name', autoSelect: false});
|
2017-01-15 19:28:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// source account name
|
2018-06-30 05:21:21 +02:00
|
|
|
if ($('input[name^="source_name["]').length > 0) {
|
2019-07-20 16:02:50 +02:00
|
|
|
console.log('Source.');
|
2018-09-23 07:39:04 +02:00
|
|
|
var sourceNames = new Bloodhound({
|
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
prefetch: {
|
2018-10-28 19:17:33 +01:00
|
|
|
url: 'json/revenue-accounts?uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
2018-10-28 19:17:33 +01:00
|
|
|
url: 'json/revenue-accounts?search=%QUERY&uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
wildcard: '%QUERY',
|
|
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
sourceNames.initialize();
|
|
|
|
|
|
|
|
|
|
$('input[name^="source_name["]').typeahead({hint: true, highlight: true,}, {source: sourceNames, displayKey: 'name', autoSelect: false});
|
2017-01-15 19:28:54 +01:00
|
|
|
}
|
|
|
|
|
|
2018-09-23 07:39:04 +02:00
|
|
|
var categories = new Bloodhound({
|
|
|
|
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
|
|
|
|
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
|
|
|
prefetch: {
|
2020-07-19 17:24:29 +02:00
|
|
|
url: 'api/v1/autocomplete/categories?uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
remote: {
|
2020-07-19 17:24:29 +02:00
|
|
|
url: 'api/v1/autocomplete/categories?query=%QUERY&uid=' + uid,
|
2018-09-23 07:39:04 +02:00
|
|
|
wildcard: '%QUERY',
|
|
|
|
|
filter: function (list) {
|
2019-07-20 16:02:50 +02:00
|
|
|
return $.map(list, function (obj) {
|
|
|
|
|
return obj;
|
2018-09-23 07:39:04 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
categories.initialize();
|
|
|
|
|
|
|
|
|
|
$('input[name^="category["]').typeahead({hint: true, highlight: true,}, {source: categories, displayKey: 'name', autoSelect: false});
|
|
|
|
|
|
2020-07-19 17:24:29 +02:00
|
|
|
});
|