diff --git a/lib/classes/sidebar/RoomSearchWidget.class.php b/lib/classes/sidebar/RoomSearchWidget.class.php index ffe747079c3d8430de739f5218594edc74384550..008065816115b02c75e6357b044f0dc24f659bb5 100644 --- a/lib/classes/sidebar/RoomSearchWidget.class.php +++ b/lib/classes/sidebar/RoomSearchWidget.class.php @@ -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; diff --git a/resources/assets/javascripts/lib/resources.js b/resources/assets/javascripts/lib/resources.js index 45b9ebe3e7dae0f857ddfa2c52e72627fc7a7950..65803511078b7d30ed68599d799d999cb3d1324b 100644 --- a/resources/assets/javascripts/lib/resources.js +++ b/resources/assets/javascripts/lib/resources.js @@ -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"]'); diff --git a/resources/assets/stylesheets/scss/resources.scss b/resources/assets/stylesheets/scss/resources.scss index b37ec2fab2bf1ed81500c6b43ecfab93cdad3d68..bdd6fdee42d0e2c15a9e03ec61c420735d8d625a 100644 --- a/resources/assets/stylesheets/scss/resources.scss +++ b/resources/assets/stylesheets/scss/resources.scss @@ -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; diff --git a/templates/sidebar/room-search-criteria-templates.php b/templates/sidebar/room-search-criteria-templates.php index 1713982e6ee4563a297ce40c965f7b5821779e44..d75ccbd3fa4afea458961691ece13ac7e169e455 100644 --- a/templates/sidebar/room-search-criteria-templates.php +++ b/templates/sidebar/room-search-criteria-templates.php @@ -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> diff --git a/templates/sidebar/room-search-criteria.php b/templates/sidebar/room-search-criteria.php index 918de6ebb78adfffc9a82c6fb5bed8ba9645a779..96c24d8baf3d46a8c4f899bacbdfdec79f8554c2 100644 --- a/templates/sidebar/room-search-criteria.php +++ b/templates/sidebar/room-search-criteria.php @@ -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'): ?>