Files
firefly-iii/public/js/ff/transactions/create-edit.js

99 lines
3.3 KiB
JavaScript
Raw Normal View History

2016-01-29 18:39:50 +01:00
/*
* create-edit.js
2016-04-01 16:46:11 +02:00
* Copyright (C) 2016 thegrumpydictator@gmail.com
2016-01-29 18:39:50 +01:00
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
2016-01-29 18:39:50 +01:00
*/
2017-01-02 12:09:46 +01:00
/** global: what */
2016-01-29 18:39:50 +01:00
$(document).ready(function () {
"use strict";
2016-04-29 17:29:13 +02:00
// the destination account name is always an expense account name.
if ($('input[name="destination_account_name"]').length > 0) {
$.getJSON('json/expense-accounts').done(function (data) {
$('input[name="destination_account_name"]').typeahead({source: data});
});
}
// also for multi input
if ($('input[name="destination_account_name[]"]').length > 0) {
2016-02-04 07:30:12 +01:00
$.getJSON('json/expense-accounts').done(function (data) {
2016-04-29 17:29:13 +02:00
$('input[name="destination_account_name[]"]').typeahead({source: data});
2016-01-29 18:39:50 +01:00
});
}
if ($('input[name="tags"]').length > 0) {
2016-02-04 07:30:12 +01:00
$.getJSON('json/tags').done(function (data) {
2017-01-05 21:32:54 +01:00
2016-01-29 18:39:50 +01:00
var opt = {
typeahead: {
2017-01-05 21:32:54 +01:00
source: data,
afterSelect: function(val) { this.$element.val(""); }
2016-01-29 18:39:50 +01:00
}
};
$('input[name="tags"]').tagsinput(
opt
);
});
}
2016-04-29 17:29:13 +02:00
// the source account name is always a revenue account name.
if ($('input[name="source_account_name"]').length > 0) {
2016-02-04 07:30:12 +01:00
$.getJSON('json/revenue-accounts').done(function (data) {
2016-04-29 17:29:13 +02:00
$('input[name="source_account_name"]').typeahead({source: data});
});
}
// also for multi-input:
if ($('input[name="source_account_name[]"]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) {
$('input[name="source_account_name[]"]').typeahead({source: data});
2016-01-29 18:39:50 +01:00
});
}
// and for split:
if ($('input[name="journal_source_account_name"]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) {
$('input[name="journal_source_account_name"]').typeahead({source: data});
});
}
2016-01-29 18:39:50 +01:00
if ($('input[name="description"]').length > 0 && !(typeof what === "undefined")) {
2016-02-04 07:30:12 +01:00
$.getJSON('json/transaction-journals/' + what).done(function (data) {
2016-01-29 18:39:50 +01:00
$('input[name="description"]').typeahead({source: data});
});
}
2016-04-29 17:29:13 +02:00
// also for multi input:
if ($('input[name="description[]"]').length > 0 && !(typeof what === "undefined")) {
2016-04-29 17:29:13 +02:00
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="description[]"]').typeahead({source: data});
});
}
// and for the (rare) journal_description:
if ($('input[name="journal_description"]').length > 0 && !(typeof what === "undefined")) {
2016-04-29 17:29:13 +02:00
$.getJSON('json/transaction-journals/' + what).done(function (data) {
$('input[name="journal_description"]').typeahead({source: data});
});
}
2016-01-29 18:39:50 +01:00
if ($('input[name="category"]').length > 0) {
2016-02-04 07:30:12 +01:00
$.getJSON('json/categories').done(function (data) {
2016-01-29 18:39:50 +01:00
$('input[name="category"]').typeahead({source: data});
});
}
2016-04-29 17:29:13 +02:00
// also for multi input:
if ($('input[name^="category["]').length > 0) {
2016-04-29 17:29:13 +02:00
$.getJSON('json/categories').done(function (data) {
$('input[name^="category["]').typeahead({source: data});
2016-04-29 17:29:13 +02:00
});
}
2016-01-29 18:39:50 +01:00
});