Lines 55-68
Link Here
|
55 |
/> |
55 |
/> |
56 |
</fieldset> |
56 |
</fieldset> |
57 |
</div> |
57 |
</div> |
58 |
<table :id="table_id"></table> |
58 |
<KohaTable ref="table" v-bind="tableOptions" @show="doShow"></KohaTable> |
59 |
</div> |
59 |
</div> |
60 |
</template> |
60 |
</template> |
61 |
|
61 |
|
62 |
<script> |
62 |
<script> |
63 |
import { inject, createVNode, render } from "vue" |
63 |
import { inject, ref, reactive } from "vue" |
64 |
import { storeToRefs } from "pinia" |
64 |
import { storeToRefs } from "pinia" |
65 |
import { useDataTable } from "../../composables/datatables" |
65 |
import { useDataTable } from "../../composables/datatables" |
|
|
66 |
import KohaTable from "../KohaTable.vue" |
66 |
|
67 |
|
67 |
export default { |
68 |
export default { |
68 |
setup() { |
69 |
setup() { |
Lines 70-229
export default {
Link Here
|
70 |
const { av_title_publication_types } = storeToRefs(AVStore) |
71 |
const { av_title_publication_types } = storeToRefs(AVStore) |
71 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
72 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
72 |
|
73 |
|
73 |
const table_id = "title_list" |
74 |
const table = ref() |
74 |
useDataTable(table_id) |
75 |
const filters = reactive({ |
|
|
76 |
publication_title: "", |
77 |
publication_type: "", |
78 |
selection_type: "", |
79 |
}) |
75 |
|
80 |
|
76 |
return { |
81 |
return { |
77 |
av_title_publication_types, |
82 |
av_title_publication_types, |
78 |
get_lib_from_av, |
83 |
get_lib_from_av, |
|
|
84 |
escape_str, |
79 |
map_av_dt_filter, |
85 |
map_av_dt_filter, |
80 |
table_id, |
86 |
table, |
81 |
} |
87 |
} |
82 |
}, |
88 |
}, |
83 |
data() { |
89 |
data() { |
|
|
90 |
this.filters = { |
91 |
publication_title: this.$route.query.publication_title || "", |
92 |
publication_type: this.$route.query.publication_type || "", |
93 |
selection_type: this.$route.query.selection_type || "", |
94 |
} |
95 |
let filters = this.filters |
84 |
return { |
96 |
return { |
85 |
filters: { |
97 |
tableOptions: { |
86 |
publication_title: "", |
98 |
columns: this.getTableColumns(), |
87 |
publication_type: "", |
99 |
url: |
88 |
selection_type: "", |
100 |
"/api/v1/erm/eholdings/ebsco/packages/" + |
|
|
101 |
this.package_id + |
102 |
"/resources", |
103 |
options: { |
104 |
embed: "title", |
105 |
ordering: false, |
106 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
107 |
aLengthMenu: [ |
108 |
[10, 20, 50, 100], |
109 |
[10, 20, 50, 100], |
110 |
], |
111 |
}, |
112 |
filters_options: { |
113 |
1: () => |
114 |
this.map_av_dt_filter("av_title_publication_types"), |
115 |
}, |
116 |
actions: { 0: ["show"] }, |
117 |
default_filters: { |
118 |
publication_title: function () { |
119 |
return filters.publication_title || "" |
120 |
}, |
121 |
publication_type: function () { |
122 |
return filters.publication_type || "" |
123 |
}, |
124 |
selection_type: function () { |
125 |
return filters.selection_type || "" |
126 |
}, |
127 |
}, |
89 |
}, |
128 |
}, |
90 |
display_filters: false, |
129 |
display_filters: false, |
91 |
} |
130 |
} |
92 |
}, |
131 |
}, |
93 |
methods: { |
132 |
methods: { |
94 |
show_resource: function (resource_id) { |
133 |
doShow: function (resource, dt, event) { |
|
|
134 |
event.preventDefault() |
95 |
this.$router.push( |
135 |
this.$router.push( |
96 |
"/cgi-bin/koha/erm/eholdings/ebsco/resources/" + resource_id |
136 |
"/cgi-bin/koha/erm/eholdings/ebsco/resources/" + |
|
|
137 |
resource.resource_id |
97 |
) |
138 |
) |
98 |
}, |
139 |
}, |
99 |
filter_table: function () { |
140 |
filter_table: function () { |
100 |
$("#" + this.table_id) |
141 |
this.$refs.table.redraw( |
101 |
.DataTable() |
142 |
"/api/v1/erm/eholdings/ebsco/packages/" + |
102 |
.draw() |
143 |
this.package_id + |
|
|
144 |
"/resources" |
145 |
) |
103 |
}, |
146 |
}, |
104 |
toggle_filters: function (e) { |
147 |
toggle_filters: function (e) { |
105 |
this.display_filters = !this.display_filters |
148 |
this.display_filters = !this.display_filters |
106 |
}, |
149 |
}, |
107 |
build_datatable: function () { |
150 |
getTableColumns: function () { |
108 |
let show_resource = this.show_resource |
|
|
109 |
let package_id = this.package_id |
110 |
let get_lib_from_av = this.get_lib_from_av |
151 |
let get_lib_from_av = this.get_lib_from_av |
111 |
let map_av_dt_filter = this.map_av_dt_filter |
152 |
let map_av_dt_filter = this.map_av_dt_filter |
112 |
let filters = this.filters |
|
|
113 |
let table_id = this.table_id |
114 |
|
115 |
window["av_title_publication_types"] = map_av_dt_filter( |
116 |
"av_title_publication_types" |
117 |
) |
118 |
|
153 |
|
119 |
let additional_filters = { |
154 |
return [ |
120 |
publication_title: function () { |
|
|
121 |
return filters.publication_title || "" |
122 |
}, |
123 |
publication_type: function () { |
124 |
return filters.publication_type || "" |
125 |
}, |
126 |
selection_type: function () { |
127 |
return filters.selection_type || "" |
128 |
}, |
129 |
} |
130 |
|
131 |
$("#" + table_id).kohaTable( |
132 |
{ |
155 |
{ |
133 |
ajax: { |
156 |
title: __("Name"), |
134 |
url: |
157 |
data: "title.publication_title", |
135 |
"/api/v1/erm/eholdings/ebsco/packages/" + |
158 |
searchable: false, |
136 |
package_id + |
159 |
orderable: false, |
137 |
"/resources", |
160 |
render: function (data, type, row, meta) { |
|
|
161 |
let node = |
162 |
'<a href="/cgi-bin/koha/erm/eholdings/ebsco/resources/' + |
163 |
row.resource_id + |
164 |
'" class="show">' + |
165 |
escape_str(`${row.title.publication_title}`) + |
166 |
"</a>" |
167 |
if (row.is_selected) { |
168 |
node += |
169 |
" " + |
170 |
'<i class="fa fa-check-square-o" style="color: green; float: right;" title="' + |
171 |
__("Is selected") + |
172 |
'" />' |
173 |
} |
174 |
return node |
138 |
}, |
175 |
}, |
139 |
ordering: false, |
176 |
}, |
140 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
177 |
{ |
141 |
aLengthMenu: [ |
178 |
title: __("Publication type"), |
142 |
[10, 20, 50, 100], |
179 |
data: "title.publication_type", |
143 |
[10, 20, 50, 100], |
180 |
searchable: false, |
144 |
], |
181 |
orderable: false, |
145 |
embed: ["title"], |
182 |
render: function (data, type, row, meta) { |
146 |
autoWidth: false, |
183 |
return escape_str( |
147 |
columns: [ |
184 |
get_lib_from_av( |
148 |
{ |
185 |
"av_title_publication_types", |
149 |
title: __("Name"), |
186 |
row.title.publication_type |
150 |
data: "title.publication_title", |
187 |
) |
151 |
searchable: false, |
|
|
152 |
orderable: false, |
153 |
render: function (data, type, row, meta) { |
154 |
// Rendering done in drawCallback |
155 |
return "" |
156 |
}, |
157 |
}, |
158 |
{ |
159 |
title: __("Publication type"), |
160 |
data: "title.publication_type", |
161 |
searchable: false, |
162 |
orderable: false, |
163 |
render: function (data, type, row, meta) { |
164 |
return escape_str( |
165 |
get_lib_from_av( |
166 |
"av_title_publication_types", |
167 |
row.title.publication_type |
168 |
) |
169 |
) |
170 |
}, |
171 |
}, |
172 |
], |
173 |
drawCallback: function (settings) { |
174 |
var api = new $.fn.dataTable.Api(settings) |
175 |
|
176 |
$.each( |
177 |
$(this).find("tbody tr td:first-child"), |
178 |
function (index, e) { |
179 |
let tr = $(this).parent() |
180 |
let row = api.row(tr).data() |
181 |
if (!row) return // Happen if the table is empty |
182 |
let n = createVNode( |
183 |
"a", |
184 |
{ |
185 |
role: "button", |
186 |
href: |
187 |
"/cgi-bin/koha/erm/eholdings/ebsco/resources/" + |
188 |
row.resource_id, |
189 |
onClick: e => { |
190 |
e.preventDefault() |
191 |
show_resource(row.resource_id) |
192 |
}, |
193 |
}, |
194 |
`${row.title.publication_title}` |
195 |
) |
196 |
if (row.is_selected) { |
197 |
n = createVNode("span", {}, [ |
198 |
n, |
199 |
" ", |
200 |
createVNode("i", { |
201 |
class: "fa fa-check-square-o", |
202 |
style: { |
203 |
color: "green", |
204 |
float: "right", |
205 |
}, |
206 |
title: __("Is selected"), |
207 |
}), |
208 |
]) |
209 |
} |
210 |
render(n, e) |
211 |
} |
212 |
) |
188 |
) |
213 |
}, |
189 |
}, |
214 |
}, |
190 |
}, |
215 |
null, |
191 |
] |
216 |
0, |
|
|
217 |
additional_filters |
218 |
) |
219 |
}, |
192 |
}, |
220 |
}, |
193 |
}, |
221 |
mounted() { |
|
|
222 |
this.build_datatable() |
223 |
}, |
224 |
props: { |
194 |
props: { |
225 |
package_id: String, |
195 |
package_id: String, |
226 |
}, |
196 |
}, |
|
|
197 |
components: { KohaTable }, |
227 |
name: "EHoldingsEBSCOPackageTitlesList", |
198 |
name: "EHoldingsEBSCOPackageTitlesList", |
228 |
} |
199 |
} |
229 |
</script> |
200 |
</script> |
230 |
- |
|
|