2 <div id="title_list_result">
3 <div id="filters" v-if="erm_provider != 'manual'">
4 <a href="#" @click.prevent="toggle_filters($event)"
5 ><i class="fa fa-search"></i>
6 {{ display_filters ? $t("Hide filters") : $t("Show filters") }}
8 <fieldset v-if="display_filters">
11 <label>{{ $t("Title") }}:</label>
14 id="publication_title_filter"
15 v-model="filters.publication_title"
16 @keyup.enter="filter_table"
20 <label>{{ $t("Publication type") }}:</label>
22 id="publication_type_filter"
23 v-model="filters.publication_type"
25 <option value="">{{ $t("All") }}</option>
27 v-for="type in av_title_publication_types"
28 :key="type.authorised_values"
29 :value="type.authorised_value"
36 <label>{{ $t("Selection status") }}:</label>
38 id="selection_type_filter"
39 v-model="filters.selection_type"
41 <option value="0">{{ $t("All") }}</option>
42 <option value="1">{{ $t("Selected") }}</option>
43 <option value="2">{{ $t("Not selected") }}</option>
56 <table id="title_list"></table>
62 import { createVNode, render } from 'vue'
63 import { useAVStore } from "../../stores/authorised_values"
64 import { storeToRefs } from "pinia"
68 const AVStore = useAVStore()
69 const { av_title_publication_types } = storeToRefs(AVStore)
70 const { get_lib_from_av } = AVStore
73 av_title_publication_types,
80 publication_title: "",
84 display_filters: false,
87 inject: ['erm_provider'],
89 show_resource: function (resource_id) {
90 this.$router.push("/cgi-bin/koha/erm/eholdings/resources/" + resource_id)
92 filter_table: function () {
93 $("#title_list").DataTable().draw()
95 toggle_filters: function (e) {
96 this.display_filters = !this.display_filters
98 build_datatable: function () {
99 let show_resource = this.show_resource
100 let package_id = this.package_id
101 let get_lib_from_av = this.get_lib_from_av
102 let filters = this.filters
104 window['av_title_publication_types'] = this.av_title_publication_types.map(e => {
105 e['_id'] = e['authorised_value']
110 let additional_filters = {}
111 if (erm_provider != 'manual') {
112 additional_filters = {
113 publication_title: function () {
114 return filters.publication_title || ""
116 publication_type: function () {
117 return filters.publication_type || ""
119 selection_type: function () {
120 return filters.selection_type || ""
125 $('#title_list').kohaTable({
127 "url": "/api/v1/erm/eholdings/packages/" + package_id + "/resources",
129 ...(erm_provider != 'manual' ? { ordering: false } : {}),
130 ...(erm_provider != 'manual' ? { dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>' } : {}),
131 ...(erm_provider != 'manual' ? { aLengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]] } : {}),
137 "data": "title.publication_title",
138 "searchable": (erm_provider == 'manual') ? 1 : 0,
139 "orderable": (erm_provider == 'manul') ? 1 : 0,
140 "render": function (data, type, row, meta) {
141 // Rendering done in drawCallback
146 "title": __("Publication type"),
147 "data": "title.publication_type",
148 "searchable": (erm_provider == 'manual') ? 1 : 0,
149 "orderable": (erm_provider == 'manul') ? 1 : 0,
150 "render": function (data, type, row, meta) {
151 return escape_str(get_lib_from_av("av_title_publication_types", row.title.publication_type))
155 drawCallback: function (settings) {
157 var api = new $.fn.dataTable.Api(settings)
159 $.each($(this).find("tbody tr td:first-child"), function (index, e) {
160 let row = api.row(index).data()
161 if (!row) return // Happen if the table is empty
162 let n = createVNode("a", {
164 href: "/cgi-bin/koha/erm/eholdings/resources/" + row.resource_id,
167 show_resource(row.resource_id)
170 `${row.title.publication_title}`
172 if (row.is_selected) {
173 n = createVNode('span', {}, [n, " ", createVNode("i", { class: "fa fa-check-square-o", style: { color: "green" }, title: __("Is selected") })])
178 ...(erm_provider == 'manual' ? {
179 preDrawCallback: function (settings) {
180 var table_id = settings.nTable.id
181 if (erm_provider == 'manual') {
182 $("#" + table_id).find("thead th").eq(1).attr('data-filter', 'av_title_publication_types')
186 }, null, erm_provider == 'manual' ? 1 : 0, additional_filters)
190 this.build_datatable()
200 name: 'EHoldingsPackageTitlesList',