Skip to content
Snippets Groups Projects
Commit 31830afc authored by Jean-Pascal Kanter's avatar Jean-Pascal Kanter :speech_balloon: Committed by Robert Lange
Browse files

refs #22135 [finc] changed daterange slider from maxlength to max value

* changed advanced search date input field to number instead of text

co-authored by: Claas Kazzer <kazzer@uni-leipzig.de>
* adds same behaviour to sidebar range slider as in adv search
* adds comments
parent d383d872
No related merge requests found
......@@ -14,23 +14,27 @@
<?=$results->getUrlQuery()->asHiddenFields(['page' => "/./", 'filter' => "/^{$this->title}:.*/"])?>
<input type="hidden" name="<?=$this->escapeHtmlAttr($this->facet['type'])?>range[]" value="<?=$this->escapeHtmlAttr($this->title)?>"/>
<div class="date-fields">
<?php $extraInputAttribs = ($this->facet['type'] == 'date') ? 'maxlength="4" ' : ''; ?>
<?php /* finc adds 'max="'.(date('Y')+1).' to prevent dates beyond the year + 1 to be entered; maxlength was causing w3c issues */ ?>
<?php $extraInputAttribs = ($this->facet['type'] == 'date') ? 'max="'.(date('Y')+1).'" ' : ''; ?>
<div class="date-from">
<label id="from-label" for="<?=$this->escapeHtmlAttr($this->title)?>from">
<?=$this->transEsc('date_from')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>from" id="<?=$this->escapeHtmlAttr($this->title)?>from" value="<?=isset($this->facet['values'][0]) ? $this->escapeHtmlAttr($this->facet['values'][0]) : ''?>" <?=$extraInputAttribs?>/>
<?php /* finc changes this to number for consistency with adv search */ ?>
<input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>from" id="<?=$this->escapeHtmlAttr($this->title)?>from" value="<?=isset($this->facet['values'][0]) ? $this->escapeHtmlAttr($this->facet['values'][0]) : ''?>" <?=$extraInputAttribs?>/>
</div>
<div class="date-to">
<label id="to-label" for="<?=$this->escapeHtmlAttr($this->title)?>to">
<?=$this->transEsc('date_to')?>:
</label>
<input type="text" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>to" id="<?=$this->escapeHtmlAttr($this->title)?>to" value="<?=isset($this->facet['values'][1]) ? $this->escapeHtmlAttr($this->facet['values'][1]) : ''?>" <?=$extraInputAttribs?>/>
<?php /* finc changes this to number for consistency with adv search */ ?>
<input type="number" class="form-control" name="<?=$this->escapeHtmlAttr($this->title)?>to" id="<?=$this->escapeHtmlAttr($this->title)?>to" value="<?=isset($this->facet['values'][1]) ? $this->escapeHtmlAttr($this->facet['values'][1]) : ''?>" <?=$extraInputAttribs?>/>
</div>
</div>
<?php if ($this->facet['type'] == 'date'): ?>
<?php /* next line finc specific, adds aria-label */?>
<div class="slider-container"><input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($this->title)?><?=$this->escapeHtml($this->facet['type'])?>Slider" aria-label="<?=$this->transEsc('Range-from-to')?>"/></div>
<div class="slider-container">
<input type="text" class="hidden" id="<?=$this->escapeHtmlAttr($this->title)?><?=$this->escapeHtml($this->facet['type'])?>Slider" aria-label="<?=$this->transEsc('Range-from-to')?>"/></div>
<?php endif; ?>
<input class="btn btn-default" type="submit" value="<?=$this->transEsc('Set')?>"/>
</form>
......
......@@ -2,7 +2,8 @@
<?php if (isset($this->ranges) && !empty($this->ranges)): ?>
<?php $params = $this->searchParams($this->searchClassId); $params->activateAllFacets(); ?>
<?php foreach ($this->ranges as $current): $escField = $this->escapeHtmlAttr($current['field']); ?>
<?php $extraInputAttribs = ($current['type'] == 'date') ? 'maxlength="4" ' : ''; ?>
<?php /* finc adds 'max="'.(date('Y')+1).' to prevent dates beyond the year + 1 to be entered; maxlength was causing w3c issues */ ?>
<?php $extraInputAttribs = ($current['type'] == 'date') ? 'max="'.(date('Y')+1).'" ' : ''; ?>
<?php /* #18306: alignment left to result - GG */ ?>
<fieldset class="range left">
<legend><?=$this->transEsc($params->getFacetLabel($current['field']))?></legend>
......@@ -10,11 +11,11 @@
<div class="date-fields">
<div class="date-from">
<label id="from-label" for="<?=$escField?>from"><?=$this->transEsc('date_from')?>:</label>
<input type="text" name="<?=$escField?>from" id="<?=$escField?>from" value="<?=isset($current['values'][0])?$this->escapeHtmlAttr($current['values'][0]):''?>" class="form-control" <?=$extraInputAttribs?>/>
<input type="number" name="<?=$escField?>from" id="<?=$escField?>from" value="<?=isset($current['values'][0])?$this->escapeHtmlAttr($current['values'][0]):''?>" class="form-control" <?=$extraInputAttribs?>/>
</div>
<div class="date-to">
<label id="to-label" for="<?=$escField?>to"><?=$this->transEsc('date_to')?>:</label>
<input type="text" name="<?=$escField?>to" id="<?=$escField?>to" value="<?=isset($current['values'][1])?$this->escapeHtmlAttr($current['values'][1]):''?>" class="form-control" <?=$extraInputAttribs?>/>
<input type="number" name="<?=$escField?>to" id="<?=$escField?>to" value="<?=isset($current['values'][1])?$this->escapeHtmlAttr($current['values'][1]):''?>" class="form-control" <?=$extraInputAttribs?>/>
</div>
</div>
<?php if ($current['type'] == 'date'): ?>
......
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