From 8935000530aec2d9a7b55325406cd0f57fc3cf34 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 17 Oct 2024 11:48:23 +0000 Subject: [PATCH] Bug 37301: Apply changes to eHoldings local packages --- .../ERM/EHoldingsLocalPackageResource.vue | 30 +++++++++ .../ERM/EHoldingsLocalPackagesList.vue | 63 +++---------------- .../ERM/EHoldingsLocalPackagesShow.vue | 56 +++-------------- 3 files changed, 49 insertions(+), 100 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageResource.vue diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageResource.vue new file mode 100644 index 0000000000..65713bc92a --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageResource.vue @@ -0,0 +1,30 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue index 51e2f87f81..2c1602aaed 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue @@ -4,8 +4,8 @@
@@ -19,9 +19,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" >
@@ -38,8 +38,10 @@ import { inject, ref, reactive } from "vue" import { storeToRefs } from "pinia" import { APIClient } from "../../fetch/api-client.js" import KohaTable from "../KohaTable.vue" +import EHoldingsLocalPackageResource from "./EHoldingsLocalPackageResource.vue" export default { + extends: EHoldingsLocalPackageResource, setup() { const vendorStore = inject("vendorStore") const { vendors } = storeToRefs(vendorStore) @@ -47,8 +49,6 @@ export default { const AVStore = inject("AVStore") const { get_lib_from_av, map_av_dt_filter } = AVStore - const { setConfirmationDialog, setMessage } = inject("mainStore") - const table = ref() const filters = reactive({ package_name: "", @@ -56,13 +56,12 @@ export default { }) return { + ...EHoldingsLocalPackageResource.setup(), vendors, get_lib_from_av, map_av_dt_filter, table, filters, - setConfirmationDialog, - setMessage, escape_str, eholdings_packages_table_settings, } @@ -80,7 +79,7 @@ export default { searchable_av_options: [], tableOptions: { columns: this.getTableColumns(), - url: "/api/v1/erm/eholdings/local/packages", + url: this.getResourceTableUrl(), options: { embed: "resources+count,vendor.name,extended_attributes,+strings", searchCols: [ @@ -169,46 +168,6 @@ export default { }) }) }, - doShow: function ({ package_id }, dt, event) { - event.preventDefault() - this.$router.push({ - name: "EHoldingsLocalPackagesShow", - params: { package_id }, - }) - }, - doEdit: function ({ package_id }, dt, event) { - this.$router.push({ - name: "EHoldingsLocalPackagesFormAddEdit", - params: { package_id }, - }) - }, - doDelete: function (erm_package, dt, event) { - this.setConfirmationDialog( - { - title: this.$__( - "Are you sure you want to remove this package?" - ), - message: erm_package.name, - accept_label: this.$__("Yes, delete"), - cancel_label: this.$__("No, do not delete"), - }, - () => { - const client = APIClient.erm - client.localPackages.delete(erm_package.package_id).then( - success => { - this.setMessage( - this.$__("Local package %s deleted").format( - erm_package.name - ), - true - ) - dt.draw() - }, - error => {} - ) - } - ) - }, getTableColumns: function () { let get_lib_from_av = this.get_lib_from_av let escape_str = this.escape_str @@ -220,9 +179,7 @@ export default { orderable: true, render: function (data, type, row, meta) { return ( - '' + + '' + escape_str(`${row.name} (#${row.package_id})`) + "" ) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue index 5f73b9d80d..381061d718 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue @@ -3,21 +3,13 @@
+ - {{ $__("Delete") }}

@@ -127,21 +119,20 @@ import { APIClient } from "../../fetch/api-client.js" import Toolbar from "../Toolbar.vue" import ToolbarButton from "../ToolbarButton.vue" import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue" +import EHoldingsLocalPackageResource from "./EHoldingsLocalPackageResource.vue" export default { + extends: EHoldingsLocalPackageResource, setup() { const format_date = $date - const { setConfirmationDialog, setMessage } = inject("mainStore") - const AVStore = inject("AVStore") const { get_lib_from_av } = AVStore return { + ...EHoldingsLocalPackageResource.setup(), format_date, get_lib_from_av, - setConfirmationDialog, - setMessage, } }, data() { @@ -181,35 +172,6 @@ export default { error => {} ) }, - delete_package: function (package_id, package_name) { - this.setConfirmationDialog( - { - title: this.$__( - "Are you sure you want to remove this package?" - ), - message: package_name, - accept_label: this.$__("Yes, delete"), - cancel_label: this.$__("No, do not delete"), - }, - () => { - const client = APIClient.erm - client.localPackages.delete(package_id).then( - success => { - this.setMessage( - this.$__("Local package %s deleted").format( - package_name - ), - true - ) - this.$router.push({ - name: "EHoldingsLocalPackagesList", - }) - }, - error => {} - ) - } - ) - }, }, components: { EHoldingsPackageTitlesList, -- 2.39.5