Bug 32991: Agreements: Add delete dialog to show. Removed FormConfirmDelete component and routes

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Agustín Moyano <agustinmoyano@theke.io>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Pedro Amorim 2023-02-27 15:22:48 +00:00 committed by Tomas Cohen Arazi
parent 0e63e366ca
commit f98c63820f
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
4 changed files with 58 additions and 101 deletions

View file

@ -1,77 +0,0 @@
<template>
<div v-if="!initialized">{{ $__("Loading") }}</div>
<div v-else id="agreements_confirm_delete">
<h2>{{ $__("Delete agreement") }}</h2>
<div>
<form @submit="onSubmit($event)">
<fieldset class="rows">
<ol>
<li>
{{ $__("Agreement name") }}:
{{ agreement.name }}
</li>
<li>{{ $__("Vendor") }}: {{ agreement.vendor_id }}</li>
<li>
{{ $__("Description") }}:
{{ agreement.description }}
</li>
</ol>
</fieldset>
<fieldset class="action">
<ButtonSubmit :text="$__('Yes, delete')" />
<router-link
to="/cgi-bin/koha/erm/agreements"
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"
import ButtonSubmit from "../ButtonSubmit.vue"
export default {
data() {
return {
agreement: {},
initialized: false,
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getAgreement(to.params.agreement_id)
})
},
methods: {
async getAgreement(agreement_id) {
const client = APIClient.erm
client.agreements.get(agreement_id).then(data => {
this.agreement = data
this.initialized = true
})
},
onSubmit(e) {
e.preventDefault()
const client = APIClient.erm
client.agreements.delete(this.agreement.agreement_id).then(
success => {
setMessage(this.$__("Agreement deleted"))
this.$router.push("/cgi-bin/koha/erm/agreements")
},
error => {}
)
},
},
components: {
ButtonSubmit,
},
name: "AgreementsFormConfirmDelete",
}
</script>

View file

@ -57,7 +57,7 @@ export default {
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const { setConfirmation, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore")
const table_id = "agreement_list"
useDataTable(table_id)
@ -68,7 +68,7 @@ export default {
map_av_dt_filter,
table_id,
logged_in_user,
setConfirmation,
setConfirmationDialog,
setMessage,
}
},
@ -124,14 +124,25 @@ export default {
"/cgi-bin/koha/erm/agreements/edit/" + agreement_id
)
},
delete_agreement: function (agreement_id) {
this.setConfirmation(
this.$__("Are you sure you want to remove this agreement?"),
delete_agreement: function (agreement_id, agreement_name) {
this.setConfirmationDialog(
{
title: this.$__(
"Are you sure you want to remove this agreement?"
),
message: agreement_name,
accept_label: this.$__("Yes, delete"),
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
client.agreements.delete(agreement_id).then(
success => {
this.setMessage(this.$__("Agreement deleted"))
this.setMessage(
this.$__("Agreement %s deleted").format(
agreement_name
)
)
this.refresh_table()
},
error => {}
@ -332,6 +343,7 @@ export default {
let agreement_id = api
.row(tr)
.data().agreement_id
let agreement_name = api.row(tr).data().name
let editButton = createVNode(
"a",
{
@ -356,7 +368,10 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
delete_agreement(agreement_id)
delete_agreement(
agreement_id,
agreement_name
)
},
},
[

View file

@ -9,12 +9,12 @@
:title="$__('Edit')"
><i class="fa fa-pencil"></i
></router-link>
<router-link
:to="`/cgi-bin/koha/erm/agreements/delete/${agreement.agreement_id}`"
:title="$__('Delete')"
<a
@click="
delete_agreement(agreement.agreement_id, agreement.name)
"
><i class="fa fa-trash"></i
></router-link>
></a>
</span>
</h2>
<div>
@ -307,6 +307,8 @@ export default {
const format_date = $date
const patron_to_html = $patron_to_html
const { setConfirmationDialog, setMessage } = inject("mainStore")
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
@ -314,6 +316,8 @@ export default {
format_date,
patron_to_html,
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
},
data() {
@ -355,6 +359,32 @@ export default {
error => {}
)
},
delete_agreement: function (agreement_id, agreement_name) {
this.setConfirmationDialog(
{
title: this.$__(
"Are you sure you want to remove this agreement?"
),
message: agreement_name,
accept_label: this.$__("Yes, delete"),
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
client.agreements.delete(agreement_id).then(
success => {
this.setMessage(
this.$__("Agreement %s deleted").format(
agreement_name
)
)
this.$router.push("/cgi-bin/koha/erm/agreements")
},
error => {}
)
}
)
},
},
name: "AgreementsShow",
}
@ -363,6 +393,7 @@ export default {
.action_links a {
padding-left: 0.2em;
font-size: 11px;
cursor: pointer;
}
#agreement_documents ul {
padding-left: 0px;

View file

@ -2,7 +2,6 @@ import Home from "../components/ERM/Home.vue";
import AgreementsList from "../components/ERM/AgreementsList.vue";
import AgreementsShow from "../components/ERM/AgreementsShow.vue";
import AgreementsFormAdd from "../components/ERM/AgreementsFormAdd.vue";
import AgreementsFormConfirmDelete from "../components/ERM/AgreementsFormConfirmDelete.vue";
import EHoldingsLocalPackagesFormAdd from "../components/ERM/EHoldingsLocalPackagesFormAdd.vue";
import EHoldingsLocalTitlesFormAdd from "../components/ERM/EHoldingsLocalTitlesFormAdd.vue";
import EHoldingsLocalTitlesFormImport from "../components/ERM/EHoldingsLocalTitlesFormImport.vue";
@ -148,17 +147,6 @@ export const routes = [
),
},
},
{
path: "delete/:agreement_id",
component: AgreementsFormConfirmDelete,
meta: {
breadcrumb: () =>
build_breadcrumb(
breadcrumb_paths.agreements,
"Delete agreement" // $t("Delete agreement")
),
},
},
{
path: "add",
component: AgreementsFormAdd,