Lines 4-16
Link Here
|
4 |
[% INCLUDE 'doc-head-open.inc' %] |
4 |
[% INCLUDE 'doc-head-open.inc' %] |
5 |
<title>Koha › Administration › Search engine configuration</title> |
5 |
<title>Koha › Administration › Search engine configuration</title> |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
6 |
[% INCLUDE 'doc-head-close.inc' %] |
|
|
7 |
[% INCLUDE 'datatables.inc' %] |
7 |
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %] |
8 |
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") | $raw %] |
|
|
9 |
[% Asset.css("css/datatables.css") | $raw %] |
8 |
<script> |
10 |
<script> |
|
|
11 |
var searchfieldst; |
12 |
var bibliost; |
13 |
var authoritiest; |
14 |
|
9 |
function clean_line( line ) { |
15 |
function clean_line( line ) { |
10 |
$(line).find('input[type="text"]').val(""); |
16 |
$(line).find('input[type="text"]').val(""); |
11 |
$(line).find('select').find('option:first').attr("selected", "selected"); |
17 |
$(line).find('select').find('option:first').attr("selected", "selected"); |
12 |
} |
18 |
} |
13 |
|
19 |
|
|
|
20 |
function reset_datatables() { |
21 |
var searchfieldSettings = searchfieldst.fnSettings(); |
22 |
var biblioSettings = bibliost.fnSettings(); |
23 |
var authoritySettings = authoritiest.fnSettings(); |
24 |
|
25 |
searchfieldSettings._iDisplayLength = 20; |
26 |
biblioSettings._iDisplayLength = 20; |
27 |
authoritySettings._iDisplayLength = 20; |
28 |
|
29 |
searchfieldst.fnDraw(); |
30 |
bibliost.fnDraw(); |
31 |
authoritiest.fnDraw(); |
32 |
} |
33 |
|
34 |
function show_all_rows() { |
35 |
var searchfieldSettings = searchfieldst.fnSettings(); |
36 |
var biblioSettings = bibliost.fnSettings(); |
37 |
var authoritySettings = authoritiest.fnSettings(); |
38 |
|
39 |
searchfieldSettings._iDisplayLength = -1; |
40 |
biblioSettings._iDisplayLength = -1; |
41 |
authoritySettings._iDisplayLength = -1; |
42 |
|
43 |
searchfieldSettings.oPreviousSearch.sSearch = ""; |
44 |
biblioSettings.oPreviousSearch.sSearch = ""; |
45 |
authoritySettings.oPreviousSearch.sSearch = ""; |
46 |
|
47 |
searchfieldst.fnDraw(); |
48 |
bibliost.fnDraw(); |
49 |
authoritiest.fnDraw(); |
50 |
} |
51 |
|
14 |
function clone_line( line ) { |
52 |
function clone_line( line ) { |
15 |
var new_line = $(line).clone(); |
53 |
var new_line = $(line).clone(); |
16 |
$(new_line).removeClass("nodrag nodrop"); |
54 |
$(new_line).removeClass("nodrag nodrop"); |
Lines 29-37
Link Here
|
29 |
|
67 |
|
30 |
$(document).ready(function() { |
68 |
$(document).ready(function() { |
31 |
$("#tabs").tabs(); |
69 |
$("#tabs").tabs(); |
32 |
$(document).on('click', '.delete', function() { |
70 |
searchfieldst = $('#search-fieldst').dataTable($.extend(true, {}, dataTablesDefaults, { |
33 |
$(this).parents('tr').remove(); |
71 |
"aoColumnDefs": [ |
34 |
var line = $(this).closest("tr"); |
72 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
|
|
73 |
], |
74 |
"sPaginationType": "full_numbers", |
75 |
})); |
76 |
|
77 |
bibliost = $('#bibliost').dataTable($.extend(true, {}, dataTablesDefaults, { |
78 |
"aoColumnDefs": [ |
79 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
80 |
], |
81 |
"sPaginationType": "full_numbers", |
82 |
})); |
83 |
|
84 |
authoritiest = $('#authoritiest').dataTable($.extend(true, {}, dataTablesDefaults, { |
85 |
"aoColumnDefs": [ |
86 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
87 |
], |
88 |
"sPaginationType": "full_numbers", |
89 |
})); |
90 |
|
91 |
$('#save').click(function() { |
92 |
show_all_rows(); |
93 |
}); |
94 |
|
95 |
$('table.dataTable').on('click', '.delete', function() { |
96 |
var tableid = $(this).closest('table').attr('id'); |
97 |
var t = $('#' + tableid).DataTable(); |
98 |
var line = $(this).closest('tr'); |
99 |
t.row( $(this).parents('tr') ).remove().draw( false ); |
100 |
|
101 |
// Show all rows on biblios and authorities table |
102 |
// to find some mapping. |
103 |
show_all_rows(); |
35 |
|
104 |
|
36 |
var name; |
105 |
var name; |
37 |
// We clicked delete button on search fields tab. |
106 |
// We clicked delete button on search fields tab. |
Lines 49-69
Link Here
|
49 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
118 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
50 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
119 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
51 |
} |
120 |
} |
|
|
121 |
//Set display length back to 20. |
122 |
reset_datatables(); |
52 |
}); |
123 |
}); |
53 |
|
124 |
|
54 |
$('.add').click(function() { |
125 |
$('.add').click(function() { |
55 |
var table = $(this).closest('table'); |
126 |
var tableid = $(this).closest('table').attr('id'); |
56 |
var index_name = $(table).attr('data-index_name'); |
127 |
var t = $('#' + tableid).DataTable(); |
57 |
var line = $(this).closest("tr"); |
128 |
var line = $(this).closest("tr"); |
|
|
129 |
var new_line = clone_line( line ); |
58 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
130 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
59 |
if ( marc_field.length > 0 ) { |
131 |
if ( marc_field.length > 0 ) { |
60 |
var new_line = clone_line( line ); |
132 |
t.row.add($(new_line)).draw( false ); |
|
|
133 |
t.order([1, 'asc']).draw(); |
134 |
t.page('last').draw(false); |
135 |
// Show all rows on search-fields table |
136 |
// to find the search field. |
137 |
var mappingSettings = mappingst.fnSettings(); |
138 |
mappingSettings._iDisplayLength = -1; |
139 |
mappingst.fnDraw(); |
140 |
|
61 |
var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); |
141 |
var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); |
62 |
new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody')); |
|
|
63 |
|
142 |
|
64 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
143 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
65 |
$(search_field_line).find('a.btn-default').addClass('disabled'); |
144 |
$(search_field_line).find('a.btn-default').addClass('disabled'); |
66 |
|
145 |
|
|
|
146 |
//Set display length back to 20. |
147 |
mappingSettings._iDisplayLength = 20; |
148 |
mappingst.fnDraw(); |
149 |
|
67 |
clean_line(line); |
150 |
clean_line(line); |
68 |
} |
151 |
} |
69 |
}); |
152 |
}); |
Lines 73-80
Link Here
|
73 |
} ); |
156 |
} ); |
74 |
|
157 |
|
75 |
$('.add-search-field').click(function() { |
158 |
$('.add-search-field').click(function() { |
76 |
var table = $(this).closest('table'); |
159 |
var t = $('#search-fieldst').DataTable(); |
77 |
var line = $(this).closest("tr"); |
160 |
var line = $(this).closest("tr"); |
|
|
161 |
var new_line = clone_line( line ); |
78 |
var name = $(line).find('input[data-id="search_field_name"]').val(); |
162 |
var name = $(line).find('input[data-id="search_field_name"]').val(); |
79 |
let already_exist = 0; |
163 |
let already_exist = 0; |
80 |
[% FOREACH search_field IN all_search_fields %] |
164 |
[% FOREACH search_field IN all_search_fields %] |
Lines 85-92
Link Here
|
85 |
} else { |
169 |
} else { |
86 |
var label = $(line).find('input[data-id="search_field_name"]').val(); |
170 |
var label = $(line).find('input[data-id="search_field_name"]').val(); |
87 |
if ( name.length > 0 && label.length > 0 ) { |
171 |
if ( name.length > 0 && label.length > 0 ) { |
88 |
var new_line = clone_line( line ); |
172 |
t.row.add($(new_line)).draw( false ); |
89 |
new_line.appendTo(table.find('tbody')); |
173 |
t.order([1, 'asc']).draw(); |
|
|
174 |
t.page('last').draw(false); |
90 |
clean_line(line); |
175 |
clean_line(line); |
91 |
} |
176 |
} |
92 |
} |
177 |
} |
Lines 189-202
a.add, a.delete {
Link Here
|
189 |
[% END %] |
274 |
[% END %] |
190 |
</ul> |
275 |
</ul> |
191 |
<div id="search_fields"> |
276 |
<div id="search_fields"> |
192 |
<table class="search_fields" data-index_name="search_fields"> |
277 |
<table id="search-fieldst" class="search_fields" data-index_name="search_fields"> |
193 |
<thead> |
278 |
<thead> |
194 |
<tr> |
279 |
<tr> |
195 |
<th>Name</th> |
280 |
<th class="string-sort">Name</th> |
196 |
<th>Label</th> |
281 |
<th class="string-sort">Label</th> |
197 |
<th>Type</th> |
282 |
<th class="string-sort">Type</th> |
198 |
<th>Weight</th> |
283 |
<th class="string-sort">Weight</th> |
199 |
<th></th> |
284 |
<th class="string-sort"></th> |
200 |
</tr> |
285 |
</tr> |
201 |
</thead> |
286 |
</thead> |
202 |
<tbody> |
287 |
<tbody> |
Lines 291-304
a.add, a.delete {
Link Here
|
291 |
</div> |
376 |
</div> |
292 |
[% FOREACH index IN indexes %] |
377 |
[% FOREACH index IN indexes %] |
293 |
<div id="mapping_[% index.index_name | html %]"> |
378 |
<div id="mapping_[% index.index_name | html %]"> |
294 |
<table class="mappings" data-index_name="[% index.index_name | html %]"> |
379 |
<table id="[% index.index_name | html %]t" class="mappings" data-index_name="[% index.index_name | html %]"> |
295 |
<thead> |
380 |
<thead> |
296 |
<tr class="nodrag nodrop"> |
381 |
<tr class="nodrag nodrop"> |
297 |
<th>Search field</th> |
382 |
<th>Search field</th> |
298 |
<th>Sortable</th> |
383 |
<th class="string-sort">Sortable</th> |
299 |
<th>Facetable</th> |
384 |
<th class="string-sort">Facetable</th> |
300 |
<th>Suggestible</th> |
385 |
<th class="string-sort">Suggestible</th> |
301 |
<th>Mapping</th> |
386 |
<th class="string-sort">Mapping</th> |
302 |
<th></th> |
387 |
<th></th> |
303 |
</tr> |
388 |
</tr> |
304 |
</thead> |
389 |
</thead> |
Lines 457-463
a.add, a.delete {
Link Here
|
457 |
[% END %] |
542 |
[% END %] |
458 |
</div> |
543 |
</div> |
459 |
<p> |
544 |
<p> |
460 |
<button class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button> |
545 |
<button id="save" class="btn btn-default" type="submit" name="op" value="edit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button> |
461 |
<button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button> |
546 |
<button class="btn btn-default" type="submit" name="op" value="reset_confirm"><i class="fa fa-refresh" aria-hidden="true"></i> Reset Mappings</button> |
462 |
</p> |
547 |
</p> |
463 |
</form> |
548 |
</form> |
464 |
- |
|
|