Koha/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue
Jonathan Druart 23266f7b00
Bug 32939: Use APIClient to fetch licenses
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>
2023-02-27 11:13:11 -03:00

77 lines
2.3 KiB
Vue

<template>
<div v-if="!initialized">{{ $__("Loading") }}</div>
<div v-else id="licenses_confirm_delete">
<h2>{{ $__("Delete license") }}</h2>
<div>
<form @submit="onSubmit($event)">
<fieldset class="rows">
<ol>
<li>
{{ $__("License name") }}:
{{ license.name }}
</li>
<li>
{{ $__("Description") }}:
{{ license.description }}
</li>
</ol>
</fieldset>
<fieldset class="action">
<input
type="submit"
variant="primary"
:value="$__('Yes, delete')"
/>
<router-link
to="/cgi-bin/koha/erm/licenses"
role="button"
class="cancel"
>{{ $__("No, do not delete") }}</router-link
>
</fieldset>
</form>
</div>
</div>
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { setMessage } from "../../messages"
export default {
data() {
return {
license: {},
initialized: false,
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.license = vm.getLicense(to.params.license_id)
vm.initialized = true
})
},
methods: {
async getLicense(license_id) {
const client = APIClient.erm
client.licenses.get(license_id).then(data => {
this.license = data
this.initialized = true
})
},
onSubmit(e) {
e.preventDefault()
const client = APIClient.erm
client.licenses.delete(this.license.license_id).then(
success => {
setMessage(this.$__("License deleted"))
this.$router.push("/cgi-bin/koha/erm/licenses")
},
error => {}
)
},
},
name: "LicensesFormConfirmDelete",
}
</script>