|
Lines 1-98
Link Here
|
| 1 |
<template> |
1 |
<template> |
| 2 |
<div id="package_list_result"> |
2 |
<div id="package_list_result"> |
| 3 |
<table :id="table_id"></table> |
3 |
<KohaTable ref="table" v-bind="tableOptions" @show="doShow"></KohaTable> |
| 4 |
</div> |
4 |
</div> |
| 5 |
</template> |
5 |
</template> |
| 6 |
|
6 |
|
| 7 |
<script> |
7 |
<script> |
| 8 |
import { createVNode, render } from "vue" |
8 |
import { ref } from "vue" |
| 9 |
import { useDataTable } from "../../composables/datatables" |
9 |
import { useDataTable } from "../../composables/datatables" |
|
|
10 |
import KohaTable from "../KohaTable.vue" |
| 10 |
|
11 |
|
| 11 |
export default { |
12 |
export default { |
| 12 |
setup() { |
13 |
setup() { |
| 13 |
const table_id = "package_list" |
14 |
const table = ref() |
| 14 |
useDataTable(table_id) |
|
|
| 15 |
|
15 |
|
| 16 |
return { |
16 |
return { |
| 17 |
table_id, |
17 |
table, |
| 18 |
} |
18 |
} |
| 19 |
}, |
19 |
}, |
| 20 |
data() { |
20 |
data() { |
| 21 |
return {} |
21 |
return { |
|
|
22 |
package_count: [], |
| 23 |
initialized: false, |
| 24 |
tableOptions: { |
| 25 |
columns: this.getTableColumns(), |
| 26 |
data: this.resources, |
| 27 |
options: { embed: "package.name" }, |
| 28 |
actions: { |
| 29 |
0: ["show"], |
| 30 |
}, |
| 31 |
}, |
| 32 |
} |
| 22 |
}, |
33 |
}, |
| 23 |
methods: { |
34 |
methods: { |
| 24 |
show_resource: function (resource_id) { |
35 |
doShow: function (resource, dt, event) { |
| 25 |
this.$router.push( |
36 |
this.$router.push( |
| 26 |
"/cgi-bin/koha/erm/eholdings/local/resources/" + resource_id |
37 |
"/cgi-bin/koha/erm/eholdings/local/resources/" + |
|
|
38 |
resource.resource_id |
| 27 |
) |
39 |
) |
| 28 |
}, |
40 |
}, |
| 29 |
build_datatable: function () { |
41 |
getTableColumns: function () { |
| 30 |
let show_resource = this.show_resource |
42 |
let get_lib_from_av = this.get_lib_from_av |
| 31 |
let resources = this.resources |
43 |
let escape_str = this.escape_str |
| 32 |
let table_id = this.table_id |
44 |
return [ |
| 33 |
|
45 |
{ |
| 34 |
$("#" + table_id).dataTable( |
46 |
title: __("Name"), |
| 35 |
$.extend(true, {}, dataTablesDefaults, { |
47 |
data: "package.name", |
| 36 |
data: resources, |
48 |
searchable: true, |
| 37 |
embed: ["package.name"], |
49 |
orderable: true, |
| 38 |
order: [[0, "asc"]], |
50 |
render: function (data, type, row, meta) { |
| 39 |
autoWidth: false, |
51 |
return ( |
| 40 |
columns: [ |
52 |
'<a href="/cgi-bin/koha/erm/eholdings/local/resources/' + |
| 41 |
{ |
53 |
row.resource_id + |
| 42 |
title: __("Name"), |
54 |
'" class="show">' + |
| 43 |
data: "package.name", |
55 |
escape_str(row.package.name) + |
| 44 |
searchable: true, |
56 |
"</a>" |
| 45 |
orderable: true, |
|
|
| 46 |
render: function (data, type, row, meta) { |
| 47 |
// Rendering done in drawCallback |
| 48 |
return "" |
| 49 |
}, |
| 50 |
width: "100%", |
| 51 |
}, |
| 52 |
], |
| 53 |
drawCallback: function (settings) { |
| 54 |
var api = new $.fn.dataTable.Api(settings) |
| 55 |
|
| 56 |
$.each( |
| 57 |
$(this).find("tbody tr td:first-child"), |
| 58 |
function (index, e) { |
| 59 |
let tr = $(this).parent() |
| 60 |
let row = api.row(tr).data() |
| 61 |
if (!row) return // Happen if the table is empty |
| 62 |
let n = createVNode( |
| 63 |
"a", |
| 64 |
{ |
| 65 |
role: "button", |
| 66 |
href: |
| 67 |
"/cgi-bin/koha/erm/eholdings/local/resources/" + |
| 68 |
row.resource_id, |
| 69 |
onClick: e => { |
| 70 |
e.preventDefault() |
| 71 |
show_resource(row.resource_id) |
| 72 |
}, |
| 73 |
}, |
| 74 |
`${row.package.name}` |
| 75 |
) |
| 76 |
render(n, e) |
| 77 |
} |
| 78 |
) |
57 |
) |
| 79 |
}, |
58 |
}, |
| 80 |
}) |
59 |
width: "100%", |
| 81 |
) |
60 |
}, |
|
|
61 |
] |
| 82 |
}, |
62 |
}, |
| 83 |
}, |
63 |
}, |
| 84 |
mounted() { |
|
|
| 85 |
this.build_datatable() |
| 86 |
}, |
| 87 |
props: { |
64 |
props: { |
| 88 |
resources: Array, |
65 |
resources: Array, |
| 89 |
}, |
66 |
}, |
|
|
67 |
components: { KohaTable }, |
| 90 |
name: "EHoldingsLocalTitlePackagesList", |
68 |
name: "EHoldingsLocalTitlePackagesList", |
| 91 |
} |
69 |
} |
| 92 |
</script> |
70 |
</script> |
| 93 |
|
71 |
|
| 94 |
<style scoped> |
72 |
<style scoped> |
| 95 |
#package_list { |
73 |
table { |
| 96 |
display: table; |
74 |
display: table; |
| 97 |
} |
75 |
} |
| 98 |
</style> |
76 |
</style> |
| 99 |
- |
|
|