Remove and clean up old code.

This commit is contained in:
James Cole committed 2026-09-02 07:00:07 +02:00
1 parent 04fd97afcb
commit 4c29d34ef7
159 files changed
+452 -20844

No files matched your search

+329 -9579
View File
File diff suppressed because it is too large. Load diff
-2
View File
@@ -18,8 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr, currencies */
$(document).ready(function () {
"use strict";
$(".content-wrapper form input:enabled:visible:first").first().focus().select();
-2
View File
@@ -18,8 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr, currencies */
$(document).ready(function () {
"use strict";
$(".content-wrapper form input:enabled:visible:first").first().focus().select();
-2
View File
@@ -18,8 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
$("#ffInput_name").focus().select();
-2
View File
@@ -18,8 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
$(".content-wrapper form input:enabled:visible:first").first().focus().select();
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: token */
var fixBillHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
+1 -2
View File
@@ -18,9 +18,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: specific */
$(function () {
"use strict";
columnChart(specific, 'period-specific-period');
});
});
+1 -2
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: everything, current, specific */
$(function () {
"use strict";
@@ -26,4 +25,4 @@ $(function () {
columnChartCustomColours(everything, 'category-everything');
columnChartCustomColours(specific, 'specific-period');
});
});
-3
View File
@@ -18,9 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: accounting */
/**
* Takes a string phrase and breaks it into separate phrases no bigger than 'maxwidth', breaks are made at complete words.
* https://stackoverflow.com/questions/21409717/chart-js-and-long-labels
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: Chart, defaultChartOptions, accounting, defaultPieOptions, noDataForChart, todayText */
var allCharts = {};
+1 -2
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: jobKey, Modernizr */
var intervalId = 0;
@@ -145,4 +144,4 @@ function checkStatus() {
function putStatusText(status) {
"use strict";
$('#status-message').text(status);
}
}
-3
View File
@@ -17,9 +17,6 @@
* 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/>.
*/
/** global: moment, token, dateRangeMeta,dateRangeConfig, accountingConfig, accounting, currencySymbol, mon_decimal_point, frac_digits, showFullList, showOnlyTop, mon_thousands_sep */
$.ajaxSetup({
headers: {
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: token, helpPageTitle, anonymous */
$(function () {
"use strict";
$('#help').click(showHelp);
-4
View File
@@ -18,13 +18,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
// auto complete for object group.
console.log('Object group auto complete thing.');
var inputElement = document.getElementById('ffInput_object_group');
new BootstrapSimpleAutocomplete(inputElement, {
fetchFunction: function (query) {
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: token */
var fixGroupHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: token */
var fixPiggyHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: piggyBankID, lineChart */
$(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr */
$(document).ready(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr, currencies */
var calendar;
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr, currencies */
var calendar;
+1 -2
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: startDate, endDate, accountIds */
function loadAjaxPartial(holder, url) {
"use strict";
$.get(url).done(function (data) {
@@ -154,4 +153,4 @@ function clickBudgetChart(e) {
var container = 'budget_chart';
columnChart(URL, container);
return false;
}
}
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: hideable */
$(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: minDate, nonSelectedText, allSelectedText, filterPlaceholder, nSelectedText, selectAllText */
var defaultMultiSelect = {
disableIfEmpty: true,
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: triggerCount, actionCount */
var autocompletes = {};
-1
View File
@@ -17,7 +17,6 @@
* 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/>.
*/
/** global: token */
var fixHelper = function (e, tr) {
"use strict";
var $originals = tr.children();
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: Modernizr, askReadWarning */
$(document).ready(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: zoomLevel, latitude, longitude, google */
$(function () {
"use strict";
-1
View File
@@ -18,7 +18,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: edit_selected_txt, edit_bulk_selected_txt, delete_selected_txt, token */
/**
* @deprecated
+52 -3
View File
@@ -18,12 +18,61 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/** global: what */
$(document).ready(function () {
"use strict";
initTagsAC();
initCategoryAC();
// auto complete for tags
// render tags:
Tags.init('select.ac-tags', {
allowClear: true,
server: urls.tag,
liveServer: true,
clearEnd: true,
labelField: 'tag',
valueField: 'id',
queryParam: 'query',
allowNew: true,
//serverDataKey: 'data',
notFoundMessage: i18next.t('firefly.nothing_found'),
noCache: true,
fetchOptions: {
headers: {
'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
}
}
});
// auto complete for category.
var inputElement = document.getElementById('category-ac');
new BootstrapSimpleAutocomplete(inputElement, {
fetchFunction: function (query) {
// Custom data fetching logic
return fetch('api/v1/autocomplete/categories?_token=' + token + '&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) => {
var result = [];
for (var i in data) {
if (data.hasOwnProperty(i)) {
result.push(data[i].name);
}
}
// Process data if needed
return result;
});
},
});
// on change, remove the checkbox.
$('input[name="category"]').change(function () {
@@ -1,146 +0,0 @@
<!--
- CreateTransaction.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<script>
export default {
name: "CreateTransaction",
methods: {
// submit transaction
collectAttachmentData(response) {
// console.log('Now incollectAttachmentData()');
let groupId = response.data.data.id;
// reverse list of transactions?
response.data.data.attributes.transactions = response.data.data.attributes.transactions.reverse();
// array of all files to be uploaded:
let toBeUploaded = [];
// array with all file data.
let fileData = [];
// all attachments
let attachments = $('input[name="attachments[]"]');
// loop over all attachments, and add references to this array:
for (const key in attachments) {
if (attachments.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
for (const fileKey in attachments[key].files) {
if (attachments[key].files.hasOwnProperty(fileKey) && /^0$|^[1-9]\d*$/.test(fileKey) && fileKey <= 4294967294) {
// include journal thing.
toBeUploaded.push(
{
journal: response.data.data.attributes.transactions[key].transaction_journal_id,
file: attachments[key].files[fileKey]
}
);
}
}
}
}
let count = toBeUploaded.length;
// console.log('Found ' + toBeUploaded.length + ' attachments.');
// loop all uploads.
for (const key in toBeUploaded) {
if (toBeUploaded.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// create file reader thing that will read all of these uploads
(function (f, i, theParent) {
let fileReader = new FileReader();
fileReader.onloadend = function (evt) {
if (evt.target.readyState === FileReader.DONE) { // DONE == 2
fileData.push(
{
name: toBeUploaded[key].file.name,
journal: toBeUploaded[key].journal,
content: new Blob([evt.target.result])
}
);
if (fileData.length === count) {
theParent.uploadFiles(fileData, groupId, response.data.data);
}
}
};
fileReader.readAsArrayBuffer(f.file);
})(toBeUploaded[key], key, this);
}
}
return count;
},
uploadFiles(fileData, groupId, transactionData) {
let count = fileData.length;
let uploads = 0;
for (const key in fileData) {
if (fileData.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// console.log('Creating attachment #' + key);
// axios thing, + then.
const uri = './api/v1/attachments';
const data = {
filename: fileData[key].name,
attachable_type: 'TransactionJournal',
attachable_id: fileData[key].journal,
};
axios.post(uri, data)
.then(response => {
// console.log('Created attachment #' + key);
// console.log('Uploading attachment #' + key);
const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload';
axios.post(uploadUri, fileData[key].content)
.then(attachmentResponse => {
// console.log('Uploaded attachment #' + key);
uploads++;
if (uploads === count) {
// finally we can redirect the user onwards.
// console.log('FINAL UPLOAD');
this.redirectUser(groupId, transactionData);
}
// console.log('Upload complete!');
return true;
}).catch(error => {
console.error('[b] Could not upload');
console.error(error);
// console.log('Uploaded attachment #' + key);
uploads++;
if (uploads === count) {
// finally we can redirect the user onwards.
// console.log('FINAL UPLOAD');
this.redirectUser(groupId, transactionData);
}
// console.log('Upload complete!');
return false;
});
}).catch(error => {
console.error('Could not create upload.');
console.error(error);
uploads++;
if (uploads === count) {
// finally we can redirect the user onwards.
// console.log('FINAL UPLOAD');
this.redirectUser(groupId, transactionData);
}
// console.log('Upload complete!');
return false;
});
}
}
},
},
}
</script>
@@ -1,72 +0,0 @@
<!--
- CustomAttachments.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}"
>
<div class="col-sm-12 text-sm">
{{ title }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input ref="input" spellcheck="false"
:name="name"
:placeholder="title"
:title="title"
autocomplete="off"
class="form-control" multiple="multiple" type="file">
<span class="input-group-btn">
<button
class="btn btn-default"
type="button"
v-on:click="clearAtt"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "CustomAttachments",
props: {
title: String,
name: String,
error: Array
},
mounted: function () {
// window.addEventListener('paste', e => {
// this.$refs.input.files = e.clipboardData.files;
// });
},
methods: {
clearAtt: function () {
this.$refs.input.value = '';
},
hasError: function () {
return this.error.length > 0;
},
}
}
</script>
@@ -1,74 +0,0 @@
<!--
- CustomDate.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}"
>
<div class="col-sm-12 text-sm">
{{ title }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input ref="date" :name="name" :placeholder="title" spellcheck="false"
:title="title" :value="value ? value.substr(0,10): ''"
autocomplete="off"
class="form-control" type="date"
@input="handleInput">
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearDate"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "CustomDate",
props: {
value: String,
title: String,
name: String,
error: Array,
},
methods: {
handleInput(e) {
this.$emit('input', this.$refs.date.value);
},
hasError: function () {
return this.error.length > 0;
},
clearDate: function () {
//props.value = '';
this.name = '';
this.$refs.date.value = '';
this.$emit('input', this.$refs.date.value);
},
}
}
</script>
@@ -1,74 +0,0 @@
<!--
- CustomString.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}"
>
<div class="col-sm-12 text-sm">
{{ title }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input ref="str" :name="name" :placeholder="title" spellcheck="false"
:title="title" :value="value"
autocomplete="off"
class="form-control" type="text"
@input="handleInput">
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearField"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "CustomString",
props: {
title: String,
name: String,
value: String,
error: Array
},
methods: {
handleInput(e) {
this.$emit('input', this.$refs.str.value);
},
clearField: function () {
//props.value = '';
this.name = '';
this.$refs.str.value = '';
this.$emit('input', this.$refs.str.value);
},
hasError: function () {
return this.error.length > 0;
}
}
}
</script>
@@ -1,67 +0,0 @@
<!--
- CustomTextarea.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}"
>
<div class="col-sm-12 text-sm">
{{ title }}
</div>
<div class="col-sm-12">
<textarea ref="str" v-model="textValue"
:name="name" :placeholder="title"
:title="title"
autocomplete="off"
class="form-control"
rows="8"
@input="handleInput"></textarea>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "CustomTextarea",
props: {
title: String,
name: String,
value: String,
error: Array
},
data() {
return {
textValue: this.value,
}
},
methods: {
handleInput(e) {
this.$emit('input', this.$refs.str.value);
},
hasError: function () {
return this.error.length > 0;
}
}
}
</script>
@@ -1,133 +0,0 @@
<!--
- CustomTransactionFields.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div>
<p class="help-block" v-html="$t('firefly.hidden_fields_preferences')"></p>
<component
v-bind:is="dateComponent"
v-if="this.fields.interest_date" v-model="value.interest_date" :error="error.interest_date"
name="interest_date[]" v-bind:title="$t('form.interest_date')"></component>
<component
v-bind:is="dateComponent"
v-if="this.fields.book_date" v-model="value.book_date" :error="error.book_date" name="book_date[]"
v-bind:title="$t('form.book_date')"></component>
<component
v-bind:is="dateComponent"
v-if="this.fields.process_date" v-model="value.process_date" :error="error.process_date"
name="process_date[]" v-bind:title="$t('form.process_date')"></component>
<component
v-bind:is="dateComponent"
v-if="this.fields.due_date" v-model="value.due_date" :error="error.due_date" name="due_date[]"
v-bind:title="$t('form.due_date')"></component>
<component
v-bind:is="dateComponent"
v-if="this.fields.payment_date" v-model="value.payment_date" :error="error.payment_date"
name="payment_date[]" v-bind:title="$t('form.payment_date')"></component>
<component
v-bind:is="dateComponent"
v-if="this.fields.invoice_date" v-model="value.invoice_date" :error="error.invoice_date"
name="invoice_date[]" v-bind:title="$t('form.invoice_date')"></component>
<component
v-bind:is="stringComponent"
v-if="this.fields.internal_reference" v-model="value.internal_reference" :error="error.internal_reference"
name="internal_reference[]" v-bind:title="$t('form.internal_reference')"></component>
<component
v-bind:is="attachmentComponent"
v-if="this.fields.attachments" v-model="value.attachments" :error="error.attachments"
name="attachments[]" v-bind:title="$t('firefly.attachments')"></component>
<component
v-bind:is="uriComponent"
v-if="this.fields.external_url" v-model="value.external_url" :error="error.external_url"
name="external_url[]" v-bind:title="$t('firefly.external_url')"></component>
<component
v-bind:is="textareaComponent"
v-if="this.fields.notes" v-model="value.notes" :error="error.notes" name="notes[]"
v-bind:title="$t('firefly.notes')"></component>
</div>
</template>
<script>
export default {
name: "CustomTransactionFields",
props: ['value', 'error'],
mounted() {
this.getPreference();
},
data() {
return {
customInterestDate: null,
fields: [
{
"interest_date": false,
"book_date": false,
"process_date": false,
"due_date": false,
"payment_date": false,
"invoice_date": false,
"internal_reference": false,
"notes": false,
"attachments": false,
"external_url": false
}
]
};
},
computed: {
// TODO this seems to be a pretty weird way of doing it.
dateComponent() {
return 'custom-date';
},
stringComponent() {
return 'custom-string';
},
attachmentComponent() {
return 'custom-attachments';
},
textareaComponent() {
return 'custom-textarea';
},
uriComponent() {
return 'custom-uri';
}
},
methods: {
handleInput(e) {
this.$emit('input', this.value);
},
getPreference() {
// Vue.component('custom-date', (resolve) => {
// console.log('loaded');
// });
const url = document.getElementsByTagName('base')[0].href + 'api/v1/preferences/transaction_journal_optional_fields';
axios.get(url).then(response => {
this.fields = response.data.data.attributes.data;
}).catch(() => console.warn('Oh. Something went wrong loading custom transaction fields.'));
},
}
}
</script>
@@ -1,73 +0,0 @@
<!--
- CustomString.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}"
>
<div class="col-sm-12 text-sm">
{{ title }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input ref="uri" :name="name" :placeholder="title" spellcheck="false"
:title="title" :value="value"
autocomplete="off"
class="form-control" type="url"
@input="handleInput">
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearField"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "CustomString",
props: {
title: String,
name: String,
value: String,
error: Array
},
methods: {
handleInput(e) {
this.$emit('input', this.$refs.uri.value);
},
clearField: function () {
this.name = '';
this.$refs.uri.value = '';
this.$emit('input', this.$refs.uri.value);
},
hasError: function () {
return this.error.length > 0;
}
}
}
</script>
@@ -1,76 +0,0 @@
<!--
- GroupDescription.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group" v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-12 text-sm">
{{ $t('firefly.split_transaction_title') }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input
spellcheck="false"
ref="descr"
:value="value"
autocomplete="off"
class="form-control"
name="group_title"
type="text"
v-bind:placeholder="$t('firefly.split_transaction_title')"
v-bind:title="$t('firefly.split_transaction_title')" @input="handleInput"
>
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearField"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<p v-if="error.length === 0" class="help-block">
{{ $t('firefly.split_transaction_title_help') }}
</p>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
props: ['error', 'value', 'index'],
name: "GroupDescription",
methods: {
hasError: function () {
return this.error.length > 0;
},
handleInput(e) {
this.$emit('input', this.$refs.descr.value);
},
clearField: function () {
//props.value = '';
this.name = '';
this.$refs.descr.value = '';
this.$emit('input', this.$refs.descr.value);
},
}
}
</script>
@@ -1,121 +0,0 @@
<!--
- PiggyBank.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div v-if="typeof this.transactionType !== 'undefined'"
class="form-group"
v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-12 text-sm">
{{ $t('firefly.piggy_bank') }}
</div>
<div class="col-sm-12">
<select ref="piggy" class="form-control" name="piggy_bank[]" @input="handleInput">
<optgroup v-for="(option, key) in this.piggies" v-bind:label="key">
<option v-for="piggy in option.piggies" :label="piggy.name_with_balance" :selected="piggy.id === value" :value="piggy.id">
{{ piggy.name_with_balance }}
</option>
</optgroup>
</select>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "PiggyBank",
props: ['value', 'transactionType', 'error', 'no_piggy_bank'],
mounted() {
this.loadPiggies();
},
data() {
return {
piggies: [],
}
},
methods: {
handleInput(e) {
this.$emit('input', this.$refs.piggy.value);
},
hasError: function () {
return this.error.length > 0;
},
loadPiggies: function () {
let URI = document.getElementsByTagName('base')[0].href + "api/v1/autocomplete/piggy-banks-with-balance?limit=1337";
axios.get(URI, {}).then((res) => {
let tempList = {
0: {
group: {
title: this.$t('firefly.default_group_title_name')
},
piggies: [
{
name_with_balance: this.no_piggy_bank,
id: 0,
}
],
}
};
for (const key in res.data) {
if (res.data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// add to temp list
let currentPiggy = res.data[key];
if (null !== currentPiggy.object_group_id) {
let groupOrder = currentPiggy.object_group_order;
if(0 === groupOrder) {
groupOrder = 1;
}
if (!tempList[groupOrder]) {
tempList[groupOrder] = {
group: {
title: currentPiggy.object_group_title
},
piggies: [],
};
}
tempList[groupOrder].piggies.push({
name_with_balance: currentPiggy.name_with_balance,
id: currentPiggy.id
});
}
if (null === currentPiggy.object_group_id) {
// add to empty one:
tempList[0].piggies.push({name_with_balance: currentPiggy.name_with_balance, id: currentPiggy.id});
}
//console.log(currentPiggy);
this.piggies.push(res.data[key]);
}
}
const ordered = {};
Object.keys(tempList).sort().forEach(function (key) {
let groupName = tempList[key].group.title;
ordered[groupName] = tempList[key];
});
// final list:
this.piggies = ordered;
// console.log(ordered);
});
}
}
}
</script>
@@ -1,75 +0,0 @@
<!--
- Reconciled.vue
- Copyright (c) 2025 james@firefly-iii.org.
-
- 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/.
-->
<template>
<div class="form-group" v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-8 col-sm-offset-4 text-sm">
</div>
<label ref="cur" class="col-sm-4 control-label">
{{ $t('firefly.is_reconciled') }}
</label>
<div class="col-sm-8">
<div class="checkbox">
<label>
<input name="create_another" @input="handleInput" type="checkbox" v-model="reconciled">
</label>
</div>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</template>
<script>
export default {
name: "Reconciled",
props: {
value: Boolean,
error: Array
},
data() {
return {
reconciled: this.value
}
},
watch: {
reconciled: function () {
// console.log('reconciled is ' + this.reconciled);
this.$emit('input', this.reconciled);
},
},
methods: {
handleInput(e) {
},
hasError: function () {
return this.error.length > 0;
},
}
}
</script>
<style scoped>
</style>
@@ -1,76 +0,0 @@
<!--
- StandardDate.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group" v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-12 text-sm">
{{ $t('firefly.date') }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input
ref="date"
:disabled="index > 0"
:value="value"
autocomplete="off"
class="form-control"
name="date[]"
type="datetime-local"
v-bind:placeholder="$t('firefly.date')"
v-bind:title="$t('firefly.date')" @input="handleInput"
>
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearDate"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
props: ['error', 'value', 'index'],
name: "StandardDate",
methods: {
hasError: function () {
return this.error.length > 0;
},
handleInput(e) {
this.$emit('input', this.$refs.date.value);
},
clearDate: function () {
//props.value = '';
this.name = '';
this.$refs.date.value = '';
this.$emit('input', this.$refs.date.value);
// some event?
this.$emit('clear:date')
},
}
}
</script>
@@ -1,109 +0,0 @@
<!--
- Tags.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group"
v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-12 text-sm">
{{ $t('firefly.tags') }}
</div>
<div class="col-sm-12">
<div class="input-group">
<vue-tags-input
v-model="tag"
:add-only-from-autocomplete="false"
:autocomplete-items="autocompleteItems"
:tags="tags"
:title="$t('firefly.tags')"
class="force-background-tags-input"
v-bind:placeholder="$t('firefly.tags')"
@tags-changed="update"
/>
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearTags"><i class="fa fa-trash-o"></i></button>
</span>
</div>
</div>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</template>
<script>
import axios from 'axios';
import VueTagsInput from '@johmun/vue-tags-input';
export default {
name: "Tags",
components: {
VueTagsInput
},
props: ['value', 'error'],
data() {
return {
tag: '',
autocompleteItems: [],
debounce: null,
tags: this.value,
};
},
watch: {
'tag': 'initItems',
},
methods: {
update(newTags) {
// console.log('update', newTags);
this.autocompleteItems = [];
this.tags = newTags;
this.$emit('input', this.tags);
},
clearTags() {
// console.log('clearTags');
this.tags = [];
this.$emit('input', this.tags);
},
hasError: function () {
return this.error.length > 0;
},
initItems() {
// console.log('Now in initItems');
if (this.tag.length < 2) {
return;
}
const url = document.getElementsByTagName('base')[0].href + `api/v1/autocomplete/tags?query=${this.tag}`;
clearTimeout(this.debounce);
this.debounce = setTimeout(() => {
axios.get(url).then(response => {
this.autocompleteItems = response.data.map(a => {
return {text: a.tag};
});
}).catch(() => console.warn('Oh. Something went wrong loading tags.'));
}, 600);
},
},
}
</script>
@@ -1,160 +0,0 @@
<!--
- TransactionDescription.vue
- Copyright (c) 2019 james@firefly-iii.org
-
- 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/>.
-->
<template>
<div class="form-group" v-bind:class="{ 'has-error': hasError()}">
<div class="col-sm-12 text-sm">
{{ $t('firefly.description') }}
</div>
<div class="col-sm-12">
<div class="input-group">
<input
spellcheck="false"
ref="descr"
:title="$t('firefly.description')"
:value="value"
autocomplete="off"
class="form-control"
name="description[]"
type="text"
v-bind:placeholder="$t('firefly.description')"
@input="handleInput"
v-on:keypress="handleEnter" v-on:submit.prevent
>
<span class="input-group-btn">
<button
class="btn btn-default"
tabIndex="-1"
type="button"
v-on:click="clearDescription"><i class="fa fa-trash-o"></i></button>
</span>
</div>
<typeahead
v-model="name"
:async-function="aSyncFunction"
:open-on-empty=true
:open-on-focus=true
:target="target"
item-key="description"
v-on:input="selectedItem"
>
<template slot="item" slot-scope="props">
<li v-for="(item, index) in props.items" :class="{active:props.activeIndex===index}">
<a role="button" @click="props.select(item)">
<span v-html="betterHighlight(item)"></span>
</a>
</li>
</template>
</typeahead>
<ul v-for="error in this.error" class="list-unstyled">
<li class="text-danger">{{ error }}</li>
</ul>
</div>
</div>
</template>
<script>
export default {
props: ['error', 'value', 'index'],
name: "TransactionDescription",
mounted() {
this.target = this.$refs.descr;
this.descriptionAutoCompleteURI = document.getElementsByTagName('base')[0].href + "api/v1/autocomplete/transactions?query=";
this.$refs.descr.focus();
},
components: {},
data() {
return {
descriptionAutoCompleteURI: null,
name: null,
description: null,
target: null,
}
},
methods: {
aSyncFunction: function (query, done) {
axios.get(this.descriptionAutoCompleteURI + query)
.then(res => {
done(res.data);
})
.catch(err => {
// any error handler
})
},
betterHighlight: function (item) {
var inputValue = this.$refs.descr.value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var escapedName = this.escapeHtml(item.description);
return escapedName.replace(new RegExp(("" + inputValue), 'i'), '<b>$&</b>');
},
escapeHtml: function (string) {
let entityMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'/': '&#x2F;',
'`': '&#x60;',
'=': '&#x3D;'
};
return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap(s) {
return entityMap[s];
});
},
search: function (input) {
return ['ab', 'cd'];
},
hasError: function () {
return this.error.length > 0;
},
clearDescription: function () {
//props.value = '';
this.description = '';
this.$refs.descr.value = '';
this.$emit('input', this.$refs.descr.value);
// some event?
this.$emit('clear:description')
},
handleInput(e) {
this.$emit('input', this.$refs.descr.value);
},
handleEnter: function (e) {
// TODO feels sloppy
if (e.keyCode === 13) {
//e.preventDefault();
}
},
selectedItem: function (e) {
if (typeof this.name === 'undefined') {
return;
}
if (typeof this.name === 'string') {
return;
}
this.$refs.descr.value = this.name.description;
this.$emit('input', this.$refs.descr.value);
},
}
}
</script>
-37
View File
@@ -1,37 +0,0 @@
{
"name": "v2",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build --emptyOutDir",
"postinstall": "patch-package --error-on-fail"
},
"devDependencies": {
"axios": "^1.15.0",
"laravel-vite-plugin": "^3",
"patch-package": "^8",
"sass": "^1",
"vite": "=8.1.3",
"vite-plugin-manifest-sri": "^0.2.0"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^7",
"@popperjs/core": "^2.11.8",
"admin-lte": "^4.0.0-rc4",
"alpinejs": "^3.15.2",
"bootstrap": "^5",
"bootstrap5-autocomplete": "^1",
"bootstrap5-tags": "^1.7.17",
"chart.js": "^4",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-chart-sankey": "^0.14.0",
"date-fns": "4.4.0",
"i18next": "^26.0.3",
"i18next-chained-backend": "^5.0.0",
"i18next-http-backend": "^4.0.0",
"i18next-localstorage-backend": "^4.2.0",
"leaflet": "^1.9.4",
"store": "^2.0.12"
}
}
@@ -1,36 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/account/overview', {params: {start: startStr, end: endStr}});
}
expense(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/account/expense-dashboard', {params: {start: startStr, end: endStr}});
}
}
@@ -1,30 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Overview {
overview(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/account/overview', {params: {start: startStr, end: endStr}});
}
}
@@ -1,30 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/budget/overview', {params: {start: startStr, end: endStr}});
}
}
@@ -1,30 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/category/overview', {params: {start: startStr, end: endStr}});
}
}
@@ -1,27 +0,0 @@
/*
* basic.js
* Copyright (c) 2021 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios";
export default class Get {
getByName(name) {
return api.get('/api/v1/configuration/' + name);
}
}
@@ -1,87 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
import {getCacheKey} from "../../../../support/get-cache-key.js";
export default class Get {
/**
*
* @param identifier
* @param date
* @returns {Promise<AxiosResponse<any>>}
*/
get(identifier, date) {
let params = {date: format(date, 'y-MM-dd').slice(0, 10)};
if (!date) {
return api.get('/api/v1/accounts/' + identifier);
}
return api.get('/api/v1/accounts/' + identifier, {params: params});
}
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
index(params) {
// first, check API in some consistent manner.
// then, load if necessary.
const cacheKey = getCacheKey('/api/v1/accounts', params);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);
if (cacheValid && typeof cachedData !== 'undefined') {
console.log('Cache is valid, return cache.');
return Promise.resolve(cachedData);
}
// if not, store in cache and then return res.
return api.get('/api/v1/accounts', {params: params}).then(response => {
console.log('Cache is invalid, return fresh.');
window.store.set(cacheKey, response.data);
return Promise.resolve({data: response.data.data, meta: response.data.meta});
});
}
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
show(identifier, params) {
return api.get('/api/v1/accounts/' + identifier, {params: params});
}
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
transactions(identifier, params) {
return api.get('/api/v1/accounts/' + identifier + '/transactions', {params: params});
}
}
@@ -1,36 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Put {
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
put(identifier, params) {
return api.put('/api/v1/accounts/' + identifier, params);
}
}
@@ -1,33 +0,0 @@
/*
* post.js
* Copyright (c) 2024 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Post {
post(fileName, attachableType, attachableId) {
let url = '/api/v1/attachments';
return api.post(url, {filename: fileName, attachable_type: attachableType, attachable_id: attachableId});
}
upload(id, data) {
let url = './api/v1/attachments/' + id + '/upload';
return axios.post(url, data);
}
}
@@ -1,35 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/budgets', {params: params});
}
}
@@ -1,35 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/currencies', {params: params});
}
}
@@ -1,35 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/piggy-banks', {params: params});
}
}
@@ -1,42 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/subscriptions', {params: params});
}
paid(params) {
return api.get('/api/v1/subscriptions/sum/paid', {params: params});
}
unpaid(params) {
return api.get('/api/v1/subscriptions/sum/unpaid', {params: params});
}
}
@@ -1,37 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/transactions', {params: params});
}
show(id, params){
return api.get('/api/v1/transactions/' + id, {params: params});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Post {
post(submission) {
let url = '/api/v1/transactions';
return api.post(url, submission);
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Put {
put(submission, params) {
let url = '/api/v1/transactions/' + parseInt(params.id);
return api.put(url, submission);
}
}
@@ -1,45 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
show(identifier, params) {
return api.get('/api/v1/user-groups/' + identifier, {params: params});
}
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
index(params) {
return api.get('/api/v1/user-groups', {params: params});
}
}
@@ -1,33 +0,0 @@
/*
* post.js
* Copyright (c) 2024 james@firefly-iii.org.
*
* 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/.
*/
import {api} from "../../../../boot/axios";
export default class Post {
post(submission) {
let url = './api/v1/user-groups';
return api.post(url, submission);
}
use(groupId) {
let url = './api/v1/user-groups/' + groupId + '/use';
return api.post(url, {});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Put {
put(submission, params) {
let url = '/api/v1/user-groups/' + parseInt(params.id);
return api.put(url, submission);
}
}
@@ -1,34 +0,0 @@
/*
* basic.js
* Copyright (c) 2021 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios";
export default class Preferences {
getByName(name) {
return api.get('/api/v1/preferences/' + name);
}
getByNameNow(name) {
return api.get('/api/v1/preferences/' + name);
}
postByName(name, value) {
return api.post('/api/v1/preferences', {name: name, data: value});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios";
export default class Post {
post(name, value) {
let url = '/api/v1/preferences';
return api.post(url, {name: name, data: value});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios";
export default class Put {
put(name, value) {
let url = '/api/v1/preferences/' + name;
return api.put(url, {data: value});
}
}
@@ -1,28 +0,0 @@
/*
* index.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios.js";
export default class Summary {
get(start, end, code) {
return api.get('/api/v1/summary/basic', {params: {start: start, end: end, code: code}});
}
}
@@ -1,36 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/account/overview', {params: {start: startStr, end: endStr}});
}
expense(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/account/expense-dashboard', {params: {start: startStr, end: endStr}});
}
}
@@ -1,30 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/budget/overview', {params: {start: startStr, end: endStr}});
}
}
@@ -1,30 +0,0 @@
/*
* overview.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import {format} from "date-fns";
export default class Dashboard {
dashboard(start, end) {
let startStr = format(start, 'y-MM-dd');
let endStr = format(end, 'y-MM-dd');
return api.get('/api/v1/chart/category/overview', {params: {start: startStr, end: endStr}});
}
}
@@ -1,82 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
import {getCacheKey} from "../../../../support/get-cache-key.js";
export default class Get {
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
show(identifier, params) {
return api.get('/api/v1/accounts/' + identifier, {params: params});
}
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
index(params) {
// first, check API in some consistent manner.
// then, load if necessary.
const cacheKey = getCacheKey('/api/v1/accounts', params);
const cacheValid = window.store.get('cacheValid');
let cachedData = window.store.get(cacheKey);
if (cacheValid && typeof cachedData !== 'undefined') {
console.log('Cache is valid, return cache.');
return Promise.resolve(cachedData);
}
// if not, store in cache and then return res.
return api.get('/api/v1/accounts', {params: params}).then(response => {
console.log('Cache is invalid, return fresh.');
window.store.set(cacheKey, response.data);
return Promise.resolve({data: response.data.data, meta: response.data.meta});
});
}
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
transactions(identifier, params) {
const newParams = {
page: params.page ?? 1
};
if (params.hasOwnProperty('start')) {
newParams.start = format(params.start, 'y-MM-dd');
}
if (params.hasOwnProperty('end')) {
newParams.end = format(params.end, 'y-MM-dd');
}
return api.get('/api/v1/accounts/' + identifier + '/transactions', {params: newParams});
}
}
@@ -1,36 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Put {
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
put(identifier, params) {
return api.put('/api/v1/accounts/' + identifier, params);
}
}
@@ -1,35 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/budgets', {params: params});
}
}
@@ -1,35 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/currencies', {params: params});
}
}
@@ -1,35 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/piggy-banks', {params: params});
}
}
@@ -1,42 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/subscriptions', {params: params});
}
paid(params) {
return api.get('/api/v1/subscriptions/sum/paid', {params: params});
}
unpaid(params) {
return api.get('/api/v1/subscriptions/sum/unpaid', {params: params});
}
}
@@ -1,40 +0,0 @@
/*
* get.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Get {
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
list(params) {
return api.get('/api/v1/transactions', {params: params});
}
infiniteList(params) {
return api.get('/api/v1/infinite/transactions', {params: params});
}
show(id, params){
return api.get('/api/v1/transactions/' + id, {params: params});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Post {
post(submission) {
let url = '/api/v1/transactions';
return api.post(url, submission);
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Put {
put(submission, params) {
let url = '/api/v1/transactions/' + parseInt(params.id);
return api.put(url, submission);
}
}
@@ -1,45 +0,0 @@
/*
* list.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
import format from "date-fns/format";
export default class Get {
/**
*
* @param identifier
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
show(identifier, params) {
return api.get('/api/v1/user-groups/' + identifier, {params: params});
}
/**
*
* @param params
* @returns {Promise<AxiosResponse<any>>}
*/
index(params) {
return api.get('/api/v1/user-groups', {params: params});
}
}
@@ -1,33 +0,0 @@
/*
* post.js
* Copyright (c) 2024 james@firefly-iii.org.
*
* 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/.
*/
import {api} from "../../../../boot/axios";
export default class Post {
post(submission) {
let url = './api/v1/user-groups';
return api.post(url, submission);
}
use(groupId) {
let url = './api/v1/user-groups/' + groupId + '/use';
return api.post(url, {});
}
}
@@ -1,28 +0,0 @@
/*
* post.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../../boot/axios";
export default class Put {
put(submission, params) {
let url = '/api/v1/user-groups/' + parseInt(params.id);
return api.put(url, submission);
}
}
@@ -1,28 +0,0 @@
/*
* index.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
import {api} from "../../../boot/axios.js";
export default class Summary {
get(start, end, code) {
return api.get('/api/v1/summary/basic', {params: {start: start, end: end, code: code}});
}
}
-40
View File
@@ -1,40 +0,0 @@
/*
* axios.js
* Copyright (c) 2022 james@firefly-iii.org
*
* 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/>.
*/
import axios from 'axios'
// Be careful when using SSR for cross-request state pollution
// due to creating a Singleton instance here;
// If any client changes this (global) instance, it might be a
// good idea to move this instance creation inside of the
// "export default () => {}" function below (which runs individually
// for each client)
// for use inside Vue files (Options API) through this.$axios and this.$api
const url = '/';
const api = axios.create({baseURL: url, withCredentials: true});
axios.defaults.withCredentials = true;
axios.defaults.baseURL = url;
export {api}
-90
View File
@@ -1,90 +0,0 @@
/*
* bootstrap.js
* Copyright (c) 2023 james@firefly-iii.org
*
* 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/>.
*/
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
// import things
import axios from 'axios';
import store from "store";
import observePlugin from 'store/plugins/observe';
import Alpine from "alpinejs";
import * as bootstrap from 'bootstrap';
import {getFreshVariable} from "../store/get-fresh-variable.js";
import {getVariable} from "../store/get-variable.js";
import {getViewRange} from "../support/get-viewrange.js";
import {loadTranslations} from "../support/load-translations.js";
import adminlte from 'admin-lte';
store.addPlugin(observePlugin);
window.bootstrapped = false;
window.store = store;
window.bootstrap = bootstrap;
// always grab the preference "marker" from Firefly III.
getFreshVariable('lastActivity').then((serverValue) => {
if(null === serverValue) {
console.log('Server value is null in getFreshVariable.');
throw new Error('401 in getFreshVariable.');
}
const localValue = store.get('lastActivity');
store.set('cacheValid', localValue === serverValue);
store.set('lastActivity', serverValue);
console.log('Server value: ' + serverValue);
console.log('Local value: ' + localValue);
console.log('Cache valid: ' + (localValue === serverValue));
}).then(() => {
Promise.all([
getVariable('viewRange'),
getVariable('darkMode'),
getVariable('locale'),
getVariable('language'),
]).then((values) => {
if (!store.get('start') || !store.get('end')) {
// calculate new start and end, and store them.
const range = getViewRange(values[0], new Date);
store.set('start', range.start);
store.set('end', range.end);
}
// save local in window.__ something
window.__localeId__ = values[2];
store.set('language', values[3]);
store.set('locale', values[3]);
loadTranslations(values[3]).then(() => {
const event = new Event('firefly-iii-bootstrapped');
document.dispatchEvent(event);
window.bootstrapped = true;
});
});
}).catch((error) => {
console.error('Error while bootstrapping: ' + error);
});
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
window.Alpine = Alpine
@@ -1,33 +0,0 @@
/*
* grid-ff3-theme.css
* Copyright (c) 2024 james@firefly-iii.org.
*
* 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/.
*/
/* ag-theme-acmecorp.css */
.ag-theme-firefly-iii {
/* --ag-odd-row-background-color: #f00; */
}
.ag-theme-firefly-iii .ag-root {
border:0;
}
.ag-theme-firefly-iii .ag-root-wrapper
{
border:0;
}
.skip-links {display: none;}
@@ -1,42 +0,0 @@
/*
* BaseMode.js
* Copyright (c) 2024 https://github.com/DarKsandr/dark-editable
*
* License: MIT
*
* Copied and slightly edited by James Cole <james@firefly-iii.org>
*/
export default class BaseMode{
constructor(context) {
if(this.constructor === BaseMode){
throw new Error(`It's abstract class`);
}
this.context = context;
}
event_show(){
this.context.typeElement.hideError();
this.context.typeElement.element.value = this.context.value;
this.context.element.dispatchEvent(new CustomEvent("show"));
}
event_shown(){
this.context.element.dispatchEvent(new CustomEvent("shown"));
}
event_hide(){
this.context.element.dispatchEvent(new CustomEvent("hide"));
}
event_hidden(){
this.context.element.dispatchEvent(new CustomEvent("hidden"));
}
init(){
throw new Error('Method `init` not define!');
}
enable(){
throw new Error('Method `enable` not define!');
}
disable(){
throw new Error('Method `disable` not define!');
}
hide(){
throw new Error('Method `hide` not define!');
}
}
@@ -1,40 +0,0 @@
/*
* InlineMode.js
* Copyright (c) 2024 https://github.com/DarKsandr/dark-editable
*
* License: MIT
*
* Copied and slightly edited by James Cole <james@firefly-iii.org>
*/
import BaseMode from "./BaseMode.js";
export default class InlineMode extends BaseMode{
init(){
const open = () => {
if(!this.context.disabled){
const item = this.context.typeElement.create();
this.event_show();
this.context.element.removeEventListener('click', open);
this.context.element.innerHTML = '';
this.context.element.append(item);
this.event_shown();
}
}
this.context.element.addEventListener('click', open);
}
enable(){
}
disable(){
}
hide(){
this.event_hide();
this.context.element.innerHTML = this.context.value;
setTimeout(() => {
this.init();
this.event_hidden();
}, 100);
}
}
@@ -1,53 +0,0 @@
/*
* PopupMode.js
* Copyright (c) 2024 https://github.com/DarKsandr/dark-editable
*
* License: MIT
*
* Copied and slightly edited by James Cole <james@firefly-iii.org>
*/
import BaseMode from "./BaseMode.js";
export default class PopupMode extends BaseMode{
init(){
this.popover = new bootstrap.Popover(this.context.element, {
container: "body",
content: this.context.typeElement.create(),
html: true,
customClass: "dark-editable",
title: this.context.title,
});
this.context.element.addEventListener('show.bs.popover', () => {
this.event_show();
});
this.context.element.addEventListener('shown.bs.popover', () => {
this.event_shown();
});
this.context.element.addEventListener('hide.bs.popover', () => {
this.event_hide();
});
this.context.element.addEventListener('hidden.bs.popover', () => {
this.event_hidden();
});
document.addEventListener('click', (e) => {
const target = e.target;
if(target === this.popover.tip || target === this.context.element) return;
let current = target;
while(current = current.parentNode){
if(current === this.popover.tip) return;
}
this.hide();
})
}
enable(){
this.popover.enable();
}
disable(){
this.popover.disable();
}
hide(){
this.popover.hide();
}
}
@@ -1,287 +0,0 @@
/*
* BaseMode.js
* Copyright (c) 2024 https://github.com/DarKsandr/dark-editable
*
* License: MIT
*
* Copied and slightly edited by James Cole <james@firefly-iii.org>
*/
export default class BaseType {
context = null;
element = null;
error = null;
form = null;
load = null;
buttonGroup = null;
buttons = {success: null, cancel: null};
constructor(context) {
if (this.constructor === BaseType) {
throw new Error(`It's abstract class`);
}
this.context = context;
}
create() {
throw new Error('Method `create` not define!');
}
createContainer(element) {
const div = document.createElement(`div`);
// original list of elements:
this.element = element;
this.error = this.createContainerError();
this.form = this.createContainerForm();
this.load = this.createContainerLoad();
this.buttons.success = this.createButtonSuccess();
this.buttons.cancel = this.createButtonCancel();
// create first div, with label and input:
const topDiv = document.createElement(`div`);
topDiv.classList.add("col-12");
// create label:
const label = document.createElement(`label`);
label.classList.add("visually-hidden");
label.for = element.id;
// add label + input to top div:
topDiv.append(label, element);
// create second div, with button group:
const bottomDiv = document.createElement(`div`);
bottomDiv.classList.add("col-12");
// create button group:
this.buttonGroup = this.createButtonGroup();
// append buttons to button group:
this.buttonGroup.append(this.buttons.success, this.buttons.cancel);
bottomDiv.append(this.buttonGroup);
// append bottom and top div to form:
this.form.append(topDiv, bottomDiv);
//this.form.append(element, this.load, this.buttons.success, this.buttons.cancel);
//this.form.append(element, this.load, this.buttonGroup);
div.append(this.error, this.form);
return div;
}
createButtonGroup() {
const div = document.createElement(`div`);
div.classList.add("btn-group", "btn-group-sm");
return div;
}
createContainerError() {
const div = document.createElement(`div`);
div.classList.add("text-danger", "fst-italic", "mb-2", "fw-bold");
div.style.display = "none";
return div;
}
createContainerForm() {
const form = document.createElement(`form`);
form.classList.add("row", "row-cols-lg-auto", "g-3", "align-items-center");
//form.style.gap = "20px";
form.addEventListener('submit', async e => {
e.preventDefault();
const newValue = this.getValue();
if (this.context.send && this.context.pk && this.context.url && (this.context.value !== newValue)) {
this.showLoad();
let msg;
try {
const response = await this.ajax(newValue);
if (response.ok) {
msg = await this.context.success(response, newValue);
} else {
msg = await this.context.error(response, newValue) || `${response.status} ${response.statusText}`;
}
} catch (error) {
console.error(error);
msg = error;
}
if (msg) {
this.setError(msg);
this.showError();
} else {
this.setError(null);
this.hideError();
this.context.value = this.getValue();
this.context.modeElement.hide();
this.initText();
}
this.hideLoad();
} else {
this.context.value = this.getValue();
this.context.modeElement.hide();
this.initText();
}
this.context.element.dispatchEvent(new CustomEvent("save"));
})
return form;
}
createContainerLoad() {
const div = document.createElement(`div`);
div.style.display = "none";
div.style.position = "absolute";
div.style.background = "white";
div.style.width = "100%";
div.style.height = "100%";
div.style.top = 0;
div.style.left = 0;
const loader = document.createElement(`div`);
loader.classList.add("dark-editable-loader");
div.append(loader);
return div;
}
createButton() {
const button = document.createElement("button");
button.type = "button";
button.classList.add("btn", "btn-sm");
button.style.color = "transparent";
button.style.textShadow = "0 0 0 white";
return button;
}
createButtonSuccess() {
const btn_success = this.createButton();
btn_success.type = "submit";
btn_success.classList.add("btn-success");
btn_success.innerHTML = "✔";
return btn_success;
}
createButtonCancel() {
const btn_cancel = this.createButton();
btn_cancel.classList.add("btn-danger");
const div = document.createElement("div");
div.innerHTML = "✖";
btn_cancel.append(div);
btn_cancel.addEventListener("click", () => {
this.context.modeElement.hide();
});
return btn_cancel;
}
hideLoad() {
this.load.style.display = "none";
}
showLoad() {
this.load.style.display = "block";
}
ajax(new_value) {
let url = this.context.url;
//const form = new FormData;
let message;
let submit = false;
console.log(this.context);
// replace form with custom sets. Not sure yet of the format, this will have to grow in time.
if ('journal_description' === this.context.options.formType) {
submit = true;
message = {
transactions: [
{
transaction_journal_id: this.context.options.journalId,
description: new_value,
}
]
};
}
if(false === submit) {
console.error('Cannot deal with form type "'+this.context.formType+'"');
}
// form.append("pk", this.context.pk);
// form.append("name", this.context.name);
// form.append("value", new_value);
const option = {
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
}
};
option.method = this.context.ajaxOptions.method;
if(this.context.options.method) {
option.method = this.context.options.method;
}
if ('POST' === option.method || 'PUT' === this.context.options.method) {
option.body = JSON.stringify(message);
} else {
url += "?" + new URLSearchParams(form).toString();
}
return fetch(url, option);
}
async successResponse(response, newValue) {
}
async errorResponse(response, newValue) {
}
setError(errorMsg) {
this.error.innerHTML = errorMsg;
}
showError() {
this.error.style.display = "block";
}
hideError() {
if (this.error) {
this.error.style.display = "none";
}
}
createElement(name) {
const element = document.createElement(name);
console.log(element);
element.classList.add("form-control");
if (this.context.required) {
element.required = this.context.required;
}
this.add_focus(element);
return element;
}
add_focus(element) {
this.context.element.addEventListener('shown', function () {
element.focus();
});
}
initText() {
if (this.context.value === "") {
this.context.element.innerHTML = this.context.emptytext;
return true;
} else {
this.context.element.innerHTML = this.context.value;
return false;
}
}
initOptions() {
}
getValue() {
return this.element.value;
}
}
@@ -1,16 +0,0 @@
import DateType from "./DateType.js";
export default class DateTimeType extends DateType{
create(){
const input = this.createElement(`input`);
input.type = "datetime-local";
return this.createContainer(input);
}
initOptions(){
this.context.get_opt("format", "YYYY-MM-DD HH:mm");
this.context.get_opt("viewformat", "YYYY-MM-DD HH:mm");
this.context.value = moment(this.context.value).format("YYYY-MM-DDTHH:mm");
}
}
@@ -1,25 +0,0 @@
import BaseType from "./BaseType.js";
export default class DateType extends BaseType{
create(){
const input = this.createElement(`input`);
input.type = "date";
return this.createContainer(input);
}
initText(){
if(this.value === ""){
this.context.element.innerHTML = this.context.emptytext;
return true;
} else {
this.context.element.innerHTML = moment(this.context.value).format(this.context.viewformat);
return false;
}
}
initOptions(){
this.context.get_opt("format", "YYYY-MM-DD");
this.context.get_opt("viewformat", "YYYY-MM-DD");
}
}
@@ -1,19 +0,0 @@
import BaseType from "./BaseType.js";
export default class InputType extends BaseType{
create(){
// expand input element with necessary classes and things.
// <input type="text" class="form-control form-control-md" id="inlineFormInputGroupUsername" placeholder="Username">
const input = this.createElement(`input`);
const id = this.context.element.id + '_input';
input.type = this.context.type;
input.id = id;
input.autocomplete = 'off';
input.placeholder = this.context.element.innerText;
input.classList.add("form-control", "form-control-md");
return this.createContainer(input);
}
}
@@ -1,36 +0,0 @@
import BaseType from "./BaseType.js";
export default class SelectType extends BaseType{
create(){
const select = this.createElement(`select`);
this.context.source.forEach(item => {
const opt = document.createElement(`option`);
opt.value = item.value;
opt.innerHTML = item.text;
select.append(opt);
});
return this.createContainer(select);
}
initText(){
this.context.element.innerHTML = this.context.emptytext;
if(this.context.value !== "" && this.context.source.length > 0){
for(const key in this.context.source){
const item = this.context.source[ key ];
if(item.value == this.context.value){
this.context.element.innerHTML = item.text;
return false;
}
}
}
return true;
}
initOptions(){
this.context.get_opt("source", []);
if(typeof this.context.source === "string" && this.context.source !== ""){
this.context.source = JSON.parse(this.context.source);
}
}
}
@@ -1,9 +0,0 @@
import BaseType from "./BaseType.js";
export default class TextAreaType extends BaseType{
create(){
const textarea = this.createElement(`textarea`);
return this.createContainer(textarea);
}
}
@@ -1,87 +0,0 @@
.dark-editable-element{
border-bottom: dashed 1px #0088cc;
text-decoration: none;
cursor: pointer;
}
.dark-editable-element-disabled{
border-bottom: none;
cursor: default;
}
.dark-editable-element-empty{
font-style: italic;
color: #DD1144;
}
.dark-editable{
max-width: none;
}
.dark-editable-loader {
font-size: 5px;
left: 50%;
top: 50%;
width: 1em;
height: 1em;
border-radius: 50%;
position: relative;
text-indent: -9999em;
-webkit-animation: load5 1.1s infinite ease;
animation: load5 1.1s infinite ease;
-webkit-transform: translateZ(0);
-ms-transform: translateZ(0);
transform: translateZ(0);
}
@-webkit-keyframes load5 {
0%,
100% {
box-shadow: 0em -2.6em 0em 0em #000000, 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.5), -1.8em -1.8em 0 0em rgba(0,0,0, 0.7);
}
12.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.7), 1.8em -1.8em 0 0em #000000, 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.5);
}
25% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.5), 1.8em -1.8em 0 0em rgba(0,0,0, 0.7), 2.5em 0em 0 0em #000000, 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
37.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.5), 2.5em 0em 0 0em rgba(0,0,0, 0.7), 1.75em 1.75em 0 0em #000000, 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
50% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.5), 1.75em 1.75em 0 0em rgba(0,0,0, 0.7), 0em 2.5em 0 0em #000000, -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
62.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.5), 0em 2.5em 0 0em rgba(0,0,0, 0.7), -1.8em 1.8em 0 0em #000000, -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
75% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.5), -1.8em 1.8em 0 0em rgba(0,0,0, 0.7), -2.6em 0em 0 0em #000000, -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
87.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.5), -2.6em 0em 0 0em rgba(0,0,0, 0.7), -1.8em -1.8em 0 0em #000000;
}
}
@keyframes load5 {
0%,
100% {
box-shadow: 0em -2.6em 0em 0em #000000, 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.5), -1.8em -1.8em 0 0em rgba(0,0,0, 0.7);
}
12.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.7), 1.8em -1.8em 0 0em #000000, 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.5);
}
25% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.5), 1.8em -1.8em 0 0em rgba(0,0,0, 0.7), 2.5em 0em 0 0em #000000, 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
37.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.5), 2.5em 0em 0 0em rgba(0,0,0, 0.7), 1.75em 1.75em 0 0em #000000, 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
50% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.5), 1.75em 1.75em 0 0em rgba(0,0,0, 0.7), 0em 2.5em 0 0em #000000, -1.8em 1.8em 0 0em rgba(0,0,0, 0.2), -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
62.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.5), 0em 2.5em 0 0em rgba(0,0,0, 0.7), -1.8em 1.8em 0 0em #000000, -2.6em 0em 0 0em rgba(0,0,0, 0.2), -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
75% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.5), -1.8em 1.8em 0 0em rgba(0,0,0, 0.7), -2.6em 0em 0 0em #000000, -1.8em -1.8em 0 0em rgba(0,0,0, 0.2);
}
87.5% {
box-shadow: 0em -2.6em 0em 0em rgba(0,0,0, 0.2), 1.8em -1.8em 0 0em rgba(0,0,0, 0.2), 2.5em 0em 0 0em rgba(0,0,0, 0.2), 1.75em 1.75em 0 0em rgba(0,0,0, 0.2), 0em 2.5em 0 0em rgba(0,0,0, 0.2), -1.8em 1.8em 0 0em rgba(0,0,0, 0.5), -2.6em 0em 0 0em rgba(0,0,0, 0.7), -1.8em -1.8em 0 0em #000000;
}
}
@@ -1,181 +0,0 @@
/*
* dark-editable.js
* Copyright (c) 2024 https://github.com/DarKsandr/dark-editable
*
* License: MIT
*
* Copied and slightly edited by James Cole <james@firefly-iii.org>
*/
import "./dark-editable.css";
import PopupMode from "./Modes/PopupMode.js";
import InlineMode from "./Modes/InlineMode.js";
import BaseType from "./Types/BaseType.js";
import InputType from "./Types/InputType.js";
import TextAreaType from "./Types/TextAreaType.js";
import SelectType from "./Types/SelectType.js";
import DateType from "./Types/DateType.js";
import DateTimeType from "./Types/DateTimeType.js";
export default class DarkEditable{
modeElement = null;
typeElement = null;
mode = null;
type = null;
emptytext = null;
viewformat = null;
pk = null;
name = null;
constructor(element, options = {}){
this.element = element;
this.options = options;
this.init_options();
this.typeElement = this.route_type();
this.typeElement.initOptions();
this.modeElement = this.route_mode();
this.modeElement.init();
this.init_text();
this.init_style();
if(this.disabled){
this.disable();
}
this.element.dispatchEvent(new CustomEvent("init"));
}
/* INIT METHODS */
get_opt(name, default_value){
return this[ name ] = this.element.dataset?.[ name ] ?? this.options?.[ name ] ?? default_value;
}
get_opt_bool(name, default_value){
this.get_opt(name, default_value);
if(typeof this[ name ] !== "boolean"){
if(this[ name ] === "true") {
this[ name ] = true;
} else if(this[ name ] === "false") {
this[ name ] = false;
} else {
this[ name ] = default_value;
}
}
return this[ name ];
}
init_options(){
//priority date elements
this.get_opt("value", this.element.innerHTML);
this.get_opt("name", this.element.id);
this.get_opt("pk", null);
this.get_opt("title", "");
this.get_opt("type", "text");
this.get_opt("emptytext", "Empty");
this.get_opt("mode", "popup");
this.get_opt("url", null);
this.get_opt("ajaxOptions", {});
this.ajaxOptions = Object.assign({
method: "POST",
dataType: "text",
}, this.ajaxOptions);
this.get_opt_bool("send", true);
this.get_opt_bool("disabled", false);
this.get_opt_bool("required", false);
if(this.options?.success && typeof this.options?.success == "function"){
this.success = this.options.success;
}
if(this.options?.error && typeof this.options?.error == "function"){
this.error = this.options.error;
}
}
init_text(){
const empty_class = "dark-editable-element-empty";
this.element.classList.remove(empty_class);
if(this.typeElement.initText()){
this.element.classList.add(empty_class);
}
}
init_style(){
this.element.classList.add("dark-editable-element");
}
/* INIT METHODS END */
route_mode(){
switch (this.mode){
default:
throw new Error(`Mode ${this.mode} not found!`)
case 'popup':
return new PopupMode(this);
case 'inline':
return new InlineMode(this);
}
}
route_type(){
if(this.type.prototype instanceof BaseType){
return new this.type(this);
}
if(typeof this.type === 'string'){
switch(this.type){
case "text":
case "password":
case "email":
case "url":
case "tel":
case "number":
case "range":
case "time":
return new InputType(this);
case "textarea":
return new TextAreaType(this);
case "select":
return new SelectType(this);
case "date":
return new DateType(this);
case "datetime":
return new DateTimeType(this);
}
}
throw new Error(`Undefined type`);
}
/* AJAX */
async success(response, newValue){
return await this.typeElement.successResponse(response, newValue);
}
async error(response, newValue){
return await this.typeElement.errorResponse(response, newValue);
}
/* AJAX END */
/* METHODS */
enable(){
this.disabled = false;
this.element.classList.remove("dark-editable-element-disabled");
this.modeElement.enable();
}
disable(){
this.disabled = true;
this.element.classList.add("dark-editable-element-disabled");
this.modeElement.enable();
}
setValue(value){
this.value = value;
this.init_text();
}
getValue(){
return this.value;
}
/* METHODS END */
}
@@ -1,489 +0,0 @@
/*
* show.js
* Copyright (c) 2024 james@firefly-iii.org.
*
* 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/.
*/
import '../../boot/bootstrap.js';
import dates from "../shared/dates.js";
import i18next from "i18next";
import {format} from "date-fns";
import formatMoney from "../../util/format-money.js";
import Get from "../../api/v1/model/account/get.js";
import Put from "../../api/v1/model/account/put.js";
import AccountRenderer from "../../support/renderers/AccountRenderer.js";
import {showInternalsButton} from "../../support/page-settings/show-internals-button.js";
import {showWizardButton} from "../../support/page-settings/show-wizard-button.js";
import {setVariable} from "../../store/set-variable.js";
import {getVariables} from "../../store/get-variables.js";
import pageNavigation from "../../support/page-navigation.js";
import {getVariable} from "../../store/get-variable.js";
// set type from URL
const beforeQuery = window.location.href.split('?');
const urlParts = beforeQuery[0].split('/');
const type = urlParts[urlParts.length - 1];
let sortingColumn = '';
let sortDirection = '';
let page = 1;
// get sort parameters
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
sortingColumn = params.column ?? '';
sortDirection = 'asc';
if(sortingColumn[0] === '-') {
sortingColumn = sortingColumn.substring(1);
sortDirection = 'desc';
}
page = parseInt(params.page ?? 1);
showInternalsButton();
showWizardButton();
// TODO currency conversion
// TODO page cleanup and recycle for transaction lists.
// TODO process startPeriod and endPeriod.
let index = function () {
return {
// notifications
notifications: {
error: {
show: false, text: '', url: '',
}, success: {
show: false, text: '', url: '',
}, wait: {
show: false, text: '',
}
},
convertToPrimary: false,
totalPages: 1,
page: 1,
pageUrl: '',
filters: {
active: null,
name: null,
type: type,
},
pageOptions: {
isLoading: true,
groupedAccounts: true,
sortingColumn: sortingColumn,
sortDirection: sortDirection,
},
// available columns:
// visible is hard coded, enabled is user-configurable.
tableColumns: {
drag_and_drop: {
visible: true,
enabled: true,
},
active: {
visible: true,
enabled: true,
},
name: {
visible: true,
enabled: true,
},
type: {
visible: type === 'asset',
enabled: true,
},
liability_type: {
visible: type === 'liabilities',
enabled: true,
},
liability_direction: {
visible: type === 'liabilities',
enabled: true,
},
liability_interest: {
visible: type === 'liabilities',
enabled: true,
},
number: {
visible: true,
enabled: true,
},
current_balance: {
visible: type !== 'liabilities',
enabled: true,
},
amount_due: {
visible: type === 'liabilities',
enabled: true,
},
last_activity: {
visible: true,
enabled: true,
},
balance_difference: {
visible: true,
enabled: true,
},
menu: {
visible: true,
enabled: true,
},
},
editors: {},
accounts: [],
lastClickedFilter: '',
lastFilterInput: '',
goToPage(page) {
this.page = page;
this.loadAccounts();
},
applyFilter() {
this.filters[this.lastClickedFilter] = this.lastFilterInput;
this.page = 1;
setVariable(this.getPreferenceKey('filters'), this.filters);
// hide modal
window.bootstrap.Modal.getInstance(document.getElementById('filterModal')).hide();
this.loadAccounts();
},
saveGroupedAccounts() {
setVariable(this.getPreferenceKey('grouped'), this.pageOptions.groupedAccounts);
this.page = 1;
this.loadAccounts();
},
removeFilter(field) {
this.filters[field] = null;
this.page = 1;
setVariable(this.getPreferenceKey('filters'), this.filters);
this.loadAccounts();
},
hasFilters() {
return this.filters.name !== null;
},
showFilterDialog(field) {
this.lastFilterInput = this.filters[field] ?? '';
this.lastClickedFilter = field;
document.getElementById('filterInput').focus();
},
accountRole(roleName) {
return i18next.t('firefly.account_role_' + roleName);
},
getPreferenceKey(name) {
return 'acc_index_' + type + '_' + name;
},
pageNavigation() {
return pageNavigation(this.totalPages, this.page, this.generatePageUrl(false));
},
sort(column) {
this.page = 1;
this.pageOptions.sortingColumn = column;
this.pageOptions.sortDirection = this.pageOptions.sortDirection === 'asc' ? 'desc' : 'asc';
this.updatePageUrl();
// get sort column
setVariable(this.getPreferenceKey('sc'), this.pageOptions.sortingColumn);
setVariable(this.getPreferenceKey('sd'), this.pageOptions.sortDirection);
this.loadAccounts();
return false;
},
updatePageUrl() {
this.pageUrl = this.generatePageUrl(true);
window.history.pushState({}, "", this.pageUrl);
},
generatePageUrl(includePageNr) {
let url = './accounts/' + type + '?column=' + this.pageOptions.sortingColumn + '&direction=' + this.pageOptions.sortDirection + '&page=';
if (includePageNr) {
return url + this.page
}
return url;
},
formatMoney(amount, currencyCode) {
return formatMoney(amount, currencyCode);
},
format(date) {
return format(date, i18next.t('config.date_time_fns'));
},
saveColumnSettings() {
let newSettings = {};
for (let key in this.tableColumns) {
if (this.tableColumns.hasOwnProperty(key)) {
newSettings[key] = this.tableColumns[key].enabled;
}
}
console.log('New settings', newSettings);
setVariable(this.getPreferenceKey('columns'), newSettings);
},
init() {
// modal filter thing
const myModalEl = document.getElementById('filterModal')
myModalEl.addEventListener('shown.bs.modal', event => {
document.getElementById('filterInput').focus();
})
// some opts
this.pageOptions.isLoading = true;
this.notifications.wait.show = true;
this.page = page;
this.notifications.wait.text = i18next.t('firefly.wait_loading_data');
// start by collecting all preferences, create + put in the local store.
getVariables([
{name: this.getPreferenceKey('columns'), default: {"drag_and_drop": false}},
{name: this.getPreferenceKey('sc'), default: ''},
{name: this.getPreferenceKey('sd'), default: ''},
{name: this.getPreferenceKey('filters'), default: this.filters},
{name: this.getPreferenceKey('grouped'), default: true},
{name: 'convert_to_primary', default: false},
]).then((res) => {
// process columns:
for (let k in res[0]) {
if (res[0].hasOwnProperty(k) && this.tableColumns.hasOwnProperty(k)) {
this.tableColumns[k].enabled = res[0][k] ?? true;
}
}
// process sorting column:
this.pageOptions.sortingColumn = '' === this.pageOptions.sortingColumn ? res[1] : this.pageOptions.sortingColumn;
// process sort direction
this.pageOptions.sortDirection = '' === this.pageOptions.sortDirection ? res[2] : this.pageOptions.sortDirection;
// filters
for (let k in res[3]) {
if (res[3].hasOwnProperty(k) && this.filters.hasOwnProperty(k)) {
this.filters[k] = res[3][k];
}
}
// group accounts
this.pageOptions.groupedAccounts = res[4];
// convert to primary?
this.convertToPrimary = res[5];
this.loadAccounts();
});
},
saveActiveFilter(e) {
this.page = 1;
if ('both' === e.currentTarget.value) {
this.filters.active = null;
}
if ('active' === e.currentTarget.value) {
this.filters.active = true;
}
if ('inactive' === e.currentTarget.value) {
this.filters.active = false;
}
setVariable(this.getPreferenceKey('filters'), this.filters);
this.loadAccounts();
},
renderObjectValue(field, account) {
let renderer = new AccountRenderer();
if ('name' === field) {
return renderer.renderName(account);
}
},
submitInlineEdit(e) {
e.preventDefault();
const newTarget = e.currentTarget;
const index = newTarget.dataset.index;
const fieldName = newTarget.dataset.field;
const accountId = newTarget.dataset.id;
// need to find the input thing
console.log('Clicked edit button for account on index #' + index + ' and field ' + fieldName);
const querySelector = 'input[data-field="' + fieldName + '"][data-index="' + index + '"]';
// console.log(querySelector);
const newValue = document.querySelectorAll(querySelector)[0].value ?? '';
if ('' === newValue) {
return;
}
console.log('new field name is ' + fieldName + '=' + newValue + ' for account #' + newTarget.dataset.id);
const params = {};
params[fieldName] = newValue;
(new Put()).put(accountId, params);
// update value, should auto render correctly!
this.accounts[index][fieldName] = newValue;
this.accounts[index].nameEditorVisible = false;
},
cancelInlineEdit(e) {
const newTarget = e.currentTarget;
const index = newTarget.dataset.index;
this.accounts[index].nameEditorVisible = false;
},
triggerEdit(e) {
const target = e.currentTarget;
const index = target.dataset.index;
const id = target.dataset.id;
console.log('Index of this row is ' + index + ' and ID is ' + id);
this.accounts[index].nameEditorVisible = true;
},
loadAccounts() {
this.pageOptions.isLoading = true;
// sort instructions (only one column)
let sorting = this.pageOptions.sortingColumn;
if('asc' === this.pageOptions.sortDirection && '' !== sorting) {
sorting = '-' + sorting;
}
// filter instructions
let filters = {};
let type = this.filters.type;
let active = this.filters.active;
for (let k in this.filters) {
if (this.filters.hasOwnProperty(k) && null !== this.filters[k]) {
filters[k] = this.filters[k];
//filters.push({column: k, filter: this.filters[k]});
}
}
delete filters.type;
// get start and end from the store:
const start = new Date(window.store.get('start'));
const end = new Date(window.store.get('end'));
const today = new Date();
let params = {
sort: sorting,
filter: filters,
active: active,
date: format(today,'yyyy-MM-dd'),
type: type,
page: this.page,
start: start,
end: end
};
if (!this.tableColumns.balance_difference.enabled) {
// delete params.startPeriod;
// delete params.endPeriod;
}
this.accounts = [];
let groupedAccounts = {};
// one page only
(new Get()).index(params).then(response => {
this.totalPages = response.meta.pagination.total_pages;
for (let i = 0; i < response.data.length; i++) {
if (response.data.hasOwnProperty(i)) {
let current = response.data[i];
let account = {
id: parseInt(current.id),
active: current.attributes.active,
name: current.attributes.name,
nameEditorVisible: false,
type: current.attributes.type,
role: current.attributes.account_role,
iban: null === current.attributes.iban ? '' : current.attributes.iban.match(/.{1,4}/g).join(' '),
account_number: null === current.attributes.account_number ? '' : current.attributes.account_number,
last_activity: null === current.attributes.last_activity ? '' : format(new Date(current.attributes.last_activity), i18next.t('config.month_and_day_fns')),
liability_type: current.attributes.liability_type,
liability_direction: current.attributes.liability_direction,
interest: current.attributes.interest,
interest_period: current.attributes.interest_period,
// currency info
currency_code: current.attributes.currency_code,
primary_currency_code: current.attributes.primary_currency_code,
// balances.
current_balance: current.attributes.current_balance,
pc_current_balance: current.attributes.pc_current_balance,
balance_difference: current.attributes.balance_difference,
pc_balance_difference: current.attributes.pc_balance_difference,
debt_amount: current.attributes.debt_amount,
pc_debt_amount: current.attributes.debt_amount,
};
console.log(account);
// get group info:
let groupId = current.attributes.object_group_id;
if(!this.pageOptions.groupedAccounts) {
groupId = '0';
}
if (!groupedAccounts.hasOwnProperty(groupId)) {
groupedAccounts[groupId] = {
group: {
id: '0' === groupId || null === groupId ? null : parseInt(groupId),
title: current.attributes.object_group_title, // are ignored if group id is null.
order: current.attributes.object_group_order,
},
accounts: [],
}
}
groupedAccounts[groupId].accounts.push(account);
}
}
// order grouped accounts by order.
let sortable = [];
for (let set in groupedAccounts) {
sortable.push(groupedAccounts[set]);
}
sortable.sort(function(a, b) {
return a.group.order - b.group.order;
});
this.accounts = sortable;
this.notifications.wait.show = false;
this.pageOptions.isLoading = false;
});
},
}
}
let comps = {index, dates};
function loadPage() {
Object.keys(comps).forEach(comp => {
console.log(`Loading page component "${comp}"`);
let data = comps[comp]();
Alpine.data(comp, () => data);
});
Alpine.magic("t", (el) => {
return (name, vars) => {
return i18next.t(name, vars);
};
});
Alpine.start();
}
// wait for load until bootstrapped event is received.
document.addEventListener('firefly-iii-bootstrapped', () => {
console.log('Loaded through event listener.');
loadPage();
});
// or is bootstrapped before event is triggered.
if (window.bootstrapped) {
console.log('Loaded through window variable.');
loadPage();
}
@@ -1,111 +0,0 @@
/*
* template.js
* Copyright (c) 2024 james@firefly-iii.org.
*
* 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/.
*/
import '../../boot/bootstrap.js';
import dates from "../shared/dates.js";
import Post from "../../api/v1/model/user-group/post.js";
import i18next from "i18next";
let administrations = function () {
return {
title: '',
errors: {
title: []
},
// notifications
notifications: {
error: {
show: false, text: '', url: '',
}, success: {
show: false, text: '', url: '',
}, wait: {
show: false, text: '',
}
},
// state of the form is stored in formState:
formStates: {
isSubmitting: false,
returnHereButton: false,
saveAsNewButton: false, // edit form only
resetButton: false,
},
// form behaviour
formBehaviour: {
formType: 'create', // or 'update'
},
changedTitle() {
},
pageProperties: {},
submitForm() {
this.errors.title = [];
(new Post()).post({title: this.title}).then(response => {
if (this.formStates.returnHereButton) {
this.notifications.success.show = true;
this.notifications.success.text = i18next.t('firefly.new_administration_created', {title: response.data.data.attributes.title});
this.notifications.success.url = './administrations';
}
if (this.formStates.resetButton) {
this.title = '';
}
if (!this.formStates.returnHereButton) {
window.location.href = './administrations?user_group_id=' + parseInt(response.data.data.id) + '&message=created';
}
}).catch(error => {
this.errors.title = error.response.data.errors.title;
});
},
cancelForm() {
window.location.href = './administrations';
},
init() {
}
}
}
let comps = {administrations, dates};
function loadPage() {
Object.keys(comps).forEach(comp => {
console.log(`Loading page component "${comp}"`);
let data = comps[comp]();
Alpine.data(comp, () => data);
});
Alpine.start();
}
// wait for load until bootstrapped event is received.
document.addEventListener('firefly-iii-bootstrapped', () => {
console.log('Loaded through event listener.');
loadPage();
});
// or is bootstrapped before event is triggered.
if (window.bootstrapped) {
console.log('Loaded through window variable.');
loadPage();
}
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff. Show more