From 655bee40e9fa27d553a19da80081f5a5a7f0d36f Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 17 Oct 2024 11:29:20 +0000 Subject: [PATCH] Bug 37301: Apply changes to licenses --- .../js/vue/components/ERM/LicenseResource.vue | 29 +++++++++ .../js/vue/components/ERM/LicensesList.vue | 60 ++++--------------- .../js/vue/components/ERM/LicensesShow.vue | 51 +++------------- 3 files changed, 48 insertions(+), 92 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicenseResource.vue diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicenseResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicenseResource.vue new file mode 100644 index 00000000000..9348542167c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicenseResource.vue @@ -0,0 +1,29 @@ + 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 aef49955d01..f38c998144e 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 @@ -3,8 +3,8 @@
@@ -14,9 +14,9 @@ v-bind="tableOptions" :searchable_additional_fields="searchable_additional_fields" :searchable_av_options="searchable_av_options" - @show="doShow" - @edit="doEdit" - @delete="doDelete" + @show="goToResourceShow" + @edit="goToResourceEdit" + @delete="doResourceDelete" >
@@ -32,8 +32,10 @@ import { inject, ref } from "vue" import { storeToRefs } from "pinia" import { APIClient } from "../../fetch/api-client.js" import KohaTable from "../KohaTable.vue" +import LicenseResource from "./LicenseResource.vue" export default { + extends: LicenseResource, setup() { const vendorStore = inject("vendorStore") const { vendors } = storeToRefs(vendorStore) @@ -41,17 +43,14 @@ export default { const AVStore = inject("AVStore") const { get_lib_from_av, map_av_dt_filter } = AVStore - const { setConfirmationDialog, setMessage } = inject("mainStore") - const table = ref() return { + ...LicenseResource.setup(), vendors, get_lib_from_av, map_av_dt_filter, table, - setConfirmationDialog, - setMessage, license_table_settings, } }, @@ -70,7 +69,7 @@ export default { searchable_av_options: [], tableOptions: { columns: this.getTableColumns(), - url: "/api/v1/erm/licenses", + url: this.getResourceTableUrl(), options: { embed: "vendor,extended_attributes,+strings" }, table_settings: this.license_table_settings, add_filters: true, @@ -149,43 +148,6 @@ export default { }) }) }, - doShow: function ({ license_id }, dt, event) { - event.preventDefault() - this.$router.push({ name: "LicensesShow", params: { license_id } }) - }, - doEdit: function ({ license_id }, dt, event) { - this.$router.push({ - name: "LicensesFormAddEdit", - params: { license_id }, - }) - }, - doDelete: function (license, dt, event) { - 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.license_id).then( - success => { - this.setMessage( - this.$__("License %s deleted").format( - license.name - ), - true - ) - dt.draw() - }, - error => {} - ) - } - ) - }, getTableColumns: function () { let get_lib_from_av = this.get_lib_from_av @@ -197,9 +159,7 @@ export default { orderable: true, render: function (data, type, row, meta) { return ( - '' + + '' + escape_str(`${row.name} (#${row.license_id})`) + "" ) 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 6e91f7d59bf..943753a3471 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 @@ -3,18 +3,13 @@
+ - {{ $__("Delete") }}

@@ -160,23 +155,22 @@ import { APIClient } from "../../fetch/api-client.js" import Toolbar from "../Toolbar.vue" import ToolbarButton from "../ToolbarButton.vue" import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue" +import LicenseResource from "./LicenseResource.vue" export default { + extends: LicenseResource, setup() { 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 return { + ...LicenseResource.setup(), format_date, patron_to_html, get_lib_from_av, - setConfirmationDialog, - setMessage, } }, data() { @@ -214,33 +208,6 @@ 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 - ), - true - ) - this.$router.push({ name: "LicensesList" }) - }, - error => {} - ) - } - ) - }, }, components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay }, name: "LicensesShow", -- 2.39.5