3 <div v-if="!this.initialized">{{ $t("Loading") }}</div>
4 <div v-else-if="this.titles" id="titles_list">
6 <div v-if="this.titles.length" id="title_list_result">
7 <table v-if="this.titles.length" id="title_list"></table>
9 <div v-else-if="this.initialized" class="dialog message">
10 {{ $t("There are no titles defined") }}
17 import Toolbar from "./EHoldingsLocalTitlesToolbar.vue"
18 import { createVNode, render } from 'vue'
19 import { useVendorStore } from "../../stores/vendors"
20 import { useAVStore } from "../../stores/authorised_values"
21 import { storeToRefs } from "pinia"
22 import { fetchLocalTitles } from "../../fetch"
26 const vendorStore = useVendorStore()
27 const { vendors } = storeToRefs(vendorStore)
29 const AVStore = useAVStore()
30 const { av_title_publication_types } = storeToRefs(AVStore)
31 const { get_lib_from_av } = AVStore
35 av_title_publication_types,
44 publication_title: this.$route.query.publication_title || "",
45 publication_type: this.$route.query.publication_type || "",
50 beforeRouteEnter(to, from, next) {
52 vm.getTitles().then(() => vm.build_datatable())
57 const titles = await fetchLocalTitles()
59 this.initialized = true
61 show_title: function (title_id) {
62 this.$router.push("/cgi-bin/koha/erm/eholdings/local/titles/" + title_id)
64 edit_title: function (title_id) {
65 this.$router.push("/cgi-bin/koha/erm/eholdings/local/titles/edit/" + title_id)
67 delete_title: function (title_id) {
68 this.$router.push("/cgi-bin/koha/erm/eholdings/local/titles/delete/" + title_id)
70 build_datatable: function () {
71 let show_title = this.show_title
72 let edit_title = this.edit_title
73 let delete_title = this.delete_title
74 let get_lib_from_av = this.get_lib_from_av
75 let filters = this.filters
77 window['vendors'] = this.vendors.map(e => {
82 let vendors_map = this.vendors.reduce((map, e) => {
86 window['av_title_publication_types'] = this.av_title_publication_types.map(e => {
87 e['_id'] = e['authorised_value']
92 $('#title_list').kohaTable({
94 url: "/api/v1/erm/eholdings/local/titles",
96 embed: ["resources.package"],
100 { search: filters.publication_title },
102 { search: filters.publication_type },
108 data: "me.publication_title",
111 render: function (data, type, row, meta) {
112 // Rendering done in drawCallback
121 render: function (data, type, row, meta) {
122 return row.vendor_id != undefined ? escape_str(vendors_map[row.vendor_id].name) : ""
126 title: __("Publication type"),
127 data: "publication_type",
130 render: function (data, type, row, meta) {
131 return escape_str(get_lib_from_av("av_title_publication_types", row.publication_type))
135 title: __("Identifier"),
136 data: "print_identifier:online_identifier",
139 render: function (data, type, row, meta) {
140 let print_identifier = row.print_identifier
141 let online_identifier = row.online_identifier
142 return (print_identifier ? escape_str(_("ISBN (Print): %s").format(print_identifier)) : "") +
143 (online_identifier ? escape_str(_("ISBN (Online): %s").format(online_identifier)) : "")
147 title: __("Actions"),
148 data: function (row, type, val, meta) {
149 return '<div class="actions"></div>'
151 className: "actions noExport",
156 drawCallback: function (settings) {
158 var api = new $.fn.dataTable.Api(settings)
160 $.each($(this).find("td .actions"), function (index, e) {
161 let title_id = api.row(index).data().title_id
162 let editButton = createVNode("a", {
163 class: "btn btn-default btn-xs", role: "button", onClick: () => {
167 [createVNode("i", { class: "fa fa-pencil", 'aria-hidden': "true" }), __("Edit")])
169 let deleteButton = createVNode("a", {
170 class: "btn btn-default btn-xs", role: "button", onClick: () => {
171 delete_title(title_id)
174 [createVNode("i", { class: "fa fa-trash", 'aria-hidden': "true" }), __("Delete")])
176 let n = createVNode('span', {}, [editButton, " ", deleteButton])
180 $.each($(this).find("tbody tr td:first-child"), function (index, e) {
181 let row = api.row(index).data()
182 if (!row) return // Happen if the table is empty
183 let n = createVNode("a", {
185 href: "/cgi-bin/koha/erm/eholdings/local/titles/" + row.title_id,
188 show_title(row.title_id)
191 `${row.publication_title} (#${row.title_id})`
196 preDrawCallback: function (settings) {
197 var table_id = settings.nTable.id
198 $("#" + table_id).find("thead th").eq(1).attr('data-filter', 'vendors')
200 }, eholdings_titles_table_settings, 1)
203 components: { Toolbar },
204 name: "EHoldingsLocalTitlesList",