Lines 89-185
export default {
Link Here
|
89 |
$.fn.dataTable.ext.search = $.fn.dataTable.ext.search.filter( |
89 |
$.fn.dataTable.ext.search = $.fn.dataTable.ext.search.filter( |
90 |
search => search.name != "apply_filter" |
90 |
search => search.name != "apply_filter" |
91 |
) |
91 |
) |
92 |
$("#" + table_id).dataTable({ |
92 |
$("#" + table_id).kohaTable({ |
93 |
...dataTablesDefaults, |
93 |
data: resources, |
94 |
...{ |
94 |
embed: ["package.name"], |
95 |
data: resources, |
95 |
ordering: false, |
96 |
embed: ["package.name"], |
96 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
97 |
ordering: false, |
97 |
lengthMenu: [ |
98 |
dom: '<"top pager"<"table_entries"ilp>>tr<"bottom pager"ip>', |
98 |
[10, 20, 50, 100], |
99 |
lengthMenu: [ |
99 |
[10, 20, 50, 100], |
100 |
[10, 20, 50, 100], |
100 |
], |
101 |
[10, 20, 50, 100], |
101 |
autoWidth: false, |
102 |
], |
102 |
columns: [ |
103 |
autoWidth: false, |
103 |
{ |
104 |
columns: [ |
104 |
title: __("Name"), |
105 |
{ |
105 |
data: "package.name", |
106 |
title: __("Name"), |
106 |
searchable: false, |
107 |
data: "package.name", |
107 |
orderable: false, |
108 |
searchable: false, |
108 |
render: function (data, type, row, meta) { |
109 |
orderable: false, |
109 |
// Rendering done in drawCallback |
110 |
render: function (data, type, row, meta) { |
110 |
return "" |
111 |
// Rendering done in drawCallback |
|
|
112 |
return "" |
113 |
}, |
114 |
width: "100%", |
115 |
}, |
111 |
}, |
116 |
], |
112 |
width: "100%", |
117 |
drawCallback: function (settings) { |
113 |
}, |
118 |
var api = new $.fn.dataTable.Api(settings) |
114 |
], |
|
|
115 |
drawCallback: function (settings) { |
116 |
var api = new $.fn.dataTable.Api(settings) |
119 |
|
117 |
|
120 |
if (!api.rows({ search: "applied" }).count()) return |
118 |
if (!api.rows({ search: "applied" }).count()) return |
121 |
|
119 |
|
122 |
$.each( |
120 |
$.each( |
123 |
$(this).find("tbody tr td:first-child"), |
121 |
$(this).find("tbody tr td:first-child"), |
124 |
function (index, e) { |
122 |
function (index, e) { |
125 |
let tr = $(this).parent() |
123 |
let tr = $(this).parent() |
126 |
let row = api.row(tr).data() |
124 |
let row = api.row(tr).data() |
127 |
if (!row) return // Happen if the table is empty |
125 |
if (!row) return // Happen if the table is empty |
128 |
let { href } = router.resolve({ |
126 |
let { href } = router.resolve({ |
129 |
name: "EHoldingsEBSCOResourcesShow", |
127 |
name: "EHoldingsEBSCOResourcesShow", |
130 |
params: { resource_id: row.resource_id }, |
128 |
params: { resource_id: row.resource_id }, |
131 |
}) |
129 |
}) |
132 |
let n = createVNode( |
130 |
let n = createVNode( |
133 |
"a", |
131 |
"a", |
134 |
{ |
132 |
{ |
135 |
role: "button", |
133 |
role: "button", |
136 |
href, |
134 |
href, |
137 |
onClick: e => { |
135 |
onClick: e => { |
138 |
e.preventDefault() |
136 |
e.preventDefault() |
139 |
show_resource(row.resource_id) |
137 |
show_resource(row.resource_id) |
140 |
}, |
|
|
141 |
}, |
138 |
}, |
142 |
`${row.package.name}` |
139 |
}, |
143 |
) |
140 |
`${row.package.name}` |
144 |
if (row.is_selected) { |
141 |
) |
145 |
n = createVNode("span", {}, [ |
142 |
if (row.is_selected) { |
146 |
n, |
143 |
n = createVNode("span", {}, [ |
147 |
" ", |
144 |
n, |
148 |
createVNode("i", { |
145 |
" ", |
149 |
class: "fa fa-check-square", |
146 |
createVNode("i", { |
150 |
style: { |
147 |
class: "fa fa-check-square", |
151 |
color: "green", |
148 |
style: { |
152 |
float: "right", |
149 |
color: "green", |
153 |
}, |
150 |
float: "right", |
154 |
title: __("Is selected"), |
151 |
}, |
155 |
}), |
152 |
title: __("Is selected"), |
156 |
]) |
153 |
}), |
157 |
} |
154 |
]) |
158 |
render(n, e) |
|
|
159 |
} |
160 |
) |
161 |
}, |
162 |
initComplete: function () { |
163 |
$.fn.dataTable.ext.search.push( |
164 |
function apply_filter( |
165 |
settings, |
166 |
data, |
167 |
dataIndex, |
168 |
row |
169 |
) { |
170 |
return ( |
171 |
row.package.name.match( |
172 |
new RegExp(filters.package_name, "i") |
173 |
) && |
174 |
(filters.selection_type == 0 || |
175 |
(filters.selection_type == 1 && |
176 |
row.is_selected) || |
177 |
(filters.selection_type == 2 && |
178 |
!row.is_selected)) |
179 |
) |
180 |
} |
155 |
} |
|
|
156 |
render(n, e) |
157 |
} |
158 |
) |
159 |
}, |
160 |
initComplete: function () { |
161 |
$.fn.dataTable.ext.search.push(function apply_filter( |
162 |
settings, |
163 |
data, |
164 |
dataIndex, |
165 |
row |
166 |
) { |
167 |
return ( |
168 |
row.package.name.match( |
169 |
new RegExp(filters.package_name, "i") |
170 |
) && |
171 |
(filters.selection_type == 0 || |
172 |
(filters.selection_type == 1 && |
173 |
row.is_selected) || |
174 |
(filters.selection_type == 2 && |
175 |
!row.is_selected)) |
181 |
) |
176 |
) |
182 |
}, |
177 |
}) |
183 |
}, |
178 |
}, |
184 |
}) |
179 |
}) |
185 |
}, |
180 |
}, |