Lines 8-14
Link Here
|
8 |
id="title_list_result" |
8 |
id="title_list_result" |
9 |
class="page-section" |
9 |
class="page-section" |
10 |
> |
10 |
> |
11 |
<table :id="table_id"></table> |
11 |
<KohaTable |
|
|
12 |
ref="table" |
13 |
v-bind="tableOptions" |
14 |
@show="doShow" |
15 |
@edit="doEdit" |
16 |
@delete="doDelete" |
17 |
></KohaTable> |
12 |
</div> |
18 |
</div> |
13 |
<div v-else class="dialog message"> |
19 |
<div v-else class="dialog message"> |
14 |
{{ $__("There are no titles defined") }} |
20 |
{{ $__("There are no titles defined") }} |
Lines 19-28
Link Here
|
19 |
|
25 |
|
20 |
<script> |
26 |
<script> |
21 |
import Toolbar from "./EHoldingsLocalTitlesToolbar.vue" |
27 |
import Toolbar from "./EHoldingsLocalTitlesToolbar.vue" |
22 |
import { inject, createVNode, render } from "vue" |
28 |
import { inject, ref, reactive } from "vue" |
23 |
import { storeToRefs } from "pinia" |
29 |
import { storeToRefs } from "pinia" |
24 |
import { APIClient } from "../../fetch/api-client.js" |
30 |
import { APIClient } from "../../fetch/api-client.js" |
25 |
import { useDataTable } from "../../composables/datatables" |
31 |
import { useDataTable } from "../../composables/datatables" |
|
|
32 |
import KohaTable from "../KohaTable.vue" |
26 |
|
33 |
|
27 |
export default { |
34 |
export default { |
28 |
setup() { |
35 |
setup() { |
Lines 32-63
export default {
Link Here
|
32 |
|
39 |
|
33 |
const { setConfirmationDialog, setMessage } = inject("mainStore") |
40 |
const { setConfirmationDialog, setMessage } = inject("mainStore") |
34 |
|
41 |
|
35 |
const table_id = "title_list" |
42 |
const table = ref() |
36 |
useDataTable(table_id) |
43 |
const filters = reactive({ |
|
|
44 |
publication_title: "", |
45 |
publication_type: "", |
46 |
}) |
37 |
|
47 |
|
38 |
return { |
48 |
return { |
39 |
av_title_publication_types, |
49 |
av_title_publication_types, |
40 |
get_lib_from_av, |
50 |
get_lib_from_av, |
41 |
map_av_dt_filter, |
51 |
map_av_dt_filter, |
42 |
table_id, |
52 |
escape_str, |
|
|
53 |
table, |
54 |
filters, |
43 |
setConfirmationDialog, |
55 |
setConfirmationDialog, |
44 |
setMessage, |
56 |
setMessage, |
|
|
57 |
eholdings_titles_table_settings, |
45 |
} |
58 |
} |
46 |
}, |
59 |
}, |
47 |
data: function () { |
60 |
data: function () { |
|
|
61 |
this.filters = { |
62 |
publication_title: this.$route.query.publication_title || "", |
63 |
publication_type: this.$route.query.publication_type || "", |
64 |
} |
65 |
let filters = this.filters |
66 |
|
48 |
return { |
67 |
return { |
49 |
title_count: 0, |
68 |
title_count: 0, |
50 |
initialized: false, |
69 |
initialized: false, |
51 |
filters: { |
70 |
tableOptions: { |
52 |
publication_title: this.$route.query.publication_title || "", |
71 |
columns: this.getTableColumns(), |
53 |
publication_type: this.$route.query.publication_type || "", |
72 |
url: "/api/v1/erm/eholdings/local/titles", |
|
|
73 |
options: { |
74 |
embed: "resources.package", |
75 |
searchCols: [ |
76 |
{ search: filters.publication_title }, |
77 |
null, |
78 |
{ search: filters.publication_type }, |
79 |
null, |
80 |
], |
81 |
}, |
82 |
table_settings: this.eholdings_titles_table_settings, |
83 |
add_filters: true, |
84 |
filters_options: { |
85 |
2: () => |
86 |
this.map_av_dt_filter("av_title_publication_types"), |
87 |
}, |
88 |
actions: { |
89 |
0: ["show"], |
90 |
"-1": ["edit", "delete"], |
91 |
}, |
54 |
}, |
92 |
}, |
55 |
cannot_search: false, |
93 |
cannot_search: false, |
56 |
} |
94 |
} |
57 |
}, |
95 |
}, |
58 |
beforeRouteEnter(to, from, next) { |
96 |
beforeRouteEnter(to, from, next) { |
59 |
next(vm => { |
97 |
next(vm => { |
60 |
vm.getTitleCount().then(() => vm.build_datatable()) |
98 |
vm.getTitleCount().then(() => (vm.initialized = true)) |
61 |
}) |
99 |
}) |
62 |
}, |
100 |
}, |
63 |
methods: { |
101 |
methods: { |
Lines 66-315
export default {
Link Here
|
66 |
await client.localTitles.count().then( |
104 |
await client.localTitles.count().then( |
67 |
count => { |
105 |
count => { |
68 |
this.title_count = count |
106 |
this.title_count = count |
69 |
this.initialized = true |
|
|
70 |
}, |
107 |
}, |
71 |
error => {} |
108 |
error => {} |
72 |
) |
109 |
) |
73 |
}, |
110 |
}, |
74 |
show_title: function (title_id) { |
111 |
doShow: function (title, dt, event) { |
|
|
112 |
event.preventDefault() |
75 |
this.$router.push( |
113 |
this.$router.push( |
76 |
"/cgi-bin/koha/erm/eholdings/local/titles/" + title_id |
114 |
"/cgi-bin/koha/erm/eholdings/local/titles/" + title.title_id |
77 |
) |
115 |
) |
78 |
}, |
116 |
}, |
79 |
edit_title: function (title_id) { |
117 |
doEdit: function (title, dt, event) { |
80 |
this.$router.push( |
118 |
this.$router.push( |
81 |
"/cgi-bin/koha/erm/eholdings/local/titles/edit/" + title_id |
119 |
"/cgi-bin/koha/erm/eholdings/local/titles/edit/" + |
|
|
120 |
title.title_id |
82 |
) |
121 |
) |
83 |
}, |
122 |
}, |
84 |
delete_title: function (title_id, title_publication_title) { |
123 |
doDelete: function (title, dt, event) { |
85 |
this.setConfirmationDialog( |
124 |
this.setConfirmationDialog( |
86 |
{ |
125 |
{ |
87 |
title: this.$__( |
126 |
title: this.$__( |
88 |
"Are you sure you want to remove this title?" |
127 |
"Are you sure you want to remove this title?" |
89 |
), |
128 |
), |
90 |
message: title_publication_title, |
129 |
message: title.publication_title, |
91 |
accept_label: this.$__("Yes, delete"), |
130 |
accept_label: this.$__("Yes, delete"), |
92 |
cancel_label: this.$__("No, do not delete"), |
131 |
cancel_label: this.$__("No, do not delete"), |
93 |
}, |
132 |
}, |
94 |
() => { |
133 |
() => { |
95 |
const client = APIClient.erm |
134 |
const client = APIClient.erm |
96 |
client.localTitles.delete(title_id).then( |
135 |
client.localTitles.delete(title.title_id).then( |
97 |
success => { |
136 |
success => { |
98 |
this.setMessage( |
137 |
this.setMessage( |
99 |
this.$__("Local title %s deleted").format( |
138 |
this.$__("Local title %s deleted").format( |
100 |
title_publication_title |
139 |
title.publication_title |
101 |
), |
140 |
), |
102 |
true |
141 |
true |
103 |
) |
142 |
) |
104 |
$("#" + this.table_id) |
143 |
dt.draw() |
105 |
.DataTable() |
|
|
106 |
.ajax.url("/api/v1/erm/eholdings/local/titles") |
107 |
.draw() |
108 |
}, |
144 |
}, |
109 |
error => {} |
145 |
error => {} |
110 |
) |
146 |
) |
111 |
} |
147 |
} |
112 |
) |
148 |
) |
113 |
}, |
149 |
}, |
114 |
build_datatable: function () { |
150 |
getTableColumns: function () { |
115 |
let show_title = this.show_title |
|
|
116 |
let edit_title = this.edit_title |
117 |
let delete_title = this.delete_title |
118 |
let get_lib_from_av = this.get_lib_from_av |
151 |
let get_lib_from_av = this.get_lib_from_av |
119 |
let map_av_dt_filter = this.map_av_dt_filter |
152 |
let escape_str = this.escape_str |
120 |
let filters = this.filters |
|
|
121 |
let table_id = this.table_id |
122 |
|
123 |
window["av_title_publication_types"] = map_av_dt_filter( |
124 |
"av_title_publication_types" |
125 |
) |
126 |
|
153 |
|
127 |
$("#" + table_id).kohaTable( |
154 |
return [ |
128 |
{ |
155 |
{ |
129 |
ajax: { |
156 |
title: __("Title"), |
130 |
url: "/api/v1/erm/eholdings/local/titles", |
157 |
data: "me.publication_title", |
|
|
158 |
searchable: true, |
159 |
orderable: true, |
160 |
render: function (data, type, row, meta) { |
161 |
return ( |
162 |
'<a href="/cgi-bin/koha/erm/eholdings/local/titles/' + |
163 |
row.title_id + |
164 |
'" class="show">' + |
165 |
escape_str( |
166 |
`${row.publication_title} (#${row.title_id})` |
167 |
) + |
168 |
"</a>" |
169 |
) |
131 |
}, |
170 |
}, |
132 |
embed: ["resources.package"], |
171 |
}, |
133 |
order: [[0, "asc"]], |
172 |
{ |
134 |
autoWidth: false, |
173 |
title: __("Contributors"), |
135 |
searchCols: [ |
174 |
data: "first_author:first_editor", |
136 |
{ search: filters.publication_title }, |
175 |
searchable: true, |
137 |
null, |
176 |
orderable: true, |
138 |
{ search: filters.publication_type }, |
177 |
render: function (data, type, row, meta) { |
139 |
null, |
178 |
return ( |
140 |
], |
179 |
escape_str(row.first_author) + |
141 |
columns: [ |
180 |
(row.first_author && row.first_editor |
142 |
{ |
181 |
? "<br/>" |
143 |
title: __("Title"), |
182 |
: "") + |
144 |
data: "me.publication_title", |
183 |
escape_str(row.first_editor) |
145 |
searchable: true, |
|
|
146 |
orderable: true, |
147 |
render: function (data, type, row, meta) { |
148 |
// Rendering done in drawCallback |
149 |
return "" |
150 |
}, |
151 |
}, |
152 |
{ |
153 |
title: __("Contributors"), |
154 |
data: "first_author:first_editor", |
155 |
searchable: true, |
156 |
orderable: true, |
157 |
render: function (data, type, row, meta) { |
158 |
return ( |
159 |
escape_str(row.first_author) + |
160 |
(row.first_author && row.first_editor |
161 |
? "<br/>" |
162 |
: "") + |
163 |
escape_str(row.first_editor) |
164 |
) |
165 |
}, |
166 |
}, |
167 |
{ |
168 |
title: __("Publication type"), |
169 |
data: "publication_type", |
170 |
searchable: true, |
171 |
orderable: true, |
172 |
render: function (data, type, row, meta) { |
173 |
return escape_str( |
174 |
get_lib_from_av( |
175 |
"av_title_publication_types", |
176 |
row.publication_type |
177 |
) |
178 |
) |
179 |
}, |
180 |
}, |
181 |
{ |
182 |
title: __("Identifier"), |
183 |
data: "print_identifier:online_identifier", |
184 |
searchable: true, |
185 |
orderable: true, |
186 |
render: function (data, type, row, meta) { |
187 |
let print_identifier = row.print_identifier |
188 |
let online_identifier = row.online_identifier |
189 |
return ( |
190 |
(print_identifier |
191 |
? escape_str( |
192 |
_("ISBN (Print): %s").format( |
193 |
print_identifier |
194 |
) |
195 |
) |
196 |
: "") + |
197 |
(online_identifier |
198 |
? escape_str( |
199 |
_("ISBN (Online): %s").format( |
200 |
online_identifier |
201 |
) |
202 |
) |
203 |
: "") |
204 |
) |
205 |
}, |
206 |
}, |
207 |
{ |
208 |
title: __("Actions"), |
209 |
data: function (row, type, val, meta) { |
210 |
return '<div class="actions"></div>' |
211 |
}, |
212 |
className: "actions noExport", |
213 |
searchable: false, |
214 |
orderable: false, |
215 |
}, |
216 |
], |
217 |
drawCallback: function (settings) { |
218 |
var api = new $.fn.dataTable.Api(settings) |
219 |
|
220 |
$.each( |
221 |
$(this).find("td .actions"), |
222 |
function (index, e) { |
223 |
let tr = $(this).parent().parent() |
224 |
let title_id = api.row(tr).data().title_id |
225 |
let title_publication_title = api |
226 |
.row(tr) |
227 |
.data().publication_title |
228 |
let editButton = createVNode( |
229 |
"a", |
230 |
{ |
231 |
class: "btn btn-default btn-xs", |
232 |
role: "button", |
233 |
onClick: () => { |
234 |
edit_title(title_id) |
235 |
}, |
236 |
}, |
237 |
[ |
238 |
createVNode("i", { |
239 |
class: "fa fa-pencil", |
240 |
"aria-hidden": "true", |
241 |
}), |
242 |
__("Edit"), |
243 |
] |
244 |
) |
245 |
|
246 |
let deleteButton = createVNode( |
247 |
"a", |
248 |
{ |
249 |
class: "btn btn-default btn-xs", |
250 |
role: "button", |
251 |
onClick: () => { |
252 |
delete_title( |
253 |
title_id, |
254 |
title_publication_title |
255 |
) |
256 |
}, |
257 |
}, |
258 |
[ |
259 |
createVNode("i", { |
260 |
class: "fa fa-trash", |
261 |
"aria-hidden": "true", |
262 |
}), |
263 |
__("Delete"), |
264 |
] |
265 |
) |
266 |
|
267 |
let n = createVNode("span", {}, [ |
268 |
editButton, |
269 |
" ", |
270 |
deleteButton, |
271 |
]) |
272 |
render(n, e) |
273 |
} |
274 |
) |
184 |
) |
275 |
|
185 |
}, |
276 |
$.each( |
186 |
}, |
277 |
$(this).find("tbody tr td:first-child"), |
187 |
{ |
278 |
function (index, e) { |
188 |
title: __("Publication type"), |
279 |
let tr = $(this).parent() |
189 |
data: "publication_type", |
280 |
let row = api.row(tr).data() |
190 |
searchable: true, |
281 |
if (!row) return // Happen if the table is empty |
191 |
orderable: true, |
282 |
let n = createVNode( |
192 |
render: function (data, type, row, meta) { |
283 |
"a", |
193 |
return escape_str( |
284 |
{ |
194 |
get_lib_from_av( |
285 |
role: "button", |
195 |
"av_title_publication_types", |
286 |
href: |
196 |
row.publication_type |
287 |
"/cgi-bin/koha/erm/eholdings/local/titles/" + |
197 |
) |
288 |
row.title_id, |
|
|
289 |
onClick: e => { |
290 |
e.preventDefault() |
291 |
show_title(row.title_id) |
292 |
}, |
293 |
}, |
294 |
`${row.publication_title} (#${row.title_id})` |
295 |
) |
296 |
render(n, e) |
297 |
} |
298 |
) |
198 |
) |
299 |
}, |
199 |
}, |
300 |
preDrawCallback: function (settings) { |
200 |
}, |
301 |
$("#" + table_id) |
201 |
{ |
302 |
.find("thead th") |
202 |
title: __("Identifier"), |
303 |
.eq(2) |
203 |
data: "print_identifier:online_identifier", |
304 |
.attr("data-filter", "av_title_publication_types") |
204 |
searchable: true, |
|
|
205 |
orderable: true, |
206 |
render: function (data, type, row, meta) { |
207 |
let print_identifier = row.print_identifier |
208 |
let online_identifier = row.online_identifier |
209 |
return ( |
210 |
(print_identifier |
211 |
? escape_str( |
212 |
_("ISBN (Print): %s").format( |
213 |
print_identifier |
214 |
) |
215 |
) |
216 |
: "") + |
217 |
(online_identifier |
218 |
? escape_str( |
219 |
_("ISBN (Online): %s").format( |
220 |
online_identifier |
221 |
) |
222 |
) |
223 |
: "") |
224 |
) |
305 |
}, |
225 |
}, |
306 |
}, |
226 |
}, |
307 |
eholdings_titles_table_settings, |
227 |
] |
308 |
1 |
|
|
309 |
) |
310 |
}, |
228 |
}, |
311 |
}, |
229 |
}, |
312 |
components: { Toolbar }, |
230 |
components: { Toolbar, KohaTable }, |
313 |
name: "EHoldingsLocalTitlesList", |
231 |
name: "EHoldingsLocalTitlesList", |
314 |
} |
232 |
} |
315 |
</script> |
233 |
</script> |
316 |
- |
|
|