Skip to content
Snippets Groups Projects
Commit 00d93e4b authored by Claas Kazzer's avatar Claas Kazzer Committed by Robert Lange
Browse files

refs #18277 [FINC: Adv Search] add / remove fields and groups

* corrects misplaced label
* sync meta attributes for inputs with js
* fix "for"-attribute of type label
* use human readable numeration for legend and aria-label - js version
* also set reset focus after deleting search field on last search field

co-authored by: Robert Lange <robert.lange@uni-leipzig.de>
parent 0876539e
No related merge requests found
...@@ -10,10 +10,13 @@ function addSearch(group, _fieldValues) { ...@@ -10,10 +10,13 @@ function addSearch(group, _fieldValues) {
var $newSearch = $($('#new_search_template').html()); var $newSearch = $($('#new_search_template').html());
$newSearch.attr('id', 'search' + inputID); $newSearch.attr('id', 'search' + inputID);
$newSearch.find('fieldset legend').text($newSearch.find('fieldset legend').text().replace('1', (groupLength[group] + 1)));
$newSearch.find('input.form-control') $newSearch.find('input.form-control')
.attr('id', 'search_lookfor' + inputID) .attr('id', 'search_lookfor' + inputID)
.attr('name', 'lookfor' + group + '[]') .attr('name', 'lookfor' + group + '[]')
.val(''); .val('');
$newSearch.find('.adv-input label').attr('for', 'search_lookfor' + inputID);
$newSearch.find('.adv-select label').attr('for', 'search_type' + inputID);
$newSearch.find('select.adv-term-type option:first-child').attr('selected', 1); $newSearch.find('select.adv-term-type option:first-child').attr('selected', 1);
$newSearch.find('select.adv-term-type') $newSearch.find('select.adv-term-type')
.attr('id', 'search_type' + inputID) .attr('id', 'search_type' + inputID)
...@@ -44,7 +47,6 @@ function addSearch(group, _fieldValues) { ...@@ -44,7 +47,6 @@ function addSearch(group, _fieldValues) {
.attr('name', 'op' + group + '[]') .attr('name', 'op' + group + '[]')
.removeClass('hidden'); .removeClass('hidden');
$newSearch.find('.first-op').remove(); $newSearch.find('.first-op').remove();
$newSearch.find('label').remove();
// Show x if we have more than one search inputs // Show x if we have more than one search inputs
$('#group' + group + ' .adv-term-remove').removeClass('hidden'); $('#group' + group + ' .adv-term-remove').removeClass('hidden');
} }
...@@ -67,7 +69,12 @@ function deleteSearch(group, sindex) { ...@@ -67,7 +69,12 @@ function deleteSearch(group, sindex) {
} }
if (groupLength[group] > 1) { if (groupLength[group] > 1) {
groupLength[group]--; groupLength[group]--;
$('#search' + group + '_' + groupLength[group]).remove(); var toRemove = $('#search' + group + '_' + groupLength[group]);
var parent = toRemove.parent();
toRemove.remove();
if(parent.length) {
parent.find('.adv-search input.form-control').focus();
}
if (groupLength[group] === 1) { if (groupLength[group] === 1) {
$('#group' + group + ' .adv-term-remove').addClass('hidden'); // Hide x $('#group' + group + ' .adv-term-remove').addClass('hidden'); // Hide x
} }
...@@ -84,6 +91,7 @@ function addGroup(_firstTerm, _firstField, _join) { ...@@ -84,6 +91,7 @@ function addGroup(_firstTerm, _firstField, _join) {
$newGroup.find('.adv-group-label') // update label $newGroup.find('.adv-group-label') // update label
.attr('for', 'search_lookfor' + nextGroup + '_0'); .attr('for', 'search_lookfor' + nextGroup + '_0');
$newGroup.attr('id', 'group' + nextGroup); $newGroup.attr('id', 'group' + nextGroup);
$newGroup.attr('aria-label', $newGroup.attr('aria-label').replace('0', nextGroup + 1));
$newGroup.find('.search_place_holder') $newGroup.find('.search_place_holder')
.attr('id', 'group' + nextGroup + 'Holder') .attr('id', 'group' + nextGroup + 'Holder')
.removeClass('hidden'); .removeClass('hidden');
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
<?php if (count($limitList) > 1): ?> <?php if (count($limitList) > 1): ?>
<fieldset class="limits"> <fieldset class="limits">
<legend><?=$this->transEsc('Results per page')?></legend> <legend><?=$this->transEsc('Results per page')?></legend>
<label for="limit"><?=$this->transEsc('Limit To')?></label>
<select id="limit" name="limit" class="form-control"> <select id="limit" name="limit" class="form-control">
<?php foreach ($limitList as $limitVal): ?> <?php foreach ($limitList as $limitVal): ?>
<option value="<?=$this->escapeHtmlAttr($limitVal)?>" <?=($limitVal == $defaultLimit) ? 'selected="selected"' : ''?>><?=$this->escapeHtml($limitVal)?></option> <option value="<?=$this->escapeHtmlAttr($limitVal)?>" <?=($limitVal == $defaultLimit) ? 'selected="selected"' : ''?>><?=$this->escapeHtml($limitVal)?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<label for="limit"><?=$this->transEsc('Limit To')?></label>
</fieldset> </fieldset>
<?php endif; ?> <?php endif; ?>
<!-- finc: search - advanced - limit - END --> <!-- finc: search - advanced - limit - END -->
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment