From 44fc4561ca49590d044013e39b6a83edea8e2f68 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 17 Oct 2024 12:06:03 +0000 Subject: [PATCH] Bug 37301: Apply changes to eholdings titles --- .../ERM/EHoldingsLocalTitleResource.vue | 30 +++++++++ .../ERM/EHoldingsLocalTitlesList.vue | 63 +++---------------- .../ERM/EHoldingsLocalTitlesShow.vue | 53 +++------------- 3 files changed, 49 insertions(+), 97 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitleResource.vue diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitleResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitleResource.vue new file mode 100644 index 0000000000..de1b91eb9c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitleResource.vue @@ -0,0 +1,30 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue index cc4125624e..5e9a4ce9fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue @@ -4,8 +4,8 @@
@@ -46,15 +46,15 @@ import { inject, ref, reactive } from "vue" import { storeToRefs } from "pinia" import { APIClient } from "../../fetch/api-client.js" import KohaTable from "../KohaTable.vue" +import EHoldingsLocalTitleResource from "./EHoldingsLocalTitleResource.vue" export default { + extends: EHoldingsLocalTitleResource, setup() { const AVStore = inject("AVStore") const { av_title_publication_types } = storeToRefs(AVStore) const { get_lib_from_av, map_av_dt_filter } = AVStore - const { setConfirmationDialog, setMessage } = inject("mainStore") - const table = ref() const filters = reactive({ publication_title: "", @@ -62,14 +62,13 @@ export default { }) return { + ...EHoldingsLocalTitleResource.setup(), av_title_publication_types, get_lib_from_av, map_av_dt_filter, escape_str, table, filters, - setConfirmationDialog, - setMessage, eholdings_titles_table_settings, } }, @@ -85,7 +84,7 @@ export default { initialized: false, tableOptions: { columns: this.getTableColumns(), - url: "/api/v1/erm/eholdings/local/titles", + url: this.getResourceTableUrl(), options: { embed: "resources.package", searchCols: [ @@ -124,46 +123,6 @@ export default { error => {} ) }, - doShow: function ({ title_id }, dt, event) { - event.preventDefault() - this.$router.push({ - name: "EHoldingsLocalTitlesShow", - params: { title_id }, - }) - }, - doEdit: function ({ title_id }, dt, event) { - this.$router.push({ - name: "EHoldingsLocalTitlesFormAddEdit", - params: { title_id }, - }) - }, - doDelete: function (title, dt, event) { - this.setConfirmationDialog( - { - title: this.$__( - "Are you sure you want to remove this title?" - ), - message: title.publication_title, - accept_label: this.$__("Yes, delete"), - cancel_label: this.$__("No, do not delete"), - }, - () => { - const client = APIClient.erm - client.localTitles.delete(title.title_id).then( - success => { - this.setMessage( - this.$__("Local title %s deleted").format( - title.publication_title - ), - true - ) - dt.draw() - }, - error => {} - ) - } - ) - }, getTableColumns: function () { let get_lib_from_av = this.get_lib_from_av let escape_str = this.escape_str @@ -176,9 +135,7 @@ export default { orderable: true, render: function (data, type, row, meta) { return ( - '' + + '' + escape_str( `${row.publication_title} (#${row.title_id})` ) + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesShow.vue index fbe7ac2752..4f567106e9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesShow.vue @@ -3,19 +3,13 @@
+ - {{ $__("Delete") }}

@@ -267,17 +261,17 @@ import EHoldingsTitlePackagesList from "./EHoldingsLocalTitlePackagesList.vue" import { APIClient } from "../../fetch/api-client.js" import Toolbar from "../Toolbar.vue" import ToolbarButton from "../ToolbarButton.vue" +import EHoldingsLocalTitleResource from "./EHoldingsLocalTitleResource.vue" export default { + extends: EHoldingsLocalTitleResource, setup() { const AVStore = inject("AVStore") const { get_lib_from_av } = AVStore - const { setConfirmationDialog, setMessage } = inject("mainStore") return { + ...EHoldingsLocalTitleResource.setup(), get_lib_from_av, - setConfirmationDialog, - setMessage, } }, data() { @@ -333,35 +327,6 @@ export default { error => {} ) }, - delete_title: function (title_id, title_publication_title) { - this.setConfirmationDialog( - { - title: this.$__( - "Are you sure you want to remove this title?" - ), - message: title_publication_title, - accept_label: this.$__("Yes, delete"), - cancel_label: this.$__("No, do not delete"), - }, - () => { - const client = APIClient.erm - client.localTitles.delete(title_id).then( - success => { - this.setMessage( - this.$__("Local title %s deleted").format( - title_publication_title - ), - true - ) - this.$router.push({ - name: "EHoldingsLocalTitlesList", - }) - }, - error => {} - ) - } - ) - }, }, components: { EHoldingsTitlePackagesList, -- 2.39.5