Skip to content
Snippets Groups Projects
Commit 3a1e78fd authored by David Siegfried's avatar David Siegfried Committed by Jan-Hendrik Willms
Browse files

fix search-filter, closes #1023

Closes #1023

Merge request studip/studip!780
parent d2160963
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,9 @@ class RoomSearchWidget extends SidebarWidget
'range_search' => $property->range_search,
'optional' => true
];
if ($property->type === 'select') {
$this->criteria[$property->name]['options'] = $property->getOptionsArray();
}
}
}
......@@ -273,12 +276,17 @@ class RoomSearchWidget extends SidebarWidget
} elseif ($data['type'] === 'num' && $data['range_search']) {
if (Request::submitted($name . '_min')
|| Request::submitted($name . '_max')) {
$this->selected_criteria[$name] = $data;
$this->selected_criteria[$name] = $data;
$this->selected_criteria[$name]['value'] = [
Request::get($name . '_min'),
Request::get($name . '_max')
];
}
} elseif ($data['type'] === 'bool') {
if (Request::submitted('options_' . $name)) {
$this->selected_criteria[$name] = $data;
$this->selected_criteria[$name]['value'] = Request::get($name);
}
} else {
if (Request::submitted($name)) {
$this->selected_criteria[$name] = $data;
......
......@@ -278,8 +278,10 @@ class Resources
jQuery(new_criteria_text_field).text(option_title);
if (option_type === 'bool') {
let new_criteria_input = jQuery(new_criteria).find('input');
let new_criteria_input = jQuery(new_criteria).find('input[type=checkbox]');
jQuery(new_criteria_input).attr('name', option_value);
let new_criteria_hidden_input = jQuery(new_criteria).find('input[type=hidden]');
jQuery(new_criteria_hidden_input).attr('name', 'options_' + option_value);
} else if (option_type === 'select') {
let new_criteria_select = jQuery(new_criteria).find('select')[0];
jQuery(new_criteria_select).attr('name', option_value);
......@@ -292,9 +294,10 @@ class Resources
for (let option of option_select_options) {
let splitted_option = option.split('~~');
options_html += '<option value="' + splitted_option[0] + '">'
+ splitted_option[1]
+ (splitted_option[1] ?? splitted_option[0])
+ '</option>';
}
$(new_criteria_select).append(options_html);
} else if (option_type === 'date') {
let time_inputs = jQuery(new_criteria).find('input[data-time="yes"]');
let date_inputs = jQuery(new_criteria).find('input[type="date"]');
......
......@@ -168,7 +168,10 @@ ul.resource-tree {
}
& > label {
input, select {
input[type=text],
input[type=number],
input[type=date],
select {
width: calc(100% - 2em);
height: 30px;
......
......@@ -5,10 +5,12 @@
'class' => 'text-bottom remove-icon'
]
) ?>
<input type="hidden"
value="1"
class="room-search-widget_criteria-list_input">
<input type="hidden" value="1">
<label class="undecorated">
<input type="checkbox"
value="1"
checked
class="room-search-widget_criteria-list_input">
<span></span>
</label>
</li>
......
......@@ -35,10 +35,12 @@
<?= $criteria['enabled'] ? 'checked="checked"' : ''?>>
<? endif ?>
<? if ($criteria['type'] == 'bool'): ?>
<input type="hidden"
name="<?= htmlReady($criteria['name'])?>"
value="1">
<label class="undecorated" for="cb_<?= htmlReady($criteria['name']); ?>">
<input type="hidden" name="options_<?= htmlReady($criteria['name']) ?>" value="1">
<label class="undecorated" for="cb_<?= htmlReady($criteria['name']) ?>">
<input type="checkbox"
value="1"
<?= Request::get($criteria['name']) ? 'checked': ''?>
name="<?= htmlReady($criteria['name'])?>">
<span><?= htmlReady($criteria['title']) ?></span>
</label>
<? elseif ($criteria['type'] == 'num'): ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment