Skip to content

Firefly III: a personal finances manager

Clean up lint errors in JS.

James Cole0902235f9258
diff --git a/resources/assets/v3/js/api/model/webhook/get.js b/resources/assets/v3/js/api/model/webhook/get.js
index 9644acf4d6..166abc7c74 100644
--- a/resources/assets/v3/js/api/model/webhook/get.js
+++ b/resources/assets/v3/js/api/model/webhook/get.js
@@ -22,6 +22,9 @@
import {api} from "../../../boot/axios";
export default class Get {
+ list(params){
+ return api.get('/api/v1/webhooks', {params: params});
+ }
show(id, params){
return api.get('/api/v1/webhooks/' + parseInt(id), {params: params});
diff --git a/resources/assets/v3/js/api/model/webhook/post.js b/resources/assets/v3/js/api/model/webhook/post.js
index 1ab1056da9..f8394b41a3 100644
--- a/resources/assets/v3/js/api/model/webhook/post.js
+++ b/resources/assets/v3/js/api/model/webhook/post.js
@@ -25,4 +25,9 @@ export default class Post {
let url = '/api/v1/webhooks';
return api.post('./api/v1/webhooks/' + webhook + '/trigger-transaction/' + transaction, {});
}
+
+ post(submission) {
+ let url = '/api/v1/webhooks/';
+ return api.post(url, submission);
+ }
}
diff --git a/resources/assets/v3/js/pages/piggy-banks/show.js b/resources/assets/v3/js/pages/piggy-banks/show.js
index 9350007706..edbfe659bf 100644
--- a/resources/assets/v3/js/pages/piggy-banks/show.js
+++ b/resources/assets/v3/js/pages/piggy-banks/show.js
@@ -25,6 +25,8 @@ import i18next from "i18next";
import {drawSingleCurrencyChart} from '../../shared/draw-chart.js';
import {getVariable} from "../../store/get-variable.js";
+window.enableDates = false;
+
let show = function () {
return {
init() {
diff --git a/resources/assets/v3/js/pages/transactions/shared/parse-from-entries.js b/resources/assets/v3/js/pages/transactions/shared/parse-from-entries.js
index 10f18a41ad..cd60192d36 100644
--- a/resources/assets/v3/js/pages/transactions/shared/parse-from-entries.js
+++ b/resources/assets/v3/js/pages/transactions/shared/parse-from-entries.js
@@ -24,7 +24,7 @@
export function parseFromEntries(entries, originals, transactionType) {
let returnArray = [];
for (let i in entries) {
- if (entries.hasOwnProperty(i)) {
+ if (Object.hasOwn(entries, i)) {
const entry = entries[i];
let compare = false;
let original = {};
diff --git a/resources/assets/v3/js/pages/transactions/shared/process-attachments.js b/resources/assets/v3/js/pages/transactions/shared/process-attachments.js
index 7b8fc4b15d..b80f7b3584 100644
--- a/resources/assets/v3/js/pages/transactions/shared/process-attachments.js
+++ b/resources/assets/v3/js/pages/transactions/shared/process-attachments.js
@@ -26,11 +26,11 @@ let uploadFiles = function (fileData) {
let hasError = false;
for (const key in fileData) {
- if (fileData.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294 && false === hasError) {
+ if (Object.hasOwn(fileData, key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294 && false === hasError) {
let poster = new AttachmentPost();
poster.post(fileData[key].name, 'TransactionJournal', fileData[key].journal).then(response => {
let attachmentId = parseInt(response.data.data.id);
- poster.upload(attachmentId, fileData[key].content).then(attachmentResponse => {
+ poster.upload(attachmentId, fileData[key].content).then(() => {
uploads++;
if (uploads === count) {
const event = new CustomEvent('upload-success', {detail: {some: 'details'}});
@@ -73,9 +73,9 @@ export function processAttachments(groupId, transactions) {
// 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) {
+ if (Object.hasOwn(attachments, 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) {
+ if (Object.hasOwn(attachments[key].files, fileKey) && /^0$|^[1-9]\d*$/.test(fileKey) && fileKey <= 4294967294) {
// include journal thing.
toBeUploaded.push({
journal: transactions[key].transaction_journal_id,
@@ -89,7 +89,7 @@ export function processAttachments(groupId, transactions) {
// loop all uploads. This is async.
for (const key in toBeUploaded) {
- if (toBeUploaded.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ if (Object.hasOwn(toBeUploaded, key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
// create file reader thing that will read all of these uploads
(function (f, key) {
diff --git a/resources/assets/v3/js/pages/transactions/shared/process-transaction-links.js b/resources/assets/v3/js/pages/transactions/shared/process-transaction-links.js
index c6b1bfc8b0..239e0d073d 100644
--- a/resources/assets/v3/js/pages/transactions/shared/process-transaction-links.js
+++ b/resources/assets/v3/js/pages/transactions/shared/process-transaction-links.js
@@ -3,10 +3,10 @@ import PostLink from "../../../api/model/transaction-link/post.js";
export function processTransactionLinks(transactions) {
let count = 0;
for (let i = 0; i < transactions.length; i++) {
- if (transactions.hasOwnProperty(i) && this.links.hasOwnProperty(i)) {
+ if (Object.hasOwn(transactions,i) && Object.hasOwn(this.links, i)) {
let journalId = transactions[i];
for (let j = 0; j < this.links[i].length; j++) {
- if (this.links[i].hasOwnProperty(j)) {
+ if (Object.hasOwn(this.links[i], j)) {
count++;
let link = this.links[i][j];
let left = journalId;
diff --git a/resources/assets/v3/js/pages/transactions/shared/redirect-after-transaction-links.js b/resources/assets/v3/js/pages/transactions/shared/redirect-after-transaction-links.js
index 5ee15826e4..52f3070b30 100644
--- a/resources/assets/v3/js/pages/transactions/shared/redirect-after-transaction-links.js
+++ b/resources/assets/v3/js/pages/transactions/shared/redirect-after-transaction-links.js
@@ -2,9 +2,9 @@ export function redirectAfterTransactionLinks(oldI, oldJ) {
this.links[oldI][oldJ].stored = true;
let completed = true;
for (let i = 0; i < this.links.length; i++) {
- if (this.links.hasOwnProperty(i)) {
+ if (Object.hasOwn(this.links, i)) {
for (let j = 0; j < this.links[i].length; j++) {
- if (this.links[i].hasOwnProperty(j)) {
+ if (Object.hasOwn(this.links[i], j)) {
if (false === this.links[i][i].stored) {
completed = false;
}
diff --git a/resources/assets/v3/js/pages/transactions/shared/render-map.js b/resources/assets/v3/js/pages/transactions/shared/render-map.js
index 9e23c8c56a..c0a8cd992a 100644
--- a/resources/assets/v3/js/pages/transactions/shared/render-map.js
+++ b/resources/assets/v3/js/pages/transactions/shared/render-map.js
@@ -59,7 +59,7 @@ export function renderMap(index, useDefault) {
}));
// add marker.
- if(this.markers.hasOwnProperty(index)) {
+ if(Object.hasOwn(this.markers, index)) {
this.maps[index].removeLayer(this.markers[index]);
}
this.markers[index] = L.marker([latitude, longitude]);
diff --git a/resources/assets/v3/js/pages/transactions/shared/respond-to-tab-switch.js b/resources/assets/v3/js/pages/transactions/shared/respond-to-tab-switch.js
index e13407ecd9..9ad634e192 100644
--- a/resources/assets/v3/js/pages/transactions/shared/respond-to-tab-switch.js
+++ b/resources/assets/v3/js/pages/transactions/shared/respond-to-tab-switch.js
@@ -23,7 +23,7 @@ export function respondToTabSwitch(event) {
// event.relatedTarget // previous active tab
let index = parseInt(event.currentTarget.dataset.index);
console.log(this);
- if (this.maps.hasOwnProperty(index)) {
+ if (Object.hasOwn(this.maps, index)) {
this.maps[index].invalidateSize();
}
//console.log('Switched to new tab!', event.target.dataset.index);
diff --git a/resources/assets/v3/js/pages/transactions/shared/splice-errors-into-transactions.js b/resources/assets/v3/js/pages/transactions/shared/splice-errors-into-transactions.js
index 8df406d30e..1781540c78 100644
--- a/resources/assets/v3/js/pages/transactions/shared/splice-errors-into-transactions.js
+++ b/resources/assets/v3/js/pages/transactions/shared/splice-errors-into-transactions.js
@@ -21,9 +21,8 @@ import i18next from "i18next";
function cleanupErrors(fullName, shortName, errors) {
let newErrors = [];
- let message = '';
for (let i in errors) {
- if (errors.hasOwnProperty(i)) {
+ if (Object.hasOwn(errors, i)) {
newErrors.push(errors[i].replace(fullName, shortName));
}
}
@@ -35,7 +34,7 @@ export function spliceErrorsIntoTransactions(errors, transactions) {
let fieldName;
let errorArray;
for (const key in errors) {
- if (errors.hasOwnProperty(key)) {
+ if (Object.hasOwn(errors,key)) {
if (key === 'group_title') {
console.error('Cannot handle error in group title.');
// todo handle group errors.
@@ -45,7 +44,7 @@ export function spliceErrorsIntoTransactions(errors, transactions) {
transactionIndex = parseInt(key.split('.')[1]);
fieldName = key.split('.')[2];
errorArray = cleanupErrors(key, fieldName, errors[key]);
- if (!transactions.hasOwnProperty(transactionIndex)) {
+ if (!Object.hasOwn(transactions, transactionIndex)) {
console.error('Cannot handle errors in index #' + transactionIndex);
continue;
}
diff --git a/resources/assets/v3/js/pages/transactions/show.js b/resources/assets/v3/js/pages/transactions/show.js
index 66700d4c7a..0515a77d3f 100644
--- a/resources/assets/v3/js/pages/transactions/show.js
+++ b/resources/assets/v3/js/pages/transactions/show.js
@@ -24,6 +24,7 @@ import dates from '../shared/dates.js';
import i18next from "i18next";
import Get from '../../api/model/transaction/get.js';
import {format} from "date-fns";
+import Alpine from 'alpinejs';
window.enableDates = false;
@@ -50,7 +51,7 @@ let show = function () {
const info = response.data.data;
this.group.transactions = [];
for(let i =0;i<info.attributes.transactions.length;i++){
- if(info.attributes.transactions.hasOwnProperty(i)) {
+ if(Object.hasOwn(info.attributes.transactions, i)) {
let current =info.attributes.transactions[i];
current.dateObject = new Date(current.date);
current.dateFormatted = format(current.dateObject, this.i18next.t('config.date_time_fns'))
diff --git a/resources/assets/v3/js/pages/webhooks/create.js b/resources/assets/v3/js/pages/webhooks/create.js
index 91b51665d2..3bde4950a3 100644
--- a/resources/assets/v3/js/pages/webhooks/create.js
+++ b/resources/assets/v3/js/pages/webhooks/create.js
@@ -25,6 +25,8 @@ import i18next from "i18next";
import {loadDeliveries} from "./shared/load-deliveries.js";
import {loadResponses} from "./shared/load-responses.js";
import {loadTriggers} from "./shared/load-triggers.js";
+import Alpine from 'alpinejs';
+import Post from '../../api/model/webhook/post.js'
window.enableDates = false;
@@ -125,10 +127,8 @@ let create = function () {
};
// post!
- axios.post('./api/v1/webhooks', data).then((response) => {
- //this.success_message = $.text(response.data.message);
- // console.log('Will now go to redirectUser()');
- let webhookId = response.data.data.id;
+ (new Post).post(data).then((response) => {
+ let webhookId = parseInt(response.data.data.id);
window.location.href = window.previousUrl + '?webhook_id=' + webhookId + '&message=created';
}).catch((error) => {
//console.log(error.response.data);
diff --git a/resources/assets/v3/js/pages/webhooks/edit.js b/resources/assets/v3/js/pages/webhooks/edit.js
index 1ce7328fc1..e4ac84f439 100644
--- a/resources/assets/v3/js/pages/webhooks/edit.js
+++ b/resources/assets/v3/js/pages/webhooks/edit.js
@@ -25,6 +25,9 @@ import i18next from "i18next";
import {loadTriggers} from "./shared/load-triggers.js";
import {loadResponses} from "./shared/load-responses.js";
import {loadDeliveries} from "./shared/load-deliveries.js";
+import Get from '../../api/model/webhook/get.js';
+import Put from '../../api/model/webhook/put.js';
+import Alpine from 'alpinejs'
window.enableDates = false;
let edit = function () {
@@ -87,7 +90,7 @@ let edit = function () {
this.downloadWebhook(webhookId);
},
downloadWebhook: function (id) {
- axios.get('./api/v1/webhooks/' + id).then(response => {
+ (new Get).show(id).then(response => {
// console.log(response.data.data.attributes);
this.title = response.data.data.attributes.title;
this.id = parseInt(response.data.data.id);
@@ -114,7 +117,7 @@ let edit = function () {
};
// disable button
- $('#submitButton').prop("disabled", true);
+ document.getElementById('submitButton').disabled = true;
// collect data
let data = {
@@ -127,7 +130,7 @@ let edit = function () {
};
// post!
- axios.put('./api/v1/webhooks/' + this.id, data).then((response) => {
+ (new Put).put(data, {id: this.id}).then((response) => {
let webhookId = parseInt(response.data.data.id);
window.location.href = window.previousUrl + '?webhook_id=' + webhookId + '&message=updated';
}).catch((error) => {
@@ -140,7 +143,7 @@ let edit = function () {
this.errors.url = error.response.data.errors.url;
// enable button again
- $('#submitButton').prop("disabled", false);
+ document.getElementById('submitButton').disabled = false;
});
if (e) {
diff --git a/resources/assets/v3/js/pages/webhooks/index.js b/resources/assets/v3/js/pages/webhooks/index.js
index fb1e7c5d83..554243b9cb 100644
--- a/resources/assets/v3/js/pages/webhooks/index.js
+++ b/resources/assets/v3/js/pages/webhooks/index.js
@@ -18,23 +18,22 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-// CSS
import '../../boot/bootstrap.js';
import sidebar from '../../pages/shared/sidebar.js';
import dates from '../shared/dates.js';
import i18next from "i18next";
+import Get from '../../api/model/webhook/get.js';
+import GetConfig from '../../api/configuration/get.js';
+import Alpine from 'alpinejs';
window.enableDates = false;
let index = function () {
return {
webhooks: [],
loading: false,
- triggers: {
- },
- responses: {
- },
- deliveries: {
- },
+ triggers: {},
+ responses: {},
+ deliveries: {},
init() {
this.loading = true;
@@ -48,10 +47,9 @@ let index = function () {
webhook.show_secret = !webhook.show_secret;
},
downloadWebhooks: function (page) {
- console.log('downloadWebhooks');
- axios.get("./api/v1/webhooks?page=" + page).then((response) => {
+ (new Get).list({page: page}).then((response) => {
for (let i in response.data.data) {
- if (response.data.data.hasOwnProperty(i)) {
+ if (Object.hasOwn(response.data.data, i)) {
let current = response.data.data[i];
let webhook = {
id: current.id,
@@ -73,44 +71,37 @@ let index = function () {
}
if (response.data.meta.pagination.current_page < response.data.meta.pagination.total_pages) {
- this.downloadWebhooks(response.data.meta.pagination.current_page + 1);
- } else {
- this.loading = false;
+ this.downloadWebhooks(parseInt(response.data.meta.pagination.current_page) + 1);
+ return;
}
+ this.loading = false;
});
},
getOptions: function () {
- console.log('getOptions');
- // get triggers
- axios.get('./api/v1/configuration/webhook.triggers').then((response) => {
+ (new GetConfig).getByName('webhook.triggers').then((response) => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ this.triggers[key] = i18next.t('firefly.webhook_trigger_' + key);
}
- this.triggers[key] = i18next.t('firefly.webhook_trigger_' + key);
- console.log(key, this.triggers[key]);
}
-
- // get responses
- axios.get('./api/v1/configuration/webhook.responses').then((response) => {
+ }).then(() => {
+ (new GetConfig).getByName('webhook.responses').then((response) => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ this.responses[key] = i18next.t('firefly.webhook_response_' + key);
}
- this.responses[key] = i18next.t('firefly.webhook_response_' + key);
}
- // get deliveries
- axios.get('./api/v1/configuration/webhook.deliveries').then((response) => {
+ }).then(() => {
+ (new GetConfig).getByName('webhook.deliveries').then((response) => {
for (let key in response.data.data.value) {
- if (!response.data.data.value.hasOwnProperty(key)) {
- continue;
+ if(Object.hasOwn(response.data.data.value, key)) {
+ this.deliveries[key] = i18next.t('firefly.webhook_delivery_' + key);
}
- this.deliveries[key] = i18next.t('firefly.webhook_delivery_' + key);
}
- // get webhooks
+ }).then(() => {
this.getWebhooks();
- })
- })
+ });
+ });
});
},
}
diff --git a/resources/assets/v3/js/pages/webhooks/show.js b/resources/assets/v3/js/pages/webhooks/show.js
index c9250e8dc0..4c50fe70ba 100644
--- a/resources/assets/v3/js/pages/webhooks/show.js
+++ b/resources/assets/v3/js/pages/webhooks/show.js
@@ -26,7 +26,7 @@ import i18next from "i18next";
import Post from '../../api/model/webhook/post.js';
import Get from '../../api/model/webhook/get.js';
import Put from '../../api/model/webhook/put.js';
-import Alpine from 'alpinejs'
+import Alpine from 'alpinejs';
window.enableDates = false;
diff --git a/resources/views/piggy-banks/add-mobile.blade.php b/resources/views/piggy-banks/add-mobile.blade.php
index 709fdb67bb..c603019ed0 100644
--- a/resources/views/piggy-banks/add-mobile.blade.php
+++ b/resources/views/piggy-banks/add-mobile.blade.php
@@ -33,5 +33,5 @@
</form>
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
@endsection
diff --git a/resources/views/piggy-banks/create.blade.php b/resources/views/piggy-banks/create.blade.php
index 581efea23c..9cf0d188f0 100644
--- a/resources/views/piggy-banks/create.blade.php
+++ b/resources/views/piggy-banks/create.blade.php
@@ -54,7 +54,7 @@
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
<script type="text/javascript" src="v1/js/ff/piggy-banks/create.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>
{{-- auto complete for object groups --}}
diff --git a/resources/views/piggy-banks/delete.blade.php b/resources/views/piggy-banks/delete.blade.php
index 08e4a0edbc..132ca3d56d 100644
--- a/resources/views/piggy-banks/delete.blade.php
+++ b/resources/views/piggy-banks/delete.blade.php
@@ -28,5 +28,5 @@
</form>
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
@endsection
diff --git a/resources/views/piggy-banks/edit.blade.php b/resources/views/piggy-banks/edit.blade.php
index 1c3bf95239..57477065cc 100644
--- a/resources/views/piggy-banks/edit.blade.php
+++ b/resources/views/piggy-banks/edit.blade.php
@@ -61,7 +61,7 @@
</form>
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
<script type="text/javascript" src="v1/js/ff/piggy-banks/create.js?v={{ $FF_BUILD_TIME }}"
nonce="{{ $JS_NONCE }}"></script>
{{-- auto complete for object groups --}}
diff --git a/resources/views/piggy-banks/index.blade.php b/resources/views/piggy-banks/index.blade.php
index 80a3365b0b..bff7487a3f 100644
--- a/resources/views/piggy-banks/index.blade.php
+++ b/resources/views/piggy-banks/index.blade.php
@@ -53,7 +53,7 @@
@endif
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
<script src="v1/js/lib/jquery-ui.min.js?v={{ $FF_BUILD_TIME }}" type="text/javascript" nonce="{{ $JS_NONCE }}"></script>
<script type="text/javascript" src="v1/js/ff/piggy-banks/index.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script>
@endsection
diff --git a/resources/views/piggy-banks/remove-mobile.blade.php b/resources/views/piggy-banks/remove-mobile.blade.php
index 79f608067b..bbae01c392 100644
--- a/resources/views/piggy-banks/remove-mobile.blade.php
+++ b/resources/views/piggy-banks/remove-mobile.blade.php
@@ -30,5 +30,5 @@
</form>
@endsection
@section('scripts')
- @vite(['js/pages/generic.js'])
+ @vite(['js/pages/generic-nodates.js'])
@endsection