Skip to content
Snippets Groups Projects
Commit 3d3bb7e2 authored by David Siegfried's avatar David Siegfried
Browse files

fix search-filter, closes #1023

Closes #1023

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