From 1851c84ea5ad21604da2e9ff5e04c50b55cc15fe Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 1 Apr 2021 22:44:44 +0200 Subject: [PATCH] started advanced search --- .../src/Form/MaterioSapiSearchForm.php | 33 +++++++++++++++---- .../custom/materiotheme/assets/dist/main.css | 17 +++++++++- .../materiotheme/assets/styles/main.scss | 22 +++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/web/modules/custom/materio_sapi/src/Form/MaterioSapiSearchForm.php b/web/modules/custom/materio_sapi/src/Form/MaterioSapiSearchForm.php index b1e48212..a16e9c3d 100644 --- a/web/modules/custom/materio_sapi/src/Form/MaterioSapiSearchForm.php +++ b/web/modules/custom/materio_sapi/src/Form/MaterioSapiSearchForm.php @@ -45,13 +45,32 @@ class MaterioSapiSearchForm extends FormBase { "v-model" => "autocomplete" ], ]; - // $form['submit'] = [ - // '#type' => 'submit', - // '#value' => $this->t('Search'), - // '#attributes' => [ - // '@click.prevent' => "submit", - // ] - // ]; + + $form['filters'] = [ + '#type' => 'container' + ]; + + $query = \Drupal::entityQuery('taxonomy_term'); + $query->condition('vid', "assisted_research"); + $tids = $query->execute(); + $terms = \Drupal\taxonomy\Entity\Term::loadMultiple($tids); + + foreach ($terms as $tid => $term) { + $childs = $term->get('field_terms')->getValue(); + $options = array($term->getName()); + foreach ($childs as $child) { + $child_term = \Drupal\taxonomy\Entity\Term::load($child['target_id']); + $options[$child_term->id()] = $child_term->getName(); + } + $form['filters']['filter-'.$tid] = array( + '#type' => 'select', + // '#title' => $term->getName(), + // '#multiple' => true, + '#options' => $options + ); + } + + $form['submit'] = array( '#type' => 'button', // '#src' => '',//drupal_get_path('module', 'materio_search_api') . '/images/search.png', diff --git a/web/themes/custom/materiotheme/assets/dist/main.css b/web/themes/custom/materiotheme/assets/dist/main.css index 7539ff30..99b1b06c 100644 --- a/web/themes/custom/materiotheme/assets/dist/main.css +++ b/web/themes/custom/materiotheme/assets/dist/main.css @@ -19751,12 +19751,27 @@ header[role="banner"] { header[role="banner"] #block-materiosapisearchblock { padding: 0; } header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form .form-item, header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form input.button { - display: inline-block; } + display: inline-block; + margin: 0; } header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-search { border: 1px #BBB solid; border-radius: 14px; padding: 0.3em; color: #666; } + header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + display: inline-block; + background-color: #e3e3e3; + padding: 0; + border-radius: 10px; + font-size: 0.756em; + border: none; } + header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select::-ms-expand { + display: none; } + header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form #edit-filters select.form-select option { + width: 5em; } header[role="banner"] #block-materiosapisearchblock #materio-sapi-search-form .button.form-submit { border: 0; text-indent: 50px; diff --git a/web/themes/custom/materiotheme/assets/styles/main.scss b/web/themes/custom/materiotheme/assets/styles/main.scss index baddc698..6276d8a7 100644 --- a/web/themes/custom/materiotheme/assets/styles/main.scss +++ b/web/themes/custom/materiotheme/assets/styles/main.scss @@ -576,6 +576,7 @@ header[role="banner"]{ #materio-sapi-search-form{ .form-item, input.button{ display: inline-block; + margin: 0; } #edit-search{ @@ -585,6 +586,27 @@ header[role="banner"]{ color:#666; } + #edit-filters{ + select.form-select{ + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + &::-ms-expand { + display: none; + } + display: inline-block; + background-color: #e3e3e3; + padding:0; + border-radius: 10px; + font-size: 0.756em; + border: none; + // background: url(../images/caret-down.svg) no-repeat 98% 64% #bbb; + option{ + width:5em; + } + } + } + .button.form-submit{ border:0; text-indent: 50px;