Lines 2-14
Link Here
|
2 |
[% INCLUDE 'doc-head-open.inc' %] |
2 |
[% INCLUDE 'doc-head-open.inc' %] |
3 |
<title>Koha › Administration › Elastic Search mappings</title> |
3 |
<title>Koha › Administration › Elastic Search mappings</title> |
4 |
[% INCLUDE 'doc-head-close.inc' %] |
4 |
[% INCLUDE 'doc-head-close.inc' %] |
|
|
5 |
[% INCLUDE 'datatables.inc' %] |
5 |
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") %] |
6 |
[% Asset.js("lib/jquery/plugins/jquery.tablednd.js") %] |
|
|
7 |
[% Asset.css("css/datatables.css") %] |
6 |
<script type="text/javascript"> |
8 |
<script type="text/javascript"> |
|
|
9 |
var searchfieldst; |
10 |
var bibliost; |
11 |
var authoritiest; |
12 |
|
7 |
function clean_line( line ) { |
13 |
function clean_line( line ) { |
8 |
$(line).find('input[type="text"]').val(""); |
14 |
$(line).find('input[type="text"]').val(""); |
9 |
$(line).find('select').find('option:first').attr("selected", "selected"); |
15 |
$(line).find('select').find('option:first').attr("selected", "selected"); |
10 |
} |
16 |
} |
11 |
|
17 |
|
|
|
18 |
function reset_datatables() { |
19 |
var searchfieldSettings = searchfieldst.fnSettings(); |
20 |
var biblioSettings = bibliost.fnSettings(); |
21 |
var authoritySettings = authoritiest.fnSettings(); |
22 |
|
23 |
searchfieldSettings._iDisplayLength = 20; |
24 |
biblioSettings._iDisplayLength = 20; |
25 |
authoritySettings._iDisplayLength = 20; |
26 |
|
27 |
searchfieldst.fnDraw(); |
28 |
bibliost.fnDraw(); |
29 |
authoritiest.fnDraw(); |
30 |
} |
31 |
|
32 |
function show_all_rows() { |
33 |
var searchfieldSettings = searchfieldst.fnSettings(); |
34 |
var biblioSettings = bibliost.fnSettings(); |
35 |
var authoritySettings = authoritiest.fnSettings(); |
36 |
|
37 |
searchfieldSettings._iDisplayLength = -1; |
38 |
biblioSettings._iDisplayLength = -1; |
39 |
authoritySettings._iDisplayLength = -1; |
40 |
|
41 |
searchfieldSettings.oPreviousSearch.sSearch = ""; |
42 |
biblioSettings.oPreviousSearch.sSearch = ""; |
43 |
authoritySettings.oPreviousSearch.sSearch = ""; |
44 |
|
45 |
searchfieldst.fnDraw(); |
46 |
bibliost.fnDraw(); |
47 |
authoritiest.fnDraw(); |
48 |
} |
49 |
|
12 |
function clone_line( line ) { |
50 |
function clone_line( line ) { |
13 |
var new_line = $(line).clone(); |
51 |
var new_line = $(line).clone(); |
14 |
$(new_line).removeClass("nodrag nodrop"); |
52 |
$(new_line).removeClass("nodrag nodrop"); |
Lines 26-85
Link Here
|
26 |
|
64 |
|
27 |
$(document).ready(function() { |
65 |
$(document).ready(function() { |
28 |
$("#tabs").tabs(); |
66 |
$("#tabs").tabs(); |
29 |
$('.delete').click(function() { |
|
|
30 |
$(this).parents('tr').remove(); |
31 |
|
67 |
|
32 |
var line = $(this).closest("tr"); |
68 |
//searchfieldst = KohaTable("search-fieldst", { |
|
|
69 |
searchfieldst = $('#search-fieldst').dataTable($.extend(true, {}, dataTablesDefaults, { |
70 |
"aoColumnDefs": [ |
71 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
72 |
], |
73 |
"sPaginationType": "full_numbers", |
74 |
})); |
75 |
|
76 |
bibliost = $('#bibliost').dataTable($.extend(true, {}, dataTablesDefaults, { |
77 |
"aoColumnDefs": [ |
78 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
79 |
], |
80 |
"sPaginationType": "full_numbers", |
81 |
})); |
82 |
|
83 |
authoritiest = $('#authoritiest').dataTable($.extend(true, {}, dataTablesDefaults, { |
84 |
"aoColumnDefs": [ |
85 |
{ "sType": "string", "aTargets": [ "string-sort" ] } |
86 |
], |
87 |
"sPaginationType": "full_numbers", |
88 |
})); |
89 |
|
90 |
$('#save').click(function() { |
91 |
show_all_rows(); |
92 |
}); |
93 |
|
94 |
$('table.dataTable').on('click', '.delete', function() { |
95 |
var tableid = $(this).closest('table').attr('id'); |
96 |
var t = $('#' + tableid).DataTable(); |
97 |
var line = $(this).closest('tr'); |
98 |
t.row( $(this).parents('tr') ).remove().draw( false ); |
99 |
|
100 |
// Show all rows on biblios and authorities table |
101 |
// to find some mapping. |
102 |
show_all_rows(); |
103 |
|
33 |
var search_field_name = $(line).find('input[name="mapping_search_field_name"]').val(); |
104 |
var search_field_name = $(line).find('input[name="mapping_search_field_name"]').val(); |
34 |
var mappings = $('input[name="mapping_search_field_name"][type="hidden"][value="' + search_field_name + '"]'); |
105 |
var mappings = $('input[name="mapping_search_field_name"][type="hidden"][value="' + search_field_name + '"]'); |
|
|
106 |
|
35 |
if (mappings.length == 0) { |
107 |
if (mappings.length == 0) { |
36 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
108 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
37 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
109 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
38 |
} |
110 |
} |
|
|
111 |
|
112 |
//Set display length back to 20. |
113 |
reset_datatables(); |
39 |
}); |
114 |
}); |
40 |
|
115 |
|
41 |
$("table.mappings").tableDnD( { |
116 |
$("table.mappings").tableDnD( { |
42 |
onDragClass: "dragClass", |
117 |
onDragClass: "dragClass", |
43 |
} ); |
118 |
} ); |
|
|
119 |
|
44 |
$('.add').click(function() { |
120 |
$('.add').click(function() { |
45 |
var table = $(this).closest('table'); |
121 |
var tableid = $(this).closest('table').attr('id'); |
46 |
var index_name = $(table).attr('data-index_name'); |
122 |
var t = $('#' + tableid).DataTable(); |
47 |
var line = $(this).closest("tr"); |
123 |
var line = $(this).closest("tr"); |
|
|
124 |
var new_line = clone_line( line ); |
125 |
|
48 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
126 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
|
|
127 |
|
49 |
if ( marc_field.length > 0 ) { |
128 |
if ( marc_field.length > 0 ) { |
50 |
var new_line = clone_line( line ); |
129 |
t.row.add($(new_line)).draw( false ); |
51 |
new_line.appendTo($('table[data-index_name="'+index_name+'"]>tbody')); |
130 |
t.order([1, 'asc']).draw(); |
52 |
$('.delete').click(function() { |
131 |
t.page('last').draw(false); |
53 |
$(this).parents('tr').remove(); |
132 |
|
54 |
}); |
133 |
// Show all rows on search-fields table |
|
|
134 |
// to find the search field. |
135 |
var mappingSettings = mappingst.fnSettings(); |
136 |
mappingSettings._iDisplayLength = -1; |
137 |
mappingst.fnDraw(); |
55 |
|
138 |
|
56 |
var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); |
139 |
var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); |
57 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
140 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
58 |
$(search_field_line).find('a.btn-default').addClass('disabled'); |
141 |
$(search_field_line).find('a.btn-default').addClass('disabled'); |
59 |
|
142 |
|
60 |
clean_line(line); |
143 |
//Set display length back to 20. |
|
|
144 |
mappingSettings._iDisplayLength = 20; |
145 |
mappingst.fnDraw(); |
61 |
|
146 |
|
62 |
$(table).tableDnD( { |
147 |
clean_line(line); |
63 |
onDragClass: "dragClass", |
|
|
64 |
} ); |
65 |
} |
148 |
} |
66 |
}); |
149 |
}); |
|
|
150 |
|
67 |
$('.add-search-field').click(function() { |
151 |
$('.add-search-field').click(function() { |
68 |
var table = $(this).closest('table'); |
152 |
var t = $('#search-fieldst').DataTable(); |
69 |
var line = $(this).closest("tr"); |
153 |
var line = $(this).closest("tr"); |
|
|
154 |
var new_line = clone_line( line ); |
155 |
|
70 |
var name = $(line).find('input[data-id="search_field_name"]').val(); |
156 |
var name = $(line).find('input[data-id="search_field_name"]').val(); |
71 |
var label = $(line).find('input[data-id="search_field_name"]').val(); |
157 |
var label = $(line).find('input[data-id="search_field_name"]').val(); |
|
|
158 |
|
72 |
if ( name.length > 0 && label.length > 0 ) { |
159 |
if ( name.length > 0 && label.length > 0 ) { |
73 |
var new_line = clone_line( line ); |
160 |
t.row.add($(new_line)).draw( false ); |
74 |
new_line.appendTo($('table[data-index_name=search_fields]>tbody')); |
161 |
t.order([1, 'asc']).draw(); |
75 |
$('.delete').click(function() { |
162 |
t.page('last').draw(false); |
76 |
$(this).parents('tr').remove(); |
|
|
77 |
}); |
78 |
clean_line(line); |
79 |
|
163 |
|
80 |
$(table).tableDnD( { |
164 |
clean_line(line); |
81 |
onDragClass: "dragClass", |
|
|
82 |
} ); |
83 |
} |
165 |
} |
84 |
}); |
166 |
}); |
85 |
}); |
167 |
}); |
Lines 159-172
a.add, a.delete {
Link Here
|
159 |
[% END %] |
241 |
[% END %] |
160 |
</ul> |
242 |
</ul> |
161 |
<div id="search_fields"> |
243 |
<div id="search_fields"> |
162 |
<table class="search_fields" data-index_name="search_fields"> |
244 |
<table id="search-fieldst" class="search_fields" data-index_name="search_fields"> |
163 |
<thead> |
245 |
<thead> |
164 |
<tr> |
246 |
<tr> |
165 |
<th>Name</th> |
247 |
<th class="string-sort">Name</th> |
166 |
<th>Label</th> |
248 |
<th class="string-sort">Label</th> |
167 |
<th>Type</th> |
249 |
<th class="string-sort">Type</th> |
168 |
<th>Weight</th> |
250 |
<th class="string-sort">Weight</th> |
169 |
<th></th> |
251 |
<th class="string-sort"></th> |
170 |
</tr> |
252 |
</tr> |
171 |
</thead> |
253 |
</thead> |
172 |
<tbody> |
254 |
<tbody> |
Lines 253-266
a.add, a.delete {
Link Here
|
253 |
</div> |
335 |
</div> |
254 |
[% FOREACH index IN indexes %] |
336 |
[% FOREACH index IN indexes %] |
255 |
<div id="mapping_[% index.index_name %]"> |
337 |
<div id="mapping_[% index.index_name %]"> |
256 |
<table class="mappings" data-index_name="[% index.index_name%]"> |
338 |
<table id="[% index.index_name%]t" class="mappings" data-index_name="[% index.index_name%]"> |
257 |
<thead> |
339 |
<thead> |
258 |
<tr class="nodrag nodrop"> |
340 |
<tr class="nodrag nodrop"> |
259 |
<th>Search field</th> |
341 |
<th>Search field</th> |
260 |
<th>Sortable</th> |
342 |
<th class="string-sort">Sortable</th> |
261 |
<th>Facetable</th> |
343 |
<th class="string-sort">Facetable</th> |
262 |
<th>Suggestible</th> |
344 |
<th class="string-sort">Suggestible</th> |
263 |
<th>Mapping</th> |
345 |
<th class="string-sort">Mapping</th> |
264 |
<th></th> |
346 |
<th></th> |
265 |
</tr> |
347 |
</tr> |
266 |
</thead> |
348 |
</thead> |
Lines 367-373
a.add, a.delete {
Link Here
|
367 |
</div> |
449 |
</div> |
368 |
[% END %] |
450 |
[% END %] |
369 |
</div> |
451 |
</div> |
370 |
<p><button class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p> |
452 |
<p><button id="save" class="btn btn-default" type="submit"><i class="fa fa-hdd-o" aria-hidden="true"></i> Save</button></p> |
371 |
</form> |
453 |
</form> |
372 |
</div> |
454 |
</div> |
373 |
|
455 |
|
374 |
- |
|
|