Bug 32939: Have a generic APIClient object
You always import the same, only once, and you can access other resources from the same object. Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
866cc641d9
commit
10322566d4
6 changed files with 16 additions and 11 deletions
|
@ -187,7 +187,7 @@ import AgreementLicenses from "./AgreementLicenses.vue"
|
|||
import AgreementRelationships from "./AgreementRelationships.vue"
|
||||
import Documents from "./Documents.vue"
|
||||
import { setMessage, setError, setWarning } from "../../messages"
|
||||
import { ERMAPIClient } from "../../fetch/erm-api-client.js"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
import { storeToRefs } from "pinia"
|
||||
|
||||
export default {
|
||||
|
@ -250,7 +250,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getAgreement(agreement_id) {
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
try {
|
||||
await client.agreements.get(agreement_id).then(data => {
|
||||
this.agreement = data
|
||||
|
@ -372,7 +372,7 @@ export default {
|
|||
|
||||
delete agreement.agreement_packages
|
||||
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
;(async () => {
|
||||
try {
|
||||
if (agreement_id) {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { ERMAPIClient } from "../../fetch/erm-api-client.js"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
import { setMessage, setError } from "../../messages"
|
||||
|
||||
export default {
|
||||
|
@ -53,7 +53,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getAgreement(agreement_id) {
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
try {
|
||||
await client.agreements.get(agreement_id).then(data => {
|
||||
this.agreement = data
|
||||
|
@ -66,7 +66,7 @@ export default {
|
|||
onSubmit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
;(async () => {
|
||||
try {
|
||||
await client.agreements
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
import flatPickr from "vue-flatpickr-component"
|
||||
import Toolbar from "./AgreementsToolbar.vue"
|
||||
import { inject, createVNode, render } from "vue"
|
||||
import { ERMAPIClient } from "../../fetch/erm-api-client.js"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
import { storeToRefs } from "pinia"
|
||||
import { useDataTable, build_url } from "../../composables/datatables"
|
||||
|
||||
|
@ -93,7 +93,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getAgreements() {
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
const agreements = await client.agreements.getAll()
|
||||
this.agreements = agreements
|
||||
this.initialized = true
|
||||
|
|
|
@ -300,7 +300,7 @@
|
|||
|
||||
<script>
|
||||
import { inject } from "vue"
|
||||
import { ERMAPIClient } from "../../fetch/erm-api-client.js"
|
||||
import { APIClient } from "../../fetch/api-client.js"
|
||||
import { setError } from "../../messages"
|
||||
|
||||
export default {
|
||||
|
@ -347,7 +347,7 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async getAgreement(agreement_id) {
|
||||
const client = new ERMAPIClient()
|
||||
const client = APIClient.erm
|
||||
try {
|
||||
await client.agreements.get(agreement_id).then(data => {
|
||||
this.agreement = data
|
||||
|
|
5
koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js
Normal file
5
koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import ERMAPIClient from "./erm-api-client";
|
||||
|
||||
export const APIClient = {
|
||||
erm: new ERMAPIClient(),
|
||||
};
|
|
@ -43,4 +43,4 @@ export class ERMAPIClient extends HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
export default ERMAPIClient;
|
||||
export default ERMAPIClient;
|
Loading…
Reference in a new issue