Lines 5-13
function clean_line(line) {
Link Here
|
5 |
$(line).find('select').find('option:first').prop("selected", true); |
5 |
$(line).find('select').find('option:first').prop("selected", true); |
6 |
} |
6 |
} |
7 |
|
7 |
|
|
|
8 |
function build_delete_link(del_class){ |
9 |
return '<a class="btn btn-default btn-xs %s" style="cursor: pointer;"><i class="fa fa-trash"></i> %s</a>'.format(del_class, __("Delete")); |
10 |
} |
11 |
|
12 |
function remove_line(line){ |
13 |
var table = $(line).closest('table'); |
14 |
let dt = $(table).DataTable(); |
15 |
dt.row(line).remove().draw(); |
16 |
} |
17 |
|
8 |
function clone_line(line) { |
18 |
function clone_line(line) { |
9 |
var new_line = $(line).clone(); |
19 |
var new_line = $(line).clone(); |
10 |
$(new_line).find('td:last-child>a').removeClass("add").addClass("delete").html('<i class="fa fa-trash"></i> %s'.format(__("Delete") )); |
20 |
let type = $(line).data('type'); |
|
|
21 |
$(new_line).find('td:last-child').html(build_delete_link('delete-%s'.format(type))); |
11 |
$(new_line).find('[data-id]').each(function () { |
22 |
$(new_line).find('[data-id]').each(function () { |
12 |
$(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); |
23 |
$(this).attr({ name: $(this).attr('data-id') }).removeAttr('data-id'); |
13 |
}); |
24 |
}); |
Lines 47-61
$(document).ready(function () {
Link Here
|
47 |
tableInit( oldtabid, newtabid ); |
58 |
tableInit( oldtabid, newtabid ); |
48 |
}); |
59 |
}); |
49 |
|
60 |
|
50 |
$(document).on('click', '.delete', function() { |
61 |
$(document).on('click', '.delete-facet', function() { |
|
|
62 |
var line = $(this).closest("tr"); |
63 |
remove_line(line); |
64 |
}); |
65 |
$(document).on('click', '.delete-mapping', function() { |
66 |
var line = $(this).closest("tr"); |
67 |
remove_line(line); |
68 |
}); |
69 |
$(document).on('click', '.delete-search-field', function() { |
51 |
if ($(this).hasClass('mandatory') && $(".mandatory[data-field_name=" + $(this).attr('data-field_name') + "]").length < 2) { |
70 |
if ($(this).hasClass('mandatory') && $(".mandatory[data-field_name=" + $(this).attr('data-field_name') + "]").length < 2) { |
52 |
alert( __("This field is mandatory and must have at least one mapping") ); |
71 |
alert( __("This field is mandatory and must have at least one mapping") ); |
53 |
return; |
72 |
return; |
54 |
} else { |
73 |
} else { |
55 |
var table = $(this).closest('table'); |
|
|
56 |
let dt = $(table).DataTable(); |
57 |
dt.row( $(this).closest('tr') ).remove().draw(); |
58 |
$(this).parents('tr').remove(); |
59 |
var line = $(this).closest("tr"); |
74 |
var line = $(this).closest("tr"); |
60 |
|
75 |
|
61 |
var name; |
76 |
var name; |
Lines 74-101
$(document).ready(function () {
Link Here
|
74 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
89 |
var search_field_line = $('input[name="search_field_name"][value="' + search_field_name + '"]').closest("tr"); |
75 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
90 |
$(search_field_line).find('a.btn-default').removeClass('disabled'); |
76 |
} |
91 |
} |
|
|
92 |
|
93 |
remove_line(line); |
77 |
} |
94 |
} |
78 |
}); |
95 |
}); |
79 |
|
96 |
|
80 |
$('.add').click(function () { |
97 |
$('.add').click(function () { |
81 |
var table = $(this).closest('table'); |
98 |
var table = $(this).closest('table'); |
82 |
let table_id = table.attr('id'); |
99 |
let table_id = table.attr('id'); |
83 |
var index_name = $(table).attr('data-index_name'); |
100 |
let dt = $('#' + table_id).DataTable(); |
84 |
var line = $(this).closest("tr"); |
101 |
var line = $(this).closest("tr"); |
85 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
102 |
var marc_field = $(line).find('input[data-id="mapping_marc_field"]').val(); |
86 |
if (marc_field.length > 0) { |
103 |
let dt_data = dt.data(); |
|
|
104 |
if ( marc_field.length ) { |
87 |
var new_line = clone_line(line); |
105 |
var new_line = clone_line(line); |
88 |
var search_field_name = $(line).find('select[data-id="mapping_search_field_name"] option:selected').text(); |
106 |
var index_name = $(table).attr('data-index_name'); |
89 |
new_line.appendTo($('table[data-index_name="' + index_name + '"]>tbody')); |
|
|
90 |
let dt = $('#' + table_id).DataTable(); |
107 |
let dt = $('#' + table_id).DataTable(); |
91 |
dt.row.add(new_line).draw(); |
108 |
dt.row.add(new_line).draw(); |
92 |
|
109 |
|
93 |
$(table).on( 'click', '.delete', function () { |
|
|
94 |
var table = $(this).closest('table'); |
95 |
let dt = $(table).DataTable(); |
96 |
dt.row( $(this).closest('tr') ).remove().draw(); |
97 |
} ); |
98 |
|
99 |
clean_line(line); |
110 |
clean_line(line); |
100 |
} |
111 |
} |
101 |
}); |
112 |
}); |
Lines 144-158
$(document).ready(function () {
Link Here
|
144 |
if (search_field_name.length > 0) { |
155 |
if (search_field_name.length > 0) { |
145 |
var new_line = clone_line(line); |
156 |
var new_line = clone_line(line); |
146 |
new_line.find('td:first').attr({'data-order': search_field_name}); |
157 |
new_line.find('td:first').attr({'data-order': search_field_name}); |
147 |
new_line.appendTo($('table#' + table_id + '>tbody')); |
|
|
148 |
dt.row.add(new_line).draw(); |
158 |
dt.row.add(new_line).draw(); |
149 |
|
159 |
|
150 |
$(table).on( 'click', '.delete', function () { |
|
|
151 |
var table = $(this).closest('table'); |
152 |
let dt = $(table).DataTable(); |
153 |
dt.row( $(this).closest('tr') ).remove().draw(); |
154 |
} ); |
155 |
|
156 |
clean_line(line); |
160 |
clean_line(line); |
157 |
} |
161 |
} |
158 |
}); |
162 |
}); |
Lines 173-187
$(document).ready(function () {
Link Here
|
173 |
if (search_field_name.length > 0) { |
177 |
if (search_field_name.length > 0) { |
174 |
const next_id = Math.max.apply(null, dt_data.map(row => row[0])) + 1; |
178 |
const next_id = Math.max.apply(null, dt_data.map(row => row[0])) + 1; |
175 |
const label = selected_option.data('label'); |
179 |
const label = selected_option.data('label'); |
176 |
new_line = [next_id, search_field_name, '<span>%s</span><input type="hidden" name="facet_name" value="%s" />'.format(label.escapeHtml(), search_field_name.escapeHtml()), '<a class="btn btn-default btn-xs delete" style="cursor: pointer;"><i class="fa fa-trash"></i> %s</a>'.format(__("Delete"))]; |
180 |
new_line = [next_id, search_field_name, '<span>%s</span><input type="hidden" name="facet_name" value="%s" />'.format(label.escapeHtml(), search_field_name.escapeHtml()), build_delete_link()] |
177 |
dt.row.add(new_line).draw(); |
181 |
dt.row.add(new_line).draw(); |
178 |
|
182 |
|
179 |
$(table).on( 'click', '.delete', function () { |
|
|
180 |
var table = $(this).closest('table'); |
181 |
let dt = $(table).DataTable(); |
182 |
dt.row( $(this).closest('tr') ).remove().draw(); |
183 |
} ); |
184 |
|
185 |
clean_line(line); |
183 |
clean_line(line); |
186 |
} |
184 |
} |
187 |
}); |
185 |
}); |
188 |
- |
|
|