1906 FIX search form autocomplete multi terms
This commit is contained in:
parent
1993f80d8d
commit
db6a82f7f7
|
@ -53,7 +53,7 @@ class Base extends ControllerBase {
|
|||
$this->and_query->setParseMode($parse_mode);
|
||||
// Set fulltext search keywords and fields.
|
||||
if ($this->keys) {
|
||||
$this->and_query->keys($this->keys);
|
||||
$this->and_query->keys(implode(' ', $this->keys));
|
||||
}
|
||||
|
||||
// in case of term id provided restrict the keys to taxo fields
|
||||
|
@ -166,7 +166,7 @@ class Base extends ControllerBase {
|
|||
|
||||
// Set fulltext search keywords and fields.
|
||||
if ($this->keys) {
|
||||
$this->or_query->keys($this->keys);
|
||||
$this->or_query->keys(implode(' ', $this->keys));
|
||||
}
|
||||
|
||||
// exclude results from and_query
|
||||
|
@ -176,7 +176,7 @@ class Base extends ControllerBase {
|
|||
}
|
||||
$this->or_query->addConditionGroup($exclude_and_results_conditions);
|
||||
|
||||
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', $this->keys, $matches)) {
|
||||
if (preg_match_all('/[WTRPCMFGSO]\d{4}/i', implode(' ', $this->keys), $matches)) {
|
||||
// in case we search for material references like W0117
|
||||
$ref_conditions = $this->or_query->createConditionGroup('OR');
|
||||
foreach ($matches[0] as $key => $value) {
|
||||
|
@ -264,8 +264,8 @@ class Base extends ControllerBase {
|
|||
$this->keys = $request->query->get('keys');
|
||||
if($this->keys){
|
||||
$this->keys = mb_strtolower($this->keys);
|
||||
// $this->keys = Tags::explode($this->keys);
|
||||
\Drupal::logger('materio_sapi')->notice($this->keys);
|
||||
$this->keys = Tags::explode($this->keys);
|
||||
// \Drupal::logger('materio_sapi')->notice($this->keys);
|
||||
}
|
||||
// get the exacte term id in case of autocomplete
|
||||
// $this->terms = $request->query->get('terms');
|
||||
|
@ -301,7 +301,7 @@ class Base extends ControllerBase {
|
|||
|
||||
$this->sapiQuery();
|
||||
|
||||
$resp['keys'] = $this->keys;
|
||||
$resp['keys'] = json_encode($this->keys);
|
||||
$resp['terms'] = json_encode($this->terms);
|
||||
$resp['filters'] = $this->filters;
|
||||
// $resp['count'] = $this->results->getResultCount();
|
||||
|
@ -313,7 +313,7 @@ class Base extends ControllerBase {
|
|||
));
|
||||
if ($this->keys) {
|
||||
$resp['infos'] .= t(' keywords @keys', array(
|
||||
"@keys" => $this->keys
|
||||
"@keys" => implode(', ', $this->keys)
|
||||
));
|
||||
}
|
||||
if ($this->keys && $this->filters) {
|
||||
|
@ -389,7 +389,7 @@ class Base extends ControllerBase {
|
|||
];
|
||||
|
||||
if ($this->keys) {
|
||||
$resp['#title'] = $this->keys;
|
||||
$resp['#title'] = implode(', ', $this->keys);
|
||||
|
||||
// $this->sapiQuery();
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
web/themes/custom/materiotheme/assets/dist/module-base.e079ad7538d0d2d307c8.bundle.js.gz
vendored
Normal file
BIN
web/themes/custom/materiotheme/assets/dist/module-base.e079ad7538d0d2d307c8.bundle.js.gz
vendored
Normal file
Binary file not shown.
|
@ -124,7 +124,7 @@ export default {
|
|||
watch: {
|
||||
typed(n, o){
|
||||
console.log('watch typed changed o:' + o + ' n:' +n)
|
||||
// todo remove terms from autocomplete if removed from typed
|
||||
// remove terms from autocomplete if removed from typed
|
||||
const r = /,\s?$/
|
||||
let tag_list = n.replace(r,'').split(', ')
|
||||
console.log('watch typed tag_list', tag_list)
|
||||
|
@ -149,7 +149,8 @@ export default {
|
|||
},
|
||||
created() {
|
||||
// fill component values with store values in case of direct page loading
|
||||
this.typed = this.keys
|
||||
console.log('SearchForm created, this.keys', this.keys)
|
||||
this.typed = this.keys.length ? this.keys.join(', ') + ', ' : ''
|
||||
this.autocomplete = this.terms
|
||||
},
|
||||
mounted(){
|
||||
|
|
|
@ -66,8 +66,11 @@ export default {
|
|||
console.log('Base created() location',window.location)
|
||||
let params = new URLSearchParams(window.location.search)
|
||||
if (params.has('keys')) {
|
||||
this.$store.commit('Search/setKeys', params.get('keys'))
|
||||
this.pagetitle = params.get('keys')
|
||||
const r = /,\s?$/
|
||||
let keys = params.get('keys').replace(r,'').split(', ')
|
||||
console.log('Base created, keys', keys)
|
||||
this.$store.commit('Search/setKeys', keys)
|
||||
this.pagetitle = keys.join(', ') //params.get('keys')
|
||||
} else {
|
||||
this.$store.commit('Search/setKeys', '')
|
||||
this.pagetitle = 'Base'
|
||||
|
@ -92,7 +95,13 @@ export default {
|
|||
beforeRouteUpdate (to, from, next) {
|
||||
// when query change launch a new search
|
||||
console.log('Base beforeRouteUpdate', to, from, next)
|
||||
this.$store.commit('Search/setKeys', to.query.keys)
|
||||
|
||||
// this.$store.commit('Search/setKeys', to.query.keys)
|
||||
const r = /,\s?$/
|
||||
let keys = to.query.keys.replace(r,'').split(', ')
|
||||
console.log('Base created, keys', keys)
|
||||
this.$store.commit('Search/setKeys', keys)
|
||||
|
||||
this.$store.commit('Search/setTerms', to.query.terms)
|
||||
this.$store.commit('Search/setFilters', to.query.filters)
|
||||
this.pagetitle = to.query.keys
|
||||
|
|
|
@ -104,15 +104,15 @@ export default {
|
|||
// actions
|
||||
actions: {
|
||||
newSearch ({ dispatch, commit, state }) {
|
||||
console.log('Search newSearch')
|
||||
console.log('Search newSearch, state.keys', state.keys)
|
||||
commit('resetUuids')
|
||||
commit('resetItems')
|
||||
commit('resetCount')
|
||||
commit('resetNoresults')
|
||||
commit('resetOffset')
|
||||
commit('resetInfos')
|
||||
if (state.keys || state.terms) {
|
||||
this.commit('Common/setPagetitle', state.keys)
|
||||
if (state.keys || state.terms.length) {
|
||||
this.commit('Common/setPagetitle', state.keys.join(', '))
|
||||
} else {
|
||||
this.commit('Common/setPagetitle', 'Base')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue