forked from mirror/Part-DB.Part-DB-server
83 lines
No EOL
2.9 KiB
Twig
83 lines
No EOL
2.9 KiB
Twig
<form method="post" action="{{ url("table_action") }}">
|
|
<input type="hidden" name="_token" value="{{ csrf_token('table_action') }}">
|
|
|
|
<input type="hidden" name="redirect_back" value="{{ app.request.uri }}">
|
|
|
|
<input type="hidden" name="ids" id="select_ids" value="">
|
|
|
|
<div class="d-none" id="select_panel">
|
|
<p><span id="select_count"></span> elements selected!</p>
|
|
|
|
<select class="selectpicker" name="action" id="select_action" onchange="updateTargetSelect()">
|
|
<option value="favorite">Favorite</option>
|
|
<option value="unfavorite">Unfavorite</option>
|
|
<option value="delete">Delete</option>
|
|
|
|
<option value="change_category" data-url="{{ path('select_category') }}">Change category</option>
|
|
<option value="change_footprint" data-url="{{ path('select_footprint') }}">Change footprint</option>
|
|
<option value="change_manufacturer" data-url="{{ path('select_manufacturer') }}">Change Manufacturer</option>
|
|
<option value="change_unit" data-url="{{ path('select_measurement_unit') }}">Change Unit</option>
|
|
</select>
|
|
|
|
<select class="" style="display: none;" data-live-search="true" name="target" id="select_target">
|
|
|
|
</select>
|
|
|
|
<button type="submit" class="btn btn-secondary">Submit</button>
|
|
</div>
|
|
|
|
<div id="part_list" class="" data-select="true" data-part_table="true" data-datatable data-settings='{{ datatable_settings(datatable)|escape('html_attr') }}'>
|
|
<div class="card-body">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h4>{% trans %}part_list.loading.caption{% endtrans %}</h4>
|
|
<h6>{% trans %}part_list.loading.message{% endtrans %}</h6>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
|
|
function updateOptions(selector, json)
|
|
{
|
|
var select = document.querySelector(selector);
|
|
|
|
//Clear options
|
|
select.innerHTML = null;
|
|
|
|
for(i=0; i<json.length; i++) {
|
|
var json_opt = json[i];
|
|
var opt = document.createElement('option');
|
|
opt.value = json_opt.value;
|
|
opt.innerHTML = json_opt.text;
|
|
|
|
if(json_opt['data-subtext']) {
|
|
opt.dataset.subtext = json_opt['data-subtext'];
|
|
}
|
|
|
|
select.appendChild(opt);
|
|
}
|
|
}
|
|
|
|
function updateTargetSelect() {
|
|
var element = document.querySelector('#select_action');
|
|
|
|
var selected = element.options[element.options.selectedIndex];
|
|
|
|
var url = selected.dataset.url;
|
|
|
|
if (url) {
|
|
|
|
|
|
fetch(url)
|
|
.then(response => response.json())
|
|
.then(data => updateOptions('#select_target', data))
|
|
.then(data => $('#select_target').selectpicker('refresh'));
|
|
|
|
} else {
|
|
$('#select_target').selectpicker('hide');
|
|
}
|
|
}
|
|
</script> |