From c75dff37a83141e30b5c55bc08006ead122ccba0 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 24 Feb 2023 17:01:15 +0000 Subject: [PATCH] Bug 32991: Licenses: Add delete dialog to list and show. Removed FormConfirmDelete component and routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Druart Signed-off-by: Pedro Amorim Signed-off-by: Agustín Moyano --- .../ERM/LicensesFormConfirmDelete.vue | 77 ------------------- .../js/vue/components/ERM/LicensesList.vue | 40 +++++++++- .../js/vue/components/ERM/LicensesShow.vue | 37 ++++++++- .../intranet-tmpl/prog/js/vue/routes/erm.js | 12 --- 4 files changed, 70 insertions(+), 96 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue deleted file mode 100644 index 0bf3dbfefa1..00000000000 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormConfirmDelete.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue index 84eb25bf441..27137fd058b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue @@ -26,6 +26,8 @@ export default { const AVStore = inject("AVStore") const { get_lib_from_av, map_av_dt_filter } = AVStore + const { setConfirmationDialog, setMessage } = inject("mainStore") + const table_id = "license_list" useDataTable(table_id) @@ -34,6 +36,8 @@ export default { get_lib_from_av, map_av_dt_filter, table_id, + setConfirmationDialog, + setMessage, } }, data: function () { @@ -64,8 +68,34 @@ export default { edit_license: function (license_id) { this.$router.push("/cgi-bin/koha/erm/licenses/edit/" + license_id) }, - delete_license: function (license_id) { - this.$router.push("/cgi-bin/koha/erm/licenses/delete/" + license_id) + delete_license: function (license_id, license_name) { + this.setConfirmationDialog( + { + title: this.$__( + "Are you sure you want to remove this license?" + ), + message: license_name, + accept_label: this.$__("Yes, delete"), + cancel_label: this.$__("No, do not delete"), + }, + () => { + const client = APIClient.erm + client.licenses.delete(license_id).then( + success => { + this.setMessage( + this.$__("License %s deleted").format( + license_name + ) + ) + $("#" + this.table_id) + .DataTable() + .ajax.url("/api/v1/erm/licenses") + .draw() + }, + error => {} + ) + } + ) }, build_datatable: function () { let show_license = this.show_license @@ -203,6 +233,7 @@ export default { function (index, e) { let tr = $(this).parent().parent() let license_id = api.row(tr).data().license_id + let license_name = api.row(tr).data().name let editButton = createVNode( "a", { @@ -227,7 +258,10 @@ export default { class: "btn btn-default btn-xs", role: "button", onClick: () => { - delete_license(license_id) + delete_license( + license_id, + license_name + ) }, }, [ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue index bf77b9f613e..e7d2810be3a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue @@ -9,11 +9,9 @@ :title="$__('Edit')" > - + >
@@ -152,6 +150,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 @@ -159,6 +159,8 @@ export default { format_date, patron_to_html, get_lib_from_av, + setConfirmationDialog, + setMessage, } }, data() { @@ -194,6 +196,32 @@ export default { error => {} ) }, + delete_license: function (license_id, license_name) { + this.setConfirmationDialog( + { + title: this.$__( + "Are you sure you want to remove this license?" + ), + message: license_name, + accept_label: this.$__("Yes, delete"), + cancel_label: this.$__("No, do not delete"), + }, + () => { + const client = APIClient.erm + client.licenses.delete(license_id).then( + success => { + this.setMessage( + this.$__("License %s deleted").format( + license_name + ) + ) + this.$router.push("/cgi-bin/koha/erm/licenses") + }, + error => {} + ) + } + ) + }, }, components: {}, name: "LicensesShow", @@ -203,6 +231,7 @@ export default { .action_links a { padding-left: 0.2em; font-size: 11px; + cursor: pointer; } #license_documents ul { padding-left: 0px; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js index 127e910f6dd..07379875646 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/erm.js @@ -19,7 +19,6 @@ import EHoldingsEBSCOTitlesShow from "../components/ERM/EHoldingsEBSCOTitlesShow import LicensesList from "../components/ERM/LicensesList.vue"; import LicensesShow from "../components/ERM/LicensesShow.vue"; import LicensesFormAdd from "../components/ERM/LicensesFormAdd.vue"; -import LicensesFormConfirmDelete from "../components/ERM/LicensesFormConfirmDelete.vue"; const breadcrumbs = { home: { @@ -470,17 +469,6 @@ export const routes = [ ), }, }, - { - path: "delete/:license_id", - component: LicensesFormConfirmDelete, - meta: { - breadcrumb: () => - build_breadcrumb( - breadcrumb_paths.licenses, - "Delete license" // $t("Delete license") - ), - }, - }, { path: "add", component: LicensesFormAdd, -- 2.25.1