|
Lines 53-66
Link Here
|
| 53 |
> |
53 |
> |
| 54 |
</div> |
54 |
</div> |
| 55 |
<div id="package_list_result" class="page-section"> |
55 |
<div id="package_list_result" class="page-section"> |
| 56 |
<table :id="table_id"></table> |
56 |
<KohaTable |
|
|
57 |
v-if="show_table" |
| 58 |
ref="table" |
| 59 |
v-bind="tableOptions" |
| 60 |
@show="doShow" |
| 61 |
></KohaTable> |
| 57 |
</div> |
62 |
</div> |
| 58 |
</div> |
63 |
</div> |
| 59 |
</div> |
64 |
</div> |
| 60 |
</template> |
65 |
</template> |
| 61 |
|
66 |
|
| 62 |
<script> |
67 |
<script> |
| 63 |
import { inject, createVNode, render } from "vue" |
68 |
import { inject, ref, reactive } from "vue" |
| 64 |
import { storeToRefs } from "pinia" |
69 |
import { storeToRefs } from "pinia" |
| 65 |
import { APIClient } from "../../fetch/api-client.js" |
70 |
import { APIClient } from "../../fetch/api-client.js" |
| 66 |
import { |
71 |
import { |
|
Lines 68-73
import {
Link Here
|
| 68 |
build_url_params, |
73 |
build_url_params, |
| 69 |
build_url, |
74 |
build_url, |
| 70 |
} from "../../composables/datatables" |
75 |
} from "../../composables/datatables" |
|
|
76 |
import KohaTable from "../KohaTable.vue" |
| 71 |
|
77 |
|
| 72 |
export default { |
78 |
export default { |
| 73 |
setup() { |
79 |
setup() { |
|
Lines 79-105
export default {
Link Here
|
| 79 |
storeToRefs(AVStore) |
85 |
storeToRefs(AVStore) |
| 80 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
86 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
| 81 |
|
87 |
|
| 82 |
const table_id = "package_list" |
88 |
const table = ref() |
| 83 |
useDataTable(table_id) |
89 |
const filters = reactive({ |
|
|
90 |
package_name: "", |
| 91 |
content_type: "", |
| 92 |
selection_type: "", |
| 93 |
}) |
| 84 |
|
94 |
|
| 85 |
return { |
95 |
return { |
| 86 |
vendors, |
96 |
vendors, |
| 87 |
av_package_types, |
97 |
av_package_types, |
| 88 |
av_package_content_types, |
98 |
av_package_content_types, |
| 89 |
get_lib_from_av, |
99 |
get_lib_from_av, |
|
|
100 |
escape_str, |
| 90 |
map_av_dt_filter, |
101 |
map_av_dt_filter, |
| 91 |
erm_providers, |
102 |
erm_providers, |
| 92 |
table_id, |
103 |
table, |
| 93 |
} |
104 |
} |
| 94 |
}, |
105 |
}, |
| 95 |
data: function () { |
106 |
data: function () { |
|
|
107 |
this.filters = { |
| 108 |
package_name: this.$route.query.package_name || "", |
| 109 |
content_type: this.$route.query.content_type || "", |
| 110 |
selection_type: this.$route.query.selection_type || "", |
| 111 |
} |
| 112 |
let filters = this.filters |
| 113 |
|
| 96 |
return { |
114 |
return { |
| 97 |
packages: [], |
115 |
packages: [], |
| 98 |
initialized: true, |
116 |
initialized: true, |
| 99 |
filters: { |
117 |
tableOptions: { |
| 100 |
package_name: this.$route.query.package_name || "", |
118 |
columns: this.getTableColumns(), |
| 101 |
content_type: this.$route.query.content_type || "", |
119 |
url: "/api/v1/erm/eholdings/ebsco/packages", |
| 102 |
selection_type: this.$route.query.selection_type || "", |
120 |
options: { |
|
|
121 |
embed: "resources+count,vendor.name", |
| 122 |
ordering: false, |
| 123 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
| 124 |
aLengthMenu: [ |
| 125 |
[10, 20, 50, 100], |
| 126 |
[10, 20, 50, 100], |
| 127 |
], |
| 128 |
}, |
| 129 |
table_settings: this.eholdings_titles_table_settings, |
| 130 |
default_filters: { |
| 131 |
name: function () { |
| 132 |
return filters.package_name || "" |
| 133 |
}, |
| 134 |
content_type: function () { |
| 135 |
return filters.content_type || "" |
| 136 |
}, |
| 137 |
selection_type: function () { |
| 138 |
return filters.selection_type || "" |
| 139 |
}, |
| 140 |
}, |
| 103 |
}, |
141 |
}, |
| 104 |
show_table: false, |
142 |
show_table: false, |
| 105 |
local_count_packages: null, |
143 |
local_count_packages: null, |
|
Lines 113-127
export default {
Link Here
|
| 113 |
) |
151 |
) |
| 114 |
}, |
152 |
}, |
| 115 |
}, |
153 |
}, |
| 116 |
beforeRouteEnter(to, from, next) { |
|
|
| 117 |
next(vm => { |
| 118 |
vm.build_datatable() |
| 119 |
}) |
| 120 |
}, |
| 121 |
methods: { |
154 |
methods: { |
| 122 |
show_package: function (package_id) { |
155 |
doShow: function (erm_package, dt, event) { |
|
|
156 |
event.preventDefault() |
| 123 |
this.$router.push( |
157 |
this.$router.push( |
| 124 |
"/cgi-bin/koha/erm/eholdings/ebsco/packages/" + package_id |
158 |
"/cgi-bin/koha/erm/eholdings/ebsco/packages/" + |
|
|
159 |
erm_package.package_id |
| 125 |
) |
160 |
) |
| 126 |
}, |
161 |
}, |
| 127 |
filter_table: async function () { |
162 |
filter_table: async function () { |
|
Lines 132-140
export default {
Link Here
|
| 132 |
this.$router.push(new_route) |
167 |
this.$router.push(new_route) |
| 133 |
this.show_table = true |
168 |
this.show_table = true |
| 134 |
this.local_count_packages = null |
169 |
this.local_count_packages = null |
| 135 |
$("#" + this.table_id) |
170 |
|
| 136 |
.DataTable() |
|
|
| 137 |
.draw() |
| 138 |
if (this.erm_providers.includes("local")) { |
171 |
if (this.erm_providers.includes("local")) { |
| 139 |
const client = APIClient.erm |
172 |
const client = APIClient.erm |
| 140 |
const query = this.filters |
173 |
const query = this.filters |
|
Lines 152-310
export default {
Link Here
|
| 152 |
error => {} |
185 |
error => {} |
| 153 |
) |
186 |
) |
| 154 |
} |
187 |
} |
| 155 |
}, |
|
|
| 156 |
build_datatable: function () { |
| 157 |
let show_package = this.show_package |
| 158 |
let get_lib_from_av = this.get_lib_from_av |
| 159 |
let map_av_dt_filter = this.map_av_dt_filter |
| 160 |
|
188 |
|
| 161 |
if (!this.show_table) { |
189 |
if (this.$refs.table) { |
| 162 |
this.show_table = build_url_params(this.filters).length |
190 |
this.$refs.table.redraw("/api/v1/erm/eholdings/ebsco/packages") |
| 163 |
? true |
|
|
| 164 |
: false |
| 165 |
} |
191 |
} |
| 166 |
let filters = this.filters |
192 |
}, |
| 167 |
let show_table = this.show_table |
193 |
getTableColumns: function () { |
| 168 |
let table_id = this.table_id |
194 |
let get_lib_from_av = this.get_lib_from_av |
| 169 |
|
195 |
let escape_str = this.escape_str |
| 170 |
window["vendors"] = this.vendors.map(e => { |
|
|
| 171 |
e["_id"] = e["id"] |
| 172 |
e["_str"] = e["name"] |
| 173 |
return e |
| 174 |
}) |
| 175 |
let avs = ["av_package_types", "av_package_content_types"] |
| 176 |
avs.forEach(function (av_cat) { |
| 177 |
window[av_cat] = map_av_dt_filter(av_cat) |
| 178 |
}) |
| 179 |
|
196 |
|
| 180 |
let additional_filters = { |
197 |
return [ |
| 181 |
name: function () { |
198 |
{ |
| 182 |
return filters.package_name || "" |
199 |
title: __("Name"), |
| 183 |
}, |
200 |
data: "me.package_id:me.name", |
| 184 |
content_type: function () { |
201 |
searchable: false, |
| 185 |
return filters.content_type || "" |
202 |
orderable: false, |
|
|
203 |
render: function (data, type, row, meta) { |
| 204 |
let node = |
| 205 |
'<a href="/cgi-bin/koha/erm/eholdings/ebsco/packages/' + |
| 206 |
row.package_id + |
| 207 |
'" class="show">' + |
| 208 |
escape_str(`${row.name} (#${row.package_id})`) |
| 209 |
;("</a>") |
| 210 |
if (row.is_selected) { |
| 211 |
node += |
| 212 |
" " + |
| 213 |
'<i class="fa fa-check-square-o" style="color: green; float: right;" title="' + |
| 214 |
__("Is selected") + |
| 215 |
'" />' |
| 216 |
} |
| 217 |
return node |
| 218 |
}, |
| 186 |
}, |
219 |
}, |
| 187 |
selection_type: function () { |
220 |
{ |
| 188 |
return filters.selection_type || "" |
221 |
title: __("Vendor"), |
|
|
222 |
data: "vendor_id", |
| 223 |
searchable: false, |
| 224 |
orderable: false, |
| 225 |
render: function (data, type, row, meta) { |
| 226 |
return row.vendor ? escape_str(row.vendor.name) : "" |
| 227 |
}, |
| 189 |
}, |
228 |
}, |
| 190 |
} |
|
|
| 191 |
|
| 192 |
$("#" + table_id).kohaTable( |
| 193 |
{ |
229 |
{ |
| 194 |
ajax: { |
230 |
title: __("Type"), |
| 195 |
url: "/api/v1/erm/eholdings/ebsco/packages", |
231 |
data: "package_type", |
|
|
232 |
searchable: false, |
| 233 |
orderable: false, |
| 234 |
render: function (data, type, row, meta) { |
| 235 |
return escape_str( |
| 236 |
get_lib_from_av( |
| 237 |
"av_package_types", |
| 238 |
row.package_type |
| 239 |
) |
| 240 |
) |
| 196 |
}, |
241 |
}, |
| 197 |
embed: ["resources+count", "vendor.name"], |
242 |
}, |
| 198 |
ordering: false, |
243 |
{ |
| 199 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
244 |
title: __("Content type"), |
| 200 |
aLengthMenu: [ |
245 |
searchable: false, |
| 201 |
[10, 20, 50, 100], |
246 |
orderable: false, |
| 202 |
[10, 20, 50, 100], |
247 |
render: function (data, type, row, meta) { |
| 203 |
], |
248 |
return escape_str( |
| 204 |
deferLoading: show_table ? false : true, |
249 |
get_lib_from_av( |
| 205 |
autoWidth: false, |
250 |
"av_package_content_types", |
| 206 |
columns: [ |
251 |
row.content_type |
| 207 |
{ |
252 |
) |
| 208 |
title: __("Name"), |
|
|
| 209 |
data: "me.package_id:me.name", |
| 210 |
searchable: false, |
| 211 |
orderable: false, |
| 212 |
render: function (data, type, row, meta) { |
| 213 |
// Rendering done in drawCallback |
| 214 |
return "" |
| 215 |
}, |
| 216 |
}, |
| 217 |
{ |
| 218 |
title: __("Vendor"), |
| 219 |
data: "vendor_id", |
| 220 |
searchable: false, |
| 221 |
orderable: false, |
| 222 |
render: function (data, type, row, meta) { |
| 223 |
return row.vendor |
| 224 |
? escape_str(row.vendor.name) |
| 225 |
: "" |
| 226 |
}, |
| 227 |
}, |
| 228 |
{ |
| 229 |
title: __("Type"), |
| 230 |
data: "package_type", |
| 231 |
searchable: false, |
| 232 |
orderable: false, |
| 233 |
render: function (data, type, row, meta) { |
| 234 |
return escape_str( |
| 235 |
get_lib_from_av( |
| 236 |
"av_package_types", |
| 237 |
row.package_type |
| 238 |
) |
| 239 |
) |
| 240 |
}, |
| 241 |
}, |
| 242 |
{ |
| 243 |
title: __("Content type"), |
| 244 |
searchable: false, |
| 245 |
orderable: false, |
| 246 |
render: function (data, type, row, meta) { |
| 247 |
return escape_str( |
| 248 |
get_lib_from_av( |
| 249 |
"av_package_content_types", |
| 250 |
row.content_type |
| 251 |
) |
| 252 |
) |
| 253 |
}, |
| 254 |
}, |
| 255 |
], |
| 256 |
drawCallback: function (settings) { |
| 257 |
var api = new $.fn.dataTable.Api(settings) |
| 258 |
|
| 259 |
$.each( |
| 260 |
$(this).find("tbody tr td:first-child"), |
| 261 |
function (index, e) { |
| 262 |
let tr = $(this).parent() |
| 263 |
let row = api.row(tr).data() |
| 264 |
if (!row) return // Happen if the table is empty |
| 265 |
let n = createVNode( |
| 266 |
"a", |
| 267 |
{ |
| 268 |
role: "button", |
| 269 |
href: |
| 270 |
"/cgi-bin/koha/erm/eholdings/ebsco/packages/" + |
| 271 |
row.package_id, |
| 272 |
onClick: e => { |
| 273 |
e.preventDefault() |
| 274 |
show_package(row.package_id) |
| 275 |
}, |
| 276 |
}, |
| 277 |
`${row.name} (#${row.package_id})` |
| 278 |
) |
| 279 |
if (row.is_selected) { |
| 280 |
n = createVNode("span", {}, [ |
| 281 |
n, |
| 282 |
" ", |
| 283 |
createVNode("i", { |
| 284 |
class: "fa fa-check-square-o", |
| 285 |
style: { |
| 286 |
color: "green", |
| 287 |
float: "right", |
| 288 |
}, |
| 289 |
title: __("Is selected"), |
| 290 |
}), |
| 291 |
]) |
| 292 |
} |
| 293 |
render(n, e) |
| 294 |
} |
| 295 |
) |
253 |
) |
| 296 |
}, |
254 |
}, |
| 297 |
}, |
255 |
}, |
| 298 |
null, |
256 |
] |
| 299 |
0, |
|
|
| 300 |
additional_filters |
| 301 |
) |
| 302 |
|
| 303 |
if (filters.package_name.length) { |
| 304 |
this.filter_table() |
| 305 |
} |
| 306 |
}, |
257 |
}, |
| 307 |
}, |
258 |
}, |
|
|
259 |
components: { KohaTable }, |
| 308 |
name: "EHoldingsEBSCOPackagesList", |
260 |
name: "EHoldingsEBSCOPackagesList", |
| 309 |
} |
261 |
} |
| 310 |
</script> |
262 |
</script> |
| 311 |
- |
|
|