2 <div v-if="!this.initialized">{{ $t("Loading") }}</div>
3 <div v-else-if="this.eholdings" id="eholdings_list">
5 <table v-if="this.eholdings.length" id="eholding_list"></table>
6 <div v-else-if="this.initialized" class="dialog message">
7 {{ $t("There are no eHoldings defined") }}
13 import Toolbar from "./EHoldingsToolbar.vue"
14 import { createVNode, render } from 'vue'
15 import { useVendorStore } from "../../stores/vendors"
16 import { storeToRefs } from "pinia"
17 import { fetchEHoldings } from "../../fetch"
21 const vendorStore = useVendorStore()
22 const { vendors } = storeToRefs(vendorStore)
34 beforeRouteEnter(to, from, next) {
40 async getEHoldings() {
41 const eholdings = await fetchEHoldings()
42 this.eholdings = eholdings
43 console.log(this.eholdings)
44 this.initialized = true
46 show_eholding: function (eholding_id) {
47 this.$router.push("/cgi-bin/koha/erm/eholdings/" + eholding_id)
49 edit_eholding: function (eholding_id) {
50 this.$router.push("/cgi-bin/koha/erm/eholdings/edit/" + eholding_id)
52 delete_eholding: function (eholding_id) {
53 this.$router.push("/cgi-bin/koha/erm/eholdings/delete/" + eholding_id)
57 let show_eholding = this.show_eholding
58 let edit_eholding = this.edit_eholding
59 let delete_eholding = this.delete_eholding
61 window['vendors'] = this.vendors.map(e => {
66 let vendors_map = this.vendors.reduce((map, e) => {
71 $('#eholding_list').kohaTable({
73 "url": eholdings_table_url,
75 "order": [[0, "asc"]],
78 "render": function (data, type, row, meta) {
79 if (type == 'display') {
80 return escape_str(data)
88 "data": ["me.eholding_id", "me.publication_title"],
91 // Rendering done in drawCallback
94 "title": __("Vendor"),
98 "render": function (data, type, row, meta) {
99 return row.vendor_id != undefined ? escape_str(vendors_map[row.vendor_id].name) : ""
103 "title": __("Publication type"),
104 "data": "publication_type",
109 "title": __("Identifier"),
110 "data": ["print_identifier", "online_identifier"],
113 "render": function (data, type, row, meta) {
114 let print_identifier = row.print_identifier
115 let online_identifier = row.online_identifier
116 return (print_identifier ? escape_str(_("ISBN (Print): %s").format(print_identifier)) : "") +
117 (online_identifier ? escape_str(_("ISBN (Online): %s").format(online_identifier)) : "")
121 "title": __("Actions"),
122 "data": function (row, type, val, meta) {
123 return '<div class="actions"></div>'
125 "className": "actions noExport",
130 drawCallback: function (settings) {
132 var api = new $.fn.dataTable.Api(settings)
134 $.each($(this).find("td .actions"), function (index, e) {
135 let eholding_id = api.row(index).data().eholding_id
136 let editButton = createVNode("a", {
137 class: "btn btn-default btn-xs", role: "button", onClick: () => {
138 edit_eholding(eholding_id)
141 [createVNode("i", { class: "fa fa-pencil", 'aria-hidden': "true" }), __("Edit")])
143 let deleteButton = createVNode("a", {
144 class: "btn btn-default btn-xs", role: "button", onClick: () => {
145 delete_eholding(eholding_id)
148 [createVNode("i", { class: "fa fa-trash", 'aria-hidden': "true" }), __("Delete")])
150 let n = createVNode('span', {}, [editButton, " ", deleteButton])
154 $.each($(this).find("tbody tr td:first-child"), function (index, e) {
155 let row = api.row(index).data()
156 if (!row) return // Happen if the table is empty
157 let n = createVNode("a", {
160 show_eholding(row.eholding_id)
163 `${row.publication_title} (#${row.eholding_id})`
168 preDrawCallback: function (settings) {
169 var table_id = settings.nTable.id
170 $("#" + table_id).find("thead th").eq(1).attr('data-filter', 'vendors')
172 }, eholding_table_settings, 1)
179 components: { Toolbar },
180 name: "EHoldingsList",