Skip to content

Firefly III: a personal finances manager

Clean up destroy routine

James Coleb9536dfe4e77
diff --git a/frontend/src/api/accounts/destroy.js b/frontend/src/api/accounts/destroy.js
deleted file mode 100644
index 3b784bf218..0000000000
--- a/frontend/src/api/accounts/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/accounts/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/accounts/get.js b/frontend/src/api/accounts/get.js
index 6d9cb854ed..e6cf5163fd 100644
--- a/frontend/src/api/accounts/get.js
+++ b/frontend/src/api/accounts/get.js
@@ -18,18 +18,34 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import {api} from "boot/axios";
+import Api from "src/api/root/api";
-export default class Get {
+export default class Get extends Api {
+ constructor() {
+ super('accounts'); // call the super class constructor and pass in the name parameter
+ }
+
+ /**
+ *
+ * @param identifier
+ * @param date
+ * @returns {Promise<AxiosResponse<any>>}
+ */
get(identifier, date) {
- let url = '/api/v1/accounts/' + identifier;
+ let params = {date: date};
if(!date) {
- return api.get(url);
+ return this.apiGet(identifier);
}
- return api.get(url, {params: {date: date}});
+ return this.apiGet(identifier, params);
}
- transactions(identifier, page, cacheKey) {
- let url = '/api/v1/accounts/' + identifier + '/transactions';
- return api.get(url, {params: {page: page, cache: cacheKey}});
+
+ /**
+ *
+ * @param identifier
+ * @param page
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+ transactions(identifier, page) {
+ return this.apiGetChildren('transactions', identifier, page);
}
}
diff --git a/frontend/src/api/accounts/list.js b/frontend/src/api/accounts/list.js
index 90a0fea825..72b5f4e20b 100644
--- a/frontend/src/api/accounts/list.js
+++ b/frontend/src/api/accounts/list.js
@@ -19,10 +19,27 @@
*/
import {api} from "boot/axios";
+import Api from "src/api/root/api";
+
+export default class List extends Api{
+ constructor() {
+ super('accounts');
+ }
-export default class List {
list(type, page, cacheKey) {
let url = '/api/v1/accounts';
return api.get(url, {params: {page: page, cache: cacheKey, type: type}});
+ // console.log('list');
+ //
+ //
+ // let params = {
+ // type: type,
+ // page: page
+ // }
+ // this.apiList(page, params).then((response) => {
+ // console.log('response OK');
+ // }).catch((err) => {
+ // console.error('api list failed');
+ // });
}
}
diff --git a/frontend/src/api/budgets/destroy.js b/frontend/src/api/budgets/destroy.js
deleted file mode 100644
index 3b17de392a..0000000000
--- a/frontend/src/api/budgets/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = 'api/v1/budgets/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/categories/destroy.js b/frontend/src/api/categories/destroy.js
deleted file mode 100644
index dcb150dc0d..0000000000
--- a/frontend/src/api/categories/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/categories/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/currencies/destroy.js b/frontend/src/api/currencies/destroy.js
deleted file mode 100644
index f9ec216790..0000000000
--- a/frontend/src/api/currencies/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/currencies/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/rules/destroy.js b/frontend/src/api/generic/destroy.js
similarity index 82%
rename from frontend/src/api/rules/destroy.js
rename to frontend/src/api/generic/destroy.js
index 025f961208..90e32cb0dd 100644
--- a/frontend/src/api/rules/destroy.js
+++ b/frontend/src/api/generic/destroy.js
@@ -1,5 +1,5 @@
/*
- * post.js
+ * destroy.js
* Copyright (c) 2022 [email protected]
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -18,11 +18,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import {api} from "boot/axios";
+import Api from "src/api/root/api";
-export default class Destroy {
- destroy(identifier) {
- let url = '/api/v1/rules/' + identifier;
- return api.delete(url);
+export default class Destroy extends Api {
+ constructor(path) {
+ super(path);
}
}
diff --git a/frontend/src/api/groups/destroy.js b/frontend/src/api/groups/destroy.js
deleted file mode 100644
index a21e6ba7d1..0000000000
--- a/frontend/src/api/groups/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/object_groups/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/piggy-banks/destroy.js b/frontend/src/api/piggy-banks/destroy.js
deleted file mode 100644
index f7d7a24744..0000000000
--- a/frontend/src/api/piggy-banks/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/piggy_banks/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/recurring/destroy.js b/frontend/src/api/recurring/destroy.js
deleted file mode 100644
index ffb61a8ac7..0000000000
--- a/frontend/src/api/recurring/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/recurrences/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/root/api.js b/frontend/src/api/root/api.js
new file mode 100644
index 0000000000..54695ee1a1
--- /dev/null
+++ b/frontend/src/api/root/api.js
@@ -0,0 +1,104 @@
+import {api} from "boot/axios";
+
+/**
+ *
+ */
+export default class Api {
+ root = '/api/v1/';
+ path = '';
+
+ constructor(path) {
+ this.path = path;
+ }
+
+ apiPath() {
+ return this.root + this.path;
+ }
+
+ apiPathId(identifier) {
+ return this.root + this.path + '/' + identifier;
+ }
+
+ /**
+ *
+ * @param identifier
+ * @param params
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+ apiGet(identifier, params) {
+ let url = this.apiPathId(identifier);
+ if (params) {
+ return api.get(url, {params: params});
+ }
+ return api.get(url);
+ }
+
+ destroy(identifier) {
+ let url = this.apiPathId(identifier);
+ return api.delete(url);
+ }
+
+ apiPathChildren(identifier, type) {
+ return this.apiPathId(identifier) + '/' + type;
+ }
+
+ apiGetChildren(type, identifier, page) {
+ let url = this.apiPathChildren(identifier, type);
+ let cacheKey = 'still-todo';
+ // needs a cache key. Based on type.
+ return api.get(url, {params: {page: page, cache: cacheKey}});
+ }
+
+
+ /**
+ *
+ * @param page
+ * @param params
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+ apiList(page, params) {
+ let type = 'transactions';
+ let identifier = '1';
+
+ let cacheKey = 'still-todo';
+ let url = this.apiPathChildren(identifier, type);
+
+ // needs a cache key. Based on type.
+ return api.get(url, {params: {page: page, cache: cacheKey}});
+
+
+ // let identifier = 'abc';
+ // // test:
+ // let type= 'expense';
+
+ // let type ='accounts';
+ //
+ // this.store.getters["fireflyiii/getScopedCacheKey"](type);
+ // let cacheKey = 'def';
+ // let url = this.apiPath();
+ //
+ // // needs a cache key. Based on type.
+ // return api.get(url, {params: {page: page, cache: cacheKey}});
+
+ //
+ //
+ // console.log('apiList');
+ // let cacheKey;
+ //
+ // //let $q = useQuasar();
+ // //const store = useStore();
+ // cacheKey = 'OK';
+ // console.log('path: ' + this.path);
+ // //cacheKey = $store.getters["fireflyiii/getScopedCacheKey"](this.path);
+ // //store.getters["fireflyiii/getScopedCacheKey"](this.path)
+ // let cache = {
+ // cache: cacheKey
+ // };
+ // let merged = {...params, ...cache};
+ // console.log(merged);
+ // let url = this.apiPath();
+ // console.log(url);
+ // return api.get(url, {params: merged});
+ }
+
+}
diff --git a/frontend/src/api/rule-groups/destroy.js b/frontend/src/api/rule-groups/destroy.js
deleted file mode 100644
index f72620bf1a..0000000000
--- a/frontend/src/api/rule-groups/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/rule_groups/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/subscriptions/destroy.js b/frontend/src/api/subscriptions/destroy.js
deleted file mode 100644
index 83bb5c833c..0000000000
--- a/frontend/src/api/subscriptions/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/bills/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/transactions/destroy.js b/frontend/src/api/transactions/destroy.js
deleted file mode 100644
index 1eca9641a6..0000000000
--- a/frontend/src/api/transactions/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/transactions/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/api/webhooks/destroy.js b/frontend/src/api/webhooks/destroy.js
deleted file mode 100644
index b99a699a89..0000000000
--- a/frontend/src/api/webhooks/destroy.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * post.js
- * Copyright (c) 2022 [email protected]
- *
- * 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 Destroy {
- destroy(identifier) {
- let url = '/api/v1/webhooks/' + identifier;
- return api.delete(url);
- }
-}
diff --git a/frontend/src/pages/accounts/Index.vue b/frontend/src/pages/accounts/Index.vue
index 6e91c86a10..18671cd1d2 100644
--- a/frontend/src/pages/accounts/Index.vue
+++ b/frontend/src/pages/accounts/Index.vue
@@ -5,7 +5,6 @@
:rows="rows"
:columns="columns"
row-key="id"
- @request="onRequest"
v-model:pagination="pagination"
:loading="loading"
class="q-ma-md"
@@ -75,7 +74,7 @@
<script>
import {mapGetters, useStore} from "vuex";
import List from "../../api/accounts/list";
-import Destroy from "../../api/accounts/destroy";
+import Destroy from "../../api/generic/destroy";
export default {
name: 'Index',
@@ -144,10 +143,11 @@ export default {
});
},
destroyAccount: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
- this.$store.dispatch('fireflyiii/refreshCacheKey');
- this.triggerUpdate();
+ (new Destroy('accounts')).destroy(id).then(() => {
+ this.rows= [];
+ this.$store.dispatch('fireflyiii/refreshCacheKey').then(() => {
+ this.triggerUpdate();
+ });
});
},
updateBreadcrumbs: function () {
@@ -169,14 +169,15 @@ export default {
return string.replace(NON_ALPHANUM, '').toUpperCase().replace(EVERY_FOUR_CHARS, "$1 ");
},
triggerUpdate: function () {
- if (this.loading) {
+ this.rows= [];
+ if (true === this.loading) {
return;
}
if (null === this.range.start || null === this.range.end) {
return;
}
this.loading = true;
- const list = new List();
+ const list = new List;
this.rows = [];
list.list(this.type, this.page, this.getCacheKey).then(
(response) => {
@@ -198,8 +199,10 @@ export default {
}
this.loading = false;
}
- )
- ;
+ ).catch((err) => {
+ console.error('Error loading list');
+ console.error(err);
+ });
}
}
}
diff --git a/frontend/src/pages/accounts/Show.vue b/frontend/src/pages/accounts/Show.vue
index 930419d5b3..39a99ddd29 100644
--- a/frontend/src/pages/accounts/Show.vue
+++ b/frontend/src/pages/accounts/Show.vue
@@ -95,7 +95,7 @@ export default {
const parser = new Parser;
this.rows = [];
- get.transactions(this.id, this.page, this.getCacheKey).then(
+ get.transactions(this.id, this.page).then(
(response) => {
let resp = parser.parseResponse(response);
diff --git a/frontend/src/pages/budgets/Index.vue b/frontend/src/pages/budgets/Index.vue
index 874c2d7f99..c2e4e9aeab 100644
--- a/frontend/src/pages/budgets/Index.vue
+++ b/frontend/src/pages/budgets/Index.vue
@@ -68,7 +68,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/budgets/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/budgets/list";
export default {
@@ -135,8 +135,7 @@ export default {
});
},
destroyBudget: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('budgets')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/categories/Index.vue b/frontend/src/pages/categories/Index.vue
index be305fa584..e87431479d 100644
--- a/frontend/src/pages/categories/Index.vue
+++ b/frontend/src/pages/categories/Index.vue
@@ -68,7 +68,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/categories/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/categories/list";
export default {
@@ -135,8 +135,7 @@ export default {
});
},
destroyCategory: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('categories')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/currencies/Index.vue b/frontend/src/pages/currencies/Index.vue
index 17264d1a2f..88ea691aaa 100644
--- a/frontend/src/pages/currencies/Index.vue
+++ b/frontend/src/pages/currencies/Index.vue
@@ -68,7 +68,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/currencies/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/currencies/list";
export default {
@@ -137,8 +137,7 @@ export default {
});
},
destroyCurrency: function (code) {
- let destr = new Destroy;
- destr.destroy(code).then(() => {
+ (new Destroy('currencies')).destroy(code).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/groups/Index.vue b/frontend/src/pages/groups/Index.vue
index d45674e526..b200438a3b 100644
--- a/frontend/src/pages/groups/Index.vue
+++ b/frontend/src/pages/groups/Index.vue
@@ -52,7 +52,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/groups/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/groups/list";
export default {
@@ -119,9 +119,8 @@ export default {
// TODO needs error catch.
});
},
- destroyGroup: function (code) {
- let destr = new Destroy;
- destr.destroy(code).then(() => {
+ destroyGroup: function (identifier) {
+ (new Destroy('object_groups')).destroy(identifier).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/piggy-banks/Index.vue b/frontend/src/pages/piggy-banks/Index.vue
index 3dac623667..d384a667d6 100644
--- a/frontend/src/pages/piggy-banks/Index.vue
+++ b/frontend/src/pages/piggy-banks/Index.vue
@@ -65,7 +65,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/piggy-banks/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/piggy-banks/list";
export default {
@@ -131,8 +131,7 @@ export default {
});
},
destroyPiggyBank: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('piggy_banks')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/recurring/Index.vue b/frontend/src/pages/recurring/Index.vue
index 21de60e2f0..a0edfa375a 100644
--- a/frontend/src/pages/recurring/Index.vue
+++ b/frontend/src/pages/recurring/Index.vue
@@ -65,7 +65,7 @@
<script>
import {mapGetters, useStore} from "vuex";
-import Destroy from "../../api/recurring/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/recurring/list";
export default {
@@ -132,8 +132,7 @@ export default {
});
},
destroyRecurring: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('recurrences')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/rules/Index.vue b/frontend/src/pages/rules/Index.vue
index ef12170050..f673e7fa93 100644
--- a/frontend/src/pages/rules/Index.vue
+++ b/frontend/src/pages/rules/Index.vue
@@ -80,8 +80,7 @@
import {mapGetters} from "vuex";
import List from "../../api/rule-groups/list";
import Get from "../../api/rule-groups/get";
-import Destroy from "../../api/rule-groups/destroy";
-import DestroyRule from "../../api/rules/destroy";
+import Destroy from "../../api/generic/destroy";
export default {
name: 'Index',
@@ -142,15 +141,13 @@ export default {
});
},
destroyRuleGroup: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('rule_groups')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
},
destroyRule: function (id) {
- let destr = new DestroyRule;
- destr.destroy(id).then(() => {
+ (new Destroy('rules')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/subscriptions/Index.vue b/frontend/src/pages/subscriptions/Index.vue
index ec806e9bec..4c211c1a51 100644
--- a/frontend/src/pages/subscriptions/Index.vue
+++ b/frontend/src/pages/subscriptions/Index.vue
@@ -67,7 +67,7 @@
<script>
import {mapGetters, useStore} from "vuex";
import List from "../../api/subscriptions/list";
-import Destroy from "../../api/subscriptions/destroy";
+import Destroy from "../../api/generic/destroy";
export default {
name: 'Index',
@@ -127,8 +127,7 @@ export default {
});
},
destroySubscription: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('bills')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});
diff --git a/frontend/src/pages/webhooks/Index.vue b/frontend/src/pages/webhooks/Index.vue
index c7b6c47007..05421b98e7 100644
--- a/frontend/src/pages/webhooks/Index.vue
+++ b/frontend/src/pages/webhooks/Index.vue
@@ -66,7 +66,7 @@
<script>
import {mapGetters} from "vuex";
-import Destroy from "../../api/webhooks/destroy";
+import Destroy from "../../api/generic/destroy";
import List from "../../api/webhooks/list";
export default {
@@ -119,8 +119,7 @@ export default {
});
},
destroyWebhook: function (id) {
- let destr = new Destroy;
- destr.destroy(id).then(() => {
+ (new Destroy('webhooks')).destroy(id).then(() => {
this.$store.dispatch('fireflyiii/refreshCacheKey');
this.triggerUpdate();
});